repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
CPSB/Validation-helper | src/Form.php | Form.error | public function error($name, $template = null)
{
$errors = $this->session->get('errors');
// Default template is bootstrap friendly.
if (is_null($template)) {
$template = config('form-helpers.error_template');
}
if ($errors && $errors->has($name)) {
return str_replace(':message', e($errors->first($name)), $template);
}
} | php | public function error($name, $template = null)
{
$errors = $this->session->get('errors');
// Default template is bootstrap friendly.
if (is_null($template)) {
$template = config('form-helpers.error_template');
}
if ($errors && $errors->has($name)) {
return str_replace(':message', e($errors->first($name)), $template);
}
} | [
"public",
"function",
"error",
"(",
"$",
"name",
",",
"$",
"template",
"=",
"null",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'errors'",
")",
";",
"// Default template is bootstrap friendly.",
"if",
"(",
"is_null",
"(",
"$",
"template",
")",
")",
"{",
"$",
"template",
"=",
"config",
"(",
"'form-helpers.error_template'",
")",
";",
"}",
"if",
"(",
"$",
"errors",
"&&",
"$",
"errors",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
"str_replace",
"(",
"':message'",
",",
"e",
"(",
"$",
"errors",
"->",
"first",
"(",
"$",
"name",
")",
")",
",",
"$",
"template",
")",
";",
"}",
"}"
] | Get the error message if exists.
@param string $name
@param string|null $template
@return string|null | [
"Get",
"the",
"error",
"message",
"if",
"exists",
"."
] | train | https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/Form.php#L149-L159 |
CPSB/Validation-helper | src/Form.php | Form.value | public function value($name, $default = null)
{
if (! is_null($value = $this->valueFromOld($name))) {
return $value;
}
if (! is_null($value = $this->valueFromModel($name))) {
return $value;
}
return $default;
} | php | public function value($name, $default = null)
{
if (! is_null($value = $this->valueFromOld($name))) {
return $value;
}
if (! is_null($value = $this->valueFromModel($name))) {
return $value;
}
return $default;
} | [
"public",
"function",
"value",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"valueFromOld",
"(",
"$",
"name",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"valueFromModel",
"(",
"$",
"name",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Get the value to use in an input field.
@param string $name
@param mixed|null $default
@return mixed|null | [
"Get",
"the",
"value",
"to",
"use",
"in",
"an",
"input",
"field",
"."
] | train | https://github.com/CPSB/Validation-helper/blob/adb91cb42b7e3c1f88be059a8b4f86de5aba64cc/src/Form.php#L168-L178 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.hasFeature | public static function hasFeature($jname, $feature) {
$return = false;
$admin = Factory::getAdmin($jname);
$user = Factory::getUser($jname);
switch ($feature) {
//Admin Features
case 'wizard':
$return = $admin->methodDefined('setupFromPath');
break;
//User Features
case 'useractivity':
$return = $user->methodDefined('activateUser');
break;
case 'duallogin':
$return = $user->methodDefined('createSession');
break;
case 'duallogout':
$return = $user->methodDefined('destroySession');
break;
case 'updatepassword':
$return = $user->methodDefined('updatePassword');
break;
case 'updateusername':
$return = $user->methodDefined('updateUsername');
break;
case 'updateemail':
$return = $user->methodDefined('updateEmail');
break;
case 'updateusergroup':
$return = $user->methodDefined('updateUsergroup');
break;
case 'updateuserlanguage':
$return = $user->methodDefined('updateUserLanguage');
break;
case 'syncsessions':
$return = $user->methodDefined('syncSessions');
break;
case 'blockuser':
$return = $user->methodDefined('blockUser');
break;
case 'activateuser':
$return = $user->methodDefined('activateUser');
break;
case 'deleteuser':
$return = $user->methodDefined('deleteUser');
break;
}
return $return;
} | php | public static function hasFeature($jname, $feature) {
$return = false;
$admin = Factory::getAdmin($jname);
$user = Factory::getUser($jname);
switch ($feature) {
//Admin Features
case 'wizard':
$return = $admin->methodDefined('setupFromPath');
break;
//User Features
case 'useractivity':
$return = $user->methodDefined('activateUser');
break;
case 'duallogin':
$return = $user->methodDefined('createSession');
break;
case 'duallogout':
$return = $user->methodDefined('destroySession');
break;
case 'updatepassword':
$return = $user->methodDefined('updatePassword');
break;
case 'updateusername':
$return = $user->methodDefined('updateUsername');
break;
case 'updateemail':
$return = $user->methodDefined('updateEmail');
break;
case 'updateusergroup':
$return = $user->methodDefined('updateUsergroup');
break;
case 'updateuserlanguage':
$return = $user->methodDefined('updateUserLanguage');
break;
case 'syncsessions':
$return = $user->methodDefined('syncSessions');
break;
case 'blockuser':
$return = $user->methodDefined('blockUser');
break;
case 'activateuser':
$return = $user->methodDefined('activateUser');
break;
case 'deleteuser':
$return = $user->methodDefined('deleteUser');
break;
}
return $return;
} | [
"public",
"static",
"function",
"hasFeature",
"(",
"$",
"jname",
",",
"$",
"feature",
")",
"{",
"$",
"return",
"=",
"false",
";",
"$",
"admin",
"=",
"Factory",
"::",
"getAdmin",
"(",
"$",
"jname",
")",
";",
"$",
"user",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"jname",
")",
";",
"switch",
"(",
"$",
"feature",
")",
"{",
"//Admin Features",
"case",
"'wizard'",
":",
"$",
"return",
"=",
"$",
"admin",
"->",
"methodDefined",
"(",
"'setupFromPath'",
")",
";",
"break",
";",
"//User Features",
"case",
"'useractivity'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'activateUser'",
")",
";",
"break",
";",
"case",
"'duallogin'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'createSession'",
")",
";",
"break",
";",
"case",
"'duallogout'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'destroySession'",
")",
";",
"break",
";",
"case",
"'updatepassword'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'updatePassword'",
")",
";",
"break",
";",
"case",
"'updateusername'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'updateUsername'",
")",
";",
"break",
";",
"case",
"'updateemail'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'updateEmail'",
")",
";",
"break",
";",
"case",
"'updateusergroup'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'updateUsergroup'",
")",
";",
"break",
";",
"case",
"'updateuserlanguage'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'updateUserLanguage'",
")",
";",
"break",
";",
"case",
"'syncsessions'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'syncSessions'",
")",
";",
"break",
";",
"case",
"'blockuser'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'blockUser'",
")",
";",
"break",
";",
"case",
"'activateuser'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'activateUser'",
")",
";",
"break",
";",
"case",
"'deleteuser'",
":",
"$",
"return",
"=",
"$",
"user",
"->",
"methodDefined",
"(",
"'deleteUser'",
")",
";",
"break",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Check if feature exists
@static
@param string $jname
@param string $feature feature
@return bool | [
"Check",
"if",
"feature",
"exists"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L75-L123 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.getXml | public static function getXml($data, $isFile = true)
{
// Disable libxml errors and allow to fetch error information as needed
libxml_use_internal_errors(true);
if ($isFile) {
// Try to load the XML file
$xml = simplexml_load_file($data);
} else {
// Try to load the XML string
$xml = simplexml_load_string($data);
}
if ($xml === false) {
$message = null;
if ($isFile) {
$message = Text::_('FILE') . ': ' . $data;
}
foreach (libxml_get_errors() as $error) {
if ($message) {
$message .= ' ';
}
$message .= ' '. Text::_('MESSAGE') . ': ' . $error->message;
}
throw new RuntimeException(Text::_('ERROR_XML_LOAD') . ' : ' . $message);
}
return $xml;
} | php | public static function getXml($data, $isFile = true)
{
// Disable libxml errors and allow to fetch error information as needed
libxml_use_internal_errors(true);
if ($isFile) {
// Try to load the XML file
$xml = simplexml_load_file($data);
} else {
// Try to load the XML string
$xml = simplexml_load_string($data);
}
if ($xml === false) {
$message = null;
if ($isFile) {
$message = Text::_('FILE') . ': ' . $data;
}
foreach (libxml_get_errors() as $error) {
if ($message) {
$message .= ' ';
}
$message .= ' '. Text::_('MESSAGE') . ': ' . $error->message;
}
throw new RuntimeException(Text::_('ERROR_XML_LOAD') . ' : ' . $message);
}
return $xml;
} | [
"public",
"static",
"function",
"getXml",
"(",
"$",
"data",
",",
"$",
"isFile",
"=",
"true",
")",
"{",
"// Disable libxml errors and allow to fetch error information as needed",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"if",
"(",
"$",
"isFile",
")",
"{",
"// Try to load the XML file",
"$",
"xml",
"=",
"simplexml_load_file",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"// Try to load the XML string",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"$",
"xml",
"===",
"false",
")",
"{",
"$",
"message",
"=",
"null",
";",
"if",
"(",
"$",
"isFile",
")",
"{",
"$",
"message",
"=",
"Text",
"::",
"_",
"(",
"'FILE'",
")",
".",
"': '",
".",
"$",
"data",
";",
"}",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"if",
"(",
"$",
"message",
")",
"{",
"$",
"message",
".=",
"' '",
";",
"}",
"$",
"message",
".=",
"' '",
".",
"Text",
"::",
"_",
"(",
"'MESSAGE'",
")",
".",
"': '",
".",
"$",
"error",
"->",
"message",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"Text",
"::",
"_",
"(",
"'ERROR_XML_LOAD'",
")",
".",
"' : '",
".",
"$",
"message",
")",
";",
"}",
"return",
"$",
"xml",
";",
"}"
] | Checks to see if a JFusion plugin is properly configured
@param string $data file path or file content
@param boolean $isFile load from file
@throws \Symfony\Component\Yaml\Exception\RuntimeException
@return SimpleXMLElement returns true if plugin is correctly configured | [
"Checks",
"to",
"see",
"if",
"a",
"JFusion",
"plugin",
"is",
"properly",
"configured"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L134-L161 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.raise | public static function raise($type, $message, $jname = '') {
if (is_array($message)) {
foreach ($message as $msgtype => $msg) {
//if still an array implode for nicer display
if (is_numeric($msgtype)) {
$msgtype = $jname;
}
static::raise($type, $msg, $msgtype);
}
} else {
$app = Application::getInstance();
if ($message instanceof Exception) {
$message = $message->getMessage();
}
if (!empty($jname)) {
$message = $jname . ': ' . $message;
}
$app->enqueueMessage($message, strtolower($type));
}
} | php | public static function raise($type, $message, $jname = '') {
if (is_array($message)) {
foreach ($message as $msgtype => $msg) {
//if still an array implode for nicer display
if (is_numeric($msgtype)) {
$msgtype = $jname;
}
static::raise($type, $msg, $msgtype);
}
} else {
$app = Application::getInstance();
if ($message instanceof Exception) {
$message = $message->getMessage();
}
if (!empty($jname)) {
$message = $jname . ': ' . $message;
}
$app->enqueueMessage($message, strtolower($type));
}
} | [
"public",
"static",
"function",
"raise",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"jname",
"=",
"''",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"message",
")",
")",
"{",
"foreach",
"(",
"$",
"message",
"as",
"$",
"msgtype",
"=>",
"$",
"msg",
")",
"{",
"//if still an array implode for nicer display",
"if",
"(",
"is_numeric",
"(",
"$",
"msgtype",
")",
")",
"{",
"$",
"msgtype",
"=",
"$",
"jname",
";",
"}",
"static",
"::",
"raise",
"(",
"$",
"type",
",",
"$",
"msg",
",",
"$",
"msgtype",
")",
";",
"}",
"}",
"else",
"{",
"$",
"app",
"=",
"Application",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"message",
"instanceof",
"Exception",
")",
"{",
"$",
"message",
"=",
"$",
"message",
"->",
"getMessage",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"jname",
")",
")",
"{",
"$",
"message",
"=",
"$",
"jname",
".",
"': '",
".",
"$",
"message",
";",
"}",
"$",
"app",
"->",
"enqueueMessage",
"(",
"$",
"message",
",",
"strtolower",
"(",
"$",
"type",
")",
")",
";",
"}",
"}"
] | Raise warning function that can handle arrays
@param $type
@param array|string|Exception $message message itself
@param string $jname
@return string nothing | [
"Raise",
"warning",
"function",
"that",
"can",
"handle",
"arrays"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L172-L191 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.getImageSize | public static function getImageSize($filename) {
$result = false;
ob_start();
if (strpos($filename, '://') !== false && function_exists('fopen') && ini_get('allow_url_fopen')) {
$stream = fopen($filename, 'r');
$rawdata = stream_get_contents($stream, 24);
if($rawdata) {
$type = null;
/**
* check for gif
*/
if (strlen($rawdata) >= 10 && strpos($rawdata, 'GIF89a') === 0 || strpos($rawdata, 'GIF87a') === 0) {
$type = 'gif';
}
/**
* check for png
*/
if (!$type && strlen($rawdata) >= 24) {
$head = unpack('C8', $rawdata);
$png = array(1 => 137, 2 => 80, 3 => 78, 4 => 71, 5 => 13, 6 => 10, 7 => 26, 8 => 10);
if ($head === $png) {
$type = 'png';
}
}
/**
* check for jpg
*/
if (!$type) {
$soi = unpack('nmagic/nmarker', $rawdata);
if ($soi['magic'] == 0xFFD8) {
$type = 'jpg';
}
}
if (!$type) {
if ( substr($rawdata, 0, 2) == 'BM' ) {
$type = 'bmp';
}
}
switch($type) {
case 'gif':
$data = unpack('c10', $rawdata);
$result = new stdClass;
$result->width = $data[8]*256 + $data[7];
$result->height = $data[10]*256 + $data[9];
break;
case 'png':
$type = substr($rawdata, 12, 4);
if ($type === 'IHDR') {
$info = unpack('Nwidth/Nheight', substr($rawdata, 16, 8));
$result = new stdClass;
$result->width = $info['width'];
$result->height = $info['height'];
}
break;
case 'bmp':
$header = unpack('H*', $rawdata);
// Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
// Cut it in parts of 2 bytes
$header = str_split($header[1], 2);
$result = new stdClass;
$result->width = hexdec($header[19] . $header[18]);
$result->height = hexdec($header[23] . $header[22]);
break;
case 'jpg':
$pos = 0;
while(1) {
$pos += 2;
$data = substr($rawdata, $pos, 9);
if (strlen($data) < 4) {
break;
}
$info = unpack('nmarker/nlength', $data);
if ($info['marker'] == 0xFFC0) {
if (strlen($data) >= 9) {
$info = unpack('nmarker/nlength/Cprecision/nheight/nwidth', $data);
$result = new stdClass;
$result->width = $info['width'];
$result->height = $info['height'];
}
break;
} else {
$pos += $info['length'];
if (strlen($rawdata) < $pos+9) {
$rawdata .= stream_get_contents($stream, $info['length']+9);
}
}
}
break;
default:
/**
* Fallback to original getimagesize this may be slower than the original but safer.
*/
$rawdata .= stream_get_contents($stream);
$temp = tmpfile();
fwrite($temp, $rawdata);
$meta_data = stream_get_meta_data($temp);
$info = getimagesize($meta_data['uri']);
if ($info) {
$result = new stdClass;
$result->width = $info[0];
$result->height = $info[1];
}
fclose($temp);
break;
}
}
fclose($stream);
}
if (!$result) {
$info = getimagesize($filename);
if ($info) {
$result = new stdClass;
$result->width = $info[0];
$result->height = $info[1];
}
}
ob_end_clean();
return $result;
} | php | public static function getImageSize($filename) {
$result = false;
ob_start();
if (strpos($filename, '://') !== false && function_exists('fopen') && ini_get('allow_url_fopen')) {
$stream = fopen($filename, 'r');
$rawdata = stream_get_contents($stream, 24);
if($rawdata) {
$type = null;
/**
* check for gif
*/
if (strlen($rawdata) >= 10 && strpos($rawdata, 'GIF89a') === 0 || strpos($rawdata, 'GIF87a') === 0) {
$type = 'gif';
}
/**
* check for png
*/
if (!$type && strlen($rawdata) >= 24) {
$head = unpack('C8', $rawdata);
$png = array(1 => 137, 2 => 80, 3 => 78, 4 => 71, 5 => 13, 6 => 10, 7 => 26, 8 => 10);
if ($head === $png) {
$type = 'png';
}
}
/**
* check for jpg
*/
if (!$type) {
$soi = unpack('nmagic/nmarker', $rawdata);
if ($soi['magic'] == 0xFFD8) {
$type = 'jpg';
}
}
if (!$type) {
if ( substr($rawdata, 0, 2) == 'BM' ) {
$type = 'bmp';
}
}
switch($type) {
case 'gif':
$data = unpack('c10', $rawdata);
$result = new stdClass;
$result->width = $data[8]*256 + $data[7];
$result->height = $data[10]*256 + $data[9];
break;
case 'png':
$type = substr($rawdata, 12, 4);
if ($type === 'IHDR') {
$info = unpack('Nwidth/Nheight', substr($rawdata, 16, 8));
$result = new stdClass;
$result->width = $info['width'];
$result->height = $info['height'];
}
break;
case 'bmp':
$header = unpack('H*', $rawdata);
// Process the header
// Structure: http://www.fastgraph.com/help/bmp_header_format.html
// Cut it in parts of 2 bytes
$header = str_split($header[1], 2);
$result = new stdClass;
$result->width = hexdec($header[19] . $header[18]);
$result->height = hexdec($header[23] . $header[22]);
break;
case 'jpg':
$pos = 0;
while(1) {
$pos += 2;
$data = substr($rawdata, $pos, 9);
if (strlen($data) < 4) {
break;
}
$info = unpack('nmarker/nlength', $data);
if ($info['marker'] == 0xFFC0) {
if (strlen($data) >= 9) {
$info = unpack('nmarker/nlength/Cprecision/nheight/nwidth', $data);
$result = new stdClass;
$result->width = $info['width'];
$result->height = $info['height'];
}
break;
} else {
$pos += $info['length'];
if (strlen($rawdata) < $pos+9) {
$rawdata .= stream_get_contents($stream, $info['length']+9);
}
}
}
break;
default:
/**
* Fallback to original getimagesize this may be slower than the original but safer.
*/
$rawdata .= stream_get_contents($stream);
$temp = tmpfile();
fwrite($temp, $rawdata);
$meta_data = stream_get_meta_data($temp);
$info = getimagesize($meta_data['uri']);
if ($info) {
$result = new stdClass;
$result->width = $info[0];
$result->height = $info[1];
}
fclose($temp);
break;
}
}
fclose($stream);
}
if (!$result) {
$info = getimagesize($filename);
if ($info) {
$result = new stdClass;
$result->width = $info[0];
$result->height = $info[1];
}
}
ob_end_clean();
return $result;
} | [
"public",
"static",
"function",
"getImageSize",
"(",
"$",
"filename",
")",
"{",
"$",
"result",
"=",
"false",
";",
"ob_start",
"(",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"filename",
",",
"'://'",
")",
"!==",
"false",
"&&",
"function_exists",
"(",
"'fopen'",
")",
"&&",
"ini_get",
"(",
"'allow_url_fopen'",
")",
")",
"{",
"$",
"stream",
"=",
"fopen",
"(",
"$",
"filename",
",",
"'r'",
")",
";",
"$",
"rawdata",
"=",
"stream_get_contents",
"(",
"$",
"stream",
",",
"24",
")",
";",
"if",
"(",
"$",
"rawdata",
")",
"{",
"$",
"type",
"=",
"null",
";",
"/**\n\t\t\t\t * check for gif\n\t\t\t\t */",
"if",
"(",
"strlen",
"(",
"$",
"rawdata",
")",
">=",
"10",
"&&",
"strpos",
"(",
"$",
"rawdata",
",",
"'GIF89a'",
")",
"===",
"0",
"||",
"strpos",
"(",
"$",
"rawdata",
",",
"'GIF87a'",
")",
"===",
"0",
")",
"{",
"$",
"type",
"=",
"'gif'",
";",
"}",
"/**\n\t\t\t\t * check for png\n\t\t\t\t */",
"if",
"(",
"!",
"$",
"type",
"&&",
"strlen",
"(",
"$",
"rawdata",
")",
">=",
"24",
")",
"{",
"$",
"head",
"=",
"unpack",
"(",
"'C8'",
",",
"$",
"rawdata",
")",
";",
"$",
"png",
"=",
"array",
"(",
"1",
"=>",
"137",
",",
"2",
"=>",
"80",
",",
"3",
"=>",
"78",
",",
"4",
"=>",
"71",
",",
"5",
"=>",
"13",
",",
"6",
"=>",
"10",
",",
"7",
"=>",
"26",
",",
"8",
"=>",
"10",
")",
";",
"if",
"(",
"$",
"head",
"===",
"$",
"png",
")",
"{",
"$",
"type",
"=",
"'png'",
";",
"}",
"}",
"/**\n\t\t\t\t * check for jpg\n\t\t\t\t */",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"$",
"soi",
"=",
"unpack",
"(",
"'nmagic/nmarker'",
",",
"$",
"rawdata",
")",
";",
"if",
"(",
"$",
"soi",
"[",
"'magic'",
"]",
"==",
"0xFFD8",
")",
"{",
"$",
"type",
"=",
"'jpg'",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"rawdata",
",",
"0",
",",
"2",
")",
"==",
"'BM'",
")",
"{",
"$",
"type",
"=",
"'bmp'",
";",
"}",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'gif'",
":",
"$",
"data",
"=",
"unpack",
"(",
"'c10'",
",",
"$",
"rawdata",
")",
";",
"$",
"result",
"=",
"new",
"stdClass",
";",
"$",
"result",
"->",
"width",
"=",
"$",
"data",
"[",
"8",
"]",
"*",
"256",
"+",
"$",
"data",
"[",
"7",
"]",
";",
"$",
"result",
"->",
"height",
"=",
"$",
"data",
"[",
"10",
"]",
"*",
"256",
"+",
"$",
"data",
"[",
"9",
"]",
";",
"break",
";",
"case",
"'png'",
":",
"$",
"type",
"=",
"substr",
"(",
"$",
"rawdata",
",",
"12",
",",
"4",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'IHDR'",
")",
"{",
"$",
"info",
"=",
"unpack",
"(",
"'Nwidth/Nheight'",
",",
"substr",
"(",
"$",
"rawdata",
",",
"16",
",",
"8",
")",
")",
";",
"$",
"result",
"=",
"new",
"stdClass",
";",
"$",
"result",
"->",
"width",
"=",
"$",
"info",
"[",
"'width'",
"]",
";",
"$",
"result",
"->",
"height",
"=",
"$",
"info",
"[",
"'height'",
"]",
";",
"}",
"break",
";",
"case",
"'bmp'",
":",
"$",
"header",
"=",
"unpack",
"(",
"'H*'",
",",
"$",
"rawdata",
")",
";",
"// Process the header",
"// Structure: http://www.fastgraph.com/help/bmp_header_format.html",
"// Cut it in parts of 2 bytes",
"$",
"header",
"=",
"str_split",
"(",
"$",
"header",
"[",
"1",
"]",
",",
"2",
")",
";",
"$",
"result",
"=",
"new",
"stdClass",
";",
"$",
"result",
"->",
"width",
"=",
"hexdec",
"(",
"$",
"header",
"[",
"19",
"]",
".",
"$",
"header",
"[",
"18",
"]",
")",
";",
"$",
"result",
"->",
"height",
"=",
"hexdec",
"(",
"$",
"header",
"[",
"23",
"]",
".",
"$",
"header",
"[",
"22",
"]",
")",
";",
"break",
";",
"case",
"'jpg'",
":",
"$",
"pos",
"=",
"0",
";",
"while",
"(",
"1",
")",
"{",
"$",
"pos",
"+=",
"2",
";",
"$",
"data",
"=",
"substr",
"(",
"$",
"rawdata",
",",
"$",
"pos",
",",
"9",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
"<",
"4",
")",
"{",
"break",
";",
"}",
"$",
"info",
"=",
"unpack",
"(",
"'nmarker/nlength'",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'marker'",
"]",
"==",
"0xFFC0",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
">=",
"9",
")",
"{",
"$",
"info",
"=",
"unpack",
"(",
"'nmarker/nlength/Cprecision/nheight/nwidth'",
",",
"$",
"data",
")",
";",
"$",
"result",
"=",
"new",
"stdClass",
";",
"$",
"result",
"->",
"width",
"=",
"$",
"info",
"[",
"'width'",
"]",
";",
"$",
"result",
"->",
"height",
"=",
"$",
"info",
"[",
"'height'",
"]",
";",
"}",
"break",
";",
"}",
"else",
"{",
"$",
"pos",
"+=",
"$",
"info",
"[",
"'length'",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"rawdata",
")",
"<",
"$",
"pos",
"+",
"9",
")",
"{",
"$",
"rawdata",
".=",
"stream_get_contents",
"(",
"$",
"stream",
",",
"$",
"info",
"[",
"'length'",
"]",
"+",
"9",
")",
";",
"}",
"}",
"}",
"break",
";",
"default",
":",
"/**\n\t\t\t\t\t\t * Fallback to original getimagesize this may be slower than the original but safer.\n\t\t\t\t\t\t */",
"$",
"rawdata",
".=",
"stream_get_contents",
"(",
"$",
"stream",
")",
";",
"$",
"temp",
"=",
"tmpfile",
"(",
")",
";",
"fwrite",
"(",
"$",
"temp",
",",
"$",
"rawdata",
")",
";",
"$",
"meta_data",
"=",
"stream_get_meta_data",
"(",
"$",
"temp",
")",
";",
"$",
"info",
"=",
"getimagesize",
"(",
"$",
"meta_data",
"[",
"'uri'",
"]",
")",
";",
"if",
"(",
"$",
"info",
")",
"{",
"$",
"result",
"=",
"new",
"stdClass",
";",
"$",
"result",
"->",
"width",
"=",
"$",
"info",
"[",
"0",
"]",
";",
"$",
"result",
"->",
"height",
"=",
"$",
"info",
"[",
"1",
"]",
";",
"}",
"fclose",
"(",
"$",
"temp",
")",
";",
"break",
";",
"}",
"}",
"fclose",
"(",
"$",
"stream",
")",
";",
"}",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$",
"info",
"=",
"getimagesize",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"info",
")",
"{",
"$",
"result",
"=",
"new",
"stdClass",
";",
"$",
"result",
"->",
"width",
"=",
"$",
"info",
"[",
"0",
"]",
";",
"$",
"result",
"->",
"height",
"=",
"$",
"info",
"[",
"1",
"]",
";",
"}",
"}",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param string $filename file name or url
@return boolean|stdClass | [
"@param",
"string",
"$filename",
"file",
"name",
"or",
"url"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L198-L325 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.getNodeID | public static function getNodeID()
{
$url = Config::get()->get('uri.base.full');
return strtolower(rtrim(parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH), '/'));
} | php | public static function getNodeID()
{
$url = Config::get()->get('uri.base.full');
return strtolower(rtrim(parse_url($url, PHP_URL_HOST) . parse_url($url, PHP_URL_PATH), '/'));
} | [
"public",
"static",
"function",
"getNodeID",
"(",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
")",
"->",
"get",
"(",
"'uri.base.full'",
")",
";",
"return",
"strtolower",
"(",
"rtrim",
"(",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_HOST",
")",
".",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_PATH",
")",
",",
"'/'",
")",
")",
";",
"}"
] | @static
@return string | [
"@static"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L361-L365 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.getPluginPath | public static function getPluginPath($name = null)
{
$path = Config::get()->get('plugin.path');
if ($name != null) {
$path = $path . '/' . $name;
}
return $path;
} | php | public static function getPluginPath($name = null)
{
$path = Config::get()->get('plugin.path');
if ($name != null) {
$path = $path . '/' . $name;
}
return $path;
} | [
"public",
"static",
"function",
"getPluginPath",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"Config",
"::",
"get",
"(",
")",
"->",
"get",
"(",
"'plugin.path'",
")",
";",
"if",
"(",
"$",
"name",
"!=",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"path",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | @static
@param string $name
@return string | [
"@static"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L374-L381 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.getComposerInfo | public static function getComposerInfo($libery = 'jfusion/framework')
{
$lib = null;
$installed = __DIR__ . '/../../../composer/installed.json';
if (file_exists($installed)) {
$json = json_decode(file_get_contents($installed));
foreach($json as $node) {
if ($node->name === $libery) {
$lib = $node;
break;
}
}
}
return $lib;
} | php | public static function getComposerInfo($libery = 'jfusion/framework')
{
$lib = null;
$installed = __DIR__ . '/../../../composer/installed.json';
if (file_exists($installed)) {
$json = json_decode(file_get_contents($installed));
foreach($json as $node) {
if ($node->name === $libery) {
$lib = $node;
break;
}
}
}
return $lib;
} | [
"public",
"static",
"function",
"getComposerInfo",
"(",
"$",
"libery",
"=",
"'jfusion/framework'",
")",
"{",
"$",
"lib",
"=",
"null",
";",
"$",
"installed",
"=",
"__DIR__",
".",
"'/../../../composer/installed.json'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"installed",
")",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"installed",
")",
")",
";",
"foreach",
"(",
"$",
"json",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"name",
"===",
"$",
"libery",
")",
"{",
"$",
"lib",
"=",
"$",
"node",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"lib",
";",
"}"
] | @param $libery
@return stdClass|null | [
"@param",
"$libery"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L388-L402 |
jfusion/org.jfusion.framework | src/Framework.php | Framework.validateUser | public static function validateUser($userinfo)
{
$plugins = Factory::getPlugins();
foreach($plugins as $plugin) {
$user = Factory::getUser($plugin->name);
if (!$user->validateUser($userinfo)) {
throw new \RuntimeException('unknown validation: ' . $plugin->name);
}
}
return true;
} | php | public static function validateUser($userinfo)
{
$plugins = Factory::getPlugins();
foreach($plugins as $plugin) {
$user = Factory::getUser($plugin->name);
if (!$user->validateUser($userinfo)) {
throw new \RuntimeException('unknown validation: ' . $plugin->name);
}
}
return true;
} | [
"public",
"static",
"function",
"validateUser",
"(",
"$",
"userinfo",
")",
"{",
"$",
"plugins",
"=",
"Factory",
"::",
"getPlugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"user",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"plugin",
"->",
"name",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"validateUser",
"(",
"$",
"userinfo",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'unknown validation: '",
".",
"$",
"plugin",
"->",
"name",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | @param Userinfo $userinfo
@return bool | [
"@param",
"Userinfo",
"$userinfo"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Framework.php#L409-L420 |
ClanCats/Core | src/bundles/Auth/CCAuth.php | CCAuth.validate | public static function validate( $identifier, $password, $name = null )
{
return Handler::create( $name )->validate( $identifier, $password );
} | php | public static function validate( $identifier, $password, $name = null )
{
return Handler::create( $name )->validate( $identifier, $password );
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"identifier",
",",
"$",
"password",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"Handler",
"::",
"create",
"(",
"$",
"name",
")",
"->",
"validate",
"(",
"$",
"identifier",
",",
"$",
"password",
")",
";",
"}"
] | Validate user credentials
@param mixed $identifier
@param string $password
@param string $name The auth instance
@return bool | [
"Validate",
"user",
"credentials"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/CCAuth.php#L44-L47 |
ClanCats/Core | src/bundles/Auth/CCAuth.php | CCAuth.sign_in | public static function sign_in( \Auth\User $user, $keep_loggedin = true, $name = null )
{
return Handler::create( $name )->sign_in( $user, $keep_loggedin );
} | php | public static function sign_in( \Auth\User $user, $keep_loggedin = true, $name = null )
{
return Handler::create( $name )->sign_in( $user, $keep_loggedin );
} | [
"public",
"static",
"function",
"sign_in",
"(",
"\\",
"Auth",
"\\",
"User",
"$",
"user",
",",
"$",
"keep_loggedin",
"=",
"true",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"Handler",
"::",
"create",
"(",
"$",
"name",
")",
"->",
"sign_in",
"(",
"$",
"user",
",",
"$",
"keep_loggedin",
")",
";",
"}"
] | Sign in a user
@param Auth\User $user
@param string $keep_loggedin
@param string $name The auth instance
@return bool | [
"Sign",
"in",
"a",
"user"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Auth/CCAuth.php#L57-L60 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php | BaseSystemSettingsPeer.getFieldNames | public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, SystemSettingsPeer::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return SystemSettingsPeer::$fieldNames[$type];
} | php | public static function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, SystemSettingsPeer::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
}
return SystemSettingsPeer::$fieldNames[$type];
} | [
"public",
"static",
"function",
"getFieldNames",
"(",
"$",
"type",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"SystemSettingsPeer",
"::",
"$",
"fieldNames",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. '",
".",
"$",
"type",
".",
"' was given.'",
")",
";",
"}",
"return",
"SystemSettingsPeer",
"::",
"$",
"fieldNames",
"[",
"$",
"type",
"]",
";",
"}"
] | Returns an array of field names.
@param string $type The type of fieldnames to return:
One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
@return array A list of field names
@throws PropelException - if the type is not valid. | [
"Returns",
"an",
"array",
"of",
"field",
"names",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php#L121-L128 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php | BaseSystemSettingsPeer.addSelectColumns | public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(SystemSettingsPeer::ID);
$criteria->addSelectColumn(SystemSettingsPeer::KEY);
$criteria->addSelectColumn(SystemSettingsPeer::VALUE);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.key');
$criteria->addSelectColumn($alias . '.value');
}
} | php | public static function addSelectColumns(Criteria $criteria, $alias = null)
{
if (null === $alias) {
$criteria->addSelectColumn(SystemSettingsPeer::ID);
$criteria->addSelectColumn(SystemSettingsPeer::KEY);
$criteria->addSelectColumn(SystemSettingsPeer::VALUE);
} else {
$criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.key');
$criteria->addSelectColumn($alias . '.value');
}
} | [
"public",
"static",
"function",
"addSelectColumns",
"(",
"Criteria",
"$",
"criteria",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"alias",
")",
"{",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"SystemSettingsPeer",
"::",
"ID",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"SystemSettingsPeer",
"::",
"KEY",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"SystemSettingsPeer",
"::",
"VALUE",
")",
";",
"}",
"else",
"{",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.id'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.key'",
")",
";",
"$",
"criteria",
"->",
"addSelectColumn",
"(",
"$",
"alias",
".",
"'.value'",
")",
";",
"}",
"}"
] | Add all the columns needed to create a new object.
Note: any columns that were marked with lazyLoad="true" in the
XML schema will not be added to the select list and only loaded
on demand.
@param Criteria $criteria object containing the columns to add.
@param string $alias optional table alias
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Add",
"all",
"the",
"columns",
"needed",
"to",
"create",
"a",
"new",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php#L159-L170 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php | BaseSystemSettingsPeer.getInstanceFromPool | public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(SystemSettingsPeer::$instances[$key])) {
return SystemSettingsPeer::$instances[$key];
}
}
return null; // just to be explicit
} | php | public static function getInstanceFromPool($key)
{
if (Propel::isInstancePoolingEnabled()) {
if (isset(SystemSettingsPeer::$instances[$key])) {
return SystemSettingsPeer::$instances[$key];
}
}
return null; // just to be explicit
} | [
"public",
"static",
"function",
"getInstanceFromPool",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"Propel",
"::",
"isInstancePoolingEnabled",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"SystemSettingsPeer",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"SystemSettingsPeer",
"::",
"$",
"instances",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"null",
";",
"// just to be explicit",
"}"
] | Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
For tables with a single-column primary key, that simple pkey value will be returned. For tables with
a multi-column primary key, a serialize()d version of the primary key will be returned.
@param string $key The key (@see getPrimaryKeyHash()) for this instance.
@return SystemSettings Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled.
@see getPrimaryKeyHash() | [
"Retrieves",
"a",
"string",
"version",
"of",
"the",
"primary",
"key",
"from",
"the",
"DB",
"resultset",
"row",
"that",
"can",
"be",
"used",
"to",
"uniquely",
"identify",
"a",
"row",
"in",
"this",
"table",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php#L341-L350 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php | BaseSystemSettingsPeer.buildTableMap | public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseSystemSettingsPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseSystemSettingsPeer::TABLE_NAME)) {
$dbMap->addTableObject(new \Slashworks\BackendBundle\Model\map\SystemSettingsTableMap());
}
} | php | public static function buildTableMap()
{
$dbMap = Propel::getDatabaseMap(BaseSystemSettingsPeer::DATABASE_NAME);
if (!$dbMap->hasTable(BaseSystemSettingsPeer::TABLE_NAME)) {
$dbMap->addTableObject(new \Slashworks\BackendBundle\Model\map\SystemSettingsTableMap());
}
} | [
"public",
"static",
"function",
"buildTableMap",
"(",
")",
"{",
"$",
"dbMap",
"=",
"Propel",
"::",
"getDatabaseMap",
"(",
"BaseSystemSettingsPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"!",
"$",
"dbMap",
"->",
"hasTable",
"(",
"BaseSystemSettingsPeer",
"::",
"TABLE_NAME",
")",
")",
"{",
"$",
"dbMap",
"->",
"addTableObject",
"(",
"new",
"\\",
"Slashworks",
"\\",
"BackendBundle",
"\\",
"Model",
"\\",
"map",
"\\",
"SystemSettingsTableMap",
"(",
")",
")",
";",
"}",
"}"
] | Add a TableMap instance to the database for this peer class. | [
"Add",
"a",
"TableMap",
"instance",
"to",
"the",
"database",
"for",
"this",
"peer",
"class",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php#L484-L490 |
slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php | BaseSystemSettingsPeer.doUpdate | public static function doUpdate($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(SystemSettingsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria(SystemSettingsPeer::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(SystemSettingsPeer::ID);
$value = $criteria->remove(SystemSettingsPeer::ID);
if ($value) {
$selectCriteria->add(SystemSettingsPeer::ID, $value, $comparison);
} else {
$selectCriteria->setPrimaryTableName(SystemSettingsPeer::TABLE_NAME);
}
} else { // $values is SystemSettings object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(SystemSettingsPeer::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
} | php | public static function doUpdate($values, PropelPDO $con = null)
{
if ($con === null) {
$con = Propel::getConnection(SystemSettingsPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
$selectCriteria = new Criteria(SystemSettingsPeer::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(SystemSettingsPeer::ID);
$value = $criteria->remove(SystemSettingsPeer::ID);
if ($value) {
$selectCriteria->add(SystemSettingsPeer::ID, $value, $comparison);
} else {
$selectCriteria->setPrimaryTableName(SystemSettingsPeer::TABLE_NAME);
}
} else { // $values is SystemSettings object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(SystemSettingsPeer::DATABASE_NAME);
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
} | [
"public",
"static",
"function",
"doUpdate",
"(",
"$",
"values",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"SystemSettingsPeer",
"::",
"DATABASE_NAME",
",",
"Propel",
"::",
"CONNECTION_WRITE",
")",
";",
"}",
"$",
"selectCriteria",
"=",
"new",
"Criteria",
"(",
"SystemSettingsPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"$",
"criteria",
"=",
"clone",
"$",
"values",
";",
"// rename for clarity",
"$",
"comparison",
"=",
"$",
"criteria",
"->",
"getComparison",
"(",
"SystemSettingsPeer",
"::",
"ID",
")",
";",
"$",
"value",
"=",
"$",
"criteria",
"->",
"remove",
"(",
"SystemSettingsPeer",
"::",
"ID",
")",
";",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"selectCriteria",
"->",
"add",
"(",
"SystemSettingsPeer",
"::",
"ID",
",",
"$",
"value",
",",
"$",
"comparison",
")",
";",
"}",
"else",
"{",
"$",
"selectCriteria",
"->",
"setPrimaryTableName",
"(",
"SystemSettingsPeer",
"::",
"TABLE_NAME",
")",
";",
"}",
"}",
"else",
"{",
"// $values is SystemSettings object",
"$",
"criteria",
"=",
"$",
"values",
"->",
"buildCriteria",
"(",
")",
";",
"// gets full criteria",
"$",
"selectCriteria",
"=",
"$",
"values",
"->",
"buildPkeyCriteria",
"(",
")",
";",
"// gets criteria w/ primary key(s)",
"}",
"// set the correct dbName",
"$",
"criteria",
"->",
"setDbName",
"(",
"SystemSettingsPeer",
"::",
"DATABASE_NAME",
")",
";",
"return",
"BasePeer",
"::",
"doUpdate",
"(",
"$",
"selectCriteria",
",",
"$",
"criteria",
",",
"$",
"con",
")",
";",
"}"
] | Performs an UPDATE on the database, given a SystemSettings or Criteria object.
@param mixed $values Criteria or SystemSettings object containing data that is used to create the UPDATE statement.
@param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
@return int The number of affected rows (if supported by underlying database driver).
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"an",
"UPDATE",
"on",
"the",
"database",
"given",
"a",
"SystemSettings",
"or",
"Criteria",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseSystemSettingsPeer.php#L555-L583 |
neos/doctools | Classes/Domain/Service/EelHelperClassParser.php | EelHelperClassParser.parseTitle | protected function parseTitle()
{
if (($registeredName = array_search($this->className, $this->defaultContextSettings)) !== false) {
return $registeredName;
} elseif (preg_match('/\\\\([^\\\\]*)Helper$/', $this->className, $matches)) {
return $matches[1];
}
return $this->className;
} | php | protected function parseTitle()
{
if (($registeredName = array_search($this->className, $this->defaultContextSettings)) !== false) {
return $registeredName;
} elseif (preg_match('/\\\\([^\\\\]*)Helper$/', $this->className, $matches)) {
return $matches[1];
}
return $this->className;
} | [
"protected",
"function",
"parseTitle",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"registeredName",
"=",
"array_search",
"(",
"$",
"this",
"->",
"className",
",",
"$",
"this",
"->",
"defaultContextSettings",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"registeredName",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/\\\\\\\\([^\\\\\\\\]*)Helper$/'",
",",
"$",
"this",
"->",
"className",
",",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"className",
";",
"}"
] | Get the title from the Eel helper class name
@return string | [
"Get",
"the",
"title",
"from",
"the",
"Eel",
"helper",
"class",
"name"
] | train | https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Domain/Service/EelHelperClassParser.php#L34-L43 |
neos/doctools | Classes/Domain/Service/EelHelperClassParser.php | EelHelperClassParser.parseDescription | protected function parseDescription()
{
$description = $this->classReflection->getDescription() . chr(10) . chr(10);
$description .= 'Implemented in: ``' . $this->className . '``' . chr(10) . chr(10);
$helperName = $this->parseTitle();
$helperInstance = new $this->className();
$methods = $this->getHelperMethods();
foreach ($methods as $methodReflection) {
if (!$helperInstance instanceof ProtectedContextAwareInterface || $helperInstance->allowsCallOfMethod($methodReflection->getName())) {
$methodDescription = $this->getMethodDescription($helperName, $methodReflection);
$description .= trim($methodDescription) . chr(10) . chr(10);
}
}
return $description;
} | php | protected function parseDescription()
{
$description = $this->classReflection->getDescription() . chr(10) . chr(10);
$description .= 'Implemented in: ``' . $this->className . '``' . chr(10) . chr(10);
$helperName = $this->parseTitle();
$helperInstance = new $this->className();
$methods = $this->getHelperMethods();
foreach ($methods as $methodReflection) {
if (!$helperInstance instanceof ProtectedContextAwareInterface || $helperInstance->allowsCallOfMethod($methodReflection->getName())) {
$methodDescription = $this->getMethodDescription($helperName, $methodReflection);
$description .= trim($methodDescription) . chr(10) . chr(10);
}
}
return $description;
} | [
"protected",
"function",
"parseDescription",
"(",
")",
"{",
"$",
"description",
"=",
"$",
"this",
"->",
"classReflection",
"->",
"getDescription",
"(",
")",
".",
"chr",
"(",
"10",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"description",
".=",
"'Implemented in: ``'",
".",
"$",
"this",
"->",
"className",
".",
"'``'",
".",
"chr",
"(",
"10",
")",
".",
"chr",
"(",
"10",
")",
";",
"$",
"helperName",
"=",
"$",
"this",
"->",
"parseTitle",
"(",
")",
";",
"$",
"helperInstance",
"=",
"new",
"$",
"this",
"->",
"className",
"(",
")",
";",
"$",
"methods",
"=",
"$",
"this",
"->",
"getHelperMethods",
"(",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"methodReflection",
")",
"{",
"if",
"(",
"!",
"$",
"helperInstance",
"instanceof",
"ProtectedContextAwareInterface",
"||",
"$",
"helperInstance",
"->",
"allowsCallOfMethod",
"(",
"$",
"methodReflection",
"->",
"getName",
"(",
")",
")",
")",
"{",
"$",
"methodDescription",
"=",
"$",
"this",
"->",
"getMethodDescription",
"(",
"$",
"helperName",
",",
"$",
"methodReflection",
")",
";",
"$",
"description",
".=",
"trim",
"(",
"$",
"methodDescription",
")",
".",
"chr",
"(",
"10",
")",
".",
"chr",
"(",
"10",
")",
";",
"}",
"}",
"return",
"$",
"description",
";",
"}"
] | Iterate over all methods in the helper class
@return string | [
"Iterate",
"over",
"all",
"methods",
"in",
"the",
"helper",
"class"
] | train | https://github.com/neos/doctools/blob/726981245a8d59319ee594a582f80a30256df98b/Classes/Domain/Service/EelHelperClassParser.php#L50-L68 |
xinix-technology/norm | src/Norm/Connection/OCIConnection.php | OCIConnection.prepareInit | protected function prepareInit()
{
$stid = oci_parse($this->raw, "ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
oci_execute($stid);
oci_free_statement($stid);
$stid = oci_parse($this->raw, "ALTER SESSION SET NLS_SORT = BINARY_CI");
oci_execute($stid);
oci_free_statement($stid);
$stid = oci_parse($this->raw, "ALTER SESSION SET NLS_COMP = LINGUISTIC");
oci_execute($stid);
oci_free_statement($stid);
} | php | protected function prepareInit()
{
$stid = oci_parse($this->raw, "ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
oci_execute($stid);
oci_free_statement($stid);
$stid = oci_parse($this->raw, "ALTER SESSION SET NLS_SORT = BINARY_CI");
oci_execute($stid);
oci_free_statement($stid);
$stid = oci_parse($this->raw, "ALTER SESSION SET NLS_COMP = LINGUISTIC");
oci_execute($stid);
oci_free_statement($stid);
} | [
"protected",
"function",
"prepareInit",
"(",
")",
"{",
"$",
"stid",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"\"ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'\"",
")",
";",
"oci_execute",
"(",
"$",
"stid",
")",
";",
"oci_free_statement",
"(",
"$",
"stid",
")",
";",
"$",
"stid",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"\"ALTER SESSION SET NLS_SORT = BINARY_CI\"",
")",
";",
"oci_execute",
"(",
"$",
"stid",
")",
";",
"oci_free_statement",
"(",
"$",
"stid",
")",
";",
"$",
"stid",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"\"ALTER SESSION SET NLS_COMP = LINGUISTIC\"",
")",
";",
"oci_execute",
"(",
"$",
"stid",
")",
";",
"oci_free_statement",
"(",
"$",
"stid",
")",
";",
"}"
] | Preparing initialization of connection
@return void | [
"Preparing",
"initialization",
"of",
"connection"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/OCIConnection.php#L72-L85 |
xinix-technology/norm | src/Norm/Connection/OCIConnection.php | OCIConnection.query | public function query($collection, array $criteria = array())
{ $collection = $this->factory($collection);
return new Cursor($collection,$criteria);
} | php | public function query($collection, array $criteria = array())
{ $collection = $this->factory($collection);
return new Cursor($collection,$criteria);
} | [
"public",
"function",
"query",
"(",
"$",
"collection",
",",
"array",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"factory",
"(",
"$",
"collection",
")",
";",
"return",
"new",
"Cursor",
"(",
"$",
"collection",
",",
"$",
"criteria",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/OCIConnection.php#L90-L94 |
xinix-technology/norm | src/Norm/Connection/OCIConnection.php | OCIConnection.persist | public function persist($collection, array $document)
{
if ($collection instanceof Collection) {
$collectionName = $collection->getName();
} else {
$collectionName = $collection;
$collection = static::factory($collection);
}
$data = $this->marshall($document);
$result = false;
if (!isset($document['$id'])) {
$id = $this->insert($collectionName, $data);
if ($id) {
$data['$id'] = $id;
$result = $data;
}
} else {
$data['id'] = $document['$id'];
unset($data['$id']);
$result = $this->update($collectionName, $data);
if ($result) {
$result = $data;
}
}
return $this->unmarshall($result);
} | php | public function persist($collection, array $document)
{
if ($collection instanceof Collection) {
$collectionName = $collection->getName();
} else {
$collectionName = $collection;
$collection = static::factory($collection);
}
$data = $this->marshall($document);
$result = false;
if (!isset($document['$id'])) {
$id = $this->insert($collectionName, $data);
if ($id) {
$data['$id'] = $id;
$result = $data;
}
} else {
$data['id'] = $document['$id'];
unset($data['$id']);
$result = $this->update($collectionName, $data);
if ($result) {
$result = $data;
}
}
return $this->unmarshall($result);
} | [
"public",
"function",
"persist",
"(",
"$",
"collection",
",",
"array",
"$",
"document",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"Collection",
")",
"{",
"$",
"collectionName",
"=",
"$",
"collection",
"->",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collectionName",
"=",
"$",
"collection",
";",
"$",
"collection",
"=",
"static",
"::",
"factory",
"(",
"$",
"collection",
")",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"marshall",
"(",
"$",
"document",
")",
";",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"document",
"[",
"'$id'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"insert",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"data",
"[",
"'$id'",
"]",
"=",
"$",
"id",
";",
"$",
"result",
"=",
"$",
"data",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"document",
"[",
"'$id'",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"'$id'",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"update",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"$",
"data",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"unmarshall",
"(",
"$",
"result",
")",
";",
"}"
] | Sync data to database. If it's new data, we insert it as new document, otherwise, if the document exists, we just update it.
@param Collection $collection
@param Model $model
@return bool | [
"Sync",
"data",
"to",
"database",
".",
"If",
"it",
"s",
"new",
"data",
"we",
"insert",
"it",
"as",
"new",
"document",
"otherwise",
"if",
"the",
"document",
"exists",
"we",
"just",
"update",
"it",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/OCIConnection.php#L104-L136 |
xinix-technology/norm | src/Norm/Connection/OCIConnection.php | OCIConnection.remove | public function remove($collection,$criteria = null)
{
if ($collection instanceof Collection) {
$collectionName = $collection->getName();
} else {
$collectionName = $collection;
$collection = static::factory($collection);
}
if($criteria instanceof Model){
$id = $criteria->getId();
$sql = 'DELETE FROM '.$collectionName.' WHERE id = :id';
$stid = oci_parse($this->raw, $sql);
oci_bind_by_name($stid, ":id", $id);
$result = oci_execute($stid);
oci_free_statement($stid);
}else{
throw new Exception('Unimplemented yet!');
}
return $result;
} | php | public function remove($collection,$criteria = null)
{
if ($collection instanceof Collection) {
$collectionName = $collection->getName();
} else {
$collectionName = $collection;
$collection = static::factory($collection);
}
if($criteria instanceof Model){
$id = $criteria->getId();
$sql = 'DELETE FROM '.$collectionName.' WHERE id = :id';
$stid = oci_parse($this->raw, $sql);
oci_bind_by_name($stid, ":id", $id);
$result = oci_execute($stid);
oci_free_statement($stid);
}else{
throw new Exception('Unimplemented yet!');
}
return $result;
} | [
"public",
"function",
"remove",
"(",
"$",
"collection",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"Collection",
")",
"{",
"$",
"collectionName",
"=",
"$",
"collection",
"->",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collectionName",
"=",
"$",
"collection",
";",
"$",
"collection",
"=",
"static",
"::",
"factory",
"(",
"$",
"collection",
")",
";",
"}",
"if",
"(",
"$",
"criteria",
"instanceof",
"Model",
")",
"{",
"$",
"id",
"=",
"$",
"criteria",
"->",
"getId",
"(",
")",
";",
"$",
"sql",
"=",
"'DELETE FROM '",
".",
"$",
"collectionName",
".",
"' WHERE id = :id'",
";",
"$",
"stid",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"$",
"sql",
")",
";",
"oci_bind_by_name",
"(",
"$",
"stid",
",",
"\":id\"",
",",
"$",
"id",
")",
";",
"$",
"result",
"=",
"oci_execute",
"(",
"$",
"stid",
")",
";",
"oci_free_statement",
"(",
"$",
"stid",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Unimplemented yet!'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/OCIConnection.php#L141-L164 |
xinix-technology/norm | src/Norm/Connection/OCIConnection.php | OCIConnection.insert | public function insert($collectionName, $data)
{
$id = 0;
$sql = $this->dialect->grammarInsert($collectionName, $data);
$stid = oci_parse($this->raw, $sql);
//Fixme : problem from other oracle dialect on method insert
oci_bind_by_name($stid, ":id", $id,-1,SQLT_INT);
foreach ($data as $key => $value) {
oci_bind_by_name($stid, ":".$key, $data[$key]);
}
oci_execute($stid);
oci_free_statement($stid);
return $id;
} | php | public function insert($collectionName, $data)
{
$id = 0;
$sql = $this->dialect->grammarInsert($collectionName, $data);
$stid = oci_parse($this->raw, $sql);
//Fixme : problem from other oracle dialect on method insert
oci_bind_by_name($stid, ":id", $id,-1,SQLT_INT);
foreach ($data as $key => $value) {
oci_bind_by_name($stid, ":".$key, $data[$key]);
}
oci_execute($stid);
oci_free_statement($stid);
return $id;
} | [
"public",
"function",
"insert",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
"{",
"$",
"id",
"=",
"0",
";",
"$",
"sql",
"=",
"$",
"this",
"->",
"dialect",
"->",
"grammarInsert",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
";",
"$",
"stid",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"$",
"sql",
")",
";",
"//Fixme : problem from other oracle dialect on method insert",
"oci_bind_by_name",
"(",
"$",
"stid",
",",
"\":id\"",
",",
"$",
"id",
",",
"-",
"1",
",",
"SQLT_INT",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"oci_bind_by_name",
"(",
"$",
"stid",
",",
"\":\"",
".",
"$",
"key",
",",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"oci_execute",
"(",
"$",
"stid",
")",
";",
"oci_free_statement",
"(",
"$",
"stid",
")",
";",
"return",
"$",
"id",
";",
"}"
] | Perform insert new document to database.
@param string $collectionName
@param mixed $data
@return bool | [
"Perform",
"insert",
"new",
"document",
"to",
"database",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/OCIConnection.php#L174-L193 |
xinix-technology/norm | src/Norm/Connection/OCIConnection.php | OCIConnection.update | public function update($collectionName, $data)
{
$sql = $this->dialect->grammarUpdate($collectionName, $data);
$stid = oci_parse($this->raw, $sql);
oci_bind_by_name($stid, ":id", $data['id']);
foreach ($data as $key => $value) {
oci_bind_by_name($stid, ":".$key, $data[$key]);
}
$result = oci_execute($stid);
oci_free_statement($stid);
return $result;
} | php | public function update($collectionName, $data)
{
$sql = $this->dialect->grammarUpdate($collectionName, $data);
$stid = oci_parse($this->raw, $sql);
oci_bind_by_name($stid, ":id", $data['id']);
foreach ($data as $key => $value) {
oci_bind_by_name($stid, ":".$key, $data[$key]);
}
$result = oci_execute($stid);
oci_free_statement($stid);
return $result;
} | [
"public",
"function",
"update",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"dialect",
"->",
"grammarUpdate",
"(",
"$",
"collectionName",
",",
"$",
"data",
")",
";",
"$",
"stid",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"$",
"sql",
")",
";",
"oci_bind_by_name",
"(",
"$",
"stid",
",",
"\":id\"",
",",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"oci_bind_by_name",
"(",
"$",
"stid",
",",
"\":\"",
".",
"$",
"key",
",",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"result",
"=",
"oci_execute",
"(",
"$",
"stid",
")",
";",
"oci_free_statement",
"(",
"$",
"stid",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Perform update to a document.
@param string $collectionName
@param mixed $data
@return bool | [
"Perform",
"update",
"to",
"a",
"document",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/OCIConnection.php#L203-L220 |
PortaText/php-sdk | src/PortaText/Command/Api/Acl.php | Acl.getBody | protected function getBody($method)
{
if ($method === "get") {
return parent::getBody($method);
}
$acls = array();
foreach ($this->getArguments() as $value) {
$acls[] = $value;
}
return json_encode(array("acl" => $acls));
} | php | protected function getBody($method)
{
if ($method === "get") {
return parent::getBody($method);
}
$acls = array();
foreach ($this->getArguments() as $value) {
$acls[] = $value;
}
return json_encode(array("acl" => $acls));
} | [
"protected",
"function",
"getBody",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"\"get\"",
")",
"{",
"return",
"parent",
"::",
"getBody",
"(",
"$",
"method",
")",
";",
"}",
"$",
"acls",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getArguments",
"(",
")",
"as",
"$",
"value",
")",
"{",
"$",
"acls",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"json_encode",
"(",
"array",
"(",
"\"acl\"",
"=>",
"$",
"acls",
")",
")",
";",
"}"
] | Returns the body for this endpoint.
@param string $method Method for this command.
@return string | [
"Returns",
"the",
"body",
"for",
"this",
"endpoint",
"."
] | train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Acl.php#L44-L54 |
AydinHassan/cli-md-renderer | src/Renderer/ListBlockRenderer.php | ListBlockRenderer.render | public function render(AbstractBlock $block, CliRenderer $renderer)
{
if (!($block instanceof ListBlock)) {
throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
}
return $renderer->renderBlocks($block->children());
} | php | public function render(AbstractBlock $block, CliRenderer $renderer)
{
if (!($block instanceof ListBlock)) {
throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
}
return $renderer->renderBlocks($block->children());
} | [
"public",
"function",
"render",
"(",
"AbstractBlock",
"$",
"block",
",",
"CliRenderer",
"$",
"renderer",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"block",
"instanceof",
"ListBlock",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Incompatible block type: \"%s\"'",
",",
"get_class",
"(",
"$",
"block",
")",
")",
")",
";",
"}",
"return",
"$",
"renderer",
"->",
"renderBlocks",
"(",
"$",
"block",
"->",
"children",
"(",
")",
")",
";",
"}"
] | @param AbstractBlock $block
@param CliRenderer $renderer
@return string | [
"@param",
"AbstractBlock",
"$block",
"@param",
"CliRenderer",
"$renderer"
] | train | https://github.com/AydinHassan/cli-md-renderer/blob/521f9ace2aeadd58bf8a3910704be8360f5bd7b2/src/Renderer/ListBlockRenderer.php#L23-L30 |
egeloen/IvorySerializerBundle | DependencyInjection/Compiler/RegisterCachePoolPass.php | RegisterCachePoolPass.process | public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition($classMetadataFactoryService = 'ivory.serializer.mapping.factory')) {
return;
}
$classMetadataFactory = $container->getDefinition($classMetadataFactoryService);
if ($classMetadataFactory->getClass() !== CacheClassMetadataFactory::class) {
return;
}
$cache = (string) $classMetadataFactory->getArgument(1);
if (class_exists(CachePoolPass::class) || $container->hasDefinition($cache)) {
return;
}
$cachePath = $container->getParameter('kernel.cache_dir').'/ivory-serializer';
$container->setDefinition(
$cache = 'ivory.serializer.cache',
new Definition(FilesystemAdapter::class, ['', 0, $cachePath])
);
$classMetadataFactory->replaceArgument(1, $cachePool = new Reference($cache));
$container
->getDefinition('ivory.serializer.cache_warmer')
->replaceArgument(2, $cachePool);
} | php | public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition($classMetadataFactoryService = 'ivory.serializer.mapping.factory')) {
return;
}
$classMetadataFactory = $container->getDefinition($classMetadataFactoryService);
if ($classMetadataFactory->getClass() !== CacheClassMetadataFactory::class) {
return;
}
$cache = (string) $classMetadataFactory->getArgument(1);
if (class_exists(CachePoolPass::class) || $container->hasDefinition($cache)) {
return;
}
$cachePath = $container->getParameter('kernel.cache_dir').'/ivory-serializer';
$container->setDefinition(
$cache = 'ivory.serializer.cache',
new Definition(FilesystemAdapter::class, ['', 0, $cachePath])
);
$classMetadataFactory->replaceArgument(1, $cachePool = new Reference($cache));
$container
->getDefinition('ivory.serializer.cache_warmer')
->replaceArgument(2, $cachePool);
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"classMetadataFactoryService",
"=",
"'ivory.serializer.mapping.factory'",
")",
")",
"{",
"return",
";",
"}",
"$",
"classMetadataFactory",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"$",
"classMetadataFactoryService",
")",
";",
"if",
"(",
"$",
"classMetadataFactory",
"->",
"getClass",
"(",
")",
"!==",
"CacheClassMetadataFactory",
"::",
"class",
")",
"{",
"return",
";",
"}",
"$",
"cache",
"=",
"(",
"string",
")",
"$",
"classMetadataFactory",
"->",
"getArgument",
"(",
"1",
")",
";",
"if",
"(",
"class_exists",
"(",
"CachePoolPass",
"::",
"class",
")",
"||",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"cache",
")",
")",
"{",
"return",
";",
"}",
"$",
"cachePath",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.cache_dir'",
")",
".",
"'/ivory-serializer'",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"cache",
"=",
"'ivory.serializer.cache'",
",",
"new",
"Definition",
"(",
"FilesystemAdapter",
"::",
"class",
",",
"[",
"''",
",",
"0",
",",
"$",
"cachePath",
"]",
")",
")",
";",
"$",
"classMetadataFactory",
"->",
"replaceArgument",
"(",
"1",
",",
"$",
"cachePool",
"=",
"new",
"Reference",
"(",
"$",
"cache",
")",
")",
";",
"$",
"container",
"->",
"getDefinition",
"(",
"'ivory.serializer.cache_warmer'",
")",
"->",
"replaceArgument",
"(",
"2",
",",
"$",
"cachePool",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/DependencyInjection/Compiler/RegisterCachePoolPass.php#L30-L60 |
Kylob/Bootstrap | src/Table.php | Table.open | public function open($vars = '', $caption = '')
{
$vars = $this->values($vars);
if (isset($vars['class'])) {
$vars['class'] = $this->prefixClasses('table', array('responsive', 'bordered', 'striped', 'hover', 'condensed'), $vars['class']);
}
return parent::open($vars, $caption);
} | php | public function open($vars = '', $caption = '')
{
$vars = $this->values($vars);
if (isset($vars['class'])) {
$vars['class'] = $this->prefixClasses('table', array('responsive', 'bordered', 'striped', 'hover', 'condensed'), $vars['class']);
}
return parent::open($vars, $caption);
} | [
"public",
"function",
"open",
"(",
"$",
"vars",
"=",
"''",
",",
"$",
"caption",
"=",
"''",
")",
"{",
"$",
"vars",
"=",
"$",
"this",
"->",
"values",
"(",
"$",
"vars",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"vars",
"[",
"'class'",
"]",
"=",
"$",
"this",
"->",
"prefixClasses",
"(",
"'table'",
",",
"array",
"(",
"'responsive'",
",",
"'bordered'",
",",
"'striped'",
",",
"'hover'",
",",
"'condensed'",
")",
",",
"$",
"vars",
"[",
"'class'",
"]",
")",
";",
"}",
"return",
"parent",
"::",
"open",
"(",
"$",
"vars",
",",
"$",
"caption",
")",
";",
"}"
] | Create a ``<table>``.
@param string|array $vars ``<table>`` attributes. Any '**responsive**', '**bordered**', '**striped**', '**hover**', and/or '**condensed**' class will be prefixed with a '**table-...**', and include the '**table**' class as well.
@param string $caption Table ``<caption>``.
@return string
@example
```php
echo $bp->table->open('class=responsive striped');
echo $bp->table->head();
echo $bp->table->cell('', 'One');
echo $bp->table->row();
echo $bp->table->cell('', 'Two');
echo $bp->table->foot();
echo $bp->table->cell('', 'Three');
echo $bp->table->close();
``` | [
"Create",
"a",
"<table",
">",
"."
] | train | https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Table.php#L30-L38 |
inpsyde/inpsyde-filter | src/AbstractFilter.php | AbstractFilter.set_options | protected function set_options( array $options = [ ] ) {
foreach ( $options as $key => $value ) {
if ( ! array_key_exists( $key, $this->options ) ) {
throw new \InvalidArgumentException(
sprintf( 'The option "%1$s" does not have a matching option[%1$s] array key', $key ),
1.0
);
continue;
}
$this->options[ $key ] = $value;
}
} | php | protected function set_options( array $options = [ ] ) {
foreach ( $options as $key => $value ) {
if ( ! array_key_exists( $key, $this->options ) ) {
throw new \InvalidArgumentException(
sprintf( 'The option "%1$s" does not have a matching option[%1$s] array key', $key ),
1.0
);
continue;
}
$this->options[ $key ] = $value;
}
} | [
"protected",
"function",
"set_options",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The option \"%1$s\" does not have a matching option[%1$s] array key'",
",",
"$",
"key",
")",
",",
"1.0",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Setting the given options from constructor.
@param array $options
@throws \InvalidArgumentException if the given option is not available to overwrite. | [
"Setting",
"the",
"given",
"options",
"from",
"constructor",
"."
] | train | https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/AbstractFilter.php#L34-L47 |
egeloen/IvorySerializerBundle | Type/FormType.php | FormType.convert | public function convert($data, TypeMetadataInterface $type, ContextInterface $context)
{
if ($context->getDirection() === Direction::DESERIALIZATION) {
throw new \RuntimeException(sprintf('Deserializing a "%s" is not supported.', Form::class));
}
return $context->getVisitor()->visitArray([
'code' => 400,
'message' => 'Validation Failed',
'errors' => $this->serializeForm($data),
], $type, $context);
} | php | public function convert($data, TypeMetadataInterface $type, ContextInterface $context)
{
if ($context->getDirection() === Direction::DESERIALIZATION) {
throw new \RuntimeException(sprintf('Deserializing a "%s" is not supported.', Form::class));
}
return $context->getVisitor()->visitArray([
'code' => 400,
'message' => 'Validation Failed',
'errors' => $this->serializeForm($data),
], $type, $context);
} | [
"public",
"function",
"convert",
"(",
"$",
"data",
",",
"TypeMetadataInterface",
"$",
"type",
",",
"ContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"context",
"->",
"getDirection",
"(",
")",
"===",
"Direction",
"::",
"DESERIALIZATION",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Deserializing a \"%s\" is not supported.'",
",",
"Form",
"::",
"class",
")",
")",
";",
"}",
"return",
"$",
"context",
"->",
"getVisitor",
"(",
")",
"->",
"visitArray",
"(",
"[",
"'code'",
"=>",
"400",
",",
"'message'",
"=>",
"'Validation Failed'",
",",
"'errors'",
"=>",
"$",
"this",
"->",
"serializeForm",
"(",
"$",
"data",
")",
",",
"]",
",",
"$",
"type",
",",
"$",
"context",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/Type/FormType.php#L28-L39 |
egeloen/IvorySerializerBundle | Type/FormType.php | FormType.serializeForm | private function serializeForm(Form $form)
{
$result = $children = [];
$errors = iterator_to_array($form->getErrors());
foreach ($form as $child) {
if ($child instanceof Form) {
$children[$child->getName()] = $this->serializeForm($child);
}
}
if (!empty($errors)) {
$result['errors'] = $errors;
}
if (!empty($children)) {
$result['children'] = $children;
}
return $result;
} | php | private function serializeForm(Form $form)
{
$result = $children = [];
$errors = iterator_to_array($form->getErrors());
foreach ($form as $child) {
if ($child instanceof Form) {
$children[$child->getName()] = $this->serializeForm($child);
}
}
if (!empty($errors)) {
$result['errors'] = $errors;
}
if (!empty($children)) {
$result['children'] = $children;
}
return $result;
} | [
"private",
"function",
"serializeForm",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"result",
"=",
"$",
"children",
"=",
"[",
"]",
";",
"$",
"errors",
"=",
"iterator_to_array",
"(",
"$",
"form",
"->",
"getErrors",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"form",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"instanceof",
"Form",
")",
"{",
"$",
"children",
"[",
"$",
"child",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"serializeForm",
"(",
"$",
"child",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"result",
"[",
"'errors'",
"]",
"=",
"$",
"errors",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"children",
")",
")",
"{",
"$",
"result",
"[",
"'children'",
"]",
"=",
"$",
"children",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | @param Form $form
@return mixed[] | [
"@param",
"Form",
"$form"
] | train | https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/Type/FormType.php#L46-L66 |
AydinHassan/cli-md-renderer | src/InlineRenderer/CodeRenderer.php | CodeRenderer.render | public function render(AbstractInline $inline, CliRenderer $renderer)
{
if (!($inline instanceof Code)) {
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
}
return $renderer->style($inline->getContent(), 'yellow');
} | php | public function render(AbstractInline $inline, CliRenderer $renderer)
{
if (!($inline instanceof Code)) {
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
}
return $renderer->style($inline->getContent(), 'yellow');
} | [
"public",
"function",
"render",
"(",
"AbstractInline",
"$",
"inline",
",",
"CliRenderer",
"$",
"renderer",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"inline",
"instanceof",
"Code",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Incompatible inline type: \"%s\"'",
",",
"get_class",
"(",
"$",
"inline",
")",
")",
")",
";",
"}",
"return",
"$",
"renderer",
"->",
"style",
"(",
"$",
"inline",
"->",
"getContent",
"(",
")",
",",
"'yellow'",
")",
";",
"}"
] | @param AbstractInline $inline
@param CliRenderer $renderer
@return string | [
"@param",
"AbstractInline",
"$inline",
"@param",
"CliRenderer",
"$renderer"
] | train | https://github.com/AydinHassan/cli-md-renderer/blob/521f9ace2aeadd58bf8a3910704be8360f5bd7b2/src/InlineRenderer/CodeRenderer.php#L23-L30 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/AppController.php | AppController.check4Client | public function check4Client($iCustomerId)
{
if ($this->get('security.context')->isGranted('ROLE_ADMIN')) {
return true;
} else {
$oUser = $this->getUser();
if (empty($oUser)) {
return false;
}
$oResult = UserCustomerRelationQuery::create()->findOneByArray(array("UserId" => $oUser->getId(), "CustomerId" => $iCustomerId));
return (!empty($oResult));
}
} | php | public function check4Client($iCustomerId)
{
if ($this->get('security.context')->isGranted('ROLE_ADMIN')) {
return true;
} else {
$oUser = $this->getUser();
if (empty($oUser)) {
return false;
}
$oResult = UserCustomerRelationQuery::create()->findOneByArray(array("UserId" => $oUser->getId(), "CustomerId" => $iCustomerId));
return (!empty($oResult));
}
} | [
"public",
"function",
"check4Client",
"(",
"$",
"iCustomerId",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'security.context'",
")",
"->",
"isGranted",
"(",
"'ROLE_ADMIN'",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"$",
"oUser",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"oUser",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"oResult",
"=",
"UserCustomerRelationQuery",
"::",
"create",
"(",
")",
"->",
"findOneByArray",
"(",
"array",
"(",
"\"UserId\"",
"=>",
"$",
"oUser",
"->",
"getId",
"(",
")",
",",
"\"CustomerId\"",
"=>",
"$",
"iCustomerId",
")",
")",
";",
"return",
"(",
"!",
"empty",
"(",
"$",
"oResult",
")",
")",
";",
"}",
"}"
] | Check if user has access to customer
@param int $iCustomerId
@return bool | [
"Check",
"if",
"user",
"has",
"access",
"to",
"customer"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/AppController.php#L59-L75 |
webtown-php/KunstmaanExtensionBundle | src/Translation/Extraction/File/KunstmaanExtractor.php | KunstmaanExtractor.visitFile | public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue)
{
if ($file->getExtension() != 'yml') {
return;
}
$path = strtr($file->getRealPath(), DIRECTORY_SEPARATOR, '/');
if (strpos($path, 'Resources/config/pageparts') === false) {
return;
}
$parser = $this->getYmlParser();
$pagePartConfigs = $parser->parse(file_get_contents($file));
if (array_key_exists('types', $pagePartConfigs) && is_array($pagePartConfigs['types'])) {
foreach ($pagePartConfigs['types'] as $type) {
if (is_array($type) && array_key_exists('name', $type)) {
$message = new Message($type['name']);
$message->addSource(new FileSource((string)$file));
$catalogue->add($message);
}
}
}
} | php | public function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue)
{
if ($file->getExtension() != 'yml') {
return;
}
$path = strtr($file->getRealPath(), DIRECTORY_SEPARATOR, '/');
if (strpos($path, 'Resources/config/pageparts') === false) {
return;
}
$parser = $this->getYmlParser();
$pagePartConfigs = $parser->parse(file_get_contents($file));
if (array_key_exists('types', $pagePartConfigs) && is_array($pagePartConfigs['types'])) {
foreach ($pagePartConfigs['types'] as $type) {
if (is_array($type) && array_key_exists('name', $type)) {
$message = new Message($type['name']);
$message->addSource(new FileSource((string)$file));
$catalogue->add($message);
}
}
}
} | [
"public",
"function",
"visitFile",
"(",
"\\",
"SplFileInfo",
"$",
"file",
",",
"MessageCatalogue",
"$",
"catalogue",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
"!=",
"'yml'",
")",
"{",
"return",
";",
"}",
"$",
"path",
"=",
"strtr",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"'/'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'Resources/config/pageparts'",
")",
"===",
"false",
")",
"{",
"return",
";",
"}",
"$",
"parser",
"=",
"$",
"this",
"->",
"getYmlParser",
"(",
")",
";",
"$",
"pagePartConfigs",
"=",
"$",
"parser",
"->",
"parse",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'types'",
",",
"$",
"pagePartConfigs",
")",
"&&",
"is_array",
"(",
"$",
"pagePartConfigs",
"[",
"'types'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"pagePartConfigs",
"[",
"'types'",
"]",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"type",
")",
"&&",
"array_key_exists",
"(",
"'name'",
",",
"$",
"type",
")",
")",
"{",
"$",
"message",
"=",
"new",
"Message",
"(",
"$",
"type",
"[",
"'name'",
"]",
")",
";",
"$",
"message",
"->",
"addSource",
"(",
"new",
"FileSource",
"(",
"(",
"string",
")",
"$",
"file",
")",
")",
";",
"$",
"catalogue",
"->",
"add",
"(",
"$",
"message",
")",
";",
"}",
"}",
"}",
"}"
] | Collect the pagepart names!
@param \SplFileInfo $file
@param MessageCatalogue $catalogue | [
"Collect",
"the",
"pagepart",
"names!"
] | train | https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Translation/Extraction/File/KunstmaanExtractor.php#L229-L249 |
steeffeen/FancyManiaLinks | FML/XmlRpc/UIProperties.php | UIProperties.setChatOffset | public function setChatOffset($offsetX, $offsetY)
{
$offset = array((float)$offsetX, (float)$offsetY);
$this->setProperty($this->chatProperties, "offset", implode(" ", $offset));
return $this;
} | php | public function setChatOffset($offsetX, $offsetY)
{
$offset = array((float)$offsetX, (float)$offsetY);
$this->setProperty($this->chatProperties, "offset", implode(" ", $offset));
return $this;
} | [
"public",
"function",
"setChatOffset",
"(",
"$",
"offsetX",
",",
"$",
"offsetY",
")",
"{",
"$",
"offset",
"=",
"array",
"(",
"(",
"float",
")",
"$",
"offsetX",
",",
"(",
"float",
")",
"$",
"offsetY",
")",
";",
"$",
"this",
"->",
"setProperty",
"(",
"$",
"this",
"->",
"chatProperties",
",",
"\"offset\"",
",",
"implode",
"(",
"\" \"",
",",
"$",
"offset",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the chat offset
@api
@param float $offsetX X offset
@param float $offsetY Y offset
@return static | [
"Set",
"the",
"chat",
"offset"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/UIProperties.php#L104-L109 |
steeffeen/FancyManiaLinks | FML/XmlRpc/UIProperties.php | UIProperties.setMapInfoPosition | public function setMapInfoPosition($positionX, $positionY, $positionZ = null)
{
$this->setPositionProperty($this->mapInfoProperties, $positionX, $positionY, $positionZ);
return $this;
} | php | public function setMapInfoPosition($positionX, $positionY, $positionZ = null)
{
$this->setPositionProperty($this->mapInfoProperties, $positionX, $positionY, $positionZ);
return $this;
} | [
"public",
"function",
"setMapInfoPosition",
"(",
"$",
"positionX",
",",
"$",
"positionY",
",",
"$",
"positionZ",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setPositionProperty",
"(",
"$",
"this",
"->",
"mapInfoProperties",
",",
"$",
"positionX",
",",
"$",
"positionY",
",",
"$",
"positionZ",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the map info position
@api
@param float $positionX X position
@param float $positionY Y position
@param float $positionZ (optional) Z position (Z-index)
@return static | [
"Set",
"the",
"map",
"info",
"position"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/UIProperties.php#L203-L207 |
steeffeen/FancyManiaLinks | FML/XmlRpc/UIProperties.php | UIProperties.setCountdownPosition | public function setCountdownPosition($positionX, $positionY, $positionZ = null)
{
$this->setPositionProperty($this->countdownProperties, $positionX, $positionY, $positionZ);
return $this;
} | php | public function setCountdownPosition($positionX, $positionY, $positionZ = null)
{
$this->setPositionProperty($this->countdownProperties, $positionX, $positionY, $positionZ);
return $this;
} | [
"public",
"function",
"setCountdownPosition",
"(",
"$",
"positionX",
",",
"$",
"positionY",
",",
"$",
"positionZ",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setPositionProperty",
"(",
"$",
"this",
"->",
"countdownProperties",
",",
"$",
"positionX",
",",
"$",
"positionY",
",",
"$",
"positionZ",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the countdown position
@api
@param float $positionX X position
@param float $positionY Y position
@param float $positionZ (optional) Z position (Z-index)
@return static | [
"Set",
"the",
"countdown",
"position"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/UIProperties.php#L253-L257 |
steeffeen/FancyManiaLinks | FML/XmlRpc/UIProperties.php | UIProperties.renderStandalone | public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $domDocument->createElement("ui_properties");
$domDocument->appendChild($domElement);
$allProperties = $this->getProperties();
foreach ($allProperties as $property => $propertySettings) {
if (!$propertySettings) {
continue;
}
$propertyDomElement = $domDocument->createElement($property);
$domElement->appendChild($propertyDomElement);
foreach ($propertySettings as $settingName => $settingValue) {
$settingValueString = (is_string($settingValue) ? $settingValue : var_export($settingValue, true));
$propertyDomElement->setAttribute($settingName, $settingValueString);
}
}
return $domDocument;
} | php | public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $domDocument->createElement("ui_properties");
$domDocument->appendChild($domElement);
$allProperties = $this->getProperties();
foreach ($allProperties as $property => $propertySettings) {
if (!$propertySettings) {
continue;
}
$propertyDomElement = $domDocument->createElement($property);
$domElement->appendChild($propertyDomElement);
foreach ($propertySettings as $settingName => $settingValue) {
$settingValueString = (is_string($settingValue) ? $settingValue : var_export($settingValue, true));
$propertyDomElement->setAttribute($settingName, $settingValueString);
}
}
return $domDocument;
} | [
"public",
"function",
"renderStandalone",
"(",
")",
"{",
"$",
"domDocument",
"=",
"new",
"\\",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"utf-8\"",
")",
";",
"$",
"domDocument",
"->",
"xmlStandalone",
"=",
"true",
";",
"$",
"domElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"ui_properties\"",
")",
";",
"$",
"domDocument",
"->",
"appendChild",
"(",
"$",
"domElement",
")",
";",
"$",
"allProperties",
"=",
"$",
"this",
"->",
"getProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"allProperties",
"as",
"$",
"property",
"=>",
"$",
"propertySettings",
")",
"{",
"if",
"(",
"!",
"$",
"propertySettings",
")",
"{",
"continue",
";",
"}",
"$",
"propertyDomElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"$",
"property",
")",
";",
"$",
"domElement",
"->",
"appendChild",
"(",
"$",
"propertyDomElement",
")",
";",
"foreach",
"(",
"$",
"propertySettings",
"as",
"$",
"settingName",
"=>",
"$",
"settingValue",
")",
"{",
"$",
"settingValueString",
"=",
"(",
"is_string",
"(",
"$",
"settingValue",
")",
"?",
"$",
"settingValue",
":",
"var_export",
"(",
"$",
"settingValue",
",",
"true",
")",
")",
";",
"$",
"propertyDomElement",
"->",
"setAttribute",
"(",
"$",
"settingName",
",",
"$",
"settingValueString",
")",
";",
"}",
"}",
"return",
"$",
"domDocument",
";",
"}"
] | Render the UI Properties standalone
@return \DOMDocument | [
"Render",
"the",
"UI",
"Properties",
"standalone"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/UIProperties.php#L336-L360 |
steeffeen/FancyManiaLinks | FML/XmlRpc/UIProperties.php | UIProperties.getProperties | protected function getProperties()
{
return array(
"chat" => $this->chatProperties,
"chat_avatar" => $this->chatAvatarProperties,
"map_info" => $this->mapInfoProperties,
"countdown" => $this->countdownProperties,
"go" => $this->goProperties,
"endmap_ladder_recap" => $this->endMapLadderRecapProperties,
"scorestable" => $this->scoresTableProperties
);
} | php | protected function getProperties()
{
return array(
"chat" => $this->chatProperties,
"chat_avatar" => $this->chatAvatarProperties,
"map_info" => $this->mapInfoProperties,
"countdown" => $this->countdownProperties,
"go" => $this->goProperties,
"endmap_ladder_recap" => $this->endMapLadderRecapProperties,
"scorestable" => $this->scoresTableProperties
);
} | [
"protected",
"function",
"getProperties",
"(",
")",
"{",
"return",
"array",
"(",
"\"chat\"",
"=>",
"$",
"this",
"->",
"chatProperties",
",",
"\"chat_avatar\"",
"=>",
"$",
"this",
"->",
"chatAvatarProperties",
",",
"\"map_info\"",
"=>",
"$",
"this",
"->",
"mapInfoProperties",
",",
"\"countdown\"",
"=>",
"$",
"this",
"->",
"countdownProperties",
",",
"\"go\"",
"=>",
"$",
"this",
"->",
"goProperties",
",",
"\"endmap_ladder_recap\"",
"=>",
"$",
"this",
"->",
"endMapLadderRecapProperties",
",",
"\"scorestable\"",
"=>",
"$",
"this",
"->",
"scoresTableProperties",
")",
";",
"}"
] | Get associative array of all properties
@return array | [
"Get",
"associative",
"array",
"of",
"all",
"properties"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/UIProperties.php#L378-L389 |
steeffeen/FancyManiaLinks | FML/XmlRpc/UIProperties.php | UIProperties.setPositionProperty | protected function setPositionProperty(array &$properties, $positionX, $positionY, $positionZ = null)
{
$position = array((float)$positionX, (float)$positionY);
if ($positionZ) {
array_push($position, (float)$positionZ);
}
$this->setProperty($properties, "pos", implode(" ", $position));
return $this;
} | php | protected function setPositionProperty(array &$properties, $positionX, $positionY, $positionZ = null)
{
$position = array((float)$positionX, (float)$positionY);
if ($positionZ) {
array_push($position, (float)$positionZ);
}
$this->setProperty($properties, "pos", implode(" ", $position));
return $this;
} | [
"protected",
"function",
"setPositionProperty",
"(",
"array",
"&",
"$",
"properties",
",",
"$",
"positionX",
",",
"$",
"positionY",
",",
"$",
"positionZ",
"=",
"null",
")",
"{",
"$",
"position",
"=",
"array",
"(",
"(",
"float",
")",
"$",
"positionX",
",",
"(",
"float",
")",
"$",
"positionY",
")",
";",
"if",
"(",
"$",
"positionZ",
")",
"{",
"array_push",
"(",
"$",
"position",
",",
"(",
"float",
")",
"$",
"positionZ",
")",
";",
"}",
"$",
"this",
"->",
"setProperty",
"(",
"$",
"properties",
",",
"\"pos\"",
",",
"implode",
"(",
"\" \"",
",",
"$",
"position",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set the Position property value
@param array $properties Properties array
@param float $positionX X position
@param float $positionY Y position
@param float $positionZ (optional) Z position (Z-index)
@return static | [
"Set",
"the",
"Position",
"property",
"value"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/UIProperties.php#L461-L469 |
php-rise/rise | src/Router/Scope.php | Scope.createScope | public function createScope($closure) {
$newScope = (new static($this->request, $this->result, $this->urlGenerator));
$newScope->setupParent(
$this->prefix,
$this->prefixMatched,
$this->requestPathOffset,
$this->params
);
$newScope->use($this->middlewares); // Must add middlewares before adding namespace, as the middlewares are already prefixed with namespace.
$newScope->namespace($this->namespace);
$closure($newScope);
} | php | public function createScope($closure) {
$newScope = (new static($this->request, $this->result, $this->urlGenerator));
$newScope->setupParent(
$this->prefix,
$this->prefixMatched,
$this->requestPathOffset,
$this->params
);
$newScope->use($this->middlewares); // Must add middlewares before adding namespace, as the middlewares are already prefixed with namespace.
$newScope->namespace($this->namespace);
$closure($newScope);
} | [
"public",
"function",
"createScope",
"(",
"$",
"closure",
")",
"{",
"$",
"newScope",
"=",
"(",
"new",
"static",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"this",
"->",
"result",
",",
"$",
"this",
"->",
"urlGenerator",
")",
")",
";",
"$",
"newScope",
"->",
"setupParent",
"(",
"$",
"this",
"->",
"prefix",
",",
"$",
"this",
"->",
"prefixMatched",
",",
"$",
"this",
"->",
"requestPathOffset",
",",
"$",
"this",
"->",
"params",
")",
";",
"$",
"newScope",
"->",
"use",
"(",
"$",
"this",
"->",
"middlewares",
")",
";",
"// Must add middlewares before adding namespace, as the middlewares are already prefixed with namespace.",
"$",
"newScope",
"->",
"namespace",
"(",
"$",
"this",
"->",
"namespace",
")",
";",
"$",
"closure",
"(",
"$",
"newScope",
")",
";",
"}"
] | Create a child scope.
@param callable $closure | [
"Create",
"a",
"child",
"scope",
"."
] | train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/Scope.php#L88-L99 |
php-rise/rise | src/Router/Scope.php | Scope.prefix | public function prefix($prefix) {
// Reset values before matching.
$this->prefix = $this->parentPrefix;
$this->requestPathOffset = $this->parentRequestPathOffset;
if ($this->parentPrefixMatched) {
$this->prefixMatched = $this->parentPrefixMatched;
}
if (!$this->result->hasHandler() && $this->prefixMatched) {
$this->prefixMatched = $this->matchPartial($prefix);
}
$this->prefix .= $prefix;
return $this;
} | php | public function prefix($prefix) {
// Reset values before matching.
$this->prefix = $this->parentPrefix;
$this->requestPathOffset = $this->parentRequestPathOffset;
if ($this->parentPrefixMatched) {
$this->prefixMatched = $this->parentPrefixMatched;
}
if (!$this->result->hasHandler() && $this->prefixMatched) {
$this->prefixMatched = $this->matchPartial($prefix);
}
$this->prefix .= $prefix;
return $this;
} | [
"public",
"function",
"prefix",
"(",
"$",
"prefix",
")",
"{",
"// Reset values before matching.",
"$",
"this",
"->",
"prefix",
"=",
"$",
"this",
"->",
"parentPrefix",
";",
"$",
"this",
"->",
"requestPathOffset",
"=",
"$",
"this",
"->",
"parentRequestPathOffset",
";",
"if",
"(",
"$",
"this",
"->",
"parentPrefixMatched",
")",
"{",
"$",
"this",
"->",
"prefixMatched",
"=",
"$",
"this",
"->",
"parentPrefixMatched",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"result",
"->",
"hasHandler",
"(",
")",
"&&",
"$",
"this",
"->",
"prefixMatched",
")",
"{",
"$",
"this",
"->",
"prefixMatched",
"=",
"$",
"this",
"->",
"matchPartial",
"(",
"$",
"prefix",
")",
";",
"}",
"$",
"this",
"->",
"prefix",
".=",
"$",
"prefix",
";",
"return",
"$",
"this",
";",
"}"
] | Set a common path prefix for all routes.
@param string $prefix
@return self | [
"Set",
"a",
"common",
"path",
"prefix",
"for",
"all",
"routes",
"."
] | train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/Scope.php#L107-L122 |
php-rise/rise | src/Router/Scope.php | Scope.use | public function use($middlewares) {
$middlewares = (array)$middlewares;
if ($this->namespace) {
foreach ($middlewares as &$middleware) {
$middleware = $this->namespace . $middleware;
}
}
$this->middlewares = array_merge($this->middlewares, (array)$middlewares);
return $this;
} | php | public function use($middlewares) {
$middlewares = (array)$middlewares;
if ($this->namespace) {
foreach ($middlewares as &$middleware) {
$middleware = $this->namespace . $middleware;
}
}
$this->middlewares = array_merge($this->middlewares, (array)$middlewares);
return $this;
} | [
"public",
"function",
"use",
"(",
"$",
"middlewares",
")",
"{",
"$",
"middlewares",
"=",
"(",
"array",
")",
"$",
"middlewares",
";",
"if",
"(",
"$",
"this",
"->",
"namespace",
")",
"{",
"foreach",
"(",
"$",
"middlewares",
"as",
"&",
"$",
"middleware",
")",
"{",
"$",
"middleware",
"=",
"$",
"this",
"->",
"namespace",
".",
"$",
"middleware",
";",
"}",
"}",
"$",
"this",
"->",
"middlewares",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"middlewares",
",",
"(",
"array",
")",
"$",
"middlewares",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add middlewares.
@param string[]|string $middlewares
@return self | [
"Add",
"middlewares",
"."
] | train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/Scope.php#L145-L157 |
php-rise/rise | src/Router/Scope.php | Scope.on | public function on($method, $path, $handler, $name = '') {
if (!$this->result->hasHandler()
&& $this->prefixMatched
&& $this->request->isMethod($method)
) {
if ($this->matchPartial($path, true)) {
$handlers = (array)$handler;
if ($this->namespace) {
foreach ($handlers as &$handler) {
$handler = $this->namespace . $handler;
}
}
if ($this->middlewares) {
$handlers = array_merge($this->middlewares, $handlers);
}
$this->result->setHandler($handlers);
$this->result->setStatus(200);
$this->result->setParams($this->params);
}
}
if ($name) {
$this->urlGenerator->add($name, $this->prefix . $path);
}
return $this;
} | php | public function on($method, $path, $handler, $name = '') {
if (!$this->result->hasHandler()
&& $this->prefixMatched
&& $this->request->isMethod($method)
) {
if ($this->matchPartial($path, true)) {
$handlers = (array)$handler;
if ($this->namespace) {
foreach ($handlers as &$handler) {
$handler = $this->namespace . $handler;
}
}
if ($this->middlewares) {
$handlers = array_merge($this->middlewares, $handlers);
}
$this->result->setHandler($handlers);
$this->result->setStatus(200);
$this->result->setParams($this->params);
}
}
if ($name) {
$this->urlGenerator->add($name, $this->prefix . $path);
}
return $this;
} | [
"public",
"function",
"on",
"(",
"$",
"method",
",",
"$",
"path",
",",
"$",
"handler",
",",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"result",
"->",
"hasHandler",
"(",
")",
"&&",
"$",
"this",
"->",
"prefixMatched",
"&&",
"$",
"this",
"->",
"request",
"->",
"isMethod",
"(",
"$",
"method",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchPartial",
"(",
"$",
"path",
",",
"true",
")",
")",
"{",
"$",
"handlers",
"=",
"(",
"array",
")",
"$",
"handler",
";",
"if",
"(",
"$",
"this",
"->",
"namespace",
")",
"{",
"foreach",
"(",
"$",
"handlers",
"as",
"&",
"$",
"handler",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"namespace",
".",
"$",
"handler",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"middlewares",
")",
"{",
"$",
"handlers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"middlewares",
",",
"$",
"handlers",
")",
";",
"}",
"$",
"this",
"->",
"result",
"->",
"setHandler",
"(",
"$",
"handlers",
")",
";",
"$",
"this",
"->",
"result",
"->",
"setStatus",
"(",
"200",
")",
";",
"$",
"this",
"->",
"result",
"->",
"setParams",
"(",
"$",
"this",
"->",
"params",
")",
";",
"}",
"}",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"urlGenerator",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"prefix",
".",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a route.
@param string $method
@param string $path
@param string|string[] $handler
@param string $name Route name.
@return self | [
"Add",
"a",
"route",
"."
] | train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/Scope.php#L168-L197 |
php-rise/rise | src/Router/Scope.php | Scope.setupParent | public function setupParent($prefix, $prefixMatched, $requestPathOffset, $params) {
$this->prefix = $prefix;
$this->parentPrefix = $prefix;
$this->prefixMatched = $prefixMatched;
$this->parentPrefixMatched = $prefixMatched;
$this->requestPathOffset = $requestPathOffset;
$this->parentRequestPathOffset = $requestPathOffset;
$this->params = $params;
} | php | public function setupParent($prefix, $prefixMatched, $requestPathOffset, $params) {
$this->prefix = $prefix;
$this->parentPrefix = $prefix;
$this->prefixMatched = $prefixMatched;
$this->parentPrefixMatched = $prefixMatched;
$this->requestPathOffset = $requestPathOffset;
$this->parentRequestPathOffset = $requestPathOffset;
$this->params = $params;
} | [
"public",
"function",
"setupParent",
"(",
"$",
"prefix",
",",
"$",
"prefixMatched",
",",
"$",
"requestPathOffset",
",",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"prefix",
"=",
"$",
"prefix",
";",
"$",
"this",
"->",
"parentPrefix",
"=",
"$",
"prefix",
";",
"$",
"this",
"->",
"prefixMatched",
"=",
"$",
"prefixMatched",
";",
"$",
"this",
"->",
"parentPrefixMatched",
"=",
"$",
"prefixMatched",
";",
"$",
"this",
"->",
"requestPathOffset",
"=",
"$",
"requestPathOffset",
";",
"$",
"this",
"->",
"parentRequestPathOffset",
"=",
"$",
"requestPathOffset",
";",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"}"
] | Inherit data from parent scope.
@param string $prefix
@param bool $prefixMatched
@param int $requestPathOffset
@param array $params | [
"Inherit",
"data",
"from",
"parent",
"scope",
"."
] | train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/Scope.php#L245-L253 |
php-rise/rise | src/Router/Scope.php | Scope.matchPartial | protected function matchPartial($routePathPartial, $toEnd = false) {
$result = false;
$numOfRouteMatches = preg_match_all(
self::ROUTE_PARAM_PATTERN,
$routePathPartial,
$routeMatches,
PREG_OFFSET_CAPTURE
);
if ($numOfRouteMatches === 0) { // plain string
if ($toEnd) {
$requestPathPartial = substr($this->request->getPath(), $this->requestPathOffset);
} else {
$requestPathPartial = substr($this->request->getPath(), $this->requestPathOffset, strlen($routePathPartial));
}
if ($routePathPartial === $requestPathPartial) {
$result = true;
if (!$toEnd) {
// Move offset if it is not matching to the end, i.e. not the last match.
$this->requestPathOffset += strlen($routePathPartial);
}
}
} else if ($numOfRouteMatches > 0) { // has params
// Build regex
$pos = 0;
$pattern = '#^';
for ($i = 0; $i < $numOfRouteMatches; $i++) {
$pattern .= substr($routePathPartial, $pos, $routeMatches[1][$i][1] - $pos);
$pattern .= '(?P<' . $routeMatches[2][$i][0] . '>[^/]+)';
$pos = $routeMatches[1][$i][1] + strlen($routeMatches[1][$i][0]);
}
$pattern .= substr($routePathPartial, $pos);
if ($toEnd) {
$pattern .= '$';
}
$pattern .= '#';
$requestPathPartial = substr($this->request->getPath(), $this->requestPathOffset);
$numOfPathMatches = preg_match($pattern, $requestPathPartial, $pathMatches);
if ($numOfPathMatches === 1) {
$result = true;
// Setup params
foreach ($routeMatches[2] as $m) {
$paramName = $m[0];
$this->params[$paramName] = $pathMatches[$paramName];
}
if (!$toEnd) {
// Move offset if it is not matching to the end, i.e. not the last match.
$this->requestPathOffset += strlen($pathMatches[0]);
}
}
}
return $result;
} | php | protected function matchPartial($routePathPartial, $toEnd = false) {
$result = false;
$numOfRouteMatches = preg_match_all(
self::ROUTE_PARAM_PATTERN,
$routePathPartial,
$routeMatches,
PREG_OFFSET_CAPTURE
);
if ($numOfRouteMatches === 0) { // plain string
if ($toEnd) {
$requestPathPartial = substr($this->request->getPath(), $this->requestPathOffset);
} else {
$requestPathPartial = substr($this->request->getPath(), $this->requestPathOffset, strlen($routePathPartial));
}
if ($routePathPartial === $requestPathPartial) {
$result = true;
if (!$toEnd) {
// Move offset if it is not matching to the end, i.e. not the last match.
$this->requestPathOffset += strlen($routePathPartial);
}
}
} else if ($numOfRouteMatches > 0) { // has params
// Build regex
$pos = 0;
$pattern = '#^';
for ($i = 0; $i < $numOfRouteMatches; $i++) {
$pattern .= substr($routePathPartial, $pos, $routeMatches[1][$i][1] - $pos);
$pattern .= '(?P<' . $routeMatches[2][$i][0] . '>[^/]+)';
$pos = $routeMatches[1][$i][1] + strlen($routeMatches[1][$i][0]);
}
$pattern .= substr($routePathPartial, $pos);
if ($toEnd) {
$pattern .= '$';
}
$pattern .= '#';
$requestPathPartial = substr($this->request->getPath(), $this->requestPathOffset);
$numOfPathMatches = preg_match($pattern, $requestPathPartial, $pathMatches);
if ($numOfPathMatches === 1) {
$result = true;
// Setup params
foreach ($routeMatches[2] as $m) {
$paramName = $m[0];
$this->params[$paramName] = $pathMatches[$paramName];
}
if (!$toEnd) {
// Move offset if it is not matching to the end, i.e. not the last match.
$this->requestPathOffset += strlen($pathMatches[0]);
}
}
}
return $result;
} | [
"protected",
"function",
"matchPartial",
"(",
"$",
"routePathPartial",
",",
"$",
"toEnd",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"numOfRouteMatches",
"=",
"preg_match_all",
"(",
"self",
"::",
"ROUTE_PARAM_PATTERN",
",",
"$",
"routePathPartial",
",",
"$",
"routeMatches",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"$",
"numOfRouteMatches",
"===",
"0",
")",
"{",
"// plain string",
"if",
"(",
"$",
"toEnd",
")",
"{",
"$",
"requestPathPartial",
"=",
"substr",
"(",
"$",
"this",
"->",
"request",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"requestPathOffset",
")",
";",
"}",
"else",
"{",
"$",
"requestPathPartial",
"=",
"substr",
"(",
"$",
"this",
"->",
"request",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"requestPathOffset",
",",
"strlen",
"(",
"$",
"routePathPartial",
")",
")",
";",
"}",
"if",
"(",
"$",
"routePathPartial",
"===",
"$",
"requestPathPartial",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"toEnd",
")",
"{",
"// Move offset if it is not matching to the end, i.e. not the last match.",
"$",
"this",
"->",
"requestPathOffset",
"+=",
"strlen",
"(",
"$",
"routePathPartial",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"numOfRouteMatches",
">",
"0",
")",
"{",
"// has params",
"// Build regex",
"$",
"pos",
"=",
"0",
";",
"$",
"pattern",
"=",
"'#^'",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numOfRouteMatches",
";",
"$",
"i",
"++",
")",
"{",
"$",
"pattern",
".=",
"substr",
"(",
"$",
"routePathPartial",
",",
"$",
"pos",
",",
"$",
"routeMatches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"-",
"$",
"pos",
")",
";",
"$",
"pattern",
".=",
"'(?P<'",
".",
"$",
"routeMatches",
"[",
"2",
"]",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
".",
"'>[^/]+)'",
";",
"$",
"pos",
"=",
"$",
"routeMatches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"routeMatches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
")",
";",
"}",
"$",
"pattern",
".=",
"substr",
"(",
"$",
"routePathPartial",
",",
"$",
"pos",
")",
";",
"if",
"(",
"$",
"toEnd",
")",
"{",
"$",
"pattern",
".=",
"'$'",
";",
"}",
"$",
"pattern",
".=",
"'#'",
";",
"$",
"requestPathPartial",
"=",
"substr",
"(",
"$",
"this",
"->",
"request",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"requestPathOffset",
")",
";",
"$",
"numOfPathMatches",
"=",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"requestPathPartial",
",",
"$",
"pathMatches",
")",
";",
"if",
"(",
"$",
"numOfPathMatches",
"===",
"1",
")",
"{",
"$",
"result",
"=",
"true",
";",
"// Setup params",
"foreach",
"(",
"$",
"routeMatches",
"[",
"2",
"]",
"as",
"$",
"m",
")",
"{",
"$",
"paramName",
"=",
"$",
"m",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"params",
"[",
"$",
"paramName",
"]",
"=",
"$",
"pathMatches",
"[",
"$",
"paramName",
"]",
";",
"}",
"if",
"(",
"!",
"$",
"toEnd",
")",
"{",
"// Move offset if it is not matching to the end, i.e. not the last match.",
"$",
"this",
"->",
"requestPathOffset",
"+=",
"strlen",
"(",
"$",
"pathMatches",
"[",
"0",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Match path partial with request path. This will move the request path offset.
@param string $routePathPartial,
@param bool $toEnd
@return bool | [
"Match",
"path",
"partial",
"with",
"request",
"path",
".",
"This",
"will",
"move",
"the",
"request",
"path",
"offset",
"."
] | train | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router/Scope.php#L262-L323 |
Lansoweb/LosReCaptcha | src/Service/ReCaptcha.php | ReCaptcha.getHtml | public function getHtml($name = null)
{
$host = self::API_SERVER;
$langOption = '';
if (isset($this->options['lang']) && ! empty($this->options['lang'])) {
$langOption = "?hl={$this->options['lang']}";
}
$return = <<<HTML
<script type="text/javascript" src="{$host}{$langOption}" async defer></script>
HTML;
return $return;
} | php | public function getHtml($name = null)
{
$host = self::API_SERVER;
$langOption = '';
if (isset($this->options['lang']) && ! empty($this->options['lang'])) {
$langOption = "?hl={$this->options['lang']}";
}
$return = <<<HTML
<script type="text/javascript" src="{$host}{$langOption}" async defer></script>
HTML;
return $return;
} | [
"public",
"function",
"getHtml",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"host",
"=",
"self",
"::",
"API_SERVER",
";",
"$",
"langOption",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'lang'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'lang'",
"]",
")",
")",
"{",
"$",
"langOption",
"=",
"\"?hl={$this->options['lang']}\"",
";",
"}",
"$",
"return",
"=",
" <<<HTML\n<script type=\"text/javascript\" src=\"{$host}{$langOption}\" async defer></script>\nHTML",
";",
"return",
"$",
"return",
";",
"}"
] | Get the HTML code for the captcha
This method uses the public key to fetch a recaptcha form.
@param null|string $name Base name for recaptcha form elements
@return string
@throws \LosReCaptcha\Service\Exception | [
"Get",
"the",
"HTML",
"code",
"for",
"the",
"captcha"
] | train | https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Service/ReCaptcha.php#L138-L153 |
Lansoweb/LosReCaptcha | src/Service/ReCaptcha.php | ReCaptcha.query | protected function query($responseField)
{
$params = new Parameters($this->secretKey, $responseField, $this->ip);
return $this->request->send($params);
} | php | protected function query($responseField)
{
$params = new Parameters($this->secretKey, $responseField, $this->ip);
return $this->request->send($params);
} | [
"protected",
"function",
"query",
"(",
"$",
"responseField",
")",
"{",
"$",
"params",
"=",
"new",
"Parameters",
"(",
"$",
"this",
"->",
"secretKey",
",",
"$",
"responseField",
",",
"$",
"this",
"->",
"ip",
")",
";",
"return",
"$",
"this",
"->",
"request",
"->",
"send",
"(",
"$",
"params",
")",
";",
"}"
] | Gets a solution to the verify server
@param string $responseField
@return \LosReCaptcha\Service\Response
@throws \LosReCaptcha\\Service\Exception | [
"Gets",
"a",
"solution",
"to",
"the",
"verify",
"server"
] | train | https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Service/ReCaptcha.php#L184-L189 |
yuncms/framework | src/user/controllers/SettingsController.php | SettingsController.actionProfile | public function actionProfile()
{
$model = UserProfile::findOne(['user_id' => Yii::$app->user->identity->getId()]);
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Your profile has been updated'));
return $this->refresh();
}
return $this->render('profile', [
'model' => $model,
]);
} | php | public function actionProfile()
{
$model = UserProfile::findOne(['user_id' => Yii::$app->user->identity->getId()]);
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Your profile has been updated'));
return $this->refresh();
}
return $this->render('profile', [
'model' => $model,
]);
} | [
"public",
"function",
"actionProfile",
"(",
")",
"{",
"$",
"model",
"=",
"UserProfile",
"::",
"findOne",
"(",
"[",
"'user_id'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
"->",
"getId",
"(",
")",
"]",
")",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
"&&",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Your profile has been updated'",
")",
")",
";",
"return",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'profile'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | Shows profile settings form.
@return array|string|Response | [
"Shows",
"profile",
"settings",
"form",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/controllers/SettingsController.php#L64-L78 |
yuncms/framework | src/user/controllers/SettingsController.php | SettingsController.actionAvatar | public function actionAvatar()
{
$model = new AvatarForm();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Your avatar has been updated'));
}
return $this->render('avatar', [
'model' => $model,
]);
} | php | public function actionAvatar()
{
$model = new AvatarForm();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->getSession()->setFlash('success', Yii::t('yuncms', 'Your avatar has been updated'));
}
return $this->render('avatar', [
'model' => $model,
]);
} | [
"public",
"function",
"actionAvatar",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"AvatarForm",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Your avatar has been updated'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'avatar'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | Show portrait setting form
@return \yii\web\Response|string
@throws \League\Flysystem\FileExistsException
@throws \League\Flysystem\FileNotFoundException
@throws \yii\base\ErrorException
@throws \yii\base\Exception
@throws \yii\base\InvalidConfigException | [
"Show",
"portrait",
"setting",
"form"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/controllers/SettingsController.php#L89-L98 |
yuncms/framework | src/user/controllers/SettingsController.php | SettingsController.actionAccount | public function actionAccount()
{
/** @var SettingsForm $model */
$model = new SettingsForm();
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your account details have been updated.'));
return $this->refresh();
}
return $this->render('account', [
'model' => $model,
]);
} | php | public function actionAccount()
{
/** @var SettingsForm $model */
$model = new SettingsForm();
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
return ActiveForm::validate($model);
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your account details have been updated.'));
return $this->refresh();
}
return $this->render('account', [
'model' => $model,
]);
} | [
"public",
"function",
"actionAccount",
"(",
")",
"{",
"/** @var SettingsForm $model */",
"$",
"model",
"=",
"new",
"SettingsForm",
"(",
")",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"isAjax",
"&&",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"return",
"ActiveForm",
"::",
"validate",
"(",
"$",
"model",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Your account details have been updated.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'account'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | Displays page where user can update account settings (username, email or password).
@return array|string|Response | [
"Displays",
"page",
"where",
"user",
"can",
"update",
"account",
"settings",
"(",
"username",
"email",
"or",
"password",
")",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/controllers/SettingsController.php#L104-L119 |
yuncms/framework | src/user/controllers/SettingsController.php | SettingsController.actionFollowerTag | public function actionFollowerTag()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$tagId = Yii::$app->request->post('tag_id', null);
if (($tag = Tag::findOne($tagId)) == null) {
throw new NotFoundHttpException ();
} else {
/** @var \yuncms\user\models\User $user */
$user = Yii::$app->user->identity;
if ($user->hasTagValues($tag->id)) {
$user->removeTagValues($tag->id);
$user->save();
return ['status' => 'unFollowed'];
} else {
$user->addTagValues($tag->id);
$user->save();
return ['status' => 'followed'];
}
}
} | php | public function actionFollowerTag()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$tagId = Yii::$app->request->post('tag_id', null);
if (($tag = Tag::findOne($tagId)) == null) {
throw new NotFoundHttpException ();
} else {
/** @var \yuncms\user\models\User $user */
$user = Yii::$app->user->identity;
if ($user->hasTagValues($tag->id)) {
$user->removeTagValues($tag->id);
$user->save();
return ['status' => 'unFollowed'];
} else {
$user->addTagValues($tag->id);
$user->save();
return ['status' => 'followed'];
}
}
} | [
"public",
"function",
"actionFollowerTag",
"(",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"format",
"=",
"Response",
"::",
"FORMAT_JSON",
";",
"$",
"tagId",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'tag_id'",
",",
"null",
")",
";",
"if",
"(",
"(",
"$",
"tag",
"=",
"Tag",
"::",
"findOne",
"(",
"$",
"tagId",
")",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"else",
"{",
"/** @var \\yuncms\\user\\models\\User $user */",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
";",
"if",
"(",
"$",
"user",
"->",
"hasTagValues",
"(",
"$",
"tag",
"->",
"id",
")",
")",
"{",
"$",
"user",
"->",
"removeTagValues",
"(",
"$",
"tag",
"->",
"id",
")",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"return",
"[",
"'status'",
"=>",
"'unFollowed'",
"]",
";",
"}",
"else",
"{",
"$",
"user",
"->",
"addTagValues",
"(",
"$",
"tag",
"->",
"id",
")",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"return",
"[",
"'status'",
"=>",
"'followed'",
"]",
";",
"}",
"}",
"}"
] | 关注某tag
@return array
@throws NotFoundHttpException | [
"关注某tag"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/controllers/SettingsController.php#L126-L145 |
yuncms/framework | src/user/controllers/SettingsController.php | SettingsController.actionConfirm | public function actionConfirm($id, $code)
{
$user = User::findOne($id);
if ($user === null || Yii::$app->settings->get('emailChangeStrategy','user') == UserSettings::STRATEGY_INSECURE) {
throw new NotFoundHttpException();
}
$user->attemptEmailChange($code);
return $this->redirect(['account']);
} | php | public function actionConfirm($id, $code)
{
$user = User::findOne($id);
if ($user === null || Yii::$app->settings->get('emailChangeStrategy','user') == UserSettings::STRATEGY_INSECURE) {
throw new NotFoundHttpException();
}
$user->attemptEmailChange($code);
return $this->redirect(['account']);
} | [
"public",
"function",
"actionConfirm",
"(",
"$",
"id",
",",
"$",
"code",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOne",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"user",
"===",
"null",
"||",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'emailChangeStrategy'",
",",
"'user'",
")",
"==",
"UserSettings",
"::",
"STRATEGY_INSECURE",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"user",
"->",
"attemptEmailChange",
"(",
"$",
"code",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'account'",
"]",
")",
";",
"}"
] | Attempts changing user's email address.
@param integer $id
@param string $code
@return string
@throws NotFoundHttpException | [
"Attempts",
"changing",
"user",
"s",
"email",
"address",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/controllers/SettingsController.php#L156-L164 |
yuncms/framework | src/user/controllers/SettingsController.php | SettingsController.actionDisconnect | public function actionDisconnect($id)
{
$account = UserSocialAccount::find()->byId($id)->one();
if ($account === null) {
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your account have been updated.'));
return $this->redirect(['networks']);
}
if ($account->user_id != Yii::$app->user->id) {
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'You do not have the right to dismiss this social account.'));
return $this->redirect(['networks']);
}
$account->delete();
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your account have been updated.'));
return $this->redirect(['networks']);
} | php | public function actionDisconnect($id)
{
$account = UserSocialAccount::find()->byId($id)->one();
if ($account === null) {
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your account have been updated.'));
return $this->redirect(['networks']);
}
if ($account->user_id != Yii::$app->user->id) {
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'You do not have the right to dismiss this social account.'));
return $this->redirect(['networks']);
}
$account->delete();
Yii::$app->session->setFlash('success', Yii::t('yuncms', 'Your account have been updated.'));
return $this->redirect(['networks']);
} | [
"public",
"function",
"actionDisconnect",
"(",
"$",
"id",
")",
"{",
"$",
"account",
"=",
"UserSocialAccount",
"::",
"find",
"(",
")",
"->",
"byId",
"(",
"$",
"id",
")",
"->",
"one",
"(",
")",
";",
"if",
"(",
"$",
"account",
"===",
"null",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Your account have been updated.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'networks'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"account",
"->",
"user_id",
"!=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"id",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'You do not have the right to dismiss this social account.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'networks'",
"]",
")",
";",
"}",
"$",
"account",
"->",
"delete",
"(",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'success'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Your account have been updated.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'networks'",
"]",
")",
";",
"}"
] | Disconnects a network account from user.
@param integer $id
@return \yii\web\Response
@throws \Exception
@throws \Throwable
@throws \yii\db\StaleObjectException | [
"Disconnects",
"a",
"network",
"account",
"from",
"user",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/controllers/SettingsController.php#L188-L202 |
struzik-vladislav/php-error-handler | src/Processor/IntoExceptionProcessor.php | IntoExceptionProcessor.handle | public function handle($errno, $errstr, $errfile, $errline)
{
$class = $this->getAssociatedClass($errno);
throw new $class($errstr, 0, $errno, $errfile, $errline);
} | php | public function handle($errno, $errstr, $errfile, $errline)
{
$class = $this->getAssociatedClass($errno);
throw new $class($errstr, 0, $errno, $errfile, $errline);
} | [
"public",
"function",
"handle",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getAssociatedClass",
"(",
"$",
"errno",
")",
";",
"throw",
"new",
"$",
"class",
"(",
"$",
"errstr",
",",
"0",
",",
"$",
"errno",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/Processor/IntoExceptionProcessor.php#L50-L55 |
struzik-vladislav/php-error-handler | src/Processor/IntoExceptionProcessor.php | IntoExceptionProcessor.getAssociatedClass | private function getAssociatedClass($errno)
{
$associations = [
E_WARNING => Exception\WarningException::class,
E_NOTICE => Exception\NoticeException::class,
E_USER_ERROR => Exception\UserErrorException::class,
E_USER_WARNING => Exception\UserWarningException::class,
E_USER_NOTICE => Exception\UserNoticeException::class,
E_STRICT => Exception\StrictException::class,
E_RECOVERABLE_ERROR => Exception\RecoverableErrorException::class,
E_DEPRECATED => Exception\DeprecatedException::class,
E_USER_DEPRECATED => Exception\UserDeprecatedException::class,
];
if (isset($associations[$errno])) {
return $associations[$errno];
}
return Exception\ErrorException::class;
} | php | private function getAssociatedClass($errno)
{
$associations = [
E_WARNING => Exception\WarningException::class,
E_NOTICE => Exception\NoticeException::class,
E_USER_ERROR => Exception\UserErrorException::class,
E_USER_WARNING => Exception\UserWarningException::class,
E_USER_NOTICE => Exception\UserNoticeException::class,
E_STRICT => Exception\StrictException::class,
E_RECOVERABLE_ERROR => Exception\RecoverableErrorException::class,
E_DEPRECATED => Exception\DeprecatedException::class,
E_USER_DEPRECATED => Exception\UserDeprecatedException::class,
];
if (isset($associations[$errno])) {
return $associations[$errno];
}
return Exception\ErrorException::class;
} | [
"private",
"function",
"getAssociatedClass",
"(",
"$",
"errno",
")",
"{",
"$",
"associations",
"=",
"[",
"E_WARNING",
"=>",
"Exception",
"\\",
"WarningException",
"::",
"class",
",",
"E_NOTICE",
"=>",
"Exception",
"\\",
"NoticeException",
"::",
"class",
",",
"E_USER_ERROR",
"=>",
"Exception",
"\\",
"UserErrorException",
"::",
"class",
",",
"E_USER_WARNING",
"=>",
"Exception",
"\\",
"UserWarningException",
"::",
"class",
",",
"E_USER_NOTICE",
"=>",
"Exception",
"\\",
"UserNoticeException",
"::",
"class",
",",
"E_STRICT",
"=>",
"Exception",
"\\",
"StrictException",
"::",
"class",
",",
"E_RECOVERABLE_ERROR",
"=>",
"Exception",
"\\",
"RecoverableErrorException",
"::",
"class",
",",
"E_DEPRECATED",
"=>",
"Exception",
"\\",
"DeprecatedException",
"::",
"class",
",",
"E_USER_DEPRECATED",
"=>",
"Exception",
"\\",
"UserDeprecatedException",
"::",
"class",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"associations",
"[",
"$",
"errno",
"]",
")",
")",
"{",
"return",
"$",
"associations",
"[",
"$",
"errno",
"]",
";",
"}",
"return",
"Exception",
"\\",
"ErrorException",
"::",
"class",
";",
"}"
] | Getting the exception class name associated with error code.
@param int $errno level of the error raised
@return string | [
"Getting",
"the",
"exception",
"class",
"name",
"associated",
"with",
"error",
"code",
"."
] | train | https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/Processor/IntoExceptionProcessor.php#L64-L83 |
webforge-labs/psc-cms | lib/Psc/Graph/DependencyVertice.php | DependencyVertice.dependsOn | public function dependsOn(Vertice $dependency) {
$this->contextGraph->add($dependency, $this);
$this->dependencies[] = $dependency;
} | php | public function dependsOn(Vertice $dependency) {
$this->contextGraph->add($dependency, $this);
$this->dependencies[] = $dependency;
} | [
"public",
"function",
"dependsOn",
"(",
"Vertice",
"$",
"dependency",
")",
"{",
"$",
"this",
"->",
"contextGraph",
"->",
"add",
"(",
"$",
"dependency",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dependencies",
"[",
"]",
"=",
"$",
"dependency",
";",
"}"
] | Füge eine Dependency zu $dependency von dieser Vertice hinzu
eine topologische Sortierung eines DAG ist eine Lineare Anordnung all seiner Knoten mit der Eigenschaft
dass u ($dependency) in der Anordnung vor v ($this) liegt (v ist abhängig von u), falls es eine Kante (u,v) gibt | [
"Füge",
"eine",
"Dependency",
"zu",
"$dependency",
"von",
"dieser",
"Vertice",
"hinzu"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Graph/DependencyVertice.php#L18-L21 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.setId | public function setId($v)
{
if ($v !== null && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = CountryPeer::ID;
}
return $this;
} | php | public function setId($v)
{
if ($v !== null && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = CountryPeer::ID;
}
return $this;
} | [
"public",
"function",
"setId",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
"&&",
"is_numeric",
"(",
"$",
"v",
")",
")",
"{",
"$",
"v",
"=",
"(",
"int",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"id",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"CountryPeer",
"::",
"ID",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [id] column.
@param int $v new value
@return Country The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"id",
"]",
"column",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L173-L186 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.setCode | public function setCode($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->code !== $v) {
$this->code = $v;
$this->modifiedColumns[] = CountryPeer::CODE;
}
return $this;
} | php | public function setCode($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->code !== $v) {
$this->code = $v;
$this->modifiedColumns[] = CountryPeer::CODE;
}
return $this;
} | [
"public",
"function",
"setCode",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"code",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"code",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"CountryPeer",
"::",
"CODE",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [code] column.
@param string $v new value
@return Country The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"code",
"]",
"column",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L194-L207 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.setEn | public function setEn($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->en !== $v) {
$this->en = $v;
$this->modifiedColumns[] = CountryPeer::EN;
}
return $this;
} | php | public function setEn($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->en !== $v) {
$this->en = $v;
$this->modifiedColumns[] = CountryPeer::EN;
}
return $this;
} | [
"public",
"function",
"setEn",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"en",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"en",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"CountryPeer",
"::",
"EN",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [en] column.
@param string $v new value
@return Country The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"en",
"]",
"column",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L215-L228 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.setDe | public function setDe($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->de !== $v) {
$this->de = $v;
$this->modifiedColumns[] = CountryPeer::DE;
}
return $this;
} | php | public function setDe($v)
{
if ($v !== null) {
$v = (string) $v;
}
if ($this->de !== $v) {
$this->de = $v;
$this->modifiedColumns[] = CountryPeer::DE;
}
return $this;
} | [
"public",
"function",
"setDe",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"de",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"de",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"CountryPeer",
"::",
"DE",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [de] column.
@param string $v new value
@return Country The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"de",
"]",
"column",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L236-L249 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.hydrate | public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->en = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->de = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
$this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 4; // 4 = CountryPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Country object", $e);
}
} | php | public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
$this->en = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
$this->de = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
$this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 4; // 4 = CountryPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating Country object", $e);
}
} | [
"public",
"function",
"hydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
"=",
"0",
",",
"$",
"rehydrate",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"id",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"0",
"]",
"!==",
"null",
")",
"?",
"(",
"int",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"0",
"]",
":",
"null",
";",
"$",
"this",
"->",
"code",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"1",
"]",
"!==",
"null",
")",
"?",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"1",
"]",
":",
"null",
";",
"$",
"this",
"->",
"en",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"2",
"]",
"!==",
"null",
")",
"?",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"2",
"]",
":",
"null",
";",
"$",
"this",
"->",
"de",
"=",
"(",
"$",
"row",
"[",
"$",
"startcol",
"+",
"3",
"]",
"!==",
"null",
")",
"?",
"(",
"string",
")",
"$",
"row",
"[",
"$",
"startcol",
"+",
"3",
"]",
":",
"null",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"if",
"(",
"$",
"rehydrate",
")",
"{",
"$",
"this",
"->",
"ensureConsistency",
"(",
")",
";",
"}",
"$",
"this",
"->",
"postHydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
",",
"$",
"rehydrate",
")",
";",
"return",
"$",
"startcol",
"+",
"4",
";",
"// 4 = CountryPeer::NUM_HYDRATE_COLUMNS.",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Error populating Country object\"",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Hydrates (populates) the object variables with values from the database resultset.
An offset (0-based "start column") is specified so that objects can be hydrated
with a subset of the columns in the resultset rows. This is needed, for example,
for results of JOIN queries where the resultset row includes columns from two or
more tables.
@param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
@param int $startcol 0-based offset column which indicates which resultset column to start with.
@param boolean $rehydrate Whether this object is being re-hydrated from the database.
@return int next starting column
@throws PropelException - Any caught Exception will be rewrapped as a PropelException. | [
"Hydrates",
"(",
"populates",
")",
"the",
"object",
"variables",
"with",
"values",
"from",
"the",
"database",
"resultset",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L287-L309 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.doSave | protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->customersScheduledForDeletion !== null) {
if (!$this->customersScheduledForDeletion->isEmpty()) {
CustomerQuery::create()
->filterByPrimaryKeys($this->customersScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->customersScheduledForDeletion = null;
}
}
if ($this->collCustomers !== null) {
foreach ($this->collCustomers as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} | php | protected function doSave(PropelPDO $con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->customersScheduledForDeletion !== null) {
if (!$this->customersScheduledForDeletion->isEmpty()) {
CustomerQuery::create()
->filterByPrimaryKeys($this->customersScheduledForDeletion->getPrimaryKeys(false))
->delete($con);
$this->customersScheduledForDeletion = null;
}
}
if ($this->collCustomers !== null) {
foreach ($this->collCustomers as $referrerFK) {
if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} | [
"protected",
"function",
"doSave",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"affectedRows",
"=",
"0",
";",
"// initialize var to track total num of affected rows",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInSave",
")",
"{",
"$",
"this",
"->",
"alreadyInSave",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"||",
"$",
"this",
"->",
"isModified",
"(",
")",
")",
"{",
"// persist changes",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"doInsert",
"(",
"$",
"con",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"doUpdate",
"(",
"$",
"con",
")",
";",
"}",
"$",
"affectedRows",
"+=",
"1",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"customersScheduledForDeletion",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"isEmpty",
"(",
")",
")",
"{",
"CustomerQuery",
"::",
"create",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"getPrimaryKeys",
"(",
"false",
")",
")",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"$",
"this",
"->",
"customersScheduledForDeletion",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomers",
"as",
"$",
"referrerFK",
")",
"{",
"if",
"(",
"!",
"$",
"referrerFK",
"->",
"isDeleted",
"(",
")",
"&&",
"(",
"$",
"referrerFK",
"->",
"isNew",
"(",
")",
"||",
"$",
"referrerFK",
"->",
"isModified",
"(",
")",
")",
")",
"{",
"$",
"affectedRows",
"+=",
"$",
"referrerFK",
"->",
"save",
"(",
"$",
"con",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"}",
"return",
"$",
"affectedRows",
";",
"}"
] | Performs the work of inserting or updating the row in the database.
If the object is new, it inserts it; otherwise an update is performed.
All related objects are also updated in this method.
@param PropelPDO $con
@return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
@throws PropelException
@see save() | [
"Performs",
"the",
"work",
"of",
"inserting",
"or",
"updating",
"the",
"row",
"in",
"the",
"database",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L475-L514 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.doInsert | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = CountryPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . CountryPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(CountryPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(CountryPeer::CODE)) {
$modifiedColumns[':p' . $index++] = '`code`';
}
if ($this->isColumnModified(CountryPeer::EN)) {
$modifiedColumns[':p' . $index++] = '`en`';
}
if ($this->isColumnModified(CountryPeer::DE)) {
$modifiedColumns[':p' . $index++] = '`de`';
}
$sql = sprintf(
'INSERT INTO `country` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`code`':
$stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
break;
case '`en`':
$stmt->bindValue($identifier, $this->en, PDO::PARAM_STR);
break;
case '`de`':
$stmt->bindValue($identifier, $this->de, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | php | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = CountryPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . CountryPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(CountryPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(CountryPeer::CODE)) {
$modifiedColumns[':p' . $index++] = '`code`';
}
if ($this->isColumnModified(CountryPeer::EN)) {
$modifiedColumns[':p' . $index++] = '`en`';
}
if ($this->isColumnModified(CountryPeer::DE)) {
$modifiedColumns[':p' . $index++] = '`de`';
}
$sql = sprintf(
'INSERT INTO `country` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`code`':
$stmt->bindValue($identifier, $this->code, PDO::PARAM_STR);
break;
case '`en`':
$stmt->bindValue($identifier, $this->en, PDO::PARAM_STR);
break;
case '`de`':
$stmt->bindValue($identifier, $this->de, PDO::PARAM_STR);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | [
"protected",
"function",
"doInsert",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"CountryPeer",
"::",
"ID",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot insert a value for auto-increment primary key ('",
".",
"CountryPeer",
"::",
"ID",
".",
"')'",
")",
";",
"}",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`id`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"CODE",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`code`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"EN",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`en`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"DE",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`de`'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO `country` (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'`id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'`code`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"code",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'`en`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"en",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"case",
"'`de`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"de",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"try",
"{",
"$",
"pk",
"=",
"$",
"con",
"->",
"lastInsertId",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unable to get autoincrement id.'",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setId",
"(",
"$",
"pk",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
] | Insert the row in the database.
@param PropelPDO $con
@throws PropelException
@see doSave() | [
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L524-L586 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.doValidate | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = CountryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collCustomers !== null) {
foreach ($this->collCustomers as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | php | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = CountryPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collCustomers !== null) {
foreach ($this->collCustomers as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | [
"protected",
"function",
"doValidate",
"(",
"$",
"columns",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInValidation",
")",
"{",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"true",
";",
"$",
"retval",
"=",
"null",
";",
"$",
"failureMap",
"=",
"array",
"(",
")",
";",
"if",
"(",
"(",
"$",
"retval",
"=",
"CountryPeer",
"::",
"doValidate",
"(",
"$",
"this",
",",
"$",
"columns",
")",
")",
"!==",
"true",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"retval",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomers",
"as",
"$",
"referrerFK",
")",
"{",
"if",
"(",
"!",
"$",
"referrerFK",
"->",
"validate",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"referrerFK",
"->",
"getValidationFailures",
"(",
")",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"}",
"return",
"(",
"!",
"empty",
"(",
"$",
"failureMap",
")",
"?",
"$",
"failureMap",
":",
"true",
")",
";",
"}"
] | This function performs the validation work for complex object models.
In addition to checking the current object, all related objects will
also be validated. If all pass then <code>true</code> is returned; otherwise
an aggregated array of ValidationFailed objects will be returned.
@param array $columns Array of column names to validate.
@return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise. | [
"This",
"function",
"performs",
"the",
"validation",
"work",
"for",
"complex",
"object",
"models",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L655-L682 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.getByPosition | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getCode();
break;
case 2:
return $this->getEn();
break;
case 3:
return $this->getDe();
break;
default:
return null;
break;
} // switch()
} | php | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getCode();
break;
case 2:
return $this->getEn();
break;
case 3:
return $this->getDe();
break;
default:
return null;
break;
} // switch()
} | [
"public",
"function",
"getByPosition",
"(",
"$",
"pos",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"return",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"return",
"$",
"this",
"->",
"getCode",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"return",
"$",
"this",
"->",
"getEn",
"(",
")",
";",
"break",
";",
"case",
"3",
":",
"return",
"$",
"this",
"->",
"getDe",
"(",
")",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"break",
";",
"}",
"// switch()",
"}"
] | Retrieves a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@return mixed Value of field at $pos | [
"Retrieves",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L709-L728 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.toArray | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['Country'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Country'][$this->getPrimaryKey()] = true;
$keys = CountryPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCode(),
$keys[2] => $this->getEn(),
$keys[3] => $this->getDe(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->collCustomers) {
$result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
} | php | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['Country'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Country'][$this->getPrimaryKey()] = true;
$keys = CountryPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCode(),
$keys[2] => $this->getEn(),
$keys[3] => $this->getDe(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->collCustomers) {
$result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
",",
"$",
"includeForeignObjects",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'Country'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'Country'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"CountryPeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getCode",
"(",
")",
",",
"$",
"keys",
"[",
"2",
"]",
"=>",
"$",
"this",
"->",
"getEn",
"(",
")",
",",
"$",
"keys",
"[",
"3",
"]",
"=>",
"$",
"this",
"->",
"getDe",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"if",
"(",
"$",
"includeForeignObjects",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"$",
"result",
"[",
"'Customers'",
"]",
"=",
"$",
"this",
"->",
"collCustomers",
"->",
"toArray",
"(",
"null",
",",
"true",
",",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L745-L770 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.setByPosition | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setCode($value);
break;
case 2:
$this->setEn($value);
break;
case 3:
$this->setDe($value);
break;
} // switch()
} | php | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setCode($value);
break;
case 2:
$this->setEn($value);
break;
case 3:
$this->setDe($value);
break;
} // switch()
} | [
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setCode",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"setEn",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"3",
":",
"$",
"this",
"->",
"setDe",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"}"
] | Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L798-L814 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.fromArray | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CountryPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setEn($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDe($arr[$keys[3]]);
} | php | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = CountryPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setEn($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDe($arr[$keys[3]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"CountryPeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setCode",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"2",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setEn",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"2",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"3",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setDe",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"3",
"]",
"]",
")",
";",
"}"
] | Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
The default key type is the column's BasePeer::TYPE_PHPNAME
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L833-L841 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(CountryPeer::DATABASE_NAME);
if ($this->isColumnModified(CountryPeer::ID)) $criteria->add(CountryPeer::ID, $this->id);
if ($this->isColumnModified(CountryPeer::CODE)) $criteria->add(CountryPeer::CODE, $this->code);
if ($this->isColumnModified(CountryPeer::EN)) $criteria->add(CountryPeer::EN, $this->en);
if ($this->isColumnModified(CountryPeer::DE)) $criteria->add(CountryPeer::DE, $this->de);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(CountryPeer::DATABASE_NAME);
if ($this->isColumnModified(CountryPeer::ID)) $criteria->add(CountryPeer::ID, $this->id);
if ($this->isColumnModified(CountryPeer::CODE)) $criteria->add(CountryPeer::CODE, $this->code);
if ($this->isColumnModified(CountryPeer::EN)) $criteria->add(CountryPeer::EN, $this->en);
if ($this->isColumnModified(CountryPeer::DE)) $criteria->add(CountryPeer::DE, $this->de);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CountryPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CountryPeer",
"::",
"ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"CODE",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CountryPeer",
"::",
"CODE",
",",
"$",
"this",
"->",
"code",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"EN",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CountryPeer",
"::",
"EN",
",",
"$",
"this",
"->",
"en",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CountryPeer",
"::",
"DE",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CountryPeer",
"::",
"DE",
",",
"$",
"this",
"->",
"de",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] | Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L848-L858 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCode($this->getCode());
$copyObj->setEn($this->getEn());
$copyObj->setDe($this->getDe());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
foreach ($this->getCustomers() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCustomer($relObj->copy($deepCopy));
}
}
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCode($this->getCode());
$copyObj->setEn($this->getEn());
$copyObj->setDe($this->getDe());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
foreach ($this->getCustomers() as $relObj) {
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
$copyObj->addCustomer($relObj->copy($deepCopy));
}
}
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setCode",
"(",
"$",
"this",
"->",
"getCode",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setEn",
"(",
"$",
"this",
"->",
"getEn",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setDe",
"(",
"$",
"this",
"->",
"getDe",
"(",
")",
")",
";",
"if",
"(",
"$",
"deepCopy",
"&&",
"!",
"$",
"this",
"->",
"startCopy",
")",
"{",
"// important: temporarily setNew(false) because this affects the behavior of",
"// the getter/setter methods for fkey referrer objects.",
"$",
"copyObj",
"->",
"setNew",
"(",
"false",
")",
";",
"// store object hash to prevent cycle",
"$",
"this",
"->",
"startCopy",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCustomers",
"(",
")",
"as",
"$",
"relObj",
")",
"{",
"if",
"(",
"$",
"relObj",
"!==",
"$",
"this",
")",
"{",
"// ensure that we don't try to copy a reference to ourselves",
"$",
"copyObj",
"->",
"addCustomer",
"(",
"$",
"relObj",
"->",
"copy",
"(",
"$",
"deepCopy",
")",
")",
";",
"}",
"}",
"//unflag object copy",
"$",
"this",
"->",
"startCopy",
"=",
"false",
";",
"}",
"// if ($deepCopy)",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"copyObj",
"->",
"setId",
"(",
"NULL",
")",
";",
"// this is a auto-increment column, so set to default value",
"}",
"}"
] | Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of Country (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L917-L944 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.initCustomers | public function initCustomers($overrideExisting = true)
{
if (null !== $this->collCustomers && !$overrideExisting) {
return;
}
$this->collCustomers = new PropelObjectCollection();
$this->collCustomers->setModel('Customer');
} | php | public function initCustomers($overrideExisting = true)
{
if (null !== $this->collCustomers && !$overrideExisting) {
return;
}
$this->collCustomers = new PropelObjectCollection();
$this->collCustomers->setModel('Customer');
} | [
"public",
"function",
"initCustomers",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collCustomers",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"new",
"PropelObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collCustomers",
"->",
"setModel",
"(",
"'Customer'",
")",
";",
"}"
] | Initializes the collCustomers collection.
By default this just sets the collCustomers collection to an empty array (like clearcollCustomers());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collCustomers",
"collection",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1041-L1048 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.getCustomers | public function getCustomers($criteria = null, PropelPDO $con = null)
{
$partial = $this->collCustomersPartial && !$this->isNew();
if (null === $this->collCustomers || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomers) {
// return empty collection
$this->initCustomers();
} else {
$collCustomers = CustomerQuery::create(null, $criteria)
->filterByCountry($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collCustomersPartial && count($collCustomers)) {
$this->initCustomers(false);
foreach ($collCustomers as $obj) {
if (false == $this->collCustomers->contains($obj)) {
$this->collCustomers->append($obj);
}
}
$this->collCustomersPartial = true;
}
$collCustomers->getInternalIterator()->rewind();
return $collCustomers;
}
if ($partial && $this->collCustomers) {
foreach ($this->collCustomers as $obj) {
if ($obj->isNew()) {
$collCustomers[] = $obj;
}
}
}
$this->collCustomers = $collCustomers;
$this->collCustomersPartial = false;
}
}
return $this->collCustomers;
} | php | public function getCustomers($criteria = null, PropelPDO $con = null)
{
$partial = $this->collCustomersPartial && !$this->isNew();
if (null === $this->collCustomers || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomers) {
// return empty collection
$this->initCustomers();
} else {
$collCustomers = CustomerQuery::create(null, $criteria)
->filterByCountry($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collCustomersPartial && count($collCustomers)) {
$this->initCustomers(false);
foreach ($collCustomers as $obj) {
if (false == $this->collCustomers->contains($obj)) {
$this->collCustomers->append($obj);
}
}
$this->collCustomersPartial = true;
}
$collCustomers->getInternalIterator()->rewind();
return $collCustomers;
}
if ($partial && $this->collCustomers) {
foreach ($this->collCustomers as $obj) {
if ($obj->isNew()) {
$collCustomers[] = $obj;
}
}
}
$this->collCustomers = $collCustomers;
$this->collCustomersPartial = false;
}
}
return $this->collCustomers;
} | [
"public",
"function",
"getCustomers",
"(",
"$",
"criteria",
"=",
"null",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collCustomersPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"// return empty collection",
"$",
"this",
"->",
"initCustomers",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collCustomers",
"=",
"CustomerQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"filterByCountry",
"(",
"$",
"this",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"collCustomersPartial",
"&&",
"count",
"(",
"$",
"collCustomers",
")",
")",
"{",
"$",
"this",
"->",
"initCustomers",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"collCustomers",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"false",
"==",
"$",
"this",
"->",
"collCustomers",
"->",
"contains",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"this",
"->",
"collCustomers",
"->",
"append",
"(",
"$",
"obj",
")",
";",
"}",
"}",
"$",
"this",
"->",
"collCustomersPartial",
"=",
"true",
";",
"}",
"$",
"collCustomers",
"->",
"getInternalIterator",
"(",
")",
"->",
"rewind",
"(",
")",
";",
"return",
"$",
"collCustomers",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomers",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"collCustomers",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"$",
"collCustomers",
";",
"$",
"this",
"->",
"collCustomersPartial",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collCustomers",
";",
"}"
] | Gets an array of Customer objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this Country is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param PropelPDO $con optional connection object
@return PropelObjectCollection|Customer[] List of Customer objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"Customer",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1064-L1107 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.setCustomers | public function setCustomers(PropelCollection $customers, PropelPDO $con = null)
{
$customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers);
$this->customersScheduledForDeletion = $customersToDelete;
foreach ($customersToDelete as $customerRemoved) {
$customerRemoved->setCountry(null);
}
$this->collCustomers = null;
foreach ($customers as $customer) {
$this->addCustomer($customer);
}
$this->collCustomers = $customers;
$this->collCustomersPartial = false;
return $this;
} | php | public function setCustomers(PropelCollection $customers, PropelPDO $con = null)
{
$customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers);
$this->customersScheduledForDeletion = $customersToDelete;
foreach ($customersToDelete as $customerRemoved) {
$customerRemoved->setCountry(null);
}
$this->collCustomers = null;
foreach ($customers as $customer) {
$this->addCustomer($customer);
}
$this->collCustomers = $customers;
$this->collCustomersPartial = false;
return $this;
} | [
"public",
"function",
"setCustomers",
"(",
"PropelCollection",
"$",
"customers",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"customersToDelete",
"=",
"$",
"this",
"->",
"getCustomers",
"(",
"new",
"Criteria",
"(",
")",
",",
"$",
"con",
")",
"->",
"diff",
"(",
"$",
"customers",
")",
";",
"$",
"this",
"->",
"customersScheduledForDeletion",
"=",
"$",
"customersToDelete",
";",
"foreach",
"(",
"$",
"customersToDelete",
"as",
"$",
"customerRemoved",
")",
"{",
"$",
"customerRemoved",
"->",
"setCountry",
"(",
"null",
")",
";",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"null",
";",
"foreach",
"(",
"$",
"customers",
"as",
"$",
"customer",
")",
"{",
"$",
"this",
"->",
"addCustomer",
"(",
"$",
"customer",
")",
";",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"$",
"customers",
";",
"$",
"this",
"->",
"collCustomersPartial",
"=",
"false",
";",
"return",
"$",
"this",
";",
"}"
] | Sets a collection of Customer objects related by a one-to-many relationship
to the current object.
It will also schedule objects for deletion based on a diff between old objects (aka persisted)
and new objects from the given Propel collection.
@param PropelCollection $customers A Propel collection.
@param PropelPDO $con Optional connection object
@return Country The current object (for fluent API support) | [
"Sets",
"a",
"collection",
"of",
"Customer",
"objects",
"related",
"by",
"a",
"one",
"-",
"to",
"-",
"many",
"relationship",
"to",
"the",
"current",
"object",
".",
"It",
"will",
"also",
"schedule",
"objects",
"for",
"deletion",
"based",
"on",
"a",
"diff",
"between",
"old",
"objects",
"(",
"aka",
"persisted",
")",
"and",
"new",
"objects",
"from",
"the",
"given",
"Propel",
"collection",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1119-L1139 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.countCustomers | public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
$partial = $this->collCustomersPartial && !$this->isNew();
if (null === $this->collCustomers || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomers) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getCustomers());
}
$query = CustomerQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCountry($this)
->count($con);
}
return count($this->collCustomers);
} | php | public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
{
$partial = $this->collCustomersPartial && !$this->isNew();
if (null === $this->collCustomers || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collCustomers) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getCustomers());
}
$query = CustomerQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByCountry($this)
->count($con);
}
return count($this->collCustomers);
} | [
"public",
"function",
"countCustomers",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"PropelPDO",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collCustomersPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"!",
"$",
"criteria",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getCustomers",
"(",
")",
")",
";",
"}",
"$",
"query",
"=",
"CustomerQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"distinct",
")",
"{",
"$",
"query",
"->",
"distinct",
"(",
")",
";",
"}",
"return",
"$",
"query",
"->",
"filterByCountry",
"(",
"$",
"this",
")",
"->",
"count",
"(",
"$",
"con",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"collCustomers",
")",
";",
"}"
] | Returns the number of related Customer objects.
@param Criteria $criteria
@param boolean $distinct
@param PropelPDO $con
@return int Count of related Customer objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"Customer",
"objects",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1150-L1172 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.addCustomer | public function addCustomer(Customer $l)
{
if ($this->collCustomers === null) {
$this->initCustomers();
$this->collCustomersPartial = true;
}
if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddCustomer($l);
if ($this->customersScheduledForDeletion and $this->customersScheduledForDeletion->contains($l)) {
$this->customersScheduledForDeletion->remove($this->customersScheduledForDeletion->search($l));
}
}
return $this;
} | php | public function addCustomer(Customer $l)
{
if ($this->collCustomers === null) {
$this->initCustomers();
$this->collCustomersPartial = true;
}
if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddCustomer($l);
if ($this->customersScheduledForDeletion and $this->customersScheduledForDeletion->contains($l)) {
$this->customersScheduledForDeletion->remove($this->customersScheduledForDeletion->search($l));
}
}
return $this;
} | [
"public",
"function",
"addCustomer",
"(",
"Customer",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initCustomers",
"(",
")",
";",
"$",
"this",
"->",
"collCustomersPartial",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"l",
",",
"$",
"this",
"->",
"collCustomers",
"->",
"getArrayCopy",
"(",
")",
",",
"true",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"doAddCustomer",
"(",
"$",
"l",
")",
";",
"if",
"(",
"$",
"this",
"->",
"customersScheduledForDeletion",
"and",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"contains",
"(",
"$",
"l",
")",
")",
"{",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"remove",
"(",
"$",
"this",
"->",
"customersScheduledForDeletion",
"->",
"search",
"(",
"$",
"l",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Method called to associate a Customer object to this object
through the Customer foreign key attribute.
@param Customer $l Customer
@return Country The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"Customer",
"object",
"to",
"this",
"object",
"through",
"the",
"Customer",
"foreign",
"key",
"attribute",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1181-L1197 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.clear | public function clear()
{
$this->id = null;
$this->code = null;
$this->en = null;
$this->de = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | php | public function clear()
{
$this->id = null;
$this->code = null;
$this->en = null;
$this->de = null;
$this->alreadyInSave = false;
$this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false;
$this->clearAllReferences();
$this->applyDefaultValues();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"null",
";",
"$",
"this",
"->",
"code",
"=",
"null",
";",
"$",
"this",
"->",
"en",
"=",
"null",
";",
"$",
"this",
"->",
"de",
"=",
"null",
";",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"false",
";",
"$",
"this",
"->",
"clearAllReferences",
"(",
")",
";",
"$",
"this",
"->",
"applyDefaultValues",
"(",
")",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"false",
")",
";",
"}"
] | Clears the current object and sets all attributes to their default values | [
"Clears",
"the",
"current",
"object",
"and",
"sets",
"all",
"attributes",
"to",
"their",
"default",
"values"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1230-L1244 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCountry.php | BaseCountry.clearAllReferences | public function clearAllReferences($deep = false)
{
if ($deep && !$this->alreadyInClearAllReferencesDeep) {
$this->alreadyInClearAllReferencesDeep = true;
if ($this->collCustomers) {
foreach ($this->collCustomers as $o) {
$o->clearAllReferences($deep);
}
}
$this->alreadyInClearAllReferencesDeep = false;
} // if ($deep)
if ($this->collCustomers instanceof PropelCollection) {
$this->collCustomers->clearIterator();
}
$this->collCustomers = null;
} | php | public function clearAllReferences($deep = false)
{
if ($deep && !$this->alreadyInClearAllReferencesDeep) {
$this->alreadyInClearAllReferencesDeep = true;
if ($this->collCustomers) {
foreach ($this->collCustomers as $o) {
$o->clearAllReferences($deep);
}
}
$this->alreadyInClearAllReferencesDeep = false;
} // if ($deep)
if ($this->collCustomers instanceof PropelCollection) {
$this->collCustomers->clearIterator();
}
$this->collCustomers = null;
} | [
"public",
"function",
"clearAllReferences",
"(",
"$",
"deep",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"deep",
"&&",
"!",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
")",
"{",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collCustomers",
"as",
"$",
"o",
")",
"{",
"$",
"o",
"->",
"clearAllReferences",
"(",
"$",
"deep",
")",
";",
"}",
"}",
"$",
"this",
"->",
"alreadyInClearAllReferencesDeep",
"=",
"false",
";",
"}",
"// if ($deep)",
"if",
"(",
"$",
"this",
"->",
"collCustomers",
"instanceof",
"PropelCollection",
")",
"{",
"$",
"this",
"->",
"collCustomers",
"->",
"clearIterator",
"(",
")",
";",
"}",
"$",
"this",
"->",
"collCustomers",
"=",
"null",
";",
"}"
] | Resets all references to other model objects or collections of model objects.
This method is a user-space workaround for PHP's inability to garbage collect
objects with circular references (even in PHP 5.3). This is currently necessary
when using Propel in certain daemon or large-volume/high-memory operations.
@param boolean $deep Whether to also clear the references on all referrer objects. | [
"Resets",
"all",
"references",
"to",
"other",
"model",
"objects",
"or",
"collections",
"of",
"model",
"objects",
"."
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCountry.php#L1255-L1272 |
CakeCMS/Core | src/Controller/Component/MoveComponent.php | MoveComponent.down | public function down(Table $table, $id, $step = 1)
{
return $this->_move($table, $id, $step, self::TYPE_DOWN);
} | php | public function down(Table $table, $id, $step = 1)
{
return $this->_move($table, $id, $step, self::TYPE_DOWN);
} | [
"public",
"function",
"down",
"(",
"Table",
"$",
"table",
",",
"$",
"id",
",",
"$",
"step",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"_move",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"step",
",",
"self",
"::",
"TYPE_DOWN",
")",
";",
"}"
] | Move down record in tree.
@param Table $table
@param int $id
@param int $step
@return \Cake\Http\Response|null | [
"Move",
"down",
"record",
"in",
"tree",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/MoveComponent.php#L53-L56 |
CakeCMS/Core | src/Controller/Component/MoveComponent.php | MoveComponent.setConfig | public function setConfig($key, $value = null, $merge = true)
{
$this->_defaultConfig = [
'messages' => [
'success' => __d('core', 'Object has been moved'),
'error' => __d('core', 'Object could not been moved')
],
'action' => 'index',
];
return parent::setConfig($key, $value, $merge);
} | php | public function setConfig($key, $value = null, $merge = true)
{
$this->_defaultConfig = [
'messages' => [
'success' => __d('core', 'Object has been moved'),
'error' => __d('core', 'Object could not been moved')
],
'action' => 'index',
];
return parent::setConfig($key, $value, $merge);
} | [
"public",
"function",
"setConfig",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"_defaultConfig",
"=",
"[",
"'messages'",
"=>",
"[",
"'success'",
"=>",
"__d",
"(",
"'core'",
",",
"'Object has been moved'",
")",
",",
"'error'",
"=>",
"__d",
"(",
"'core'",
",",
"'Object could not been moved'",
")",
"]",
",",
"'action'",
"=>",
"'index'",
",",
"]",
";",
"return",
"parent",
"::",
"setConfig",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"merge",
")",
";",
"}"
] | Sets the config.
@param array|string $key
@param null|mixed $value
@param bool $merge
@return mixed
@throws \Aura\Intl\Exception
@throws \Cake\Core\Exception\Exception When trying to set a key that is invalid. | [
"Sets",
"the",
"config",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/MoveComponent.php#L69-L80 |
CakeCMS/Core | src/Controller/Component/MoveComponent.php | MoveComponent.up | public function up(Table $table, $id, $step = 1)
{
return $this->_move($table, $id, $step);
} | php | public function up(Table $table, $id, $step = 1)
{
return $this->_move($table, $id, $step);
} | [
"public",
"function",
"up",
"(",
"Table",
"$",
"table",
",",
"$",
"id",
",",
"$",
"step",
"=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"_move",
"(",
"$",
"table",
",",
"$",
"id",
",",
"$",
"step",
")",
";",
"}"
] | Move up record in tree.
@param Table $table
@param int $id
@param int $step
@return \Cake\Http\Response|null
@SuppressWarnings(PHPMD.ShortMethodName) | [
"Move",
"up",
"record",
"in",
"tree",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/MoveComponent.php#L92-L95 |
CakeCMS/Core | src/Controller/Component/MoveComponent.php | MoveComponent._move | protected function _move(Table $table, $id, $step = 1, $type = self::TYPE_UP)
{
$behaviors = $table->behaviors();
if (!Arr::in('Tree', $behaviors->loaded())) {
$behaviors->load('Tree');
}
$entity = $table->get($id);
/** @var TreeBehavior $treeBehavior */
$treeBehavior = $behaviors->get('Tree');
$treeBehavior->setConfig('scope', $entity->get('id'));
if ($table->{$type}($entity, $step)) {
$this->Flash->success($this->_configRead('messages.success'));
} else {
$this->Flash->error($this->_configRead('messages.error'));
}
return $this->_redirect();
} | php | protected function _move(Table $table, $id, $step = 1, $type = self::TYPE_UP)
{
$behaviors = $table->behaviors();
if (!Arr::in('Tree', $behaviors->loaded())) {
$behaviors->load('Tree');
}
$entity = $table->get($id);
/** @var TreeBehavior $treeBehavior */
$treeBehavior = $behaviors->get('Tree');
$treeBehavior->setConfig('scope', $entity->get('id'));
if ($table->{$type}($entity, $step)) {
$this->Flash->success($this->_configRead('messages.success'));
} else {
$this->Flash->error($this->_configRead('messages.error'));
}
return $this->_redirect();
} | [
"protected",
"function",
"_move",
"(",
"Table",
"$",
"table",
",",
"$",
"id",
",",
"$",
"step",
"=",
"1",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_UP",
")",
"{",
"$",
"behaviors",
"=",
"$",
"table",
"->",
"behaviors",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"in",
"(",
"'Tree'",
",",
"$",
"behaviors",
"->",
"loaded",
"(",
")",
")",
")",
"{",
"$",
"behaviors",
"->",
"load",
"(",
"'Tree'",
")",
";",
"}",
"$",
"entity",
"=",
"$",
"table",
"->",
"get",
"(",
"$",
"id",
")",
";",
"/** @var TreeBehavior $treeBehavior */",
"$",
"treeBehavior",
"=",
"$",
"behaviors",
"->",
"get",
"(",
"'Tree'",
")",
";",
"$",
"treeBehavior",
"->",
"setConfig",
"(",
"'scope'",
",",
"$",
"entity",
"->",
"get",
"(",
"'id'",
")",
")",
";",
"if",
"(",
"$",
"table",
"->",
"{",
"$",
"type",
"}",
"(",
"$",
"entity",
",",
"$",
"step",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"$",
"this",
"->",
"_configRead",
"(",
"'messages.success'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"_configRead",
"(",
"'messages.error'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_redirect",
"(",
")",
";",
"}"
] | Move object in tree table.
@param Table $table
@param string $type
@param int $id
@param int $step
@return \Cake\Http\Response|null | [
"Move",
"object",
"in",
"tree",
"table",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/MoveComponent.php#L106-L126 |
CakeCMS/Core | src/Controller/Component/MoveComponent.php | MoveComponent._redirect | protected function _redirect()
{
$request = $this->_controller->request;
return $this->_controller->redirect([
'prefix' => $request->getParam('prefix'),
'plugin' => $request->getParam('plugin'),
'controller' => $request->getParam('controller'),
'action' => $this->getConfig('action')
]);
} | php | protected function _redirect()
{
$request = $this->_controller->request;
return $this->_controller->redirect([
'prefix' => $request->getParam('prefix'),
'plugin' => $request->getParam('plugin'),
'controller' => $request->getParam('controller'),
'action' => $this->getConfig('action')
]);
} | [
"protected",
"function",
"_redirect",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"_controller",
"->",
"request",
";",
"return",
"$",
"this",
"->",
"_controller",
"->",
"redirect",
"(",
"[",
"'prefix'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
",",
"'plugin'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'plugin'",
")",
",",
"'controller'",
"=>",
"$",
"request",
"->",
"getParam",
"(",
"'controller'",
")",
",",
"'action'",
"=>",
"$",
"this",
"->",
"getConfig",
"(",
"'action'",
")",
"]",
")",
";",
"}"
] | Process redirect.
@return \Cake\Http\Response|null | [
"Process",
"redirect",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/MoveComponent.php#L133-L142 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_base.& | function &getDebugAsXMLComment()
{
// it would be nice to use a memory stream here to use
// memory more efficiently
while (strpos($this->debug_str, '--')) {
$this->debug_str = str_replace('--', '- -', $this->debug_str);
}
$ret = "<!--\n" . $this->debug_str . "\n-->";
return $ret;
} | php | function &getDebugAsXMLComment()
{
// it would be nice to use a memory stream here to use
// memory more efficiently
while (strpos($this->debug_str, '--')) {
$this->debug_str = str_replace('--', '- -', $this->debug_str);
}
$ret = "<!--\n" . $this->debug_str . "\n-->";
return $ret;
} | [
"function",
"&",
"getDebugAsXMLComment",
"(",
")",
"{",
"// it would be nice to use a memory stream here to use",
"// memory more efficiently",
"while",
"(",
"strpos",
"(",
"$",
"this",
"->",
"debug_str",
",",
"'--'",
")",
")",
"{",
"$",
"this",
"->",
"debug_str",
"=",
"str_replace",
"(",
"'--'",
",",
"'- -'",
",",
"$",
"this",
"->",
"debug_str",
")",
";",
"}",
"$",
"ret",
"=",
"\"<!--\\n\"",
".",
"$",
"this",
"->",
"debug_str",
".",
"\"\\n-->\"",
";",
"return",
"$",
"ret",
";",
"}"
] | gets the current debug data for this instance as an XML comment
this may change the contents of the debug data
@return debug data as an XML comment
@access public | [
"gets",
"the",
"current",
"debug",
"data",
"for",
"this",
"instance",
"as",
"an",
"XML",
"comment",
"this",
"may",
"change",
"the",
"contents",
"of",
"the",
"debug",
"data"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L346-L356 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_base.serialize_val | function serialize_val(
$val, $name = FALSE, $type = FALSE, $name_ns = FALSE, $type_ns = FALSE, $attributes = FALSE, $use = 'encoded', $soapval = FALSE
) {
$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
$this->appendDebug('value=' . $this->varDump($val));
$this->appendDebug('attributes=' . $this->varDump($attributes));
if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
$this->debug("serialize_val: serialize soapval");
$xml = $val->serialize($use);
$this->appendDebug($val->getDebug());
$val->clearDebug();
$this->debug("serialize_val of soapval returning $xml");
return $xml;
}
// force valid name if necessary
if (is_numeric($name)) {
$name = '__numeric_' . $name;
} elseif (!$name) {
$name = 'noname';
}
// if name has ns, add ns prefix to name
$xmlns = '';
if ($name_ns) {
$prefix = 'nu' . rand(1000, 9999);
$name = $prefix . ':' . $name;
$xmlns .= " xmlns:$prefix=\"$name_ns\"";
}
// if type is prefixed, create type prefix
if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
// need to fix this. shouldn't default to xsd if no ns specified
// w/o checking against typemap
$type_prefix = 'xsd';
} elseif ($type_ns) {
$type_prefix = 'ns' . rand(1000, 9999);
$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
}
// serialize attributes if present
$atts = '';
if ($attributes) {
foreach ($attributes as $k => $v) {
$atts .= " $k=\"" . $this->expandEntities($v) . '"';
}
}
// serialize null value
if (is_null($val)) {
$this->debug("serialize_val: serialize null");
if ($use == 'literal') {
// TODO: depends on minOccurs
$xml = "<$name$xmlns$atts/>";
$this->debug("serialize_val returning $xml");
return $xml;
} else {
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
$this->debug("serialize_val returning $xml");
return $xml;
}
}
// serialize if an xsd built-in primitive type
if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
$this->debug("serialize_val: serialize xsd built-in primitive type");
if (is_bool($val)) {
if ($type == 'boolean') {
$val = $val ? 'true' : 'false';
} elseif (!$val) {
$val = 0;
}
} elseif (is_string($val)) {
$val = $this->expandEntities($val);
}
if ($use == 'literal') {
$xml = "<$name$xmlns$atts>$val</$name>";
$this->debug("serialize_val returning $xml");
return $xml;
} else {
$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
$this->debug("serialize_val returning $xml");
return $xml;
}
}
// detect type and serialize
$xml = '';
switch (TRUE) {
case (is_bool($val) || $type == 'boolean'):
$this->debug("serialize_val: serialize boolean");
if ($type == 'boolean') {
$val = $val ? 'true' : 'false';
} elseif (!$val) {
$val = 0;
}
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
}
break;
case (is_int($val) || is_long($val) || $type == 'int'):
$this->debug("serialize_val: serialize int");
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
}
break;
case (is_float($val) || is_double($val) || $type == 'float'):
$this->debug("serialize_val: serialize float");
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
}
break;
case (is_string($val) || $type == 'string'):
$this->debug("serialize_val: serialize string");
$val = $this->expandEntities($val);
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
}
break;
case is_object($val):
$this->debug("serialize_val: serialize object");
if (get_class($val) == 'soapval') {
$this->debug("serialize_val: serialize soapval object");
$pXml = $val->serialize($use);
$this->appendDebug($val->getDebug());
$val->clearDebug();
} else {
if (!$name) {
$name = get_class($val);
$this->debug("In serialize_val, used class name $name as element name");
} else {
$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
}
foreach (get_object_vars($val) as $k => $v) {
$pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, FALSE, FALSE, FALSE, FALSE, $use) : $this->serialize_val($v, $k, FALSE, FALSE, FALSE, FALSE, $use);
}
}
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$pXml</$name>";
} else {
$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
}
break;
break;
case (is_array($val) || $type):
// detect if struct or array
$valueType = $this->isArraySimpleOrStruct($val);
if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
$this->debug("serialize_val: serialize array");
$i = 0;
if (is_array($val) && count($val) > 0) {
foreach ($val as $v) {
if (is_object($v) && get_class($v) == 'soapval') {
$tt_ns = $v->type_ns;
$tt = $v->type;
} elseif (is_array($v)) {
$tt = $this->isArraySimpleOrStruct($v);
} else {
$tt = gettype($v);
}
$array_types[$tt] = 1;
// TODO: for literal, the name should be $name
$xml .= $this->serialize_val($v, 'item', FALSE, FALSE, FALSE, FALSE, $use);
++$i;
}
if (count($array_types) > 1) {
$array_typename = 'xsd:anyType';
} elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
if ($tt == 'integer') {
$tt = 'int';
}
$array_typename = 'xsd:' . $tt;
} elseif (isset($tt) && $tt == 'arraySimple') {
$array_typename = 'SOAP-ENC:Array';
} elseif (isset($tt) && $tt == 'arrayStruct') {
$array_typename = 'unnamed_struct_use_soapval';
} else {
// if type is prefixed, create type prefix
if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
$array_typename = 'xsd:' . $tt;
} elseif ($tt_ns) {
$tt_prefix = 'ns' . rand(1000, 9999);
$array_typename = "$tt_prefix:$tt";
$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
} else {
$array_typename = $tt;
}
}
$array_type = $i;
if ($use == 'literal') {
$type_str = '';
} elseif (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\"";
}
// empty array
} else {
if ($use == 'literal') {
$type_str = '';
} elseif (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
}
}
// TODO: for array in literal, there is no wrapper here
$xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>";
} else {
// got a struct
$this->debug("serialize_val: serialize struct");
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>";
} else {
$xml .= "<$name$xmlns$type_str$atts>";
}
foreach ($val as $k => $v) {
// Apache Map
if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
$xml .= '<item>';
$xml .= $this->serialize_val($k, 'key', FALSE, FALSE, FALSE, FALSE, $use);
$xml .= $this->serialize_val($v, 'value', FALSE, FALSE, FALSE, FALSE, $use);
$xml .= '</item>';
} else {
$xml .= $this->serialize_val($v, $k, FALSE, FALSE, FALSE, FALSE, $use);
}
}
$xml .= "</$name>";
}
break;
default:
$this->debug("serialize_val: serialize unknown");
$xml .= 'not detected, got ' . gettype($val) . ' for ' . $val;
break;
}
$this->debug("serialize_val returning $xml");
return $xml;
} | php | function serialize_val(
$val, $name = FALSE, $type = FALSE, $name_ns = FALSE, $type_ns = FALSE, $attributes = FALSE, $use = 'encoded', $soapval = FALSE
) {
$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
$this->appendDebug('value=' . $this->varDump($val));
$this->appendDebug('attributes=' . $this->varDump($attributes));
if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
$this->debug("serialize_val: serialize soapval");
$xml = $val->serialize($use);
$this->appendDebug($val->getDebug());
$val->clearDebug();
$this->debug("serialize_val of soapval returning $xml");
return $xml;
}
// force valid name if necessary
if (is_numeric($name)) {
$name = '__numeric_' . $name;
} elseif (!$name) {
$name = 'noname';
}
// if name has ns, add ns prefix to name
$xmlns = '';
if ($name_ns) {
$prefix = 'nu' . rand(1000, 9999);
$name = $prefix . ':' . $name;
$xmlns .= " xmlns:$prefix=\"$name_ns\"";
}
// if type is prefixed, create type prefix
if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
// need to fix this. shouldn't default to xsd if no ns specified
// w/o checking against typemap
$type_prefix = 'xsd';
} elseif ($type_ns) {
$type_prefix = 'ns' . rand(1000, 9999);
$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
}
// serialize attributes if present
$atts = '';
if ($attributes) {
foreach ($attributes as $k => $v) {
$atts .= " $k=\"" . $this->expandEntities($v) . '"';
}
}
// serialize null value
if (is_null($val)) {
$this->debug("serialize_val: serialize null");
if ($use == 'literal') {
// TODO: depends on minOccurs
$xml = "<$name$xmlns$atts/>";
$this->debug("serialize_val returning $xml");
return $xml;
} else {
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
$this->debug("serialize_val returning $xml");
return $xml;
}
}
// serialize if an xsd built-in primitive type
if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
$this->debug("serialize_val: serialize xsd built-in primitive type");
if (is_bool($val)) {
if ($type == 'boolean') {
$val = $val ? 'true' : 'false';
} elseif (!$val) {
$val = 0;
}
} elseif (is_string($val)) {
$val = $this->expandEntities($val);
}
if ($use == 'literal') {
$xml = "<$name$xmlns$atts>$val</$name>";
$this->debug("serialize_val returning $xml");
return $xml;
} else {
$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
$this->debug("serialize_val returning $xml");
return $xml;
}
}
// detect type and serialize
$xml = '';
switch (TRUE) {
case (is_bool($val) || $type == 'boolean'):
$this->debug("serialize_val: serialize boolean");
if ($type == 'boolean') {
$val = $val ? 'true' : 'false';
} elseif (!$val) {
$val = 0;
}
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
}
break;
case (is_int($val) || is_long($val) || $type == 'int'):
$this->debug("serialize_val: serialize int");
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
}
break;
case (is_float($val) || is_double($val) || $type == 'float'):
$this->debug("serialize_val: serialize float");
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
}
break;
case (is_string($val) || $type == 'string'):
$this->debug("serialize_val: serialize string");
$val = $this->expandEntities($val);
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$val</$name>";
} else {
$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
}
break;
case is_object($val):
$this->debug("serialize_val: serialize object");
if (get_class($val) == 'soapval') {
$this->debug("serialize_val: serialize soapval object");
$pXml = $val->serialize($use);
$this->appendDebug($val->getDebug());
$val->clearDebug();
} else {
if (!$name) {
$name = get_class($val);
$this->debug("In serialize_val, used class name $name as element name");
} else {
$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
}
foreach (get_object_vars($val) as $k => $v) {
$pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, FALSE, FALSE, FALSE, FALSE, $use) : $this->serialize_val($v, $k, FALSE, FALSE, FALSE, FALSE, $use);
}
}
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>$pXml</$name>";
} else {
$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
}
break;
break;
case (is_array($val) || $type):
// detect if struct or array
$valueType = $this->isArraySimpleOrStruct($val);
if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
$this->debug("serialize_val: serialize array");
$i = 0;
if (is_array($val) && count($val) > 0) {
foreach ($val as $v) {
if (is_object($v) && get_class($v) == 'soapval') {
$tt_ns = $v->type_ns;
$tt = $v->type;
} elseif (is_array($v)) {
$tt = $this->isArraySimpleOrStruct($v);
} else {
$tt = gettype($v);
}
$array_types[$tt] = 1;
// TODO: for literal, the name should be $name
$xml .= $this->serialize_val($v, 'item', FALSE, FALSE, FALSE, FALSE, $use);
++$i;
}
if (count($array_types) > 1) {
$array_typename = 'xsd:anyType';
} elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
if ($tt == 'integer') {
$tt = 'int';
}
$array_typename = 'xsd:' . $tt;
} elseif (isset($tt) && $tt == 'arraySimple') {
$array_typename = 'SOAP-ENC:Array';
} elseif (isset($tt) && $tt == 'arrayStruct') {
$array_typename = 'unnamed_struct_use_soapval';
} else {
// if type is prefixed, create type prefix
if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
$array_typename = 'xsd:' . $tt;
} elseif ($tt_ns) {
$tt_prefix = 'ns' . rand(1000, 9999);
$array_typename = "$tt_prefix:$tt";
$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
} else {
$array_typename = $tt;
}
}
$array_type = $i;
if ($use == 'literal') {
$type_str = '';
} elseif (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\"";
}
// empty array
} else {
if ($use == 'literal') {
$type_str = '';
} elseif (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
}
}
// TODO: for array in literal, there is no wrapper here
$xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>";
} else {
// got a struct
$this->debug("serialize_val: serialize struct");
if (isset($type) && isset($type_prefix)) {
$type_str = " xsi:type=\"$type_prefix:$type\"";
} else {
$type_str = '';
}
if ($use == 'literal') {
$xml .= "<$name$xmlns$atts>";
} else {
$xml .= "<$name$xmlns$type_str$atts>";
}
foreach ($val as $k => $v) {
// Apache Map
if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
$xml .= '<item>';
$xml .= $this->serialize_val($k, 'key', FALSE, FALSE, FALSE, FALSE, $use);
$xml .= $this->serialize_val($v, 'value', FALSE, FALSE, FALSE, FALSE, $use);
$xml .= '</item>';
} else {
$xml .= $this->serialize_val($v, $k, FALSE, FALSE, FALSE, FALSE, $use);
}
}
$xml .= "</$name>";
}
break;
default:
$this->debug("serialize_val: serialize unknown");
$xml .= 'not detected, got ' . gettype($val) . ' for ' . $val;
break;
}
$this->debug("serialize_val returning $xml");
return $xml;
} | [
"function",
"serialize_val",
"(",
"$",
"val",
",",
"$",
"name",
"=",
"FALSE",
",",
"$",
"type",
"=",
"FALSE",
",",
"$",
"name_ns",
"=",
"FALSE",
",",
"$",
"type_ns",
"=",
"FALSE",
",",
"$",
"attributes",
"=",
"FALSE",
",",
"$",
"use",
"=",
"'encoded'",
",",
"$",
"soapval",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval\"",
")",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"'value='",
".",
"$",
"this",
"->",
"varDump",
"(",
"$",
"val",
")",
")",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"'attributes='",
".",
"$",
"this",
"->",
"varDump",
"(",
"$",
"attributes",
")",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"val",
")",
"&&",
"get_class",
"(",
"$",
"val",
")",
"==",
"'soapval'",
"&&",
"(",
"!",
"$",
"soapval",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize soapval\"",
")",
";",
"$",
"xml",
"=",
"$",
"val",
"->",
"serialize",
"(",
"$",
"use",
")",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"$",
"val",
"->",
"getDebug",
"(",
")",
")",
";",
"$",
"val",
"->",
"clearDebug",
"(",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val of soapval returning $xml\"",
")",
";",
"return",
"$",
"xml",
";",
"}",
"// force valid name if necessary",
"if",
"(",
"is_numeric",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"'__numeric_'",
".",
"$",
"name",
";",
"}",
"elseif",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"'noname'",
";",
"}",
"// if name has ns, add ns prefix to name",
"$",
"xmlns",
"=",
"''",
";",
"if",
"(",
"$",
"name_ns",
")",
"{",
"$",
"prefix",
"=",
"'nu'",
".",
"rand",
"(",
"1000",
",",
"9999",
")",
";",
"$",
"name",
"=",
"$",
"prefix",
".",
"':'",
".",
"$",
"name",
";",
"$",
"xmlns",
".=",
"\" xmlns:$prefix=\\\"$name_ns\\\"\"",
";",
"}",
"// if type is prefixed, create type prefix",
"if",
"(",
"$",
"type_ns",
"!=",
"''",
"&&",
"$",
"type_ns",
"==",
"$",
"this",
"->",
"namespaces",
"[",
"'xsd'",
"]",
")",
"{",
"// need to fix this. shouldn't default to xsd if no ns specified",
"// w/o checking against typemap",
"$",
"type_prefix",
"=",
"'xsd'",
";",
"}",
"elseif",
"(",
"$",
"type_ns",
")",
"{",
"$",
"type_prefix",
"=",
"'ns'",
".",
"rand",
"(",
"1000",
",",
"9999",
")",
";",
"$",
"xmlns",
".=",
"\" xmlns:$type_prefix=\\\"$type_ns\\\"\"",
";",
"}",
"// serialize attributes if present",
"$",
"atts",
"=",
"''",
";",
"if",
"(",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"atts",
".=",
"\" $k=\\\"\"",
".",
"$",
"this",
"->",
"expandEntities",
"(",
"$",
"v",
")",
".",
"'\"'",
";",
"}",
"}",
"// serialize null value",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize null\"",
")",
";",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"// TODO: depends on minOccurs",
"$",
"xml",
"=",
"\"<$name$xmlns$atts/>\"",
";",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val returning $xml\"",
")",
";",
"return",
"$",
"xml",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"type",
")",
"&&",
"isset",
"(",
"$",
"type_prefix",
")",
")",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"$type_prefix:$type\\\"\"",
";",
"}",
"else",
"{",
"$",
"type_str",
"=",
"''",
";",
"}",
"$",
"xml",
"=",
"\"<$name$xmlns$type_str$atts xsi:nil=\\\"true\\\"/>\"",
";",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val returning $xml\"",
")",
";",
"return",
"$",
"xml",
";",
"}",
"}",
"// serialize if an xsd built-in primitive type",
"if",
"(",
"$",
"type",
"!=",
"''",
"&&",
"isset",
"(",
"$",
"this",
"->",
"typemap",
"[",
"$",
"this",
"->",
"XMLSchemaVersion",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize xsd built-in primitive type\"",
")",
";",
"if",
"(",
"is_bool",
"(",
"$",
"val",
")",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'boolean'",
")",
"{",
"$",
"val",
"=",
"$",
"val",
"?",
"'true'",
":",
"'false'",
";",
"}",
"elseif",
"(",
"!",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"0",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"val",
")",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"expandEntities",
"(",
"$",
"val",
")",
";",
"}",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
"=",
"\"<$name$xmlns$atts>$val</$name>\"",
";",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val returning $xml\"",
")",
";",
"return",
"$",
"xml",
";",
"}",
"else",
"{",
"$",
"xml",
"=",
"\"<$name$xmlns xsi:type=\\\"xsd:$type\\\"$atts>$val</$name>\"",
";",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val returning $xml\"",
")",
";",
"return",
"$",
"xml",
";",
"}",
"}",
"// detect type and serialize",
"$",
"xml",
"=",
"''",
";",
"switch",
"(",
"TRUE",
")",
"{",
"case",
"(",
"is_bool",
"(",
"$",
"val",
")",
"||",
"$",
"type",
"==",
"'boolean'",
")",
":",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize boolean\"",
")",
";",
"if",
"(",
"$",
"type",
"==",
"'boolean'",
")",
"{",
"$",
"val",
"=",
"$",
"val",
"?",
"'true'",
":",
"'false'",
";",
"}",
"elseif",
"(",
"!",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"0",
";",
"}",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$atts>$val</$name>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns xsi:type=\\\"xsd:boolean\\\"$atts>$val</$name>\"",
";",
"}",
"break",
";",
"case",
"(",
"is_int",
"(",
"$",
"val",
")",
"||",
"is_long",
"(",
"$",
"val",
")",
"||",
"$",
"type",
"==",
"'int'",
")",
":",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize int\"",
")",
";",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$atts>$val</$name>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns xsi:type=\\\"xsd:int\\\"$atts>$val</$name>\"",
";",
"}",
"break",
";",
"case",
"(",
"is_float",
"(",
"$",
"val",
")",
"||",
"is_double",
"(",
"$",
"val",
")",
"||",
"$",
"type",
"==",
"'float'",
")",
":",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize float\"",
")",
";",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$atts>$val</$name>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns xsi:type=\\\"xsd:float\\\"$atts>$val</$name>\"",
";",
"}",
"break",
";",
"case",
"(",
"is_string",
"(",
"$",
"val",
")",
"||",
"$",
"type",
"==",
"'string'",
")",
":",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize string\"",
")",
";",
"$",
"val",
"=",
"$",
"this",
"->",
"expandEntities",
"(",
"$",
"val",
")",
";",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$atts>$val</$name>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns xsi:type=\\\"xsd:string\\\"$atts>$val</$name>\"",
";",
"}",
"break",
";",
"case",
"is_object",
"(",
"$",
"val",
")",
":",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize object\"",
")",
";",
"if",
"(",
"get_class",
"(",
"$",
"val",
")",
"==",
"'soapval'",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize soapval object\"",
")",
";",
"$",
"pXml",
"=",
"$",
"val",
"->",
"serialize",
"(",
"$",
"use",
")",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"$",
"val",
"->",
"getDebug",
"(",
")",
")",
";",
"$",
"val",
"->",
"clearDebug",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"get_class",
"(",
"$",
"val",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"In serialize_val, used class name $name as element name\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"In serialize_val, do not override name $name for element name for class \"",
".",
"get_class",
"(",
"$",
"val",
")",
")",
";",
"}",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"val",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"pXml",
"=",
"isset",
"(",
"$",
"pXml",
")",
"?",
"$",
"pXml",
".",
"$",
"this",
"->",
"serialize_val",
"(",
"$",
"v",
",",
"$",
"k",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"$",
"use",
")",
":",
"$",
"this",
"->",
"serialize_val",
"(",
"$",
"v",
",",
"$",
"k",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"$",
"use",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"type",
")",
"&&",
"isset",
"(",
"$",
"type_prefix",
")",
")",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"$type_prefix:$type\\\"\"",
";",
"}",
"else",
"{",
"$",
"type_str",
"=",
"''",
";",
"}",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$atts>$pXml</$name>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$type_str$atts>$pXml</$name>\"",
";",
"}",
"break",
";",
"break",
";",
"case",
"(",
"is_array",
"(",
"$",
"val",
")",
"||",
"$",
"type",
")",
":",
"// detect if struct or array",
"$",
"valueType",
"=",
"$",
"this",
"->",
"isArraySimpleOrStruct",
"(",
"$",
"val",
")",
";",
"if",
"(",
"$",
"valueType",
"==",
"'arraySimple'",
"||",
"preg_match",
"(",
"'/^ArrayOf/'",
",",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize array\"",
")",
";",
"$",
"i",
"=",
"0",
";",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
"&&",
"count",
"(",
"$",
"val",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"val",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"v",
")",
"&&",
"get_class",
"(",
"$",
"v",
")",
"==",
"'soapval'",
")",
"{",
"$",
"tt_ns",
"=",
"$",
"v",
"->",
"type_ns",
";",
"$",
"tt",
"=",
"$",
"v",
"->",
"type",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"tt",
"=",
"$",
"this",
"->",
"isArraySimpleOrStruct",
"(",
"$",
"v",
")",
";",
"}",
"else",
"{",
"$",
"tt",
"=",
"gettype",
"(",
"$",
"v",
")",
";",
"}",
"$",
"array_types",
"[",
"$",
"tt",
"]",
"=",
"1",
";",
"// TODO: for literal, the name should be $name",
"$",
"xml",
".=",
"$",
"this",
"->",
"serialize_val",
"(",
"$",
"v",
",",
"'item'",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"$",
"use",
")",
";",
"++",
"$",
"i",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"array_types",
")",
">",
"1",
")",
"{",
"$",
"array_typename",
"=",
"'xsd:anyType'",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"tt",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"typemap",
"[",
"$",
"this",
"->",
"XMLSchemaVersion",
"]",
"[",
"$",
"tt",
"]",
")",
")",
"{",
"if",
"(",
"$",
"tt",
"==",
"'integer'",
")",
"{",
"$",
"tt",
"=",
"'int'",
";",
"}",
"$",
"array_typename",
"=",
"'xsd:'",
".",
"$",
"tt",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"tt",
")",
"&&",
"$",
"tt",
"==",
"'arraySimple'",
")",
"{",
"$",
"array_typename",
"=",
"'SOAP-ENC:Array'",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"tt",
")",
"&&",
"$",
"tt",
"==",
"'arrayStruct'",
")",
"{",
"$",
"array_typename",
"=",
"'unnamed_struct_use_soapval'",
";",
"}",
"else",
"{",
"// if type is prefixed, create type prefix",
"if",
"(",
"$",
"tt_ns",
"!=",
"''",
"&&",
"$",
"tt_ns",
"==",
"$",
"this",
"->",
"namespaces",
"[",
"'xsd'",
"]",
")",
"{",
"$",
"array_typename",
"=",
"'xsd:'",
".",
"$",
"tt",
";",
"}",
"elseif",
"(",
"$",
"tt_ns",
")",
"{",
"$",
"tt_prefix",
"=",
"'ns'",
".",
"rand",
"(",
"1000",
",",
"9999",
")",
";",
"$",
"array_typename",
"=",
"\"$tt_prefix:$tt\"",
";",
"$",
"xmlns",
".=",
"\" xmlns:$tt_prefix=\\\"$tt_ns\\\"\"",
";",
"}",
"else",
"{",
"$",
"array_typename",
"=",
"$",
"tt",
";",
"}",
"}",
"$",
"array_type",
"=",
"$",
"i",
";",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"type_str",
"=",
"''",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"type",
")",
"&&",
"isset",
"(",
"$",
"type_prefix",
")",
")",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"$type_prefix:$type\\\"\"",
";",
"}",
"else",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"SOAP-ENC:Array\\\" SOAP-ENC:arrayType=\\\"\"",
".",
"$",
"array_typename",
".",
"\"[$array_type]\\\"\"",
";",
"}",
"// empty array",
"}",
"else",
"{",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"type_str",
"=",
"''",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"type",
")",
"&&",
"isset",
"(",
"$",
"type_prefix",
")",
")",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"$type_prefix:$type\\\"\"",
";",
"}",
"else",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"SOAP-ENC:Array\\\" SOAP-ENC:arrayType=\\\"xsd:anyType[0]\\\"\"",
";",
"}",
"}",
"// TODO: for array in literal, there is no wrapper here",
"$",
"xml",
"=",
"\"<$name$xmlns$type_str$atts>\"",
".",
"$",
"xml",
".",
"\"</$name>\"",
";",
"}",
"else",
"{",
"// got a struct",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize struct\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"type",
")",
"&&",
"isset",
"(",
"$",
"type_prefix",
")",
")",
"{",
"$",
"type_str",
"=",
"\" xsi:type=\\\"$type_prefix:$type\\\"\"",
";",
"}",
"else",
"{",
"$",
"type_str",
"=",
"''",
";",
"}",
"if",
"(",
"$",
"use",
"==",
"'literal'",
")",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$atts>\"",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"\"<$name$xmlns$type_str$atts>\"",
";",
"}",
"foreach",
"(",
"$",
"val",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// Apache Map",
"if",
"(",
"$",
"type",
"==",
"'Map'",
"&&",
"$",
"type_ns",
"==",
"'http://xml.apache.org/xml-soap'",
")",
"{",
"$",
"xml",
".=",
"'<item>'",
";",
"$",
"xml",
".=",
"$",
"this",
"->",
"serialize_val",
"(",
"$",
"k",
",",
"'key'",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"$",
"use",
")",
";",
"$",
"xml",
".=",
"$",
"this",
"->",
"serialize_val",
"(",
"$",
"v",
",",
"'value'",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"$",
"use",
")",
";",
"$",
"xml",
".=",
"'</item>'",
";",
"}",
"else",
"{",
"$",
"xml",
".=",
"$",
"this",
"->",
"serialize_val",
"(",
"$",
"v",
",",
"$",
"k",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
",",
"$",
"use",
")",
";",
"}",
"}",
"$",
"xml",
".=",
"\"</$name>\"",
";",
"}",
"break",
";",
"default",
":",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val: serialize unknown\"",
")",
";",
"$",
"xml",
".=",
"'not detected, got '",
".",
"gettype",
"(",
"$",
"val",
")",
".",
"' for '",
".",
"$",
"val",
";",
"break",
";",
"}",
"$",
"this",
"->",
"debug",
"(",
"\"serialize_val returning $xml\"",
")",
";",
"return",
"$",
"xml",
";",
"}"
] | serializes PHP values in accordance w/ section 5. Type information is
not serialized if $use == 'literal'.
@param mixed $val The value to serialize
@param string $name The name (local part) of the XML element
@param string $type The XML schema type (local part) for the element
@param string $name_ns The namespace for the name of the XML element
@param string $type_ns The namespace for the type of the element
@param array $attributes The attributes to serialize as name=>value pairs
@param string $use The WSDL "use" (encoded|literal)
@param boolean $soapval Whether this is called from soapval.
@return string The serialized element, possibly with child elements
@access public | [
"serializes",
"PHP",
"values",
"in",
"accordance",
"w",
"/",
"section",
"5",
".",
"Type",
"information",
"is",
"not",
"serialized",
"if",
"$use",
"==",
"literal",
"."
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L440-L700 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_base.getNamespaceFromPrefix | function getNamespaceFromPrefix($prefix)
{
if (isset($this->namespaces[$prefix])) {
return $this->namespaces[$prefix];
}
//$this->setError("No namespace registered for prefix '$prefix'");
return FALSE;
} | php | function getNamespaceFromPrefix($prefix)
{
if (isset($this->namespaces[$prefix])) {
return $this->namespaces[$prefix];
}
//$this->setError("No namespace registered for prefix '$prefix'");
return FALSE;
} | [
"function",
"getNamespaceFromPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"prefix",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"prefix",
"]",
";",
"}",
"//$this->setError(\"No namespace registered for prefix '$prefix'\");",
"return",
"FALSE",
";",
"}"
] | pass it a prefix, it returns a namespace
@param string $prefix The prefix
@return mixed The namespace, false if no namespace has the specified prefix
@access public | [
"pass",
"it",
"a",
"prefix",
"it",
"returns",
"a",
"namespace"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L883-L891 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_base.getPrefixFromNamespace | function getPrefixFromNamespace($ns)
{
foreach ($this->namespaces as $p => $n) {
if ($ns == $n || $ns == $p) {
$this->usedNamespaces[$p] = $n;
return $p;
}
}
return FALSE;
} | php | function getPrefixFromNamespace($ns)
{
foreach ($this->namespaces as $p => $n) {
if ($ns == $n || $ns == $p) {
$this->usedNamespaces[$p] = $n;
return $p;
}
}
return FALSE;
} | [
"function",
"getPrefixFromNamespace",
"(",
"$",
"ns",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"p",
"=>",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"ns",
"==",
"$",
"n",
"||",
"$",
"ns",
"==",
"$",
"p",
")",
"{",
"$",
"this",
"->",
"usedNamespaces",
"[",
"$",
"p",
"]",
"=",
"$",
"n",
";",
"return",
"$",
"p",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | returns the prefix for a given namespace (or prefix)
or false if no prefixes registered for the given namespace
@param string $ns The namespace
@return mixed The prefix, false if the namespace has no prefixes
@access public | [
"returns",
"the",
"prefix",
"for",
"a",
"given",
"namespace",
"(",
"or",
"prefix",
")",
"or",
"false",
"if",
"no",
"prefixes",
"registered",
"for",
"the",
"given",
"namespace"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L902-L913 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.parseFile | function parseFile($xml, $type)
{
// parse xml file
if ($xml != "") {
$xmlStr = @join("", @file($xml));
if ($xmlStr == "") {
$msg = 'Error reading XML from ' . $xml;
$this->setError($msg);
$this->debug($msg);
return FALSE;
} else {
$this->debug("parsing $xml");
$this->parseString($xmlStr, $type);
$this->debug("done parsing $xml");
return TRUE;
}
}
return FALSE;
} | php | function parseFile($xml, $type)
{
// parse xml file
if ($xml != "") {
$xmlStr = @join("", @file($xml));
if ($xmlStr == "") {
$msg = 'Error reading XML from ' . $xml;
$this->setError($msg);
$this->debug($msg);
return FALSE;
} else {
$this->debug("parsing $xml");
$this->parseString($xmlStr, $type);
$this->debug("done parsing $xml");
return TRUE;
}
}
return FALSE;
} | [
"function",
"parseFile",
"(",
"$",
"xml",
",",
"$",
"type",
")",
"{",
"// parse xml file",
"if",
"(",
"$",
"xml",
"!=",
"\"\"",
")",
"{",
"$",
"xmlStr",
"=",
"@",
"join",
"(",
"\"\"",
",",
"@",
"file",
"(",
"$",
"xml",
")",
")",
";",
"if",
"(",
"$",
"xmlStr",
"==",
"\"\"",
")",
"{",
"$",
"msg",
"=",
"'Error reading XML from '",
".",
"$",
"xml",
";",
"$",
"this",
"->",
"setError",
"(",
"$",
"msg",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"msg",
")",
";",
"return",
"FALSE",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"parsing $xml\"",
")",
";",
"$",
"this",
"->",
"parseString",
"(",
"$",
"xmlStr",
",",
"$",
"type",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"done parsing $xml\"",
")",
";",
"return",
"TRUE",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | parse an XML file
@param string $xml path/URL to XML file
@param string $type (schema | xml)
@return boolean
@access public | [
"parse",
"an",
"XML",
"file"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L1252-L1273 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.schemaStartElement | function schemaStartElement($parser, $name, $attrs)
{
// position in the total number of elements, starting from 0
$pos = $this->position++;
$depth = $this->depth++;
// set self as current value for this depth
$this->depth_array[$depth] = $pos;
$this->message[$pos] = ['cdata' => ''];
if ($depth > 0) {
$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
} else {
$this->defaultNamespace[$pos] = FALSE;
}
// get element prefix
if ($prefix = $this->getPrefix($name)) {
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
// loop thru attributes, expanding, and registering namespace declarations
if (count($attrs) > 0) {
foreach ($attrs as $k => $v) {
// if ns declarations, add to class level array of valid namespaces
if (preg_match('/^xmlns/', $k)) {
//$this->xdebug("$k: $v");
//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
//$this->xdebug("Add namespace[$ns_prefix] = $v");
$this->namespaces[$ns_prefix] = $v;
} else {
$this->defaultNamespace[$pos] = $v;
if (!$this->getPrefixFromNamespace($v)) {
$this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
}
}
if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
$this->XMLSchemaVersion = $v;
$this->namespaces['xsi'] = $v . '-instance';
}
}
}
foreach ($attrs as $k => $v) {
// expand each attribute
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
$v = strpos($v, ':') ? $this->expandQname($v) : $v;
$eAttrs[$k] = $v;
}
$attrs = $eAttrs;
} else {
$attrs = [];
}
// find status, register data
switch ($name) {
case 'all': // (optional) compositor content for a complexType
case 'choice':
case 'group':
case 'sequence':
//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
//if($name == 'all' || $name == 'sequence'){
// $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
//}
break;
case 'attribute': // complexType attribute
//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
$this->xdebug("parsing attribute:");
$this->appendDebug($this->varDump($attrs));
if (!isset($attrs['form'])) {
// TODO: handle globals
$attrs['form'] = $this->schemaInfo['attributeFormDefault'];
}
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
if (!strpos($v, ':')) {
// no namespace in arrayType attribute value...
if ($this->defaultNamespace[$pos]) {
// ...so use the default
$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
}
}
if (isset($attrs['name'])) {
$this->attributes[$attrs['name']] = $attrs;
$aname = $attrs['name'];
} elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$aname = '';
}
} elseif (isset($attrs['ref'])) {
$aname = $attrs['ref'];
$this->attributes[$attrs['ref']] = $attrs;
}
if ($this->currentComplexType) { // This should *always* be
$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
}
// arrayType attribute
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
$prefix = $this->getPrefix($aname);
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$v = '';
}
if (strpos($v, '[,]')) {
$this->complexTypes[$this->currentComplexType]['multidimensional'] = TRUE;
}
$v = substr($v, 0, strpos($v, '[')); // clip the []
if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
$v = $this->XMLSchemaVersion . ':' . $v;
}
$this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
}
break;
case 'complexContent': // (optional) content for a complexType
$this->xdebug("do nothing for element $name");
break;
case 'complexType':
array_push($this->complexTypeStack, $this->currentComplexType);
if (isset($attrs['name'])) {
// TODO: what is the scope of named complexTypes that appear
// nested within other c complexTypes?
$this->xdebug('processing named complexType ' . $attrs['name']);
//$this->currentElement = false;
$this->currentComplexType = $attrs['name'];
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
} else {
$name = $this->CreateTypeName($this->currentElement);
$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
$this->currentComplexType = $name;
//$this->currentElement = false;
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}
$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
break;
case 'element':
array_push($this->elementStack, $this->currentElement);
if (!isset($attrs['form'])) {
if ($this->currentComplexType) {
$attrs['form'] = $this->schemaInfo['elementFormDefault'];
} else {
// global
$attrs['form'] = 'qualified';
}
}
if (isset($attrs['type'])) {
$this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']);
if (!$this->getPrefix($attrs['type'])) {
if ($this->defaultNamespace[$pos]) {
$attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
$this->xdebug('used default namespace to make type ' . $attrs['type']);
}
}
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
$this->xdebug('arrayType for unusual array is ' . $attrs['type']);
$this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
}
$this->currentElement = $attrs['name'];
$ename = $attrs['name'];
} elseif (isset($attrs['ref'])) {
$this->xdebug("processing element as ref to " . $attrs['ref']);
$this->currentElement = "ref to " . $attrs['ref'];
$ename = $this->getLocalPart($attrs['ref']);
} else {
$type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
$this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
$this->currentElement = $attrs['name'];
$attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
$ename = $attrs['name'];
}
if (isset($ename) && $this->currentComplexType) {
$this->xdebug("add element $ename to complexType $this->currentComplexType");
$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
} elseif (!isset($attrs['ref'])) {
$this->xdebug("add element $ename to elements array");
$this->elements[$attrs['name']] = $attrs;
$this->elements[$attrs['name']]['typeClass'] = 'element';
}
break;
case 'enumeration': // restriction value list member
$this->xdebug('enumeration ' . $attrs['value']);
if ($this->currentSimpleType) {
$this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
} elseif ($this->currentComplexType) {
$this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
}
break;
case 'extension': // simpleContent or complexContent type extension
$this->xdebug('extension ' . $attrs['base']);
if ($this->currentComplexType) {
$ns = $this->getPrefix($attrs['base']);
if ($ns == '') {
$this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
} else {
$this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
}
} else {
$this->xdebug('no current complexType to set extensionBase');
}
break;
case 'import':
if (isset($attrs['schemaLocation'])) {
$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
$this->imports[$attrs['namespace']][] = ['location' => $attrs['schemaLocation'], 'loaded' => FALSE];
} else {
$this->xdebug('import namespace ' . $attrs['namespace']);
$this->imports[$attrs['namespace']][] = ['location' => '', 'loaded' => TRUE];
if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
$this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
}
}
break;
case 'include':
if (isset($attrs['schemaLocation'])) {
$this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
$this->imports[$this->schemaTargetNamespace][] = ['location' => $attrs['schemaLocation'], 'loaded' => FALSE];
} else {
$this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
}
break;
case 'list': // simpleType value list
$this->xdebug("do nothing for element $name");
break;
case 'restriction': // simpleType, simpleContent or complexContent value restriction
$this->xdebug('restriction ' . $attrs['base']);
if ($this->currentSimpleType) {
$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
} elseif ($this->currentComplexType) {
$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
if (strstr($attrs['base'], ':') == ':Array') {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
}
}
break;
case 'schema':
$this->schemaInfo = $attrs;
$this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
if (isset($attrs['targetNamespace'])) {
$this->schemaTargetNamespace = $attrs['targetNamespace'];
}
if (!isset($attrs['elementFormDefault'])) {
$this->schemaInfo['elementFormDefault'] = 'unqualified';
}
if (!isset($attrs['attributeFormDefault'])) {
$this->schemaInfo['attributeFormDefault'] = 'unqualified';
}
break;
case 'simpleContent': // (optional) content for a complexType
if ($this->currentComplexType) { // This should *always* be
$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
} else {
$this->xdebug("do nothing for element $name because there is no current complexType");
}
break;
case 'simpleType':
array_push($this->simpleTypeStack, $this->currentSimpleType);
if (isset($attrs['name'])) {
$this->xdebug("processing simpleType for name " . $attrs['name']);
$this->currentSimpleType = $attrs['name'];
$this->simpleTypes[$attrs['name']] = $attrs;
$this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType';
$this->simpleTypes[$attrs['name']]['phpType'] = 'scalar';
} else {
$name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
$this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
$this->currentSimpleType = $name;
//$this->currentElement = false;
$this->simpleTypes[$this->currentSimpleType] = $attrs;
$this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
}
break;
case 'union': // simpleType type list
$this->xdebug("do nothing for element $name");
break;
default:
$this->xdebug("do not have any logic to process element $name");
}
} | php | function schemaStartElement($parser, $name, $attrs)
{
// position in the total number of elements, starting from 0
$pos = $this->position++;
$depth = $this->depth++;
// set self as current value for this depth
$this->depth_array[$depth] = $pos;
$this->message[$pos] = ['cdata' => ''];
if ($depth > 0) {
$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
} else {
$this->defaultNamespace[$pos] = FALSE;
}
// get element prefix
if ($prefix = $this->getPrefix($name)) {
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
// loop thru attributes, expanding, and registering namespace declarations
if (count($attrs) > 0) {
foreach ($attrs as $k => $v) {
// if ns declarations, add to class level array of valid namespaces
if (preg_match('/^xmlns/', $k)) {
//$this->xdebug("$k: $v");
//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
//$this->xdebug("Add namespace[$ns_prefix] = $v");
$this->namespaces[$ns_prefix] = $v;
} else {
$this->defaultNamespace[$pos] = $v;
if (!$this->getPrefixFromNamespace($v)) {
$this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
}
}
if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
$this->XMLSchemaVersion = $v;
$this->namespaces['xsi'] = $v . '-instance';
}
}
}
foreach ($attrs as $k => $v) {
// expand each attribute
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
$v = strpos($v, ':') ? $this->expandQname($v) : $v;
$eAttrs[$k] = $v;
}
$attrs = $eAttrs;
} else {
$attrs = [];
}
// find status, register data
switch ($name) {
case 'all': // (optional) compositor content for a complexType
case 'choice':
case 'group':
case 'sequence':
//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
//if($name == 'all' || $name == 'sequence'){
// $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
//}
break;
case 'attribute': // complexType attribute
//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
$this->xdebug("parsing attribute:");
$this->appendDebug($this->varDump($attrs));
if (!isset($attrs['form'])) {
// TODO: handle globals
$attrs['form'] = $this->schemaInfo['attributeFormDefault'];
}
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
if (!strpos($v, ':')) {
// no namespace in arrayType attribute value...
if ($this->defaultNamespace[$pos]) {
// ...so use the default
$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
}
}
}
if (isset($attrs['name'])) {
$this->attributes[$attrs['name']] = $attrs;
$aname = $attrs['name'];
} elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$aname = '';
}
} elseif (isset($attrs['ref'])) {
$aname = $attrs['ref'];
$this->attributes[$attrs['ref']] = $attrs;
}
if ($this->currentComplexType) { // This should *always* be
$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
}
// arrayType attribute
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
$prefix = $this->getPrefix($aname);
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
} else {
$v = '';
}
if (strpos($v, '[,]')) {
$this->complexTypes[$this->currentComplexType]['multidimensional'] = TRUE;
}
$v = substr($v, 0, strpos($v, '[')); // clip the []
if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
$v = $this->XMLSchemaVersion . ':' . $v;
}
$this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
}
break;
case 'complexContent': // (optional) content for a complexType
$this->xdebug("do nothing for element $name");
break;
case 'complexType':
array_push($this->complexTypeStack, $this->currentComplexType);
if (isset($attrs['name'])) {
// TODO: what is the scope of named complexTypes that appear
// nested within other c complexTypes?
$this->xdebug('processing named complexType ' . $attrs['name']);
//$this->currentElement = false;
$this->currentComplexType = $attrs['name'];
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
} else {
$name = $this->CreateTypeName($this->currentElement);
$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
$this->currentComplexType = $name;
//$this->currentElement = false;
$this->complexTypes[$this->currentComplexType] = $attrs;
$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}
$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
break;
case 'element':
array_push($this->elementStack, $this->currentElement);
if (!isset($attrs['form'])) {
if ($this->currentComplexType) {
$attrs['form'] = $this->schemaInfo['elementFormDefault'];
} else {
// global
$attrs['form'] = 'qualified';
}
}
if (isset($attrs['type'])) {
$this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']);
if (!$this->getPrefix($attrs['type'])) {
if ($this->defaultNamespace[$pos]) {
$attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
$this->xdebug('used default namespace to make type ' . $attrs['type']);
}
}
// This is for constructs like
// <complexType name="ListOfString" base="soap:Array">
// <sequence>
// <element name="string" type="xsd:string"
// minOccurs="0" maxOccurs="unbounded" />
// </sequence>
// </complexType>
if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
$this->xdebug('arrayType for unusual array is ' . $attrs['type']);
$this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
}
$this->currentElement = $attrs['name'];
$ename = $attrs['name'];
} elseif (isset($attrs['ref'])) {
$this->xdebug("processing element as ref to " . $attrs['ref']);
$this->currentElement = "ref to " . $attrs['ref'];
$ename = $this->getLocalPart($attrs['ref']);
} else {
$type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
$this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
$this->currentElement = $attrs['name'];
$attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
$ename = $attrs['name'];
}
if (isset($ename) && $this->currentComplexType) {
$this->xdebug("add element $ename to complexType $this->currentComplexType");
$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
} elseif (!isset($attrs['ref'])) {
$this->xdebug("add element $ename to elements array");
$this->elements[$attrs['name']] = $attrs;
$this->elements[$attrs['name']]['typeClass'] = 'element';
}
break;
case 'enumeration': // restriction value list member
$this->xdebug('enumeration ' . $attrs['value']);
if ($this->currentSimpleType) {
$this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
} elseif ($this->currentComplexType) {
$this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
}
break;
case 'extension': // simpleContent or complexContent type extension
$this->xdebug('extension ' . $attrs['base']);
if ($this->currentComplexType) {
$ns = $this->getPrefix($attrs['base']);
if ($ns == '') {
$this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
} else {
$this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
}
} else {
$this->xdebug('no current complexType to set extensionBase');
}
break;
case 'import':
if (isset($attrs['schemaLocation'])) {
$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
$this->imports[$attrs['namespace']][] = ['location' => $attrs['schemaLocation'], 'loaded' => FALSE];
} else {
$this->xdebug('import namespace ' . $attrs['namespace']);
$this->imports[$attrs['namespace']][] = ['location' => '', 'loaded' => TRUE];
if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
$this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
}
}
break;
case 'include':
if (isset($attrs['schemaLocation'])) {
$this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
$this->imports[$this->schemaTargetNamespace][] = ['location' => $attrs['schemaLocation'], 'loaded' => FALSE];
} else {
$this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
}
break;
case 'list': // simpleType value list
$this->xdebug("do nothing for element $name");
break;
case 'restriction': // simpleType, simpleContent or complexContent value restriction
$this->xdebug('restriction ' . $attrs['base']);
if ($this->currentSimpleType) {
$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
} elseif ($this->currentComplexType) {
$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
if (strstr($attrs['base'], ':') == ':Array') {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
}
}
break;
case 'schema':
$this->schemaInfo = $attrs;
$this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
if (isset($attrs['targetNamespace'])) {
$this->schemaTargetNamespace = $attrs['targetNamespace'];
}
if (!isset($attrs['elementFormDefault'])) {
$this->schemaInfo['elementFormDefault'] = 'unqualified';
}
if (!isset($attrs['attributeFormDefault'])) {
$this->schemaInfo['attributeFormDefault'] = 'unqualified';
}
break;
case 'simpleContent': // (optional) content for a complexType
if ($this->currentComplexType) { // This should *always* be
$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
} else {
$this->xdebug("do nothing for element $name because there is no current complexType");
}
break;
case 'simpleType':
array_push($this->simpleTypeStack, $this->currentSimpleType);
if (isset($attrs['name'])) {
$this->xdebug("processing simpleType for name " . $attrs['name']);
$this->currentSimpleType = $attrs['name'];
$this->simpleTypes[$attrs['name']] = $attrs;
$this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType';
$this->simpleTypes[$attrs['name']]['phpType'] = 'scalar';
} else {
$name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
$this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
$this->currentSimpleType = $name;
//$this->currentElement = false;
$this->simpleTypes[$this->currentSimpleType] = $attrs;
$this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
}
break;
case 'union': // simpleType type list
$this->xdebug("do nothing for element $name");
break;
default:
$this->xdebug("do not have any logic to process element $name");
}
} | [
"function",
"schemaStartElement",
"(",
"$",
"parser",
",",
"$",
"name",
",",
"$",
"attrs",
")",
"{",
"// position in the total number of elements, starting from 0",
"$",
"pos",
"=",
"$",
"this",
"->",
"position",
"++",
";",
"$",
"depth",
"=",
"$",
"this",
"->",
"depth",
"++",
";",
"// set self as current value for this depth",
"$",
"this",
"->",
"depth_array",
"[",
"$",
"depth",
"]",
"=",
"$",
"pos",
";",
"$",
"this",
"->",
"message",
"[",
"$",
"pos",
"]",
"=",
"[",
"'cdata'",
"=>",
"''",
"]",
";",
"if",
"(",
"$",
"depth",
">",
"0",
")",
"{",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
"=",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"this",
"->",
"depth_array",
"[",
"$",
"depth",
"-",
"1",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
"=",
"FALSE",
";",
"}",
"// get element prefix",
"if",
"(",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getPrefix",
"(",
"$",
"name",
")",
")",
"{",
"// get unqualified name",
"$",
"name",
"=",
"$",
"this",
"->",
"getLocalPart",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"prefix",
"=",
"''",
";",
"}",
"// loop thru attributes, expanding, and registering namespace declarations",
"if",
"(",
"count",
"(",
"$",
"attrs",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"attrs",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// if ns declarations, add to class level array of valid namespaces",
"if",
"(",
"preg_match",
"(",
"'/^xmlns/'",
",",
"$",
"k",
")",
")",
"{",
"//$this->xdebug(\"$k: $v\");",
"//$this->xdebug('ns_prefix: '.$this->getPrefix($k));",
"if",
"(",
"$",
"ns_prefix",
"=",
"substr",
"(",
"strrchr",
"(",
"$",
"k",
",",
"':'",
")",
",",
"1",
")",
")",
"{",
"//$this->xdebug(\"Add namespace[$ns_prefix] = $v\");",
"$",
"this",
"->",
"namespaces",
"[",
"$",
"ns_prefix",
"]",
"=",
"$",
"v",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
"=",
"$",
"v",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getPrefixFromNamespace",
"(",
"$",
"v",
")",
")",
"{",
"$",
"this",
"->",
"namespaces",
"[",
"'ns'",
".",
"(",
"count",
"(",
"$",
"this",
"->",
"namespaces",
")",
"+",
"1",
")",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"if",
"(",
"$",
"v",
"==",
"'http://www.w3.org/2001/XMLSchema'",
"||",
"$",
"v",
"==",
"'http://www.w3.org/1999/XMLSchema'",
"||",
"$",
"v",
"==",
"'http://www.w3.org/2000/10/XMLSchema'",
")",
"{",
"$",
"this",
"->",
"XMLSchemaVersion",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"namespaces",
"[",
"'xsi'",
"]",
"=",
"$",
"v",
".",
"'-instance'",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"attrs",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// expand each attribute",
"$",
"k",
"=",
"strpos",
"(",
"$",
"k",
",",
"':'",
")",
"?",
"$",
"this",
"->",
"expandQname",
"(",
"$",
"k",
")",
":",
"$",
"k",
";",
"$",
"v",
"=",
"strpos",
"(",
"$",
"v",
",",
"':'",
")",
"?",
"$",
"this",
"->",
"expandQname",
"(",
"$",
"v",
")",
":",
"$",
"v",
";",
"$",
"eAttrs",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"$",
"attrs",
"=",
"$",
"eAttrs",
";",
"}",
"else",
"{",
"$",
"attrs",
"=",
"[",
"]",
";",
"}",
"// find status, register data",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'all'",
":",
"// (optional) compositor content for a complexType",
"case",
"'choice'",
":",
"case",
"'group'",
":",
"case",
"'sequence'",
":",
"//$this->xdebug(\"compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement\");",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'compositor'",
"]",
"=",
"$",
"name",
";",
"//if($name == 'all' || $name == 'sequence'){",
"//\t$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';",
"//}",
"break",
";",
"case",
"'attribute'",
":",
"// complexType attribute",
"//$this->xdebug(\"parsing attribute $attrs[name] $attrs[ref] of value: \".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);",
"$",
"this",
"->",
"xdebug",
"(",
"\"parsing attribute:\"",
")",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"$",
"this",
"->",
"varDump",
"(",
"$",
"attrs",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attrs",
"[",
"'form'",
"]",
")",
")",
"{",
"// TODO: handle globals",
"$",
"attrs",
"[",
"'form'",
"]",
"=",
"$",
"this",
"->",
"schemaInfo",
"[",
"'attributeFormDefault'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
")",
")",
"{",
"$",
"v",
"=",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
";",
"if",
"(",
"!",
"strpos",
"(",
"$",
"v",
",",
"':'",
")",
")",
"{",
"// no namespace in arrayType attribute value...",
"if",
"(",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
")",
"{",
"// ...so use the default",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
"=",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
".",
"':'",
".",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attrs",
"[",
"'name'",
"]",
"]",
"=",
"$",
"attrs",
";",
"$",
"aname",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'ref'",
"]",
")",
"&&",
"$",
"attrs",
"[",
"'ref'",
"]",
"==",
"'http://schemas.xmlsoap.org/soap/encoding/:arrayType'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
")",
")",
"{",
"$",
"aname",
"=",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
";",
"}",
"else",
"{",
"$",
"aname",
"=",
"''",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'ref'",
"]",
")",
")",
"{",
"$",
"aname",
"=",
"$",
"attrs",
"[",
"'ref'",
"]",
";",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attrs",
"[",
"'ref'",
"]",
"]",
"=",
"$",
"attrs",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"// This should *always* be",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'attrs'",
"]",
"[",
"$",
"aname",
"]",
"=",
"$",
"attrs",
";",
"}",
"// arrayType attribute",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
")",
"||",
"$",
"this",
"->",
"getLocalPart",
"(",
"$",
"aname",
")",
"==",
"'arrayType'",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"=",
"'array'",
";",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getPrefix",
"(",
"$",
"aname",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
")",
")",
"{",
"$",
"v",
"=",
"$",
"attrs",
"[",
"'http://schemas.xmlsoap.org/wsdl/:arrayType'",
"]",
";",
"}",
"else",
"{",
"$",
"v",
"=",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"v",
",",
"'[,]'",
")",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'multidimensional'",
"]",
"=",
"TRUE",
";",
"}",
"$",
"v",
"=",
"substr",
"(",
"$",
"v",
",",
"0",
",",
"strpos",
"(",
"$",
"v",
",",
"'['",
")",
")",
";",
"// clip the []",
"if",
"(",
"!",
"strpos",
"(",
"$",
"v",
",",
"':'",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"typemap",
"[",
"$",
"this",
"->",
"XMLSchemaVersion",
"]",
"[",
"$",
"v",
"]",
")",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"XMLSchemaVersion",
".",
"':'",
".",
"$",
"v",
";",
"}",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'arrayType'",
"]",
"=",
"$",
"v",
";",
"}",
"break",
";",
"case",
"'complexContent'",
":",
"// (optional) content for a complexType",
"$",
"this",
"->",
"xdebug",
"(",
"\"do nothing for element $name\"",
")",
";",
"break",
";",
"case",
"'complexType'",
":",
"array_push",
"(",
"$",
"this",
"->",
"complexTypeStack",
",",
"$",
"this",
"->",
"currentComplexType",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'name'",
"]",
")",
")",
"{",
"// TODO: what is the scope of named complexTypes that appear",
"// nested within other c complexTypes?",
"$",
"this",
"->",
"xdebug",
"(",
"'processing named complexType '",
".",
"$",
"attrs",
"[",
"'name'",
"]",
")",
";",
"//$this->currentElement = false;",
"$",
"this",
"->",
"currentComplexType",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"=",
"$",
"attrs",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'typeClass'",
"]",
"=",
"'complexType'",
";",
"// This is for constructs like",
"// <complexType name=\"ListOfString\" base=\"soap:Array\">",
"// <sequence>",
"// <element name=\"string\" type=\"xsd:string\"",
"// minOccurs=\"0\" maxOccurs=\"unbounded\" />",
"// </sequence>",
"// </complexType>",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'base'",
"]",
")",
"&&",
"preg_match",
"(",
"'/:Array$/'",
",",
"$",
"attrs",
"[",
"'base'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'complexType is unusual array'",
")",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"=",
"'array'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"=",
"'struct'",
";",
"}",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"CreateTypeName",
"(",
"$",
"this",
"->",
"currentElement",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"'processing unnamed complexType for element '",
".",
"$",
"this",
"->",
"currentElement",
".",
"' named '",
".",
"$",
"name",
")",
";",
"$",
"this",
"->",
"currentComplexType",
"=",
"$",
"name",
";",
"//$this->currentElement = false;",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"=",
"$",
"attrs",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'typeClass'",
"]",
"=",
"'complexType'",
";",
"// This is for constructs like",
"// <complexType name=\"ListOfString\" base=\"soap:Array\">",
"// <sequence>",
"// <element name=\"string\" type=\"xsd:string\"",
"// minOccurs=\"0\" maxOccurs=\"unbounded\" />",
"// </sequence>",
"// </complexType>",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'base'",
"]",
")",
"&&",
"preg_match",
"(",
"'/:Array$/'",
",",
"$",
"attrs",
"[",
"'base'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'complexType is unusual array'",
")",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"=",
"'array'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"=",
"'struct'",
";",
"}",
"}",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'simpleContent'",
"]",
"=",
"'false'",
";",
"break",
";",
"case",
"'element'",
":",
"array_push",
"(",
"$",
"this",
"->",
"elementStack",
",",
"$",
"this",
"->",
"currentElement",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attrs",
"[",
"'form'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"$",
"attrs",
"[",
"'form'",
"]",
"=",
"$",
"this",
"->",
"schemaInfo",
"[",
"'elementFormDefault'",
"]",
";",
"}",
"else",
"{",
"// global",
"$",
"attrs",
"[",
"'form'",
"]",
"=",
"'qualified'",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"processing typed element \"",
".",
"$",
"attrs",
"[",
"'name'",
"]",
".",
"\" of type \"",
".",
"$",
"attrs",
"[",
"'type'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getPrefix",
"(",
"$",
"attrs",
"[",
"'type'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
")",
"{",
"$",
"attrs",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"defaultNamespace",
"[",
"$",
"pos",
"]",
".",
"':'",
".",
"$",
"attrs",
"[",
"'type'",
"]",
";",
"$",
"this",
"->",
"xdebug",
"(",
"'used default namespace to make type '",
".",
"$",
"attrs",
"[",
"'type'",
"]",
")",
";",
"}",
"}",
"// This is for constructs like",
"// <complexType name=\"ListOfString\" base=\"soap:Array\">",
"// <sequence>",
"// <element name=\"string\" type=\"xsd:string\"",
"// minOccurs=\"0\" maxOccurs=\"unbounded\" />",
"// </sequence>",
"// </complexType>",
"if",
"(",
"$",
"this",
"->",
"currentComplexType",
"&&",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"==",
"'array'",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'arrayType for unusual array is '",
".",
"$",
"attrs",
"[",
"'type'",
"]",
")",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'arrayType'",
"]",
"=",
"$",
"attrs",
"[",
"'type'",
"]",
";",
"}",
"$",
"this",
"->",
"currentElement",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"$",
"ename",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'ref'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"processing element as ref to \"",
".",
"$",
"attrs",
"[",
"'ref'",
"]",
")",
";",
"$",
"this",
"->",
"currentElement",
"=",
"\"ref to \"",
".",
"$",
"attrs",
"[",
"'ref'",
"]",
";",
"$",
"ename",
"=",
"$",
"this",
"->",
"getLocalPart",
"(",
"$",
"attrs",
"[",
"'ref'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"CreateTypeName",
"(",
"$",
"this",
"->",
"currentComplexType",
".",
"'_'",
".",
"$",
"attrs",
"[",
"'name'",
"]",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"\"processing untyped element \"",
".",
"$",
"attrs",
"[",
"'name'",
"]",
".",
"' type '",
".",
"$",
"type",
")",
";",
"$",
"this",
"->",
"currentElement",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"$",
"attrs",
"[",
"'type'",
"]",
"=",
"$",
"this",
"->",
"schemaTargetNamespace",
".",
"':'",
".",
"$",
"type",
";",
"$",
"ename",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"ename",
")",
"&&",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"add element $ename to complexType $this->currentComplexType\"",
")",
";",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'elements'",
"]",
"[",
"$",
"ename",
"]",
"=",
"$",
"attrs",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"attrs",
"[",
"'ref'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"add element $ename to elements array\"",
")",
";",
"$",
"this",
"->",
"elements",
"[",
"$",
"attrs",
"[",
"'name'",
"]",
"]",
"=",
"$",
"attrs",
";",
"$",
"this",
"->",
"elements",
"[",
"$",
"attrs",
"[",
"'name'",
"]",
"]",
"[",
"'typeClass'",
"]",
"=",
"'element'",
";",
"}",
"break",
";",
"case",
"'enumeration'",
":",
"//\trestriction value list member",
"$",
"this",
"->",
"xdebug",
"(",
"'enumeration '",
".",
"$",
"attrs",
"[",
"'value'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"currentSimpleType",
")",
"{",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"this",
"->",
"currentSimpleType",
"]",
"[",
"'enumeration'",
"]",
"[",
"]",
"=",
"$",
"attrs",
"[",
"'value'",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'enumeration'",
"]",
"[",
"]",
"=",
"$",
"attrs",
"[",
"'value'",
"]",
";",
"}",
"break",
";",
"case",
"'extension'",
":",
"// simpleContent or complexContent type extension",
"$",
"this",
"->",
"xdebug",
"(",
"'extension '",
".",
"$",
"attrs",
"[",
"'base'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"$",
"ns",
"=",
"$",
"this",
"->",
"getPrefix",
"(",
"$",
"attrs",
"[",
"'base'",
"]",
")",
";",
"if",
"(",
"$",
"ns",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'extensionBase'",
"]",
"=",
"$",
"this",
"->",
"schemaTargetNamespace",
".",
"':'",
".",
"$",
"attrs",
"[",
"'base'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'extensionBase'",
"]",
"=",
"$",
"attrs",
"[",
"'base'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'no current complexType to set extensionBase'",
")",
";",
"}",
"break",
";",
"case",
"'import'",
":",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'schemaLocation'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'import namespace '",
".",
"$",
"attrs",
"[",
"'namespace'",
"]",
".",
"' from '",
".",
"$",
"attrs",
"[",
"'schemaLocation'",
"]",
")",
";",
"$",
"this",
"->",
"imports",
"[",
"$",
"attrs",
"[",
"'namespace'",
"]",
"]",
"[",
"]",
"=",
"[",
"'location'",
"=>",
"$",
"attrs",
"[",
"'schemaLocation'",
"]",
",",
"'loaded'",
"=>",
"FALSE",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'import namespace '",
".",
"$",
"attrs",
"[",
"'namespace'",
"]",
")",
";",
"$",
"this",
"->",
"imports",
"[",
"$",
"attrs",
"[",
"'namespace'",
"]",
"]",
"[",
"]",
"=",
"[",
"'location'",
"=>",
"''",
",",
"'loaded'",
"=>",
"TRUE",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getPrefixFromNamespace",
"(",
"$",
"attrs",
"[",
"'namespace'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"namespaces",
"[",
"'ns'",
".",
"(",
"count",
"(",
"$",
"this",
"->",
"namespaces",
")",
"+",
"1",
")",
"]",
"=",
"$",
"attrs",
"[",
"'namespace'",
"]",
";",
"}",
"}",
"break",
";",
"case",
"'include'",
":",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'schemaLocation'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'include into namespace '",
".",
"$",
"this",
"->",
"schemaTargetNamespace",
".",
"' from '",
".",
"$",
"attrs",
"[",
"'schemaLocation'",
"]",
")",
";",
"$",
"this",
"->",
"imports",
"[",
"$",
"this",
"->",
"schemaTargetNamespace",
"]",
"[",
"]",
"=",
"[",
"'location'",
"=>",
"$",
"attrs",
"[",
"'schemaLocation'",
"]",
",",
"'loaded'",
"=>",
"FALSE",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'ignoring invalid XML Schema construct: include without schemaLocation attribute'",
")",
";",
"}",
"break",
";",
"case",
"'list'",
":",
"// simpleType value list",
"$",
"this",
"->",
"xdebug",
"(",
"\"do nothing for element $name\"",
")",
";",
"break",
";",
"case",
"'restriction'",
":",
"// simpleType, simpleContent or complexContent value restriction",
"$",
"this",
"->",
"xdebug",
"(",
"'restriction '",
".",
"$",
"attrs",
"[",
"'base'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"currentSimpleType",
")",
"{",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"this",
"->",
"currentSimpleType",
"]",
"[",
"'type'",
"]",
"=",
"$",
"attrs",
"[",
"'base'",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'restrictionBase'",
"]",
"=",
"$",
"attrs",
"[",
"'base'",
"]",
";",
"if",
"(",
"strstr",
"(",
"$",
"attrs",
"[",
"'base'",
"]",
",",
"':'",
")",
"==",
"':Array'",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'phpType'",
"]",
"=",
"'array'",
";",
"}",
"}",
"break",
";",
"case",
"'schema'",
":",
"$",
"this",
"->",
"schemaInfo",
"=",
"$",
"attrs",
";",
"$",
"this",
"->",
"schemaInfo",
"[",
"'schemaVersion'",
"]",
"=",
"$",
"this",
"->",
"getNamespaceFromPrefix",
"(",
"$",
"prefix",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'targetNamespace'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"schemaTargetNamespace",
"=",
"$",
"attrs",
"[",
"'targetNamespace'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attrs",
"[",
"'elementFormDefault'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"schemaInfo",
"[",
"'elementFormDefault'",
"]",
"=",
"'unqualified'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attrs",
"[",
"'attributeFormDefault'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"schemaInfo",
"[",
"'attributeFormDefault'",
"]",
"=",
"'unqualified'",
";",
"}",
"break",
";",
"case",
"'simpleContent'",
":",
"// (optional) content for a complexType",
"if",
"(",
"$",
"this",
"->",
"currentComplexType",
")",
"{",
"// This should *always* be",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
"[",
"'simpleContent'",
"]",
"=",
"'true'",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"do nothing for element $name because there is no current complexType\"",
")",
";",
"}",
"break",
";",
"case",
"'simpleType'",
":",
"array_push",
"(",
"$",
"this",
"->",
"simpleTypeStack",
",",
"$",
"this",
"->",
"currentSimpleType",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"processing simpleType for name \"",
".",
"$",
"attrs",
"[",
"'name'",
"]",
")",
";",
"$",
"this",
"->",
"currentSimpleType",
"=",
"$",
"attrs",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"attrs",
"[",
"'name'",
"]",
"]",
"=",
"$",
"attrs",
";",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"attrs",
"[",
"'name'",
"]",
"]",
"[",
"'typeClass'",
"]",
"=",
"'simpleType'",
";",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"attrs",
"[",
"'name'",
"]",
"]",
"[",
"'phpType'",
"]",
"=",
"'scalar'",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"CreateTypeName",
"(",
"$",
"this",
"->",
"currentComplexType",
".",
"'_'",
".",
"$",
"this",
"->",
"currentElement",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"'processing unnamed simpleType for element '",
".",
"$",
"this",
"->",
"currentElement",
".",
"' named '",
".",
"$",
"name",
")",
";",
"$",
"this",
"->",
"currentSimpleType",
"=",
"$",
"name",
";",
"//$this->currentElement = false;",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"this",
"->",
"currentSimpleType",
"]",
"=",
"$",
"attrs",
";",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"this",
"->",
"currentSimpleType",
"]",
"[",
"'phpType'",
"]",
"=",
"'scalar'",
";",
"}",
"break",
";",
"case",
"'union'",
":",
"// simpleType type list",
"$",
"this",
"->",
"xdebug",
"(",
"\"do nothing for element $name\"",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"xdebug",
"(",
"\"do not have any logic to process element $name\"",
")",
";",
"}",
"}"
] | start-element handler
@param string $parser XML parser object
@param string $name element name
@param string $attrs associative array of attributes
@access private | [
"start",
"-",
"element",
"handler"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L1352-L1671 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.schemaEndElement | function schemaEndElement($parser, $name)
{
// bring depth down a notch
$this->depth--;
// position of current element is equal to the last value left in depth_array for my depth
if (isset($this->depth_array[$this->depth])) {
$pos = $this->depth_array[$this->depth];
}
// get element prefix
if ($prefix = $this->getPrefix($name)) {
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
// move on...
if ($name == 'complexType') {
$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
$this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
$this->currentComplexType = array_pop($this->complexTypeStack);
//$this->currentElement = false;
}
if ($name == 'element') {
$this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
$this->currentElement = array_pop($this->elementStack);
}
if ($name == 'simpleType') {
$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
$this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
$this->currentSimpleType = array_pop($this->simpleTypeStack);
}
} | php | function schemaEndElement($parser, $name)
{
// bring depth down a notch
$this->depth--;
// position of current element is equal to the last value left in depth_array for my depth
if (isset($this->depth_array[$this->depth])) {
$pos = $this->depth_array[$this->depth];
}
// get element prefix
if ($prefix = $this->getPrefix($name)) {
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
// move on...
if ($name == 'complexType') {
$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
$this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
$this->currentComplexType = array_pop($this->complexTypeStack);
//$this->currentElement = false;
}
if ($name == 'element') {
$this->xdebug('done processing element ' . ($this->currentElement ? $this->currentElement : '(unknown)'));
$this->currentElement = array_pop($this->elementStack);
}
if ($name == 'simpleType') {
$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
$this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
$this->currentSimpleType = array_pop($this->simpleTypeStack);
}
} | [
"function",
"schemaEndElement",
"(",
"$",
"parser",
",",
"$",
"name",
")",
"{",
"// bring depth down a notch",
"$",
"this",
"->",
"depth",
"--",
";",
"// position of current element is equal to the last value left in depth_array for my depth",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"depth_array",
"[",
"$",
"this",
"->",
"depth",
"]",
")",
")",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"depth_array",
"[",
"$",
"this",
"->",
"depth",
"]",
";",
"}",
"// get element prefix",
"if",
"(",
"$",
"prefix",
"=",
"$",
"this",
"->",
"getPrefix",
"(",
"$",
"name",
")",
")",
"{",
"// get unqualified name",
"$",
"name",
"=",
"$",
"this",
"->",
"getLocalPart",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"prefix",
"=",
"''",
";",
"}",
"// move on...",
"if",
"(",
"$",
"name",
"==",
"'complexType'",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'done processing complexType '",
".",
"(",
"$",
"this",
"->",
"currentComplexType",
"?",
"$",
"this",
"->",
"currentComplexType",
":",
"'(unknown)'",
")",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"$",
"this",
"->",
"varDump",
"(",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"this",
"->",
"currentComplexType",
"]",
")",
")",
";",
"$",
"this",
"->",
"currentComplexType",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"complexTypeStack",
")",
";",
"//$this->currentElement = false;",
"}",
"if",
"(",
"$",
"name",
"==",
"'element'",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'done processing element '",
".",
"(",
"$",
"this",
"->",
"currentElement",
"?",
"$",
"this",
"->",
"currentElement",
":",
"'(unknown)'",
")",
")",
";",
"$",
"this",
"->",
"currentElement",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"elementStack",
")",
";",
"}",
"if",
"(",
"$",
"name",
"==",
"'simpleType'",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"'done processing simpleType '",
".",
"(",
"$",
"this",
"->",
"currentSimpleType",
"?",
"$",
"this",
"->",
"currentSimpleType",
":",
"'(unknown)'",
")",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"$",
"this",
"->",
"varDump",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"this",
"->",
"currentSimpleType",
"]",
")",
")",
";",
"$",
"this",
"->",
"currentSimpleType",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"simpleTypeStack",
")",
";",
"}",
"}"
] | end-element handler
@param string $parser XML parser object
@param string $name element name
@access private | [
"end",
"-",
"element",
"handler"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L1681-L1712 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.getPHPType | function getPHPType($type, $ns)
{
if (isset($this->typemap[$ns][$type])) {
//print "found type '$type' and ns $ns in typemap<br>";
return $this->typemap[$ns][$type];
} elseif (isset($this->complexTypes[$type])) {
//print "getting type '$type' and ns $ns from complexTypes array<br>";
return $this->complexTypes[$type]['phpType'];
}
return FALSE;
} | php | function getPHPType($type, $ns)
{
if (isset($this->typemap[$ns][$type])) {
//print "found type '$type' and ns $ns in typemap<br>";
return $this->typemap[$ns][$type];
} elseif (isset($this->complexTypes[$type])) {
//print "getting type '$type' and ns $ns from complexTypes array<br>";
return $this->complexTypes[$type]['phpType'];
}
return FALSE;
} | [
"function",
"getPHPType",
"(",
"$",
"type",
",",
"$",
"ns",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"typemap",
"[",
"$",
"ns",
"]",
"[",
"$",
"type",
"]",
")",
")",
"{",
"//print \"found type '$type' and ns $ns in typemap<br>\";",
"return",
"$",
"this",
"->",
"typemap",
"[",
"$",
"ns",
"]",
"[",
"$",
"type",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"//print \"getting type '$type' and ns $ns from complexTypes array<br>\";",
"return",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"type",
"]",
"[",
"'phpType'",
"]",
";",
"}",
"return",
"FALSE",
";",
"}"
] | get the PHP type of a user defined type in the schema
PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
returns false if no type exists, or not w/ the given namespace
else returns a string that is either a native php type, or 'struct'
@param string $type name of defined type
@param string $ns namespace of type
@return mixed
@access public
@deprecated | [
"get",
"the",
"PHP",
"type",
"of",
"a",
"user",
"defined",
"type",
"in",
"the",
"schema",
"PHP",
"type",
"is",
"kind",
"of",
"a",
"misnomer",
"since",
"it",
"actually",
"returns",
"struct",
"for",
"assoc",
".",
"arrays",
"returns",
"false",
"if",
"no",
"type",
"exists",
"or",
"not",
"w",
"/",
"the",
"given",
"namespace",
"else",
"returns",
"a",
"string",
"that",
"is",
"either",
"a",
"native",
"php",
"type",
"or",
"struct"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L1872-L1883 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.getTypeDef | function getTypeDef($type)
{
//$this->debug("in getTypeDef for type $type");
if (substr($type, -1) == '^') {
$is_element = 1;
$type = substr($type, 0, -1);
} else {
$is_element = 0;
}
if ((!$is_element) && isset($this->complexTypes[$type])) {
$this->xdebug("in getTypeDef, found complexType $type");
return $this->complexTypes[$type];
} elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
$this->xdebug("in getTypeDef, found simpleType $type");
if (!isset($this->simpleTypes[$type]['phpType'])) {
// get info for type to tack onto the simple type
// TODO: can this ever really apply (i.e. what is a simpleType really?)
$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
$this->xdebug("in getTypeDef, found type for simpleType $type:");
$this->xdebug($this->varDump($etype));
if (isset($etype['phpType'])) {
$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->simpleTypes[$type]['elements'] = $etype['elements'];
}
}
}
return $this->simpleTypes[$type];
} elseif (isset($this->elements[$type])) {
$this->xdebug("in getTypeDef, found element $type");
if (!isset($this->elements[$type]['phpType'])) {
// get info for type to tack onto the element
$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
$ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
$this->xdebug("in getTypeDef, found type for element $type:");
$this->xdebug($this->varDump($etype));
if (isset($etype['phpType'])) {
$this->elements[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->elements[$type]['elements'] = $etype['elements'];
}
if (isset($etype['extensionBase'])) {
$this->elements[$type]['extensionBase'] = $etype['extensionBase'];
}
} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
$this->xdebug("in getTypeDef, element $type is an XSD type");
$this->elements[$type]['phpType'] = 'scalar';
}
}
return $this->elements[$type];
} elseif (isset($this->attributes[$type])) {
$this->xdebug("in getTypeDef, found attribute $type");
return $this->attributes[$type];
} elseif (preg_match('/_ContainedType$/', $type)) {
$this->xdebug("in getTypeDef, have an untyped element $type");
$typeDef['typeClass'] = 'simpleType';
$typeDef['phpType'] = 'scalar';
$typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
return $typeDef;
}
$this->xdebug("in getTypeDef, did not find $type");
return FALSE;
} | php | function getTypeDef($type)
{
//$this->debug("in getTypeDef for type $type");
if (substr($type, -1) == '^') {
$is_element = 1;
$type = substr($type, 0, -1);
} else {
$is_element = 0;
}
if ((!$is_element) && isset($this->complexTypes[$type])) {
$this->xdebug("in getTypeDef, found complexType $type");
return $this->complexTypes[$type];
} elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
$this->xdebug("in getTypeDef, found simpleType $type");
if (!isset($this->simpleTypes[$type]['phpType'])) {
// get info for type to tack onto the simple type
// TODO: can this ever really apply (i.e. what is a simpleType really?)
$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
$ns = substr($this->simpleTypes[$type]['type'], 0, strrpos($this->simpleTypes[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
$this->xdebug("in getTypeDef, found type for simpleType $type:");
$this->xdebug($this->varDump($etype));
if (isset($etype['phpType'])) {
$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->simpleTypes[$type]['elements'] = $etype['elements'];
}
}
}
return $this->simpleTypes[$type];
} elseif (isset($this->elements[$type])) {
$this->xdebug("in getTypeDef, found element $type");
if (!isset($this->elements[$type]['phpType'])) {
// get info for type to tack onto the element
$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
$ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
$etype = $this->getTypeDef($uqType);
if ($etype) {
$this->xdebug("in getTypeDef, found type for element $type:");
$this->xdebug($this->varDump($etype));
if (isset($etype['phpType'])) {
$this->elements[$type]['phpType'] = $etype['phpType'];
}
if (isset($etype['elements'])) {
$this->elements[$type]['elements'] = $etype['elements'];
}
if (isset($etype['extensionBase'])) {
$this->elements[$type]['extensionBase'] = $etype['extensionBase'];
}
} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
$this->xdebug("in getTypeDef, element $type is an XSD type");
$this->elements[$type]['phpType'] = 'scalar';
}
}
return $this->elements[$type];
} elseif (isset($this->attributes[$type])) {
$this->xdebug("in getTypeDef, found attribute $type");
return $this->attributes[$type];
} elseif (preg_match('/_ContainedType$/', $type)) {
$this->xdebug("in getTypeDef, have an untyped element $type");
$typeDef['typeClass'] = 'simpleType';
$typeDef['phpType'] = 'scalar';
$typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
return $typeDef;
}
$this->xdebug("in getTypeDef, did not find $type");
return FALSE;
} | [
"function",
"getTypeDef",
"(",
"$",
"type",
")",
"{",
"//$this->debug(\"in getTypeDef for type $type\");",
"if",
"(",
"substr",
"(",
"$",
"type",
",",
"-",
"1",
")",
"==",
"'^'",
")",
"{",
"$",
"is_element",
"=",
"1",
";",
"$",
"type",
"=",
"substr",
"(",
"$",
"type",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"else",
"{",
"$",
"is_element",
"=",
"0",
";",
"}",
"if",
"(",
"(",
"!",
"$",
"is_element",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, found complexType $type\"",
")",
";",
"return",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"type",
"]",
";",
"}",
"elseif",
"(",
"(",
"!",
"$",
"is_element",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, found simpleType $type\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'phpType'",
"]",
")",
")",
"{",
"// get info for type to tack onto the simple type",
"// TODO: can this ever really apply (i.e. what is a simpleType really?)",
"$",
"uqType",
"=",
"substr",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"strrpos",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"':'",
")",
"+",
"1",
")",
";",
"$",
"ns",
"=",
"substr",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"0",
",",
"strrpos",
"(",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"':'",
")",
")",
";",
"$",
"etype",
"=",
"$",
"this",
"->",
"getTypeDef",
"(",
"$",
"uqType",
")",
";",
"if",
"(",
"$",
"etype",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, found type for simpleType $type:\"",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"$",
"this",
"->",
"varDump",
"(",
"$",
"etype",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"etype",
"[",
"'phpType'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'phpType'",
"]",
"=",
"$",
"etype",
"[",
"'phpType'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"etype",
"[",
"'elements'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
"[",
"'elements'",
"]",
"=",
"$",
"etype",
"[",
"'elements'",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"simpleTypes",
"[",
"$",
"type",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, found element $type\"",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'phpType'",
"]",
")",
")",
"{",
"// get info for type to tack onto the element",
"$",
"uqType",
"=",
"substr",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"strrpos",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"':'",
")",
"+",
"1",
")",
";",
"$",
"ns",
"=",
"substr",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"0",
",",
"strrpos",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'type'",
"]",
",",
"':'",
")",
")",
";",
"$",
"etype",
"=",
"$",
"this",
"->",
"getTypeDef",
"(",
"$",
"uqType",
")",
";",
"if",
"(",
"$",
"etype",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, found type for element $type:\"",
")",
";",
"$",
"this",
"->",
"xdebug",
"(",
"$",
"this",
"->",
"varDump",
"(",
"$",
"etype",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"etype",
"[",
"'phpType'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'phpType'",
"]",
"=",
"$",
"etype",
"[",
"'phpType'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"etype",
"[",
"'elements'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'elements'",
"]",
"=",
"$",
"etype",
"[",
"'elements'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"etype",
"[",
"'extensionBase'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'extensionBase'",
"]",
"=",
"$",
"etype",
"[",
"'extensionBase'",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"ns",
"==",
"'http://www.w3.org/2001/XMLSchema'",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, element $type is an XSD type\"",
")",
";",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
"[",
"'phpType'",
"]",
"=",
"'scalar'",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"elements",
"[",
"$",
"type",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, found attribute $type\"",
")",
";",
"return",
"$",
"this",
"->",
"attributes",
"[",
"$",
"type",
"]",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/_ContainedType$/'",
",",
"$",
"type",
")",
")",
"{",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, have an untyped element $type\"",
")",
";",
"$",
"typeDef",
"[",
"'typeClass'",
"]",
"=",
"'simpleType'",
";",
"$",
"typeDef",
"[",
"'phpType'",
"]",
"=",
"'scalar'",
";",
"$",
"typeDef",
"[",
"'type'",
"]",
"=",
"'http://www.w3.org/2001/XMLSchema:string'",
";",
"return",
"$",
"typeDef",
";",
"}",
"$",
"this",
"->",
"xdebug",
"(",
"\"in getTypeDef, did not find $type\"",
")",
";",
"return",
"FALSE",
";",
"}"
] | returns an associative array of information about a given type
returns false if no type exists by the given name
For a complexType typeDef = array(
'restrictionBase' => '',
'phpType' => '',
'compositor' => '(sequence|all)',
'elements' => array(), // refs to elements array
'attrs' => array() // refs to attributes array
... and so on (see addComplexType)
)
For simpleType or element, the array has different keys.
@param string $type
@return mixed
@access public
@see addComplexType
@see addSimpleType
@see addElement | [
"returns",
"an",
"associative",
"array",
"of",
"information",
"about",
"a",
"given",
"type",
"returns",
"false",
"if",
"no",
"type",
"exists",
"by",
"the",
"given",
"name"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L1908-L1984 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.serializeTypeDef | function serializeTypeDef($type)
{
//print "in sTD() for type $type<br>";
if ($typeDef = $this->getTypeDef($type)) {
$str .= '<' . $type;
if (is_array($typeDef['attrs'])) {
foreach ($typeDef['attrs'] as $attName => $data) {
$str .= " $attName=\"{type = " . $data['type'] . "}\"";
}
}
$str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
if (count($typeDef['elements']) > 0) {
$str .= ">";
foreach ($typeDef['elements'] as $element => $eData) {
$str .= $this->serializeTypeDef($element);
}
$str .= "</$type>";
} elseif ($typeDef['typeClass'] == 'element') {
$str .= "></$type>";
} else {
$str .= "/>";
}
return $str;
}
return FALSE;
} | php | function serializeTypeDef($type)
{
//print "in sTD() for type $type<br>";
if ($typeDef = $this->getTypeDef($type)) {
$str .= '<' . $type;
if (is_array($typeDef['attrs'])) {
foreach ($typeDef['attrs'] as $attName => $data) {
$str .= " $attName=\"{type = " . $data['type'] . "}\"";
}
}
$str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
if (count($typeDef['elements']) > 0) {
$str .= ">";
foreach ($typeDef['elements'] as $element => $eData) {
$str .= $this->serializeTypeDef($element);
}
$str .= "</$type>";
} elseif ($typeDef['typeClass'] == 'element') {
$str .= "></$type>";
} else {
$str .= "/>";
}
return $str;
}
return FALSE;
} | [
"function",
"serializeTypeDef",
"(",
"$",
"type",
")",
"{",
"//print \"in sTD() for type $type<br>\";",
"if",
"(",
"$",
"typeDef",
"=",
"$",
"this",
"->",
"getTypeDef",
"(",
"$",
"type",
")",
")",
"{",
"$",
"str",
".=",
"'<'",
".",
"$",
"type",
";",
"if",
"(",
"is_array",
"(",
"$",
"typeDef",
"[",
"'attrs'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"typeDef",
"[",
"'attrs'",
"]",
"as",
"$",
"attName",
"=>",
"$",
"data",
")",
"{",
"$",
"str",
".=",
"\" $attName=\\\"{type = \"",
".",
"$",
"data",
"[",
"'type'",
"]",
".",
"\"}\\\"\"",
";",
"}",
"}",
"$",
"str",
".=",
"\" xmlns=\\\"\"",
".",
"$",
"this",
"->",
"schema",
"[",
"'targetNamespace'",
"]",
".",
"\"\\\"\"",
";",
"if",
"(",
"count",
"(",
"$",
"typeDef",
"[",
"'elements'",
"]",
")",
">",
"0",
")",
"{",
"$",
"str",
".=",
"\">\"",
";",
"foreach",
"(",
"$",
"typeDef",
"[",
"'elements'",
"]",
"as",
"$",
"element",
"=>",
"$",
"eData",
")",
"{",
"$",
"str",
".=",
"$",
"this",
"->",
"serializeTypeDef",
"(",
"$",
"element",
")",
";",
"}",
"$",
"str",
".=",
"\"</$type>\"",
";",
"}",
"elseif",
"(",
"$",
"typeDef",
"[",
"'typeClass'",
"]",
"==",
"'element'",
")",
"{",
"$",
"str",
".=",
"\"></$type>\"",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"\"/>\"",
";",
"}",
"return",
"$",
"str",
";",
"}",
"return",
"FALSE",
";",
"}"
] | returns a sample serialization of a given type, or false if no type by the given name
@param string $type name of type
@return mixed
@access public
@deprecated | [
"returns",
"a",
"sample",
"serialization",
"of",
"a",
"given",
"type",
"or",
"false",
"if",
"no",
"type",
"by",
"the",
"given",
"name"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L1995-L2022 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.typeToForm | function typeToForm($name, $type)
{
// get typedef
if ($typeDef = $this->getTypeDef($type)) {
// if struct
if ($typeDef['phpType'] == 'struct') {
$buffer .= '<table>';
foreach ($typeDef['elements'] as $child => $childDef) {
$buffer .= "
<tr><td align='right'>$childDef[name] (type: " . $this->getLocalPart($childDef['type']) . "):</td>
<td><input type='text' name='parameters[" . $name . "][$childDef[name]]'></td></tr>";
}
$buffer .= '</table>';
// if array
} elseif ($typeDef['phpType'] == 'array') {
$buffer .= '<table>';
for ($i = 0; $i < 3; $i++) {
$buffer .= "
<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
<td><input type='text' name='parameters[" . $name . "][]'></td></tr>";
}
$buffer .= '</table>';
// if scalar
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
return $buffer;
} | php | function typeToForm($name, $type)
{
// get typedef
if ($typeDef = $this->getTypeDef($type)) {
// if struct
if ($typeDef['phpType'] == 'struct') {
$buffer .= '<table>';
foreach ($typeDef['elements'] as $child => $childDef) {
$buffer .= "
<tr><td align='right'>$childDef[name] (type: " . $this->getLocalPart($childDef['type']) . "):</td>
<td><input type='text' name='parameters[" . $name . "][$childDef[name]]'></td></tr>";
}
$buffer .= '</table>';
// if array
} elseif ($typeDef['phpType'] == 'array') {
$buffer .= '<table>';
for ($i = 0; $i < 3; $i++) {
$buffer .= "
<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
<td><input type='text' name='parameters[" . $name . "][]'></td></tr>";
}
$buffer .= '</table>';
// if scalar
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
return $buffer;
} | [
"function",
"typeToForm",
"(",
"$",
"name",
",",
"$",
"type",
")",
"{",
"// get typedef",
"if",
"(",
"$",
"typeDef",
"=",
"$",
"this",
"->",
"getTypeDef",
"(",
"$",
"type",
")",
")",
"{",
"// if struct",
"if",
"(",
"$",
"typeDef",
"[",
"'phpType'",
"]",
"==",
"'struct'",
")",
"{",
"$",
"buffer",
".=",
"'<table>'",
";",
"foreach",
"(",
"$",
"typeDef",
"[",
"'elements'",
"]",
"as",
"$",
"child",
"=>",
"$",
"childDef",
")",
"{",
"$",
"buffer",
".=",
"\"\n\t\t\t\t\t<tr><td align='right'>$childDef[name] (type: \"",
".",
"$",
"this",
"->",
"getLocalPart",
"(",
"$",
"childDef",
"[",
"'type'",
"]",
")",
".",
"\"):</td>\n\t\t\t\t\t<td><input type='text' name='parameters[\"",
".",
"$",
"name",
".",
"\"][$childDef[name]]'></td></tr>\"",
";",
"}",
"$",
"buffer",
".=",
"'</table>'",
";",
"// if array",
"}",
"elseif",
"(",
"$",
"typeDef",
"[",
"'phpType'",
"]",
"==",
"'array'",
")",
"{",
"$",
"buffer",
".=",
"'<table>'",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"3",
";",
"$",
"i",
"++",
")",
"{",
"$",
"buffer",
".=",
"\"\n\t\t\t\t\t<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>\n\t\t\t\t\t<td><input type='text' name='parameters[\"",
".",
"$",
"name",
".",
"\"][]'></td></tr>\"",
";",
"}",
"$",
"buffer",
".=",
"'</table>'",
";",
"// if scalar",
"}",
"else",
"{",
"$",
"buffer",
".=",
"\"<input type='text' name='parameters[$name]'>\"",
";",
"}",
"}",
"else",
"{",
"$",
"buffer",
".=",
"\"<input type='text' name='parameters[$name]'>\"",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
] | returns HTML form elements that allow a user
to enter values for creating an instance of the given type.
@param string $name name for type instance
@param string $type name of type
@return string
@access public
@deprecated | [
"returns",
"HTML",
"form",
"elements",
"that",
"allow",
"a",
"user",
"to",
"enter",
"values",
"for",
"creating",
"an",
"instance",
"of",
"the",
"given",
"type",
"."
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L2035-L2066 |
nguyenanhung/nusoap | src-fix/nusoap.php | nusoap_xmlschema.addComplexType | function addComplexType(
$name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = [], $attrs = [],
$arrayType = ''
) {
$this->complexTypes[$name] = [
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'compositor' => $compositor,
'restrictionBase' => $restrictionBase,
'elements' => $elements,
'attrs' => $attrs,
'arrayType' => $arrayType
];
$this->xdebug("addComplexType $name:");
$this->appendDebug($this->varDump($this->complexTypes[$name]));
} | php | function addComplexType(
$name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = [], $attrs = [],
$arrayType = ''
) {
$this->complexTypes[$name] = [
'name' => $name,
'typeClass' => $typeClass,
'phpType' => $phpType,
'compositor' => $compositor,
'restrictionBase' => $restrictionBase,
'elements' => $elements,
'attrs' => $attrs,
'arrayType' => $arrayType
];
$this->xdebug("addComplexType $name:");
$this->appendDebug($this->varDump($this->complexTypes[$name]));
} | [
"function",
"addComplexType",
"(",
"$",
"name",
",",
"$",
"typeClass",
"=",
"'complexType'",
",",
"$",
"phpType",
"=",
"'array'",
",",
"$",
"compositor",
"=",
"''",
",",
"$",
"restrictionBase",
"=",
"''",
",",
"$",
"elements",
"=",
"[",
"]",
",",
"$",
"attrs",
"=",
"[",
"]",
",",
"$",
"arrayType",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"name",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'typeClass'",
"=>",
"$",
"typeClass",
",",
"'phpType'",
"=>",
"$",
"phpType",
",",
"'compositor'",
"=>",
"$",
"compositor",
",",
"'restrictionBase'",
"=>",
"$",
"restrictionBase",
",",
"'elements'",
"=>",
"$",
"elements",
",",
"'attrs'",
"=>",
"$",
"attrs",
",",
"'arrayType'",
"=>",
"$",
"arrayType",
"]",
";",
"$",
"this",
"->",
"xdebug",
"(",
"\"addComplexType $name:\"",
")",
";",
"$",
"this",
"->",
"appendDebug",
"(",
"$",
"this",
"->",
"varDump",
"(",
"$",
"this",
"->",
"complexTypes",
"[",
"$",
"name",
"]",
")",
")",
";",
"}"
] | adds a complex type to the schema
example: array
addType(
'ArrayOfstring',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
'xsd:string'
);
example: PHP associative array ( SOAP Struct )
addType(
'SOAPStruct',
'complexType',
'struct',
'all',
array('myVar'=> array('name'=>'myVar','type'=>'string')
);
@param name
@param typeClass (complexType|simpleType|attribute)
@param phpType : currently supported are array and struct (php assoc array)
@param compositor (all|sequence|choice)
@param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
@param elements = array ( name = array(name=>'',type=>'') )
@param attrs = array(
array(
'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType",
"http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]"
)
)
@param arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string)
@access public
@see getTypeDef | [
"adds",
"a",
"complex",
"type",
"to",
"the",
"schema"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L2110-L2127 |
nguyenanhung/nusoap | src-fix/nusoap.php | soap_transport_http.setURL | function setURL($url)
{
$this->url = $url;
$u = parse_url($url);
foreach ($u as $k => $v) {
$this->debug("parsed URL $k = $v");
$this->$k = $v;
}
// add any GET params to path
if (isset($u['query']) && $u['query'] != '') {
$this->path .= '?' . $u['query'];
}
// set default port
if (!isset($u['port'])) {
if ($u['scheme'] == 'https') {
$this->port = 443;
} else {
$this->port = 80;
}
}
$this->uri = $this->path;
$this->digest_uri = $this->uri;
// build headers
if (!isset($u['port'])) {
$this->setHeader('Host', $this->host);
} else {
$this->setHeader('Host', $this->host . ':' . $this->port);
}
if (isset($u['user']) && $u['user'] != '') {
$this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
}
} | php | function setURL($url)
{
$this->url = $url;
$u = parse_url($url);
foreach ($u as $k => $v) {
$this->debug("parsed URL $k = $v");
$this->$k = $v;
}
// add any GET params to path
if (isset($u['query']) && $u['query'] != '') {
$this->path .= '?' . $u['query'];
}
// set default port
if (!isset($u['port'])) {
if ($u['scheme'] == 'https') {
$this->port = 443;
} else {
$this->port = 80;
}
}
$this->uri = $this->path;
$this->digest_uri = $this->uri;
// build headers
if (!isset($u['port'])) {
$this->setHeader('Host', $this->host);
} else {
$this->setHeader('Host', $this->host . ':' . $this->port);
}
if (isset($u['user']) && $u['user'] != '') {
$this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
}
} | [
"function",
"setURL",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"$",
"u",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"foreach",
"(",
"$",
"u",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"parsed URL $k = $v\"",
")",
";",
"$",
"this",
"->",
"$",
"k",
"=",
"$",
"v",
";",
"}",
"// add any GET params to path",
"if",
"(",
"isset",
"(",
"$",
"u",
"[",
"'query'",
"]",
")",
"&&",
"$",
"u",
"[",
"'query'",
"]",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"path",
".=",
"'?'",
".",
"$",
"u",
"[",
"'query'",
"]",
";",
"}",
"// set default port",
"if",
"(",
"!",
"isset",
"(",
"$",
"u",
"[",
"'port'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"u",
"[",
"'scheme'",
"]",
"==",
"'https'",
")",
"{",
"$",
"this",
"->",
"port",
"=",
"443",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"port",
"=",
"80",
";",
"}",
"}",
"$",
"this",
"->",
"uri",
"=",
"$",
"this",
"->",
"path",
";",
"$",
"this",
"->",
"digest_uri",
"=",
"$",
"this",
"->",
"uri",
";",
"// build headers",
"if",
"(",
"!",
"isset",
"(",
"$",
"u",
"[",
"'port'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Host'",
",",
"$",
"this",
"->",
"host",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Host'",
",",
"$",
"this",
"->",
"host",
".",
"':'",
".",
"$",
"this",
"->",
"port",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"u",
"[",
"'user'",
"]",
")",
"&&",
"$",
"u",
"[",
"'user'",
"]",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"setCredentials",
"(",
"urldecode",
"(",
"$",
"u",
"[",
"'user'",
"]",
")",
",",
"isset",
"(",
"$",
"u",
"[",
"'pass'",
"]",
")",
"?",
"urldecode",
"(",
"$",
"u",
"[",
"'pass'",
"]",
")",
":",
"''",
")",
";",
"}",
"}"
] | sets the URL to which to connect
@param string $url The URL to which to connect
@access private | [
"sets",
"the",
"URL",
"to",
"which",
"to",
"connect"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L2409-L2446 |
nguyenanhung/nusoap | src-fix/nusoap.php | soap_transport_http.setEncoding | function setEncoding($enc = 'gzip, deflate')
{
if (function_exists('gzdeflate')) {
$this->protocol_version = '1.1';
$this->setHeader('Accept-Encoding', $enc);
if (!isset($this->outgoing_headers['Connection'])) {
$this->setHeader('Connection', 'close');
$this->persistentConnection = FALSE;
}
// deprecated as of PHP 5.3.0
//set_magic_quotes_runtime(0);
$this->encoding = $enc;
}
} | php | function setEncoding($enc = 'gzip, deflate')
{
if (function_exists('gzdeflate')) {
$this->protocol_version = '1.1';
$this->setHeader('Accept-Encoding', $enc);
if (!isset($this->outgoing_headers['Connection'])) {
$this->setHeader('Connection', 'close');
$this->persistentConnection = FALSE;
}
// deprecated as of PHP 5.3.0
//set_magic_quotes_runtime(0);
$this->encoding = $enc;
}
} | [
"function",
"setEncoding",
"(",
"$",
"enc",
"=",
"'gzip, deflate'",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gzdeflate'",
")",
")",
"{",
"$",
"this",
"->",
"protocol_version",
"=",
"'1.1'",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'Accept-Encoding'",
",",
"$",
"enc",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"outgoing_headers",
"[",
"'Connection'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Connection'",
",",
"'close'",
")",
";",
"$",
"this",
"->",
"persistentConnection",
"=",
"FALSE",
";",
"}",
"// deprecated as of PHP 5.3.0",
"//set_magic_quotes_runtime(0);",
"$",
"this",
"->",
"encoding",
"=",
"$",
"enc",
";",
"}",
"}"
] | use http encoding
@param string $enc encoding style. supported values: gzip, deflate, or both
@access public | [
"use",
"http",
"encoding"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L2873-L2886 |
nguyenanhung/nusoap | src-fix/nusoap.php | soap_transport_http.isSkippableCurlHeader | function isSkippableCurlHeader(&$data)
{
$skipHeaders = ['HTTP/1.1 100',
'HTTP/1.0 301',
'HTTP/1.1 301',
'HTTP/1.0 302',
'HTTP/1.1 302',
'HTTP/1.0 401',
'HTTP/1.1 401',
'HTTP/1.0 200 Connection established'];
foreach ($skipHeaders as $hd) {
$prefix = substr($data, 0, strlen($hd));
if ($prefix == $hd) {
return TRUE;
}
}
return FALSE;
} | php | function isSkippableCurlHeader(&$data)
{
$skipHeaders = ['HTTP/1.1 100',
'HTTP/1.0 301',
'HTTP/1.1 301',
'HTTP/1.0 302',
'HTTP/1.1 302',
'HTTP/1.0 401',
'HTTP/1.1 401',
'HTTP/1.0 200 Connection established'];
foreach ($skipHeaders as $hd) {
$prefix = substr($data, 0, strlen($hd));
if ($prefix == $hd) {
return TRUE;
}
}
return FALSE;
} | [
"function",
"isSkippableCurlHeader",
"(",
"&",
"$",
"data",
")",
"{",
"$",
"skipHeaders",
"=",
"[",
"'HTTP/1.1 100'",
",",
"'HTTP/1.0 301'",
",",
"'HTTP/1.1 301'",
",",
"'HTTP/1.0 302'",
",",
"'HTTP/1.1 302'",
",",
"'HTTP/1.0 401'",
",",
"'HTTP/1.1 401'",
",",
"'HTTP/1.0 200 Connection established'",
"]",
";",
"foreach",
"(",
"$",
"skipHeaders",
"as",
"$",
"hd",
")",
"{",
"$",
"prefix",
"=",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"strlen",
"(",
"$",
"hd",
")",
")",
";",
"if",
"(",
"$",
"prefix",
"==",
"$",
"hd",
")",
"{",
"return",
"TRUE",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | Test if the given string starts with a header that is to be skipped.
Skippable headers result from chunked transfer and proxy requests.
@param string $data The string to check.
@returns boolean Whether a skippable header was found.
@access private | [
"Test",
"if",
"the",
"given",
"string",
"starts",
"with",
"a",
"header",
"that",
"is",
"to",
"be",
"skipped",
".",
"Skippable",
"headers",
"result",
"from",
"chunked",
"transfer",
"and",
"proxy",
"requests",
"."
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L2928-L2946 |
nguyenanhung/nusoap | src-fix/nusoap.php | soap_transport_http.getResponse | function getResponse()
{
$this->incoming_payload = '';
if ($this->io_method() == 'socket') {
// loop until headers have been retrieved
$data = '';
while (!isset($lb)) {
// We might EOF during header read.
if (feof($this->fp)) {
$this->incoming_payload = $data;
$this->debug('found no headers before EOF after length ' . strlen($data));
$this->debug("received before EOF:\n" . $data);
$this->setError('server failed to send headers');
return FALSE;
}
$tmp = fgets($this->fp, 256);
$tmplen = strlen($tmp);
$this->debug("read line of $tmplen bytes: " . trim($tmp));
if ($tmplen == 0) {
$this->incoming_payload = $data;
$this->debug('socket read of headers timed out after length ' . strlen($data));
$this->debug("read before timeout: " . $data);
$this->setError('socket read of headers timed out');
return FALSE;
}
$data .= $tmp;
$pos = strpos($data, "\r\n\r\n");
if ($pos > 1) {
$lb = "\r\n";
} else {
$pos = strpos($data, "\n\n");
if ($pos > 1) {
$lb = "\n";
}
}
// remove 100 headers
if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
unset($lb);
$data = '';
}//
}
// store header data
$this->incoming_payload .= $data;
$this->debug('found end of headers after length ' . strlen($data));
// process headers
$header_data = trim(substr($data, 0, $pos));
$header_array = explode($lb, $header_data);
$this->incoming_headers = [];
$this->incoming_cookies = [];
foreach ($header_array as $header_line) {
$arr = explode(':', $header_line, 2);
if (count($arr) > 1) {
$header_name = strtolower(trim($arr[0]));
$this->incoming_headers[$header_name] = trim($arr[1]);
if ($header_name == 'set-cookie') {
// TODO: allow multiple cookies from parseCookie
$cookie = $this->parseCookie(trim($arr[1]));
if ($cookie) {
$this->incoming_cookies[] = $cookie;
$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
} else {
$this->debug('did not find cookie in ' . trim($arr[1]));
}
}
} elseif (isset($header_name)) {
// append continuation line to previous header
$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
}
}
// loop until msg has been received
if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
$content_length = 2147483647; // ignore any content-length header
$chunked = TRUE;
$this->debug("want to read chunked content");
} elseif (isset($this->incoming_headers['content-length'])) {
$content_length = $this->incoming_headers['content-length'];
$chunked = FALSE;
$this->debug("want to read content of length $content_length");
} else {
$content_length = 2147483647;
$chunked = FALSE;
$this->debug("want to read content to EOF");
}
$data = '';
do {
if ($chunked) {
$tmp = fgets($this->fp, 256);
$tmplen = strlen($tmp);
$this->debug("read chunk line of $tmplen bytes");
if ($tmplen == 0) {
$this->incoming_payload = $data;
$this->debug('socket read of chunk length timed out after length ' . strlen($data));
$this->debug("read before timeout:\n" . $data);
$this->setError('socket read of chunk length timed out');
return FALSE;
}
$content_length = hexdec(trim($tmp));
$this->debug("chunk length $content_length");
}
$strlen = 0;
while (($strlen < $content_length) && (!feof($this->fp))) {
$readlen = min(8192, $content_length - $strlen);
$tmp = fread($this->fp, $readlen);
$tmplen = strlen($tmp);
$this->debug("read buffer of $tmplen bytes");
if (($tmplen == 0) && (!feof($this->fp))) {
$this->incoming_payload = $data;
$this->debug('socket read of body timed out after length ' . strlen($data));
$this->debug("read before timeout:\n" . $data);
$this->setError('socket read of body timed out');
return FALSE;
}
$strlen += $tmplen;
$data .= $tmp;
}
if ($chunked && ($content_length > 0)) {
$tmp = fgets($this->fp, 256);
$tmplen = strlen($tmp);
$this->debug("read chunk terminator of $tmplen bytes");
if ($tmplen == 0) {
$this->incoming_payload = $data;
$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
$this->debug("read before timeout:\n" . $data);
$this->setError('socket read of chunk terminator timed out');
return FALSE;
}
}
}
while ($chunked && ($content_length > 0) && (!feof($this->fp)));
if (feof($this->fp)) {
$this->debug('read to EOF');
}
$this->debug('read body of length ' . strlen($data));
$this->incoming_payload .= $data;
$this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
// close filepointer
if (
(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
(!$this->persistentConnection) || feof($this->fp)
) {
fclose($this->fp);
$this->fp = FALSE;
$this->debug('closed socket');
}
// connection was closed unexpectedly
if ($this->incoming_payload == '') {
$this->setError('no response from server');
return FALSE;
}
// decode transfer-encoding
// if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
// if(!$data = $this->decodeChunked($data, $lb)){
// $this->setError('Decoding of chunked data failed');
// return false;
// }
//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
// set decoded payload
// $this->incoming_payload = $header_data.$lb.$lb.$data;
// }
} elseif ($this->io_method() == 'curl') {
// send and receive
$this->debug('send and receive with cURL');
$this->incoming_payload = curl_exec($this->ch);
$data = $this->incoming_payload;
$cErr = curl_error($this->ch);
if ($cErr != '') {
$err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
foreach (curl_getinfo($this->ch) as $k => $v) {
if (is_array($v)) {
$this->debug("$k: " . json_encode($v));
} else {
$this->debug("$k: $v<br>");
}
}
$this->debug($err);
$this->setError($err);
curl_close($this->ch);
return FALSE;
} else {
//echo '<pre>';
//var_dump(curl_getinfo($this->ch));
//echo '</pre>';
}
// close curl
$this->debug('No cURL error, closing cURL');
curl_close($this->ch);
// try removing skippable headers
$savedata = $data;
while ($this->isSkippableCurlHeader($data)) {
$this->debug("Found HTTP header to skip");
if ($pos = strpos($data, "\r\n\r\n")) {
$data = ltrim(substr($data, $pos));
} elseif ($pos = strpos($data, "\n\n")) {
$data = ltrim(substr($data, $pos));
}
}
if ($data == '') {
// have nothing left; just remove 100 header(s)
$data = $savedata;
while (preg_match('/^HTTP\/1.1 100/', $data)) {
if ($pos = strpos($data, "\r\n\r\n")) {
$data = ltrim(substr($data, $pos));
} elseif ($pos = strpos($data, "\n\n")) {
$data = ltrim(substr($data, $pos));
}
}
}
// separate content from HTTP headers
if ($pos = strpos($data, "\r\n\r\n")) {
$lb = "\r\n";
} elseif ($pos = strpos($data, "\n\n")) {
$lb = "\n";
} else {
$this->debug('no proper separation of headers and document');
$this->setError('no proper separation of headers and document');
return FALSE;
}
$header_data = trim(substr($data, 0, $pos));
$header_array = explode($lb, $header_data);
$data = ltrim(substr($data, $pos));
$this->debug('found proper separation of headers and document');
$this->debug('cleaned data, stringlen: ' . strlen($data));
// clean headers
foreach ($header_array as $header_line) {
$arr = explode(':', $header_line, 2);
if (count($arr) > 1) {
$header_name = strtolower(trim($arr[0]));
$this->incoming_headers[$header_name] = trim($arr[1]);
if ($header_name == 'set-cookie') {
// TODO: allow multiple cookies from parseCookie
$cookie = $this->parseCookie(trim($arr[1]));
if ($cookie) {
$this->incoming_cookies[] = $cookie;
$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
} else {
$this->debug('did not find cookie in ' . trim($arr[1]));
}
}
} elseif (isset($header_name)) {
// append continuation line to previous header
$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
}
}
}
$this->response_status_line = $header_array[0];
$arr = explode(' ', $this->response_status_line, 3);
$http_version = $arr[0];
$http_status = intval($arr[1]);
$http_reason = count($arr) > 2 ? $arr[2] : '';
// see if we need to resend the request with http digest authentication
if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
$this->setURL($this->incoming_headers['location']);
$this->tryagain = TRUE;
return FALSE;
}
// see if we need to resend the request with http digest authentication
if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
$this->debug('Server wants digest authentication');
// remove "Digest " from our elements
$digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
// parse elements into array
$digestElements = explode(',', $digestString);
foreach ($digestElements as $val) {
$tempElement = explode('=', trim($val), 2);
$digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
}
// should have (at least) qop, realm, nonce
if (isset($digestRequest['nonce'])) {
$this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
$this->tryagain = TRUE;
return FALSE;
}
}
$this->debug('HTTP authentication failed');
$this->setError('HTTP authentication failed');
return FALSE;
}
if (
($http_status >= 300 && $http_status <= 307) ||
($http_status >= 400 && $http_status <= 417) ||
($http_status >= 501 && $http_status <= 505)
) {
$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
return FALSE;
}
// decode content-encoding
if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
// if decoding works, use it. else assume data wasn't gzencoded
if (function_exists('gzinflate')) {
//$timer->setMarker('starting decoding of gzip/deflated content');
// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
// this means there are no Zlib headers, although there should be
$this->debug('The gzinflate function exists');
$datalen = strlen($data);
if ($this->incoming_headers['content-encoding'] == 'deflate') {
if ($degzdata = @gzinflate($data)) {
$data = $degzdata;
$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
if (strlen($data) < $datalen) {
// test for the case that the payload has been compressed twice
$this->debug('The inflated payload is smaller than the gzipped one; try again');
if ($degzdata = @gzinflate($data)) {
$data = $degzdata;
$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
}
}
} else {
$this->debug('Error using gzinflate to inflate the payload');
$this->setError('Error using gzinflate to inflate the payload');
}
} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
$data = $degzdata;
$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
if (strlen($data) < $datalen) {
// test for the case that the payload has been compressed twice
$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
if ($degzdata = @gzinflate(substr($data, 10))) {
$data = $degzdata;
$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
}
}
} else {
$this->debug('Error using gzinflate to un-gzip the payload');
$this->setError('Error using gzinflate to un-gzip the payload');
}
}
//$timer->setMarker('finished decoding of gzip/deflated content');
//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
// set decoded payload
$this->incoming_payload = $header_data . $lb . $lb . $data;
} else {
$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
}
} else {
$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
}
} else {
$this->debug('No Content-Encoding header');
}
if (strlen($data) == 0) {
$this->debug('no data after headers!');
$this->setError('no data present after HTTP headers');
return FALSE;
}
return $data;
} | php | function getResponse()
{
$this->incoming_payload = '';
if ($this->io_method() == 'socket') {
// loop until headers have been retrieved
$data = '';
while (!isset($lb)) {
// We might EOF during header read.
if (feof($this->fp)) {
$this->incoming_payload = $data;
$this->debug('found no headers before EOF after length ' . strlen($data));
$this->debug("received before EOF:\n" . $data);
$this->setError('server failed to send headers');
return FALSE;
}
$tmp = fgets($this->fp, 256);
$tmplen = strlen($tmp);
$this->debug("read line of $tmplen bytes: " . trim($tmp));
if ($tmplen == 0) {
$this->incoming_payload = $data;
$this->debug('socket read of headers timed out after length ' . strlen($data));
$this->debug("read before timeout: " . $data);
$this->setError('socket read of headers timed out');
return FALSE;
}
$data .= $tmp;
$pos = strpos($data, "\r\n\r\n");
if ($pos > 1) {
$lb = "\r\n";
} else {
$pos = strpos($data, "\n\n");
if ($pos > 1) {
$lb = "\n";
}
}
// remove 100 headers
if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
unset($lb);
$data = '';
}//
}
// store header data
$this->incoming_payload .= $data;
$this->debug('found end of headers after length ' . strlen($data));
// process headers
$header_data = trim(substr($data, 0, $pos));
$header_array = explode($lb, $header_data);
$this->incoming_headers = [];
$this->incoming_cookies = [];
foreach ($header_array as $header_line) {
$arr = explode(':', $header_line, 2);
if (count($arr) > 1) {
$header_name = strtolower(trim($arr[0]));
$this->incoming_headers[$header_name] = trim($arr[1]);
if ($header_name == 'set-cookie') {
// TODO: allow multiple cookies from parseCookie
$cookie = $this->parseCookie(trim($arr[1]));
if ($cookie) {
$this->incoming_cookies[] = $cookie;
$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
} else {
$this->debug('did not find cookie in ' . trim($arr[1]));
}
}
} elseif (isset($header_name)) {
// append continuation line to previous header
$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
}
}
// loop until msg has been received
if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
$content_length = 2147483647; // ignore any content-length header
$chunked = TRUE;
$this->debug("want to read chunked content");
} elseif (isset($this->incoming_headers['content-length'])) {
$content_length = $this->incoming_headers['content-length'];
$chunked = FALSE;
$this->debug("want to read content of length $content_length");
} else {
$content_length = 2147483647;
$chunked = FALSE;
$this->debug("want to read content to EOF");
}
$data = '';
do {
if ($chunked) {
$tmp = fgets($this->fp, 256);
$tmplen = strlen($tmp);
$this->debug("read chunk line of $tmplen bytes");
if ($tmplen == 0) {
$this->incoming_payload = $data;
$this->debug('socket read of chunk length timed out after length ' . strlen($data));
$this->debug("read before timeout:\n" . $data);
$this->setError('socket read of chunk length timed out');
return FALSE;
}
$content_length = hexdec(trim($tmp));
$this->debug("chunk length $content_length");
}
$strlen = 0;
while (($strlen < $content_length) && (!feof($this->fp))) {
$readlen = min(8192, $content_length - $strlen);
$tmp = fread($this->fp, $readlen);
$tmplen = strlen($tmp);
$this->debug("read buffer of $tmplen bytes");
if (($tmplen == 0) && (!feof($this->fp))) {
$this->incoming_payload = $data;
$this->debug('socket read of body timed out after length ' . strlen($data));
$this->debug("read before timeout:\n" . $data);
$this->setError('socket read of body timed out');
return FALSE;
}
$strlen += $tmplen;
$data .= $tmp;
}
if ($chunked && ($content_length > 0)) {
$tmp = fgets($this->fp, 256);
$tmplen = strlen($tmp);
$this->debug("read chunk terminator of $tmplen bytes");
if ($tmplen == 0) {
$this->incoming_payload = $data;
$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
$this->debug("read before timeout:\n" . $data);
$this->setError('socket read of chunk terminator timed out');
return FALSE;
}
}
}
while ($chunked && ($content_length > 0) && (!feof($this->fp)));
if (feof($this->fp)) {
$this->debug('read to EOF');
}
$this->debug('read body of length ' . strlen($data));
$this->incoming_payload .= $data;
$this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
// close filepointer
if (
(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
(!$this->persistentConnection) || feof($this->fp)
) {
fclose($this->fp);
$this->fp = FALSE;
$this->debug('closed socket');
}
// connection was closed unexpectedly
if ($this->incoming_payload == '') {
$this->setError('no response from server');
return FALSE;
}
// decode transfer-encoding
// if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
// if(!$data = $this->decodeChunked($data, $lb)){
// $this->setError('Decoding of chunked data failed');
// return false;
// }
//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
// set decoded payload
// $this->incoming_payload = $header_data.$lb.$lb.$data;
// }
} elseif ($this->io_method() == 'curl') {
// send and receive
$this->debug('send and receive with cURL');
$this->incoming_payload = curl_exec($this->ch);
$data = $this->incoming_payload;
$cErr = curl_error($this->ch);
if ($cErr != '') {
$err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
foreach (curl_getinfo($this->ch) as $k => $v) {
if (is_array($v)) {
$this->debug("$k: " . json_encode($v));
} else {
$this->debug("$k: $v<br>");
}
}
$this->debug($err);
$this->setError($err);
curl_close($this->ch);
return FALSE;
} else {
//echo '<pre>';
//var_dump(curl_getinfo($this->ch));
//echo '</pre>';
}
// close curl
$this->debug('No cURL error, closing cURL');
curl_close($this->ch);
// try removing skippable headers
$savedata = $data;
while ($this->isSkippableCurlHeader($data)) {
$this->debug("Found HTTP header to skip");
if ($pos = strpos($data, "\r\n\r\n")) {
$data = ltrim(substr($data, $pos));
} elseif ($pos = strpos($data, "\n\n")) {
$data = ltrim(substr($data, $pos));
}
}
if ($data == '') {
// have nothing left; just remove 100 header(s)
$data = $savedata;
while (preg_match('/^HTTP\/1.1 100/', $data)) {
if ($pos = strpos($data, "\r\n\r\n")) {
$data = ltrim(substr($data, $pos));
} elseif ($pos = strpos($data, "\n\n")) {
$data = ltrim(substr($data, $pos));
}
}
}
// separate content from HTTP headers
if ($pos = strpos($data, "\r\n\r\n")) {
$lb = "\r\n";
} elseif ($pos = strpos($data, "\n\n")) {
$lb = "\n";
} else {
$this->debug('no proper separation of headers and document');
$this->setError('no proper separation of headers and document');
return FALSE;
}
$header_data = trim(substr($data, 0, $pos));
$header_array = explode($lb, $header_data);
$data = ltrim(substr($data, $pos));
$this->debug('found proper separation of headers and document');
$this->debug('cleaned data, stringlen: ' . strlen($data));
// clean headers
foreach ($header_array as $header_line) {
$arr = explode(':', $header_line, 2);
if (count($arr) > 1) {
$header_name = strtolower(trim($arr[0]));
$this->incoming_headers[$header_name] = trim($arr[1]);
if ($header_name == 'set-cookie') {
// TODO: allow multiple cookies from parseCookie
$cookie = $this->parseCookie(trim($arr[1]));
if ($cookie) {
$this->incoming_cookies[] = $cookie;
$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
} else {
$this->debug('did not find cookie in ' . trim($arr[1]));
}
}
} elseif (isset($header_name)) {
// append continuation line to previous header
$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
}
}
}
$this->response_status_line = $header_array[0];
$arr = explode(' ', $this->response_status_line, 3);
$http_version = $arr[0];
$http_status = intval($arr[1]);
$http_reason = count($arr) > 2 ? $arr[2] : '';
// see if we need to resend the request with http digest authentication
if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
$this->setURL($this->incoming_headers['location']);
$this->tryagain = TRUE;
return FALSE;
}
// see if we need to resend the request with http digest authentication
if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
$this->debug('Server wants digest authentication');
// remove "Digest " from our elements
$digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
// parse elements into array
$digestElements = explode(',', $digestString);
foreach ($digestElements as $val) {
$tempElement = explode('=', trim($val), 2);
$digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
}
// should have (at least) qop, realm, nonce
if (isset($digestRequest['nonce'])) {
$this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
$this->tryagain = TRUE;
return FALSE;
}
}
$this->debug('HTTP authentication failed');
$this->setError('HTTP authentication failed');
return FALSE;
}
if (
($http_status >= 300 && $http_status <= 307) ||
($http_status >= 400 && $http_status <= 417) ||
($http_status >= 501 && $http_status <= 505)
) {
$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
return FALSE;
}
// decode content-encoding
if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
// if decoding works, use it. else assume data wasn't gzencoded
if (function_exists('gzinflate')) {
//$timer->setMarker('starting decoding of gzip/deflated content');
// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
// this means there are no Zlib headers, although there should be
$this->debug('The gzinflate function exists');
$datalen = strlen($data);
if ($this->incoming_headers['content-encoding'] == 'deflate') {
if ($degzdata = @gzinflate($data)) {
$data = $degzdata;
$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
if (strlen($data) < $datalen) {
// test for the case that the payload has been compressed twice
$this->debug('The inflated payload is smaller than the gzipped one; try again');
if ($degzdata = @gzinflate($data)) {
$data = $degzdata;
$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
}
}
} else {
$this->debug('Error using gzinflate to inflate the payload');
$this->setError('Error using gzinflate to inflate the payload');
}
} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
$data = $degzdata;
$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
if (strlen($data) < $datalen) {
// test for the case that the payload has been compressed twice
$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
if ($degzdata = @gzinflate(substr($data, 10))) {
$data = $degzdata;
$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
}
}
} else {
$this->debug('Error using gzinflate to un-gzip the payload');
$this->setError('Error using gzinflate to un-gzip the payload');
}
}
//$timer->setMarker('finished decoding of gzip/deflated content');
//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
// set decoded payload
$this->incoming_payload = $header_data . $lb . $lb . $data;
} else {
$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
}
} else {
$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
}
} else {
$this->debug('No Content-Encoding header');
}
if (strlen($data) == 0) {
$this->debug('no data after headers!');
$this->setError('no data present after HTTP headers');
return FALSE;
}
return $data;
} | [
"function",
"getResponse",
"(",
")",
"{",
"$",
"this",
"->",
"incoming_payload",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"io_method",
"(",
")",
"==",
"'socket'",
")",
"{",
"// loop until headers have been retrieved",
"$",
"data",
"=",
"''",
";",
"while",
"(",
"!",
"isset",
"(",
"$",
"lb",
")",
")",
"{",
"// We might EOF during header read.",
"if",
"(",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"$",
"this",
"->",
"incoming_payload",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'found no headers before EOF after length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"received before EOF:\\n\"",
".",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'server failed to send headers'",
")",
";",
"return",
"FALSE",
";",
"}",
"$",
"tmp",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fp",
",",
"256",
")",
";",
"$",
"tmplen",
"=",
"strlen",
"(",
"$",
"tmp",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read line of $tmplen bytes: \"",
".",
"trim",
"(",
"$",
"tmp",
")",
")",
";",
"if",
"(",
"$",
"tmplen",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"incoming_payload",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'socket read of headers timed out after length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read before timeout: \"",
".",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'socket read of headers timed out'",
")",
";",
"return",
"FALSE",
";",
"}",
"$",
"data",
".=",
"$",
"tmp",
";",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\r\\n\\r\\n\"",
")",
";",
"if",
"(",
"$",
"pos",
">",
"1",
")",
"{",
"$",
"lb",
"=",
"\"\\r\\n\"",
";",
"}",
"else",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\n\\n\"",
")",
";",
"if",
"(",
"$",
"pos",
">",
"1",
")",
"{",
"$",
"lb",
"=",
"\"\\n\"",
";",
"}",
"}",
"// remove 100 headers",
"if",
"(",
"isset",
"(",
"$",
"lb",
")",
"&&",
"preg_match",
"(",
"'/^HTTP\\/1.1 100/'",
",",
"$",
"data",
")",
")",
"{",
"unset",
"(",
"$",
"lb",
")",
";",
"$",
"data",
"=",
"''",
";",
"}",
"//",
"}",
"// store header data",
"$",
"this",
"->",
"incoming_payload",
".=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'found end of headers after length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"// process headers",
"$",
"header_data",
"=",
"trim",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"pos",
")",
")",
";",
"$",
"header_array",
"=",
"explode",
"(",
"$",
"lb",
",",
"$",
"header_data",
")",
";",
"$",
"this",
"->",
"incoming_headers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"incoming_cookies",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"header_array",
"as",
"$",
"header_line",
")",
"{",
"$",
"arr",
"=",
"explode",
"(",
"':'",
",",
"$",
"header_line",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arr",
")",
">",
"1",
")",
"{",
"$",
"header_name",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"arr",
"[",
"0",
"]",
")",
")",
";",
"$",
"this",
"->",
"incoming_headers",
"[",
"$",
"header_name",
"]",
"=",
"trim",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"header_name",
"==",
"'set-cookie'",
")",
"{",
"// TODO: allow multiple cookies from parseCookie",
"$",
"cookie",
"=",
"$",
"this",
"->",
"parseCookie",
"(",
"trim",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"cookie",
")",
"{",
"$",
"this",
"->",
"incoming_cookies",
"[",
"]",
"=",
"$",
"cookie",
";",
"$",
"this",
"->",
"debug",
"(",
"'found cookie: '",
".",
"$",
"cookie",
"[",
"'name'",
"]",
".",
"' = '",
".",
"$",
"cookie",
"[",
"'value'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'did not find cookie in '",
".",
"trim",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"header_name",
")",
")",
"{",
"// append continuation line to previous header",
"$",
"this",
"->",
"incoming_headers",
"[",
"$",
"header_name",
"]",
".=",
"$",
"lb",
".",
"' '",
".",
"$",
"header_line",
";",
"}",
"}",
"// loop until msg has been received",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'transfer-encoding'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'transfer-encoding'",
"]",
")",
"==",
"'chunked'",
")",
"{",
"$",
"content_length",
"=",
"2147483647",
";",
"// ignore any content-length header",
"$",
"chunked",
"=",
"TRUE",
";",
"$",
"this",
"->",
"debug",
"(",
"\"want to read chunked content\"",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-length'",
"]",
")",
")",
"{",
"$",
"content_length",
"=",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-length'",
"]",
";",
"$",
"chunked",
"=",
"FALSE",
";",
"$",
"this",
"->",
"debug",
"(",
"\"want to read content of length $content_length\"",
")",
";",
"}",
"else",
"{",
"$",
"content_length",
"=",
"2147483647",
";",
"$",
"chunked",
"=",
"FALSE",
";",
"$",
"this",
"->",
"debug",
"(",
"\"want to read content to EOF\"",
")",
";",
"}",
"$",
"data",
"=",
"''",
";",
"do",
"{",
"if",
"(",
"$",
"chunked",
")",
"{",
"$",
"tmp",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fp",
",",
"256",
")",
";",
"$",
"tmplen",
"=",
"strlen",
"(",
"$",
"tmp",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read chunk line of $tmplen bytes\"",
")",
";",
"if",
"(",
"$",
"tmplen",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"incoming_payload",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'socket read of chunk length timed out after length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read before timeout:\\n\"",
".",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'socket read of chunk length timed out'",
")",
";",
"return",
"FALSE",
";",
"}",
"$",
"content_length",
"=",
"hexdec",
"(",
"trim",
"(",
"$",
"tmp",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"chunk length $content_length\"",
")",
";",
"}",
"$",
"strlen",
"=",
"0",
";",
"while",
"(",
"(",
"$",
"strlen",
"<",
"$",
"content_length",
")",
"&&",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
")",
"{",
"$",
"readlen",
"=",
"min",
"(",
"8192",
",",
"$",
"content_length",
"-",
"$",
"strlen",
")",
";",
"$",
"tmp",
"=",
"fread",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"readlen",
")",
";",
"$",
"tmplen",
"=",
"strlen",
"(",
"$",
"tmp",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read buffer of $tmplen bytes\"",
")",
";",
"if",
"(",
"(",
"$",
"tmplen",
"==",
"0",
")",
"&&",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
")",
"{",
"$",
"this",
"->",
"incoming_payload",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'socket read of body timed out after length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read before timeout:\\n\"",
".",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'socket read of body timed out'",
")",
";",
"return",
"FALSE",
";",
"}",
"$",
"strlen",
"+=",
"$",
"tmplen",
";",
"$",
"data",
".=",
"$",
"tmp",
";",
"}",
"if",
"(",
"$",
"chunked",
"&&",
"(",
"$",
"content_length",
">",
"0",
")",
")",
"{",
"$",
"tmp",
"=",
"fgets",
"(",
"$",
"this",
"->",
"fp",
",",
"256",
")",
";",
"$",
"tmplen",
"=",
"strlen",
"(",
"$",
"tmp",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read chunk terminator of $tmplen bytes\"",
")",
";",
"if",
"(",
"$",
"tmplen",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"incoming_payload",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'socket read of chunk terminator timed out after length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"read before timeout:\\n\"",
".",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'socket read of chunk terminator timed out'",
")",
";",
"return",
"FALSE",
";",
"}",
"}",
"}",
"while",
"(",
"$",
"chunked",
"&&",
"(",
"$",
"content_length",
">",
"0",
")",
"&&",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
")",
";",
"if",
"(",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'read to EOF'",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"(",
"'read body of length '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"incoming_payload",
".=",
"$",
"data",
";",
"$",
"this",
"->",
"debug",
"(",
"'received a total of '",
".",
"strlen",
"(",
"$",
"this",
"->",
"incoming_payload",
")",
".",
"' bytes of data from server'",
")",
";",
"// close filepointer",
"if",
"(",
"(",
"isset",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'connection'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'connection'",
"]",
")",
"==",
"'close'",
")",
"||",
"(",
"!",
"$",
"this",
"->",
"persistentConnection",
")",
"||",
"feof",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"FALSE",
";",
"$",
"this",
"->",
"debug",
"(",
"'closed socket'",
")",
";",
"}",
"// connection was closed unexpectedly",
"if",
"(",
"$",
"this",
"->",
"incoming_payload",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'no response from server'",
")",
";",
"return",
"FALSE",
";",
"}",
"// decode transfer-encoding",
"//\t\tif(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){",
"//\t\t\tif(!$data = $this->decodeChunked($data, $lb)){",
"//\t\t\t\t$this->setError('Decoding of chunked data failed');",
"//\t\t\t\treturn false;",
"//\t\t\t}",
"//print \"<pre>\\nde-chunked:\\n---------------\\n$data\\n\\n---------------\\n</pre>\";",
"// set decoded payload",
"//\t\t\t$this->incoming_payload = $header_data.$lb.$lb.$data;",
"//\t\t}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"io_method",
"(",
")",
"==",
"'curl'",
")",
"{",
"// send and receive",
"$",
"this",
"->",
"debug",
"(",
"'send and receive with cURL'",
")",
";",
"$",
"this",
"->",
"incoming_payload",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"ch",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"incoming_payload",
";",
"$",
"cErr",
"=",
"curl_error",
"(",
"$",
"this",
"->",
"ch",
")",
";",
"if",
"(",
"$",
"cErr",
"!=",
"''",
")",
"{",
"$",
"err",
"=",
"'cURL ERROR: '",
".",
"curl_errno",
"(",
"$",
"this",
"->",
"ch",
")",
".",
"': '",
".",
"$",
"cErr",
".",
"'<br>'",
";",
"// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE",
"foreach",
"(",
"curl_getinfo",
"(",
"$",
"this",
"->",
"ch",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"$k: \"",
".",
"json_encode",
"(",
"$",
"v",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"$k: $v<br>\"",
")",
";",
"}",
"}",
"$",
"this",
"->",
"debug",
"(",
"$",
"err",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"$",
"err",
")",
";",
"curl_close",
"(",
"$",
"this",
"->",
"ch",
")",
";",
"return",
"FALSE",
";",
"}",
"else",
"{",
"//echo '<pre>';",
"//var_dump(curl_getinfo($this->ch));",
"//echo '</pre>';",
"}",
"// close curl",
"$",
"this",
"->",
"debug",
"(",
"'No cURL error, closing cURL'",
")",
";",
"curl_close",
"(",
"$",
"this",
"->",
"ch",
")",
";",
"// try removing skippable headers",
"$",
"savedata",
"=",
"$",
"data",
";",
"while",
"(",
"$",
"this",
"->",
"isSkippableCurlHeader",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Found HTTP header to skip\"",
")",
";",
"if",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\r\\n\\r\\n\"",
")",
")",
"{",
"$",
"data",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"data",
",",
"$",
"pos",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\n\\n\"",
")",
")",
"{",
"$",
"data",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"data",
",",
"$",
"pos",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"data",
"==",
"''",
")",
"{",
"// have nothing left; just remove 100 header(s)",
"$",
"data",
"=",
"$",
"savedata",
";",
"while",
"(",
"preg_match",
"(",
"'/^HTTP\\/1.1 100/'",
",",
"$",
"data",
")",
")",
"{",
"if",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\r\\n\\r\\n\"",
")",
")",
"{",
"$",
"data",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"data",
",",
"$",
"pos",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\n\\n\"",
")",
")",
"{",
"$",
"data",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"data",
",",
"$",
"pos",
")",
")",
";",
"}",
"}",
"}",
"// separate content from HTTP headers",
"if",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\r\\n\\r\\n\"",
")",
")",
"{",
"$",
"lb",
"=",
"\"\\r\\n\"",
";",
"}",
"elseif",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"data",
",",
"\"\\n\\n\"",
")",
")",
"{",
"$",
"lb",
"=",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'no proper separation of headers and document'",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'no proper separation of headers and document'",
")",
";",
"return",
"FALSE",
";",
"}",
"$",
"header_data",
"=",
"trim",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"pos",
")",
")",
";",
"$",
"header_array",
"=",
"explode",
"(",
"$",
"lb",
",",
"$",
"header_data",
")",
";",
"$",
"data",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"data",
",",
"$",
"pos",
")",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"'found proper separation of headers and document'",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"'cleaned data, stringlen: '",
".",
"strlen",
"(",
"$",
"data",
")",
")",
";",
"// clean headers",
"foreach",
"(",
"$",
"header_array",
"as",
"$",
"header_line",
")",
"{",
"$",
"arr",
"=",
"explode",
"(",
"':'",
",",
"$",
"header_line",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arr",
")",
">",
"1",
")",
"{",
"$",
"header_name",
"=",
"strtolower",
"(",
"trim",
"(",
"$",
"arr",
"[",
"0",
"]",
")",
")",
";",
"$",
"this",
"->",
"incoming_headers",
"[",
"$",
"header_name",
"]",
"=",
"trim",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"header_name",
"==",
"'set-cookie'",
")",
"{",
"// TODO: allow multiple cookies from parseCookie",
"$",
"cookie",
"=",
"$",
"this",
"->",
"parseCookie",
"(",
"trim",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"cookie",
")",
"{",
"$",
"this",
"->",
"incoming_cookies",
"[",
"]",
"=",
"$",
"cookie",
";",
"$",
"this",
"->",
"debug",
"(",
"'found cookie: '",
".",
"$",
"cookie",
"[",
"'name'",
"]",
".",
"' = '",
".",
"$",
"cookie",
"[",
"'value'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'did not find cookie in '",
".",
"trim",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"header_name",
")",
")",
"{",
"// append continuation line to previous header",
"$",
"this",
"->",
"incoming_headers",
"[",
"$",
"header_name",
"]",
".=",
"$",
"lb",
".",
"' '",
".",
"$",
"header_line",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"response_status_line",
"=",
"$",
"header_array",
"[",
"0",
"]",
";",
"$",
"arr",
"=",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"response_status_line",
",",
"3",
")",
";",
"$",
"http_version",
"=",
"$",
"arr",
"[",
"0",
"]",
";",
"$",
"http_status",
"=",
"intval",
"(",
"$",
"arr",
"[",
"1",
"]",
")",
";",
"$",
"http_reason",
"=",
"count",
"(",
"$",
"arr",
")",
">",
"2",
"?",
"$",
"arr",
"[",
"2",
"]",
":",
"''",
";",
"// see if we need to resend the request with http digest authentication",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'location'",
"]",
")",
"&&",
"(",
"$",
"http_status",
"==",
"301",
"||",
"$",
"http_status",
"==",
"302",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Got $http_status $http_reason with Location: \"",
".",
"$",
"this",
"->",
"incoming_headers",
"[",
"'location'",
"]",
")",
";",
"$",
"this",
"->",
"setURL",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'location'",
"]",
")",
";",
"$",
"this",
"->",
"tryagain",
"=",
"TRUE",
";",
"return",
"FALSE",
";",
"}",
"// see if we need to resend the request with http digest authentication",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'www-authenticate'",
"]",
")",
"&&",
"$",
"http_status",
"==",
"401",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Got 401 $http_reason with WWW-Authenticate: \"",
".",
"$",
"this",
"->",
"incoming_headers",
"[",
"'www-authenticate'",
"]",
")",
";",
"if",
"(",
"strstr",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'www-authenticate'",
"]",
",",
"\"Digest \"",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Server wants digest authentication'",
")",
";",
"// remove \"Digest \" from our elements",
"$",
"digestString",
"=",
"str_replace",
"(",
"'Digest '",
",",
"''",
",",
"$",
"this",
"->",
"incoming_headers",
"[",
"'www-authenticate'",
"]",
")",
";",
"// parse elements into array",
"$",
"digestElements",
"=",
"explode",
"(",
"','",
",",
"$",
"digestString",
")",
";",
"foreach",
"(",
"$",
"digestElements",
"as",
"$",
"val",
")",
"{",
"$",
"tempElement",
"=",
"explode",
"(",
"'='",
",",
"trim",
"(",
"$",
"val",
")",
",",
"2",
")",
";",
"$",
"digestRequest",
"[",
"$",
"tempElement",
"[",
"0",
"]",
"]",
"=",
"str_replace",
"(",
"\"\\\"\"",
",",
"''",
",",
"$",
"tempElement",
"[",
"1",
"]",
")",
";",
"}",
"// should have (at least) qop, realm, nonce",
"if",
"(",
"isset",
"(",
"$",
"digestRequest",
"[",
"'nonce'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setCredentials",
"(",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"'digest'",
",",
"$",
"digestRequest",
")",
";",
"$",
"this",
"->",
"tryagain",
"=",
"TRUE",
";",
"return",
"FALSE",
";",
"}",
"}",
"$",
"this",
"->",
"debug",
"(",
"'HTTP authentication failed'",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'HTTP authentication failed'",
")",
";",
"return",
"FALSE",
";",
"}",
"if",
"(",
"(",
"$",
"http_status",
">=",
"300",
"&&",
"$",
"http_status",
"<=",
"307",
")",
"||",
"(",
"$",
"http_status",
">=",
"400",
"&&",
"$",
"http_status",
"<=",
"417",
")",
"||",
"(",
"$",
"http_status",
">=",
"501",
"&&",
"$",
"http_status",
"<=",
"505",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"\"Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)\"",
")",
";",
"return",
"FALSE",
";",
"}",
"// decode content-encoding",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
")",
"&&",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
"!=",
"''",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
")",
"==",
"'deflate'",
"||",
"strtolower",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
")",
"==",
"'gzip'",
")",
"{",
"// if decoding works, use it. else assume data wasn't gzencoded",
"if",
"(",
"function_exists",
"(",
"'gzinflate'",
")",
")",
"{",
"//$timer->setMarker('starting decoding of gzip/deflated content');",
"// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)",
"// this means there are no Zlib headers, although there should be",
"$",
"this",
"->",
"debug",
"(",
"'The gzinflate function exists'",
")",
";",
"$",
"datalen",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
"==",
"'deflate'",
")",
"{",
"if",
"(",
"$",
"degzdata",
"=",
"@",
"gzinflate",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"degzdata",
";",
"$",
"this",
"->",
"debug",
"(",
"'The payload has been inflated to '",
".",
"strlen",
"(",
"$",
"data",
")",
".",
"' bytes'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
"<",
"$",
"datalen",
")",
"{",
"// test for the case that the payload has been compressed twice",
"$",
"this",
"->",
"debug",
"(",
"'The inflated payload is smaller than the gzipped one; try again'",
")",
";",
"if",
"(",
"$",
"degzdata",
"=",
"@",
"gzinflate",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"degzdata",
";",
"$",
"this",
"->",
"debug",
"(",
"'The payload has been inflated again to '",
".",
"strlen",
"(",
"$",
"data",
")",
".",
"' bytes'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Error using gzinflate to inflate the payload'",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'Error using gzinflate to inflate the payload'",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
"==",
"'gzip'",
")",
"{",
"if",
"(",
"$",
"degzdata",
"=",
"@",
"gzinflate",
"(",
"substr",
"(",
"$",
"data",
",",
"10",
")",
")",
")",
"{",
"// do our best",
"$",
"data",
"=",
"$",
"degzdata",
";",
"$",
"this",
"->",
"debug",
"(",
"'The payload has been un-gzipped to '",
".",
"strlen",
"(",
"$",
"data",
")",
".",
"' bytes'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
"<",
"$",
"datalen",
")",
"{",
"// test for the case that the payload has been compressed twice",
"$",
"this",
"->",
"debug",
"(",
"'The un-gzipped payload is smaller than the gzipped one; try again'",
")",
";",
"if",
"(",
"$",
"degzdata",
"=",
"@",
"gzinflate",
"(",
"substr",
"(",
"$",
"data",
",",
"10",
")",
")",
")",
"{",
"$",
"data",
"=",
"$",
"degzdata",
";",
"$",
"this",
"->",
"debug",
"(",
"'The payload has been un-gzipped again to '",
".",
"strlen",
"(",
"$",
"data",
")",
".",
"' bytes'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Error using gzinflate to un-gzip the payload'",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'Error using gzinflate to un-gzip the payload'",
")",
";",
"}",
"}",
"//$timer->setMarker('finished decoding of gzip/deflated content');",
"//print \"<xmp>\\nde-inflated:\\n---------------\\n$data\\n-------------\\n</xmp>\";",
"// set decoded payload",
"$",
"this",
"->",
"incoming_payload",
"=",
"$",
"header_data",
".",
"$",
"lb",
".",
"$",
"lb",
".",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.'",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Unsupported Content-Encoding '",
".",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'Unsupported Content-Encoding '",
".",
"$",
"this",
"->",
"incoming_headers",
"[",
"'content-encoding'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"debug",
"(",
"'No Content-Encoding header'",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"data",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'no data after headers!'",
")",
";",
"$",
"this",
"->",
"setError",
"(",
"'no data present after HTTP headers'",
")",
";",
"return",
"FALSE",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | gets the SOAP response via HTTP[S]
@return string the response (also sets member variables like incoming_payload)
@access private | [
"gets",
"the",
"SOAP",
"response",
"via",
"HTTP",
"[",
"S",
"]"
] | train | https://github.com/nguyenanhung/nusoap/blob/a9b4d98f4f3fe748f8e5d9f8091dfc53585d2556/src-fix/nusoap.php#L3132-L3521 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.