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
|
---|---|---|---|---|---|---|---|---|---|---|
PHPPowertools/HTML5 | src/PowerTools/HTML5/Parser/UTF8Utils.php | HTML5_Parser_UTF8Utils.countChars | public static function countChars($string) {
// Get the length for the string we need.
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, 'utf-8');
} elseif (function_exists('mb_strlen')) {
return mb_strlen($string, 'utf-8');
} elseif (function_exists('utf8_decode')) {
// MPB: Will this work? Won't certain decodes lead to two chars
// extrapolated out of 2-byte chars?
return strlen(utf8_decode($string));
}
$count = count_chars($string);
// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
return array_sum(array_slice($count, 0, 0x80)) + array_sum(array_slice($count, 0xC2, 0x33));
} | php | public static function countChars($string) {
// Get the length for the string we need.
if (function_exists('iconv_strlen')) {
return iconv_strlen($string, 'utf-8');
} elseif (function_exists('mb_strlen')) {
return mb_strlen($string, 'utf-8');
} elseif (function_exists('utf8_decode')) {
// MPB: Will this work? Won't certain decodes lead to two chars
// extrapolated out of 2-byte chars?
return strlen(utf8_decode($string));
}
$count = count_chars($string);
// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)
// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)
return array_sum(array_slice($count, 0, 0x80)) + array_sum(array_slice($count, 0xC2, 0x33));
} | [
"public",
"static",
"function",
"countChars",
"(",
"$",
"string",
")",
"{",
"// Get the length for the string we need.",
"if",
"(",
"function_exists",
"(",
"'iconv_strlen'",
")",
")",
"{",
"return",
"iconv_strlen",
"(",
"$",
"string",
",",
"'utf-8'",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'mb_strlen'",
")",
")",
"{",
"return",
"mb_strlen",
"(",
"$",
"string",
",",
"'utf-8'",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'utf8_decode'",
")",
")",
"{",
"// MPB: Will this work? Won't certain decodes lead to two chars",
"// extrapolated out of 2-byte chars?",
"return",
"strlen",
"(",
"utf8_decode",
"(",
"$",
"string",
")",
")",
";",
"}",
"$",
"count",
"=",
"count_chars",
"(",
"$",
"string",
")",
";",
"// 0x80 = 0x7F - 0 + 1 (one added to get inclusive range)",
"// 0x33 = 0xF4 - 0x2C + 1 (one added to get inclusive range)",
"return",
"array_sum",
"(",
"array_slice",
"(",
"$",
"count",
",",
"0",
",",
"0x80",
")",
")",
"+",
"array_sum",
"(",
"array_slice",
"(",
"$",
"count",
",",
"0xC2",
",",
"0x33",
")",
")",
";",
"}"
] | Count the number of characters in a string.
UTF-8 aware. This will try (in order) iconv,
MB, libxml, and finally a custom counter.
@todo Move this to a general utility class. | [
"Count",
"the",
"number",
"of",
"characters",
"in",
"a",
"string",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/UTF8Utils.php#L133-L148 |
PHPPowertools/HTML5 | src/PowerTools/HTML5/Parser/UTF8Utils.php | HTML5_Parser_UTF8Utils.convertToUTF8 | public static function convertToUTF8($data, $encoding = 'UTF-8') {
/*
* From the HTML5 spec: Given an encoding, the bytes in the input stream must be converted to Unicode characters for the tokeniser, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below). Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode characters must be converted to U+FFFD REPLACEMENT CHARACTER code points.
*/
// mb_convert_encoding is chosen over iconv because of a bug. The best
// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643
// which contains links to the actual but reports as well as work around
// details.
if (function_exists('mb_convert_encoding')) {
// mb library has the following behaviors:
// - UTF-16 surrogates result in false.
// - Overlongs and outside Plane 16 result in empty strings.
// Before we run mb_convert_encoding we need to tell it what to do with
// characters it does not know. This could be different than the parent
// application executing this library so we store the value, change it
// to our needs, and then change it back when we are done. This feels
// a little excessive and it would be great if there was a better way.
$save = ini_get('mbstring.substitute_character');
ini_set('mbstring.substitute_character', "none");
$data = mb_convert_encoding($data, 'UTF-8', $encoding);
ini_set('mbstring.substitute_character', $save);
} // @todo Get iconv running in at least some environments if that is possible.
elseif (function_exists('iconv') && $encoding != 'auto') {
// fprintf(STDOUT, "iconv found\n");
// iconv has the following behaviors:
// - Overlong representations are ignored.
// - Beyond Plane 16 is replaced with a lower char.
// - Incomplete sequences generate a warning.
$data = @iconv($encoding, 'UTF-8//IGNORE', $data);
} else {
// we can make a conforming native implementation
throw new Exception('Not implemented, please install mbstring or iconv');
}
/*
* One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.
*/
if (substr($data, 0, 3) === "\xEF\xBB\xBF") {
$data = substr($data, 3);
}
return $data;
} | php | public static function convertToUTF8($data, $encoding = 'UTF-8') {
/*
* From the HTML5 spec: Given an encoding, the bytes in the input stream must be converted to Unicode characters for the tokeniser, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below). Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode characters must be converted to U+FFFD REPLACEMENT CHARACTER code points.
*/
// mb_convert_encoding is chosen over iconv because of a bug. The best
// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643
// which contains links to the actual but reports as well as work around
// details.
if (function_exists('mb_convert_encoding')) {
// mb library has the following behaviors:
// - UTF-16 surrogates result in false.
// - Overlongs and outside Plane 16 result in empty strings.
// Before we run mb_convert_encoding we need to tell it what to do with
// characters it does not know. This could be different than the parent
// application executing this library so we store the value, change it
// to our needs, and then change it back when we are done. This feels
// a little excessive and it would be great if there was a better way.
$save = ini_get('mbstring.substitute_character');
ini_set('mbstring.substitute_character', "none");
$data = mb_convert_encoding($data, 'UTF-8', $encoding);
ini_set('mbstring.substitute_character', $save);
} // @todo Get iconv running in at least some environments if that is possible.
elseif (function_exists('iconv') && $encoding != 'auto') {
// fprintf(STDOUT, "iconv found\n");
// iconv has the following behaviors:
// - Overlong representations are ignored.
// - Beyond Plane 16 is replaced with a lower char.
// - Incomplete sequences generate a warning.
$data = @iconv($encoding, 'UTF-8//IGNORE', $data);
} else {
// we can make a conforming native implementation
throw new Exception('Not implemented, please install mbstring or iconv');
}
/*
* One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.
*/
if (substr($data, 0, 3) === "\xEF\xBB\xBF") {
$data = substr($data, 3);
}
return $data;
} | [
"public",
"static",
"function",
"convertToUTF8",
"(",
"$",
"data",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"/*\n * From the HTML5 spec: Given an encoding, the bytes in the input stream must be converted to Unicode characters for the tokeniser, as described by the rules for that encoding, except that the leading U+FEFF BYTE ORDER MARK character, if any, must not be stripped by the encoding layer (it is stripped by the rule below). Bytes or sequences of bytes in the original byte stream that could not be converted to Unicode characters must be converted to U+FFFD REPLACEMENT CHARACTER code points.\n */",
"// mb_convert_encoding is chosen over iconv because of a bug. The best",
"// details for the bug are on http://us1.php.net/manual/en/function.iconv.php#108643",
"// which contains links to the actual but reports as well as work around",
"// details.",
"if",
"(",
"function_exists",
"(",
"'mb_convert_encoding'",
")",
")",
"{",
"// mb library has the following behaviors:",
"// - UTF-16 surrogates result in false.",
"// - Overlongs and outside Plane 16 result in empty strings.",
"// Before we run mb_convert_encoding we need to tell it what to do with",
"// characters it does not know. This could be different than the parent",
"// application executing this library so we store the value, change it",
"// to our needs, and then change it back when we are done. This feels",
"// a little excessive and it would be great if there was a better way.",
"$",
"save",
"=",
"ini_get",
"(",
"'mbstring.substitute_character'",
")",
";",
"ini_set",
"(",
"'mbstring.substitute_character'",
",",
"\"none\"",
")",
";",
"$",
"data",
"=",
"mb_convert_encoding",
"(",
"$",
"data",
",",
"'UTF-8'",
",",
"$",
"encoding",
")",
";",
"ini_set",
"(",
"'mbstring.substitute_character'",
",",
"$",
"save",
")",
";",
"}",
"// @todo Get iconv running in at least some environments if that is possible.",
"elseif",
"(",
"function_exists",
"(",
"'iconv'",
")",
"&&",
"$",
"encoding",
"!=",
"'auto'",
")",
"{",
"// fprintf(STDOUT, \"iconv found\\n\");",
"// iconv has the following behaviors:",
"// - Overlong representations are ignored.",
"// - Beyond Plane 16 is replaced with a lower char.",
"// - Incomplete sequences generate a warning.",
"$",
"data",
"=",
"@",
"iconv",
"(",
"$",
"encoding",
",",
"'UTF-8//IGNORE'",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"// we can make a conforming native implementation",
"throw",
"new",
"Exception",
"(",
"'Not implemented, please install mbstring or iconv'",
")",
";",
"}",
"/*\n * One leading U+FEFF BYTE ORDER MARK character must be ignored if any are present.\n */",
"if",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"3",
")",
"===",
"\"\\xEF\\xBB\\xBF\"",
")",
"{",
"$",
"data",
"=",
"substr",
"(",
"$",
"data",
",",
"3",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Convert data from the given encoding to UTF-8.
This has not yet been tested with charactersets other than UTF-8.
It should work with ISO-8859-1/-13 and standard Latin Win charsets.
@param string $data
The data to convert.
@param string $encoding
A valid encoding. Examples: http://www.php.net/manual/en/mbstring.supported-encodings.php | [
"Convert",
"data",
"from",
"the",
"given",
"encoding",
"to",
"UTF",
"-",
"8",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/UTF8Utils.php#L161-L204 |
PHPPowertools/HTML5 | src/PowerTools/HTML5/Parser/UTF8Utils.php | HTML5_Parser_UTF8Utils.checkForIllegalCodepoints | public static function checkForIllegalCodepoints($data) {
if (!function_exists('preg_match_all')) {
throw HTML5_Exception('The PCRE library is not loaded or is not available.');
}
// Vestigal error handling.
$errors = array();
/*
* All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.
*/
for ($i = 0, $count = substr_count($data, "\0"); $i < $count; $i ++) {
$errors[] = 'null-character';
}
/*
* Any occurrences of any characters in the ranges U+0001 to U+0008, U+000B, U+000E to U+001F, U+007F to U+009F, U+D800 to U+DFFF , U+FDD0 to U+FDEF, and characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are parse errors. (These are all control characters or permanently undefined Unicode characters.)
*/
// Check PCRE is loaded.
$count = preg_match_all(
'/(?:
[\x01-\x08\x0B\x0E-\x1F\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F
|
\xC2[\x80-\x9F] # U+0080 to U+009F
|
\xED(?:\xA0[\x80-\xFF]|[\xA1-\xBE][\x00-\xFF]|\xBF[\x00-\xBF]) # U+D800 to U+DFFFF
|
\xEF\xB7[\x90-\xAF] # U+FDD0 to U+FDEF
|
\xEF\xBF[\xBE\xBF] # U+FFFE and U+FFFF
|
[\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})
)/x', $data, $matches);
for ($i = 0; $i < $count; $i ++) {
$errors[] = 'invalid-codepoint';
}
return $errors;
} | php | public static function checkForIllegalCodepoints($data) {
if (!function_exists('preg_match_all')) {
throw HTML5_Exception('The PCRE library is not loaded or is not available.');
}
// Vestigal error handling.
$errors = array();
/*
* All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.
*/
for ($i = 0, $count = substr_count($data, "\0"); $i < $count; $i ++) {
$errors[] = 'null-character';
}
/*
* Any occurrences of any characters in the ranges U+0001 to U+0008, U+000B, U+000E to U+001F, U+007F to U+009F, U+D800 to U+DFFF , U+FDD0 to U+FDEF, and characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are parse errors. (These are all control characters or permanently undefined Unicode characters.)
*/
// Check PCRE is loaded.
$count = preg_match_all(
'/(?:
[\x01-\x08\x0B\x0E-\x1F\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F
|
\xC2[\x80-\x9F] # U+0080 to U+009F
|
\xED(?:\xA0[\x80-\xFF]|[\xA1-\xBE][\x00-\xFF]|\xBF[\x00-\xBF]) # U+D800 to U+DFFFF
|
\xEF\xB7[\x90-\xAF] # U+FDD0 to U+FDEF
|
\xEF\xBF[\xBE\xBF] # U+FFFE and U+FFFF
|
[\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})
)/x', $data, $matches);
for ($i = 0; $i < $count; $i ++) {
$errors[] = 'invalid-codepoint';
}
return $errors;
} | [
"public",
"static",
"function",
"checkForIllegalCodepoints",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'preg_match_all'",
")",
")",
"{",
"throw",
"HTML5_Exception",
"(",
"'The PCRE library is not loaded or is not available.'",
")",
";",
"}",
"// Vestigal error handling.",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/*\n * All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.\n */",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"substr_count",
"(",
"$",
"data",
",",
"\"\\0\"",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'null-character'",
";",
"}",
"/*\n * Any occurrences of any characters in the ranges U+0001 to U+0008, U+000B, U+000E to U+001F, U+007F to U+009F, U+D800 to U+DFFF , U+FDD0 to U+FDEF, and characters U+FFFE, U+FFFF, U+1FFFE, U+1FFFF, U+2FFFE, U+2FFFF, U+3FFFE, U+3FFFF, U+4FFFE, U+4FFFF, U+5FFFE, U+5FFFF, U+6FFFE, U+6FFFF, U+7FFFE, U+7FFFF, U+8FFFE, U+8FFFF, U+9FFFE, U+9FFFF, U+AFFFE, U+AFFFF, U+BFFFE, U+BFFFF, U+CFFFE, U+CFFFF, U+DFFFE, U+DFFFF, U+EFFFE, U+EFFFF, U+FFFFE, U+FFFFF, U+10FFFE, and U+10FFFF are parse errors. (These are all control characters or permanently undefined Unicode characters.)\n */",
"// Check PCRE is loaded.",
"$",
"count",
"=",
"preg_match_all",
"(",
"'/(?:\n [\\x01-\\x08\\x0B\\x0E-\\x1F\\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F\n |\n \\xC2[\\x80-\\x9F] # U+0080 to U+009F\n |\n \\xED(?:\\xA0[\\x80-\\xFF]|[\\xA1-\\xBE][\\x00-\\xFF]|\\xBF[\\x00-\\xBF]) # U+D800 to U+DFFFF\n |\n \\xEF\\xB7[\\x90-\\xAF] # U+FDD0 to U+FDEF\n |\n \\xEF\\xBF[\\xBE\\xBF] # U+FFFE and U+FFFF\n |\n [\\xF0-\\xF4][\\x8F-\\xBF]\\xBF[\\xBE\\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16})\n )/x'",
",",
"$",
"data",
",",
"$",
"matches",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"'invalid-codepoint'",
";",
"}",
"return",
"$",
"errors",
";",
"}"
] | Checks for Unicode code points that are not valid in a document.
@param string $data
A string to analyze.
@return array An array of (string) error messages produced by the scanning. | [
"Checks",
"for",
"Unicode",
"code",
"points",
"that",
"are",
"not",
"valid",
"in",
"a",
"document",
"."
] | train | https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/UTF8Utils.php#L213-L251 |
wplibs/rules | src/Rule.php | Rule.apply | public function apply( $context ) {
if ( ! $context instanceof RContext ) {
$context = new Context( $context );
}
return $this->evaluate( $context );
} | php | public function apply( $context ) {
if ( ! $context instanceof RContext ) {
$context = new Context( $context );
}
return $this->evaluate( $context );
} | [
"public",
"function",
"apply",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"instanceof",
"RContext",
")",
"{",
"$",
"context",
"=",
"new",
"Context",
"(",
"$",
"context",
")",
";",
"}",
"return",
"$",
"this",
"->",
"evaluate",
"(",
"$",
"context",
")",
";",
"}"
] | Evaluate the Rule with the given Context.
@param \Ruler\Context|array $context Context with which to evaluate this Rule.
@return boolean | [
"Evaluate",
"the",
"Rule",
"with",
"the",
"given",
"Context",
"."
] | train | https://github.com/wplibs/rules/blob/29b4495e2ae87349fd64fcd844f3ba96cc268e3d/src/Rule.php#L31-L37 |
Eresus/EresusCMS | src/core/classes/WebPage.php | HtmlElement.getAttribute | public function getAttribute($name)
{
if (!isset($this->attrs[$name]))
{
return null;
}
return $this->attrs[$name];
} | php | public function getAttribute($name)
{
if (!isset($this->attrs[$name]))
{
return null;
}
return $this->attrs[$name];
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attrs",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"attrs",
"[",
"$",
"name",
"]",
";",
"}"
] | Возвращает значение атрибута
@param string $name имя атрибута
@return mixed
@since 2.15 | [
"Возвращает",
"значение",
"атрибута"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/WebPage.php#L97-L105 |
Eresus/EresusCMS | src/core/classes/WebPage.php | HtmlElement.getHTML | public function getHTML()
{
// Открывающий тег
$html = '<' . $this->tagName;
/* Добавляем атрибуты */
foreach ($this->attrs as $name => $value)
{
$html .= ' ' . $name;
if ($value !== true)
{
$html .= '="' . $value . '"';
}
}
$html .= '>';
/* Если есть содержимое, то добавляем его и закрывающий тег */
if ($this->contents !== null)
{
$html .= $this->contents . '</' . $this->tagName . '>';
}
return $html;
} | php | public function getHTML()
{
// Открывающий тег
$html = '<' . $this->tagName;
/* Добавляем атрибуты */
foreach ($this->attrs as $name => $value)
{
$html .= ' ' . $name;
if ($value !== true)
{
$html .= '="' . $value . '"';
}
}
$html .= '>';
/* Если есть содержимое, то добавляем его и закрывающий тег */
if ($this->contents !== null)
{
$html .= $this->contents . '</' . $this->tagName . '>';
}
return $html;
} | [
"public",
"function",
"getHTML",
"(",
")",
"{",
"// Открывающий тег",
"$",
"html",
"=",
"'<'",
".",
"$",
"this",
"->",
"tagName",
";",
"/* Добавляем атрибуты */",
"foreach",
"(",
"$",
"this",
"->",
"attrs",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"html",
".=",
"' '",
".",
"$",
"name",
";",
"if",
"(",
"$",
"value",
"!==",
"true",
")",
"{",
"$",
"html",
".=",
"'=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"}",
"}",
"$",
"html",
".=",
"'>'",
";",
"/* Если есть содержимое, то добавляем его и закрывающий тег */",
"if",
"(",
"$",
"this",
"->",
"contents",
"!==",
"null",
")",
"{",
"$",
"html",
".=",
"$",
"this",
"->",
"contents",
".",
"'</'",
".",
"$",
"this",
"->",
"tagName",
".",
"'>'",
";",
"}",
"return",
"$",
"html",
";",
"}"
] | Возвращает разметку элемента
@return string разметка HTML
@since 2.15 | [
"Возвращает",
"разметку",
"элемента"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/WebPage.php#L130-L155 |
Eresus/EresusCMS | src/core/classes/WebPage.php | WebPage.url | public function url($args = array())
{
global $Eresus;
/* Объединяем аргументы метода и аргументы текущего запроса */
$args = array_merge($Eresus->request['arg'], $args);
/* Превращаем значения-массивы в строки, соединяя элементы запятой */
foreach ($args as $key => $value)
{
if (is_array($value))
{
$args[$key] = implode(',', $value);
}
}
$result = array();
foreach ($args as $key => $value)
{
if ($value !== '')
{
$result []= "$key=$value";
}
}
$result = implode('&', $result);
$result = Eresus_CMS::getLegacyKernel()->request['path'] .'?'.$result;
return $result;
} | php | public function url($args = array())
{
global $Eresus;
/* Объединяем аргументы метода и аргументы текущего запроса */
$args = array_merge($Eresus->request['arg'], $args);
/* Превращаем значения-массивы в строки, соединяя элементы запятой */
foreach ($args as $key => $value)
{
if (is_array($value))
{
$args[$key] = implode(',', $value);
}
}
$result = array();
foreach ($args as $key => $value)
{
if ($value !== '')
{
$result []= "$key=$value";
}
}
$result = implode('&', $result);
$result = Eresus_CMS::getLegacyKernel()->request['path'] .'?'.$result;
return $result;
} | [
"public",
"function",
"url",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"Eresus",
";",
"/* Объединяем аргументы метода и аргументы текущего запроса */",
"$",
"args",
"=",
"array_merge",
"(",
"$",
"Eresus",
"->",
"request",
"[",
"'arg'",
"]",
",",
"$",
"args",
")",
";",
"/* Превращаем значения-массивы в строки, соединяя элементы запятой */",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"args",
"[",
"$",
"key",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"''",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\"$key=$value\"",
";",
"}",
"}",
"$",
"result",
"=",
"implode",
"(",
"'&'",
",",
"$",
"result",
")",
";",
"$",
"result",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'path'",
"]",
".",
"'?'",
".",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] | Строит URL GET-запроса на основе переданных аргументов
URL будет состоять из двух частей:
1. Адрес текущего раздела ($Eresus->request['path'])
2. key=value аргументы
Список аргументов составляется объединением списка аргументов текущего запроса
и элементов массива $args. Элементы $args имеют приоритет над аргументами текущего
запроса.
Если значение аргумента - пустая строка, он будет удалён из запроса.
Если значение аргумента – массив, то его элементы будут объединены в строку через запятую.
<b>Пример</b>
Обрабатывается запрос: http://example.com/page/?name=igor&second_name=orlov&date=18.11.10
<code>
$args = array(
'second_name' => 'zotov',
'date' => '',
'age' => 31,
'flags' => array('new', 'customer', 'discount'),
);
return $page->url($args);
</code>
Этот код:
- Оставит ''name'' нетронутым, потому что его нет в $args
- Заменит значение ''second_name''
- Удалит аргумент ''date''
- Добавит числовой аргумент ''age''
- Добавит массив ''flags''
Получится:
http://example.com/page/?name=igor&second_name=zotov&age=31&flags=new,customer,discount
@param array $args Установить аргументы
@return string
@since 2.10 | [
"Строит",
"URL",
"GET",
"-",
"запроса",
"на",
"основе",
"переданных",
"аргументов"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/WebPage.php#L307-L335 |
Eresus/EresusCMS | src/core/classes/WebPage.php | WebPage.clientURL | public function clientURL($id)
{
$parents = Eresus_CMS::getLegacyKernel()->sections->parents($id);
if (is_null($parents))
{
return null;
}
array_push($parents, $id);
$items = Eresus_CMS::getLegacyKernel()->sections->get( $parents);
$list = array();
for ($i = 0; $i < count($items); $i++)
{
$list[array_search($items[$i]['id'], $parents)-1] = $items[$i]['name'];
}
$result = Eresus_CMS::getLegacyKernel()->root;
for ($i = 0; $i < count($list); $i++)
{
$result .= $list[$i].'/';
}
return $result;
} | php | public function clientURL($id)
{
$parents = Eresus_CMS::getLegacyKernel()->sections->parents($id);
if (is_null($parents))
{
return null;
}
array_push($parents, $id);
$items = Eresus_CMS::getLegacyKernel()->sections->get( $parents);
$list = array();
for ($i = 0; $i < count($items); $i++)
{
$list[array_search($items[$i]['id'], $parents)-1] = $items[$i]['name'];
}
$result = Eresus_CMS::getLegacyKernel()->root;
for ($i = 0; $i < count($list); $i++)
{
$result .= $list[$i].'/';
}
return $result;
} | [
"public",
"function",
"clientURL",
"(",
"$",
"id",
")",
"{",
"$",
"parents",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"parents",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"parents",
")",
")",
"{",
"return",
"null",
";",
"}",
"array_push",
"(",
"$",
"parents",
",",
"$",
"id",
")",
";",
"$",
"items",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"sections",
"->",
"get",
"(",
"$",
"parents",
")",
";",
"$",
"list",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"items",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"list",
"[",
"array_search",
"(",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'id'",
"]",
",",
"$",
"parents",
")",
"-",
"1",
"]",
"=",
"$",
"items",
"[",
"$",
"i",
"]",
"[",
"'name'",
"]",
";",
"}",
"$",
"result",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"root",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"list",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"result",
".=",
"$",
"list",
"[",
"$",
"i",
"]",
".",
"'/'",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Возвращает клиентский URL страницы с идентификатором $id
@param int $id Идентификатор страницы
@return string URL страницы или NULL если раздела $id не существует
@since 2.10 | [
"Возвращает",
"клиентский",
"URL",
"страницы",
"с",
"идентификатором",
"$id"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/WebPage.php#L346-L370 |
Eresus/EresusCMS | src/core/classes/WebPage.php | WebPage.pageSelector | public function pageSelector($total, $current, $url = null, $templates = null)
{
# Загрузка шаблонов
if (!is_array($templates))
{
$templates = array();
}
for ($i=0; $i < 5; $i++)
{
if (!isset($templates[$i]))
{
$templates[$i] = $this->defaults['pageselector'][$i];
}
}
if (is_null($url))
{
$url = Eresus_CMS::getLegacyKernel()->request['path'].'p%d/';
}
$pages = array(); # Отображаемые страницы
# Определяем номера первой и последней отображаемых страниц
$visible = 10;
if ($total > $visible)
{
# Будут показаны НЕ все страницы
$from = floor($current - $visible / 2); # Начинаем показ с текущей минус половину видимых
if ($from < 1)
{
$from = 1; # Страниц меньше 1-й не существует
}
$to = $from + $visible - 1; # мы должны показать $visible страниц
if ($to > $total)
{
# Но если это больше чем страниц всего, вносим исправления
$to = $total;
$from = $to - $visible + 1;
}
}
else
{
# Будут показаны все страницы
$from = 1;
$to = $total;
}
for ($i = $from; $i <= $to; $i++)
{
$src['href'] = sprintf($url, $i);
$src['number'] = $i;
$pages[] = replaceMacros($templates[$i != $current ? 1 : 2], $src);
}
$pages = implode('', $pages);
if ($from != 1)
{
$pages = replaceMacros($templates[3], array('href' => sprintf($url, 1))).$pages;
}
if ($to != $total)
{
$pages .= replaceMacros($templates[4], array('href' => sprintf($url, $total)));
}
$result = replaceMacros($templates[0], array('pages' => $pages));
return $result;
} | php | public function pageSelector($total, $current, $url = null, $templates = null)
{
# Загрузка шаблонов
if (!is_array($templates))
{
$templates = array();
}
for ($i=0; $i < 5; $i++)
{
if (!isset($templates[$i]))
{
$templates[$i] = $this->defaults['pageselector'][$i];
}
}
if (is_null($url))
{
$url = Eresus_CMS::getLegacyKernel()->request['path'].'p%d/';
}
$pages = array(); # Отображаемые страницы
# Определяем номера первой и последней отображаемых страниц
$visible = 10;
if ($total > $visible)
{
# Будут показаны НЕ все страницы
$from = floor($current - $visible / 2); # Начинаем показ с текущей минус половину видимых
if ($from < 1)
{
$from = 1; # Страниц меньше 1-й не существует
}
$to = $from + $visible - 1; # мы должны показать $visible страниц
if ($to > $total)
{
# Но если это больше чем страниц всего, вносим исправления
$to = $total;
$from = $to - $visible + 1;
}
}
else
{
# Будут показаны все страницы
$from = 1;
$to = $total;
}
for ($i = $from; $i <= $to; $i++)
{
$src['href'] = sprintf($url, $i);
$src['number'] = $i;
$pages[] = replaceMacros($templates[$i != $current ? 1 : 2], $src);
}
$pages = implode('', $pages);
if ($from != 1)
{
$pages = replaceMacros($templates[3], array('href' => sprintf($url, 1))).$pages;
}
if ($to != $total)
{
$pages .= replaceMacros($templates[4], array('href' => sprintf($url, $total)));
}
$result = replaceMacros($templates[0], array('pages' => $pages));
return $result;
} | [
"public",
"function",
"pageSelector",
"(",
"$",
"total",
",",
"$",
"current",
",",
"$",
"url",
"=",
"null",
",",
"$",
"templates",
"=",
"null",
")",
"{",
"# Загрузка шаблонов",
"if",
"(",
"!",
"is_array",
"(",
"$",
"templates",
")",
")",
"{",
"$",
"templates",
"=",
"array",
"(",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"5",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"templates",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"templates",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"defaults",
"[",
"'pageselector'",
"]",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"request",
"[",
"'path'",
"]",
".",
"'p%d/'",
";",
"}",
"$",
"pages",
"=",
"array",
"(",
")",
";",
"# Отображаемые страницы",
"# Определяем номера первой и последней отображаемых страниц",
"$",
"visible",
"=",
"10",
";",
"if",
"(",
"$",
"total",
">",
"$",
"visible",
")",
"{",
"# Будут показаны НЕ все страницы",
"$",
"from",
"=",
"floor",
"(",
"$",
"current",
"-",
"$",
"visible",
"/",
"2",
")",
";",
"# Начинаем показ с текущей минус половину видимых",
"if",
"(",
"$",
"from",
"<",
"1",
")",
"{",
"$",
"from",
"=",
"1",
";",
"# Страниц меньше 1-й не существует",
"}",
"$",
"to",
"=",
"$",
"from",
"+",
"$",
"visible",
"-",
"1",
";",
"# мы должны показать $visible страниц",
"if",
"(",
"$",
"to",
">",
"$",
"total",
")",
"{",
"# Но если это больше чем страниц всего, вносим исправления",
"$",
"to",
"=",
"$",
"total",
";",
"$",
"from",
"=",
"$",
"to",
"-",
"$",
"visible",
"+",
"1",
";",
"}",
"}",
"else",
"{",
"# Будут показаны все страницы",
"$",
"from",
"=",
"1",
";",
"$",
"to",
"=",
"$",
"total",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"$",
"from",
";",
"$",
"i",
"<=",
"$",
"to",
";",
"$",
"i",
"++",
")",
"{",
"$",
"src",
"[",
"'href'",
"]",
"=",
"sprintf",
"(",
"$",
"url",
",",
"$",
"i",
")",
";",
"$",
"src",
"[",
"'number'",
"]",
"=",
"$",
"i",
";",
"$",
"pages",
"[",
"]",
"=",
"replaceMacros",
"(",
"$",
"templates",
"[",
"$",
"i",
"!=",
"$",
"current",
"?",
"1",
":",
"2",
"]",
",",
"$",
"src",
")",
";",
"}",
"$",
"pages",
"=",
"implode",
"(",
"''",
",",
"$",
"pages",
")",
";",
"if",
"(",
"$",
"from",
"!=",
"1",
")",
"{",
"$",
"pages",
"=",
"replaceMacros",
"(",
"$",
"templates",
"[",
"3",
"]",
",",
"array",
"(",
"'href'",
"=>",
"sprintf",
"(",
"$",
"url",
",",
"1",
")",
")",
")",
".",
"$",
"pages",
";",
"}",
"if",
"(",
"$",
"to",
"!=",
"$",
"total",
")",
"{",
"$",
"pages",
".=",
"replaceMacros",
"(",
"$",
"templates",
"[",
"4",
"]",
",",
"array",
"(",
"'href'",
"=>",
"sprintf",
"(",
"$",
"url",
",",
"$",
"total",
")",
")",
")",
";",
"}",
"$",
"result",
"=",
"replaceMacros",
"(",
"$",
"templates",
"[",
"0",
"]",
",",
"array",
"(",
"'pages'",
"=>",
"$",
"pages",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Отрисовка переключателя страниц
@param int $total Общее количество страниц
@param int $current Номер текущей страницы
@param string $url Шаблон адреса для перехода к подстранице
@param array $templates Шаблоны оформления
@return string
@since 2.10
@deprecated с 3.01 используйте {@link PaginationHelper} | [
"Отрисовка",
"переключателя",
"страниц"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/WebPage.php#L385-L449 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.composeEmailAddress | public static function composeEmailAddress( ezcMailAddress $item )
{
$name = trim( $item->name );
if ( $name !== '' )
{
// remove the quotes around the name part if they are already there
if ( $name{0} === '"' && $name{strlen( $name ) - 1} === '"' )
{
$name = substr( $name, 1, -1 );
}
// add slashes to " and \ and surround the name part with quotes
if ( strpbrk( $name, ",@<>:;'\"" ) !== false )
{
$name = str_replace( '\\', '\\\\', $name );
$name = str_replace( '"', '\"', $name );
$name = "\"{$name}\"";
}
switch ( strtolower( $item->charset ) )
{
case 'us-ascii':
$text = $name . ' <' . $item->email . '>';
break;
case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-3': case 'iso-8859-4':
case 'iso-8859-5': case 'iso-8859-6': case 'iso-8859-7': case 'iso-8859-8':
case 'iso-8859-9': case 'iso-8859-10': case 'iso-8859-11': case 'iso-8859-12':
case 'iso-8859-13': case 'iso-8859-14': case 'iso-8859-15' :case 'iso-8859-16':
case 'windows-1250': case 'windows-1251': case 'windows-1252':
case 'utf-8':
if ( strpbrk( $name, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false )
{
$text = $name . ' <' . $item->email . '>';
break;
}
// break intentionally missing
default:
$preferences = array(
'input-charset' => $item->charset,
'output-charset' => $item->charset,
'scheme' => 'Q',
'line-break-chars' => ezcMailTools::lineBreak(),
'line-length' => 996
);
$name = iconv_mime_encode( 'dummy', $name, $preferences );
$name = substr( $name, 7 ); // "dummy: " + 1
$text = $name . ' <' . $item->email . '>';
break;
}
}
else
{
$text = $item->email;
}
return $text;
} | php | public static function composeEmailAddress( ezcMailAddress $item )
{
$name = trim( $item->name );
if ( $name !== '' )
{
// remove the quotes around the name part if they are already there
if ( $name{0} === '"' && $name{strlen( $name ) - 1} === '"' )
{
$name = substr( $name, 1, -1 );
}
// add slashes to " and \ and surround the name part with quotes
if ( strpbrk( $name, ",@<>:;'\"" ) !== false )
{
$name = str_replace( '\\', '\\\\', $name );
$name = str_replace( '"', '\"', $name );
$name = "\"{$name}\"";
}
switch ( strtolower( $item->charset ) )
{
case 'us-ascii':
$text = $name . ' <' . $item->email . '>';
break;
case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-3': case 'iso-8859-4':
case 'iso-8859-5': case 'iso-8859-6': case 'iso-8859-7': case 'iso-8859-8':
case 'iso-8859-9': case 'iso-8859-10': case 'iso-8859-11': case 'iso-8859-12':
case 'iso-8859-13': case 'iso-8859-14': case 'iso-8859-15' :case 'iso-8859-16':
case 'windows-1250': case 'windows-1251': case 'windows-1252':
case 'utf-8':
if ( strpbrk( $name, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false )
{
$text = $name . ' <' . $item->email . '>';
break;
}
// break intentionally missing
default:
$preferences = array(
'input-charset' => $item->charset,
'output-charset' => $item->charset,
'scheme' => 'Q',
'line-break-chars' => ezcMailTools::lineBreak(),
'line-length' => 996
);
$name = iconv_mime_encode( 'dummy', $name, $preferences );
$name = substr( $name, 7 ); // "dummy: " + 1
$text = $name . ' <' . $item->email . '>';
break;
}
}
else
{
$text = $item->email;
}
return $text;
} | [
"public",
"static",
"function",
"composeEmailAddress",
"(",
"ezcMailAddress",
"$",
"item",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"item",
"->",
"name",
")",
";",
"if",
"(",
"$",
"name",
"!==",
"''",
")",
"{",
"// remove the quotes around the name part if they are already there",
"if",
"(",
"$",
"name",
"{",
"0",
"}",
"===",
"'\"'",
"&&",
"$",
"name",
"{",
"strlen",
"(",
"$",
"name",
")",
"-",
"1",
"}",
"===",
"'\"'",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"// add slashes to \" and \\ and surround the name part with quotes",
"if",
"(",
"strpbrk",
"(",
"$",
"name",
",",
"\",@<>:;'\\\"\"",
")",
"!==",
"false",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"'\"'",
",",
"'\\\"'",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"\"\\\"{$name}\\\"\"",
";",
"}",
"switch",
"(",
"strtolower",
"(",
"$",
"item",
"->",
"charset",
")",
")",
"{",
"case",
"'us-ascii'",
":",
"$",
"text",
"=",
"$",
"name",
".",
"' <'",
".",
"$",
"item",
"->",
"email",
".",
"'>'",
";",
"break",
";",
"case",
"'iso-8859-1'",
":",
"case",
"'iso-8859-2'",
":",
"case",
"'iso-8859-3'",
":",
"case",
"'iso-8859-4'",
":",
"case",
"'iso-8859-5'",
":",
"case",
"'iso-8859-6'",
":",
"case",
"'iso-8859-7'",
":",
"case",
"'iso-8859-8'",
":",
"case",
"'iso-8859-9'",
":",
"case",
"'iso-8859-10'",
":",
"case",
"'iso-8859-11'",
":",
"case",
"'iso-8859-12'",
":",
"case",
"'iso-8859-13'",
":",
"case",
"'iso-8859-14'",
":",
"case",
"'iso-8859-15'",
":",
"case",
"'iso-8859-16'",
":",
"case",
"'windows-1250'",
":",
"case",
"'windows-1251'",
":",
"case",
"'windows-1252'",
":",
"case",
"'utf-8'",
":",
"if",
"(",
"strpbrk",
"(",
"$",
"name",
",",
"\"\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff\"",
")",
"===",
"false",
")",
"{",
"$",
"text",
"=",
"$",
"name",
".",
"' <'",
".",
"$",
"item",
"->",
"email",
".",
"'>'",
";",
"break",
";",
"}",
"// break intentionally missing",
"default",
":",
"$",
"preferences",
"=",
"array",
"(",
"'input-charset'",
"=>",
"$",
"item",
"->",
"charset",
",",
"'output-charset'",
"=>",
"$",
"item",
"->",
"charset",
",",
"'scheme'",
"=>",
"'Q'",
",",
"'line-break-chars'",
"=>",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
",",
"'line-length'",
"=>",
"996",
")",
";",
"$",
"name",
"=",
"iconv_mime_encode",
"(",
"'dummy'",
",",
"$",
"name",
",",
"$",
"preferences",
")",
";",
"$",
"name",
"=",
"substr",
"(",
"$",
"name",
",",
"7",
")",
";",
"// \"dummy: \" + 1",
"$",
"text",
"=",
"$",
"name",
".",
"' <'",
".",
"$",
"item",
"->",
"email",
".",
"'>'",
";",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"item",
"->",
"email",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Returns ezcMailAddress $item as a RFC822 compliant address string.
Example:
<code>
composeEmailAddress( new ezcMailAddress( '[email protected]', 'John Doe' ) );
</code>
Returns:
<pre>
John Doe <[email protected]>
</pre>
The name part of $item will be surrounded by quotes if it contains any of
these characters: , @ < > : ; ' "
@param ezcMailAddress $item
@return string | [
"Returns",
"ezcMailAddress",
"$item",
"as",
"a",
"RFC822",
"compliant",
"address",
"string",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L86-L143 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.composeEmailAddresses | public static function composeEmailAddresses( array $items, $foldLength = null )
{
$textElements = array();
foreach ( $items as $item )
{
$textElements[] = ezcMailTools::composeEmailAddress( $item );
}
if ( $foldLength === null ) // quick version
{
return implode( ', ', $textElements );
}
$result = "";
$charsSinceFold = 0;
foreach ( $textElements as $element )
{
$length = strlen( $element );
if ( ( $charsSinceFold + $length + 2 /* comma, space */ ) > $foldLength )
{
// fold last line if there is any
if ( $result != '' )
{
$result .= "," . ezcMailTools::lineBreak() .' ';
$charsSinceFold = 0;
}
$result .= $element;
}
else
{
if ( $result == '' )
{
$result = $element;
}
else
{
$result .= ', ' . $element;
}
}
$charsSinceFold += $length + 1 /*space*/;
}
return $result;
} | php | public static function composeEmailAddresses( array $items, $foldLength = null )
{
$textElements = array();
foreach ( $items as $item )
{
$textElements[] = ezcMailTools::composeEmailAddress( $item );
}
if ( $foldLength === null ) // quick version
{
return implode( ', ', $textElements );
}
$result = "";
$charsSinceFold = 0;
foreach ( $textElements as $element )
{
$length = strlen( $element );
if ( ( $charsSinceFold + $length + 2 /* comma, space */ ) > $foldLength )
{
// fold last line if there is any
if ( $result != '' )
{
$result .= "," . ezcMailTools::lineBreak() .' ';
$charsSinceFold = 0;
}
$result .= $element;
}
else
{
if ( $result == '' )
{
$result = $element;
}
else
{
$result .= ', ' . $element;
}
}
$charsSinceFold += $length + 1 /*space*/;
}
return $result;
} | [
"public",
"static",
"function",
"composeEmailAddresses",
"(",
"array",
"$",
"items",
",",
"$",
"foldLength",
"=",
"null",
")",
"{",
"$",
"textElements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"textElements",
"[",
"]",
"=",
"ezcMailTools",
"::",
"composeEmailAddress",
"(",
"$",
"item",
")",
";",
"}",
"if",
"(",
"$",
"foldLength",
"===",
"null",
")",
"// quick version",
"{",
"return",
"implode",
"(",
"', '",
",",
"$",
"textElements",
")",
";",
"}",
"$",
"result",
"=",
"\"\"",
";",
"$",
"charsSinceFold",
"=",
"0",
";",
"foreach",
"(",
"$",
"textElements",
"as",
"$",
"element",
")",
"{",
"$",
"length",
"=",
"strlen",
"(",
"$",
"element",
")",
";",
"if",
"(",
"(",
"$",
"charsSinceFold",
"+",
"$",
"length",
"+",
"2",
"/* comma, space */",
")",
">",
"$",
"foldLength",
")",
"{",
"// fold last line if there is any",
"if",
"(",
"$",
"result",
"!=",
"''",
")",
"{",
"$",
"result",
".=",
"\",\"",
".",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
".",
"' '",
";",
"$",
"charsSinceFold",
"=",
"0",
";",
"}",
"$",
"result",
".=",
"$",
"element",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"result",
"==",
"''",
")",
"{",
"$",
"result",
"=",
"$",
"element",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"', '",
".",
"$",
"element",
";",
"}",
"}",
"$",
"charsSinceFold",
"+=",
"$",
"length",
"+",
"1",
"/*space*/",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the array $items consisting of ezcMailAddress objects
as one RFC822 compliant address string.
Set foldLength to control how many characters each line can have before a line
break is inserted according to the folding rules specified in RFC2822.
@param array(ezcMailAddress) $items
@param int $foldLength
@return string | [
"Returns",
"the",
"array",
"$items",
"consisting",
"of",
"ezcMailAddress",
"objects",
"as",
"one",
"RFC822",
"compliant",
"address",
"string",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L156-L198 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.parseEmailAddress | public static function parseEmailAddress( $address, $encoding = "mime" )
{
// we don't care about the "group" part of the address since this is not used anywhere
$matches = array();
$pattern = '/<?\"?[a-zA-Z0-9!#\$\%\&\'\*\+\-\/=\?\^_`{\|}~\.]+\"?@[a-zA-Z0-9!#\$\%\&\'\*\+\-\/=\?\^_`{\|}~\.]+>?$/';
if ( preg_match( trim( $pattern ), $address, $matches, PREG_OFFSET_CAPTURE ) != 1 )
{
return null;
}
$name = substr( $address, 0, $matches[0][1] );
// trim <> from the address and "" from the name
$name = trim( $name, '" ' );
$mail = trim( $matches[0][0], '<>' );
// remove any quotes found in mail addresses like "bah,"@example.com
$mail = str_replace( '"', '', $mail );
if ( $encoding == 'mime' )
{
// the name may contain interesting character encoding. We need to convert it.
$name = ezcMailTools::mimeDecode( $name );
}
else
{
$name = ezcMailCharsetConverter::convertToUTF8( $name, $encoding );
}
$address = new ezcMailAddress( $mail, $name, 'utf-8' );
return $address;
} | php | public static function parseEmailAddress( $address, $encoding = "mime" )
{
// we don't care about the "group" part of the address since this is not used anywhere
$matches = array();
$pattern = '/<?\"?[a-zA-Z0-9!#\$\%\&\'\*\+\-\/=\?\^_`{\|}~\.]+\"?@[a-zA-Z0-9!#\$\%\&\'\*\+\-\/=\?\^_`{\|}~\.]+>?$/';
if ( preg_match( trim( $pattern ), $address, $matches, PREG_OFFSET_CAPTURE ) != 1 )
{
return null;
}
$name = substr( $address, 0, $matches[0][1] );
// trim <> from the address and "" from the name
$name = trim( $name, '" ' );
$mail = trim( $matches[0][0], '<>' );
// remove any quotes found in mail addresses like "bah,"@example.com
$mail = str_replace( '"', '', $mail );
if ( $encoding == 'mime' )
{
// the name may contain interesting character encoding. We need to convert it.
$name = ezcMailTools::mimeDecode( $name );
}
else
{
$name = ezcMailCharsetConverter::convertToUTF8( $name, $encoding );
}
$address = new ezcMailAddress( $mail, $name, 'utf-8' );
return $address;
} | [
"public",
"static",
"function",
"parseEmailAddress",
"(",
"$",
"address",
",",
"$",
"encoding",
"=",
"\"mime\"",
")",
"{",
"// we don't care about the \"group\" part of the address since this is not used anywhere",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"pattern",
"=",
"'/<?\\\"?[a-zA-Z0-9!#\\$\\%\\&\\'\\*\\+\\-\\/=\\?\\^_`{\\|}~\\.]+\\\"?@[a-zA-Z0-9!#\\$\\%\\&\\'\\*\\+\\-\\/=\\?\\^_`{\\|}~\\.]+>?$/'",
";",
"if",
"(",
"preg_match",
"(",
"trim",
"(",
"$",
"pattern",
")",
",",
"$",
"address",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
"!=",
"1",
")",
"{",
"return",
"null",
";",
"}",
"$",
"name",
"=",
"substr",
"(",
"$",
"address",
",",
"0",
",",
"$",
"matches",
"[",
"0",
"]",
"[",
"1",
"]",
")",
";",
"// trim <> from the address and \"\" from the name",
"$",
"name",
"=",
"trim",
"(",
"$",
"name",
",",
"'\" '",
")",
";",
"$",
"mail",
"=",
"trim",
"(",
"$",
"matches",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"'<>'",
")",
";",
"// remove any quotes found in mail addresses like \"bah,\"@example.com",
"$",
"mail",
"=",
"str_replace",
"(",
"'\"'",
",",
"''",
",",
"$",
"mail",
")",
";",
"if",
"(",
"$",
"encoding",
"==",
"'mime'",
")",
"{",
"// the name may contain interesting character encoding. We need to convert it.",
"$",
"name",
"=",
"ezcMailTools",
"::",
"mimeDecode",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"ezcMailCharsetConverter",
"::",
"convertToUTF8",
"(",
"$",
"name",
",",
"$",
"encoding",
")",
";",
"}",
"$",
"address",
"=",
"new",
"ezcMailAddress",
"(",
"$",
"mail",
",",
"$",
"name",
",",
"'utf-8'",
")",
";",
"return",
"$",
"address",
";",
"}"
] | Returns an ezcMailAddress object parsed from the address string $address.
You can set the encoding of the name part with the $encoding parameter.
If $encoding is omitted or set to "mime" parseEmailAddress will asume that
the name part is mime encoded.
This method does not perform validation. It will also accept slightly
malformed addresses.
If the mail address given can not be decoded null is returned.
Example:
<code>
ezcMailTools::parseEmailAddress( 'John Doe <[email protected]>' );
</code>
@param string $address
@param string $encoding
@return ezcMailAddress | [
"Returns",
"an",
"ezcMailAddress",
"object",
"parsed",
"from",
"the",
"address",
"string",
"$address",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L221-L251 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.parseEmailAddresses | public static function parseEmailAddresses( $addresses, $encoding = "mime" )
{
$addressesArray = array();
$inQuote = false;
$last = 0; // last hit
$length = strlen( $addresses );
for ( $i = 0; $i < $length; $i++ )
{
if ( $addresses[$i] == '"' )
{
$inQuote = !$inQuote;
}
else if ( $addresses[$i] == ',' && !$inQuote )
{
$addressesArray[] = substr( $addresses, $last, $i - $last );
$last = $i + 1; // eat comma
}
}
// fetch the last one
$addressesArray[] = substr( $addresses, $last );
$addressObjects = array();
foreach ( $addressesArray as $address )
{
$addressObject = self::parseEmailAddress( $address, $encoding );
if ( $addressObject !== null )
{
$addressObjects[] = $addressObject;
}
}
return $addressObjects;
} | php | public static function parseEmailAddresses( $addresses, $encoding = "mime" )
{
$addressesArray = array();
$inQuote = false;
$last = 0; // last hit
$length = strlen( $addresses );
for ( $i = 0; $i < $length; $i++ )
{
if ( $addresses[$i] == '"' )
{
$inQuote = !$inQuote;
}
else if ( $addresses[$i] == ',' && !$inQuote )
{
$addressesArray[] = substr( $addresses, $last, $i - $last );
$last = $i + 1; // eat comma
}
}
// fetch the last one
$addressesArray[] = substr( $addresses, $last );
$addressObjects = array();
foreach ( $addressesArray as $address )
{
$addressObject = self::parseEmailAddress( $address, $encoding );
if ( $addressObject !== null )
{
$addressObjects[] = $addressObject;
}
}
return $addressObjects;
} | [
"public",
"static",
"function",
"parseEmailAddresses",
"(",
"$",
"addresses",
",",
"$",
"encoding",
"=",
"\"mime\"",
")",
"{",
"$",
"addressesArray",
"=",
"array",
"(",
")",
";",
"$",
"inQuote",
"=",
"false",
";",
"$",
"last",
"=",
"0",
";",
"// last hit",
"$",
"length",
"=",
"strlen",
"(",
"$",
"addresses",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"addresses",
"[",
"$",
"i",
"]",
"==",
"'\"'",
")",
"{",
"$",
"inQuote",
"=",
"!",
"$",
"inQuote",
";",
"}",
"else",
"if",
"(",
"$",
"addresses",
"[",
"$",
"i",
"]",
"==",
"','",
"&&",
"!",
"$",
"inQuote",
")",
"{",
"$",
"addressesArray",
"[",
"]",
"=",
"substr",
"(",
"$",
"addresses",
",",
"$",
"last",
",",
"$",
"i",
"-",
"$",
"last",
")",
";",
"$",
"last",
"=",
"$",
"i",
"+",
"1",
";",
"// eat comma",
"}",
"}",
"// fetch the last one",
"$",
"addressesArray",
"[",
"]",
"=",
"substr",
"(",
"$",
"addresses",
",",
"$",
"last",
")",
";",
"$",
"addressObjects",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"addressesArray",
"as",
"$",
"address",
")",
"{",
"$",
"addressObject",
"=",
"self",
"::",
"parseEmailAddress",
"(",
"$",
"address",
",",
"$",
"encoding",
")",
";",
"if",
"(",
"$",
"addressObject",
"!==",
"null",
")",
"{",
"$",
"addressObjects",
"[",
"]",
"=",
"$",
"addressObject",
";",
"}",
"}",
"return",
"$",
"addressObjects",
";",
"}"
] | Returns an array of ezcMailAddress objects parsed from the address string $addresses.
You can set the encoding of the name parts with the $encoding parameter.
If $encoding is omitted or set to "mime" parseEmailAddresses will asume that
the name parts are mime encoded.
Example:
<code>
ezcMailTools::parseEmailAddresses( 'John Doe <[email protected]>' );
</code>
@param string $addresses
@param string $encoding
@return array(ezcMailAddress) | [
"Returns",
"an",
"array",
"of",
"ezcMailAddress",
"objects",
"parsed",
"from",
"the",
"address",
"string",
"$addresses",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L269-L302 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.validateEmailAddress | public static function validateEmailAddress( $address, $checkMxRecords = false )
{
$pattern = '/^((\"[^\"\f\n\r\t\v\b]+\")|([A-Za-z0-9_\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[A-Za-z0-9_\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]{2,}))$/';
if ( preg_match( $pattern, $address ) )
{
if ( $checkMxRecords )
{
return self::validateEmailAddressMx( $address );
}
else
{
// $address passed through regexp, with no MX checks
return true;
}
}
else
{
// $address did not pass through regexp
return false;
}
} | php | public static function validateEmailAddress( $address, $checkMxRecords = false )
{
$pattern = '/^((\"[^\"\f\n\r\t\v\b]+\")|([A-Za-z0-9_\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[A-Za-z0-9_\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]{2,}))$/';
if ( preg_match( $pattern, $address ) )
{
if ( $checkMxRecords )
{
return self::validateEmailAddressMx( $address );
}
else
{
// $address passed through regexp, with no MX checks
return true;
}
}
else
{
// $address did not pass through regexp
return false;
}
} | [
"public",
"static",
"function",
"validateEmailAddress",
"(",
"$",
"address",
",",
"$",
"checkMxRecords",
"=",
"false",
")",
"{",
"$",
"pattern",
"=",
"'/^((\\\"[^\\\"\\f\\n\\r\\t\\v\\b]+\\\")|([A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\\-])+\\.)+[A-Za-z\\-]{2,}))$/'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"address",
")",
")",
"{",
"if",
"(",
"$",
"checkMxRecords",
")",
"{",
"return",
"self",
"::",
"validateEmailAddressMx",
"(",
"$",
"address",
")",
";",
"}",
"else",
"{",
"// $address passed through regexp, with no MX checks",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"// $address did not pass through regexp",
"return",
"false",
";",
"}",
"}"
] | Returns true if $address is a valid email address, false otherwise.
By default it will only validate against the same regular expression
used in ext/filter. It follows
{@link http://www.faqs.org/rfcs/rfc822.html RFC822} and
{@link http://www.faqs.org/rfcs/rfc2822.html RFC2822}.
If $checkMxRecords is true, then an MX records check will be performed
also, by sending a test mail (RCPT TO) to $address using the MX records
found for the domain part of $address. MX record checking does not work
on Windows due to the lack of getmxrr() and checkdnsrr() PHP functions.
The ezcBaseFunctionalityNotSupportedException is thrown in this case.
If checking against MX records, set these values before performing the
check, to ensure the MX record checks work properly:
<code>
ezcMailTools::$mxValidateServer = 'your.mail.server'; // default 'smtp.ez.no'
ezcMailTools::$mxValidateAddress = '[email protected]'; // default '[email protected]'
</code>
The input email address $address should be trimmed from white spaces
and/or quotes around it before calling this function (if needed).
An email address has this form:
<code>
localpart@domainpart
</code>
The localpart has these rules, and these rules are just an approximation of
the rules in RFC2822:
- allowed characters: . + ~ / ' - _ ` ^ $ % & ! ' | {
- the dot (.) cannot be the first or the last character
- the double-quote character (") can only surround the localpart (so
if it appears it must be the first and the last character of localpart)
- spaces are allowed if the localpart is surrounded in double-quotes
- other ASCII characters (even from the extended-ASCII set) are allowed
if the localparts is surrounded in double-quotes (the function
ezcMailTools::composeEmailAddress will encode it when using it
in a mail header)
- the double-quotes character (") cannot be escaped to appear in a
localpart surrounded by double quotes (so "john"doe"@example.com is not
a valid email address)
The domainpart has the same rules as a domain name, as defined in
{@link http://www.faqs.org/rfcs/rfc822.html RFC822} and
{@link http://www.faqs.org/rfcs/rfc2822.html RFC2822}.
See also the test files (in the "Mail/tests/tools/data" directory) for
examples of correct and incorrect email addresses.
@throws ezcBaseFunctionalityNotSupportedException
if $checkMxRecords is true and getmxrr() or checkdnsrr() functions
are missing (e.g. on Windows)
@param string $address
@param bool $checkMxRecords
@return bool | [
"Returns",
"true",
"if",
"$address",
"is",
"a",
"valid",
"email",
"address",
"false",
"otherwise",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L362-L383 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.validateEmailAddressMx | protected static function validateEmailAddressMx( $address )
{
if ( !ezcBaseFeatures::hasFunction( 'getmxrr' ) || !ezcBaseFeatures::hasFunction( 'checkdnsrr' ) )
{
throw new ezcBaseFunctionalityNotSupportedException( 'Checking DNS records', 'getmxrr() or checkdnsrr() missing' );
}
$timeoutOpen = 3; // for fsockopen()
$timeoutConnection = 5; // for stream_set_timeout()
list( $local, $domain ) = explode( '@', $address );
if ( !empty( $domain ) )
{
if ( getmxrr( $domain, $hosts, $weights ) )
{
for ( $i = 0; $i < count( $hosts ); $i++ )
{
$mx[$hosts[$i]] = $weights[$i];
}
asort( $mx );
$mx = array_keys( $mx );
}
elseif ( checkdnsrr( $domain, 'A' ) )
{
$mx[0] = gethostbyname( $domain );
}
else
{
$mx = array();
}
if ( ( $numberOfMx = count( $mx ) ) > 0 )
{
$smtp = array(
"HELO " . self::$mxValidateServer,
"MAIL FROM: <" . self::$mxValidateAddress . ">",
"RCPT TO: <{$address}>",
"QUIT",
);
for ( $i = 0; $i < $numberOfMx; $i++ )
{
if ( $socket = @fsockopen( $mx[$i], 25, $errno = 0, $errstr = 0, $timeoutOpen ) )
{
$response = fgets( $socket );
stream_set_timeout( $socket, $timeoutConnection );
$meta = stream_get_meta_data( $socket );
if ( !$meta['timed_out'] && !preg_match( '/^2\d\d[ -]/', $response ) )
{
return false;
}
foreach ( $smtp as $command )
{
fputs( $socket, "{$command}\r\n" );
$response = fgets( $socket, 4096 );
if ( !$meta['timed_out'] && preg_match( '/^5\d\d[ -]/', $response ) )
{
return false;
}
}
fclose( $socket );
return true;
}
elseif ( $i === $numberOfMx - 1 )
{
// none of the mail servers could be contacted
return false;
}
}
}
else
{
// no mail servers found
return false;
}
}
} | php | protected static function validateEmailAddressMx( $address )
{
if ( !ezcBaseFeatures::hasFunction( 'getmxrr' ) || !ezcBaseFeatures::hasFunction( 'checkdnsrr' ) )
{
throw new ezcBaseFunctionalityNotSupportedException( 'Checking DNS records', 'getmxrr() or checkdnsrr() missing' );
}
$timeoutOpen = 3; // for fsockopen()
$timeoutConnection = 5; // for stream_set_timeout()
list( $local, $domain ) = explode( '@', $address );
if ( !empty( $domain ) )
{
if ( getmxrr( $domain, $hosts, $weights ) )
{
for ( $i = 0; $i < count( $hosts ); $i++ )
{
$mx[$hosts[$i]] = $weights[$i];
}
asort( $mx );
$mx = array_keys( $mx );
}
elseif ( checkdnsrr( $domain, 'A' ) )
{
$mx[0] = gethostbyname( $domain );
}
else
{
$mx = array();
}
if ( ( $numberOfMx = count( $mx ) ) > 0 )
{
$smtp = array(
"HELO " . self::$mxValidateServer,
"MAIL FROM: <" . self::$mxValidateAddress . ">",
"RCPT TO: <{$address}>",
"QUIT",
);
for ( $i = 0; $i < $numberOfMx; $i++ )
{
if ( $socket = @fsockopen( $mx[$i], 25, $errno = 0, $errstr = 0, $timeoutOpen ) )
{
$response = fgets( $socket );
stream_set_timeout( $socket, $timeoutConnection );
$meta = stream_get_meta_data( $socket );
if ( !$meta['timed_out'] && !preg_match( '/^2\d\d[ -]/', $response ) )
{
return false;
}
foreach ( $smtp as $command )
{
fputs( $socket, "{$command}\r\n" );
$response = fgets( $socket, 4096 );
if ( !$meta['timed_out'] && preg_match( '/^5\d\d[ -]/', $response ) )
{
return false;
}
}
fclose( $socket );
return true;
}
elseif ( $i === $numberOfMx - 1 )
{
// none of the mail servers could be contacted
return false;
}
}
}
else
{
// no mail servers found
return false;
}
}
} | [
"protected",
"static",
"function",
"validateEmailAddressMx",
"(",
"$",
"address",
")",
"{",
"if",
"(",
"!",
"ezcBaseFeatures",
"::",
"hasFunction",
"(",
"'getmxrr'",
")",
"||",
"!",
"ezcBaseFeatures",
"::",
"hasFunction",
"(",
"'checkdnsrr'",
")",
")",
"{",
"throw",
"new",
"ezcBaseFunctionalityNotSupportedException",
"(",
"'Checking DNS records'",
",",
"'getmxrr() or checkdnsrr() missing'",
")",
";",
"}",
"$",
"timeoutOpen",
"=",
"3",
";",
"// for fsockopen()",
"$",
"timeoutConnection",
"=",
"5",
";",
"// for stream_set_timeout()",
"list",
"(",
"$",
"local",
",",
"$",
"domain",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"address",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"domain",
")",
")",
"{",
"if",
"(",
"getmxrr",
"(",
"$",
"domain",
",",
"$",
"hosts",
",",
"$",
"weights",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"hosts",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"mx",
"[",
"$",
"hosts",
"[",
"$",
"i",
"]",
"]",
"=",
"$",
"weights",
"[",
"$",
"i",
"]",
";",
"}",
"asort",
"(",
"$",
"mx",
")",
";",
"$",
"mx",
"=",
"array_keys",
"(",
"$",
"mx",
")",
";",
"}",
"elseif",
"(",
"checkdnsrr",
"(",
"$",
"domain",
",",
"'A'",
")",
")",
"{",
"$",
"mx",
"[",
"0",
"]",
"=",
"gethostbyname",
"(",
"$",
"domain",
")",
";",
"}",
"else",
"{",
"$",
"mx",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"(",
"$",
"numberOfMx",
"=",
"count",
"(",
"$",
"mx",
")",
")",
">",
"0",
")",
"{",
"$",
"smtp",
"=",
"array",
"(",
"\"HELO \"",
".",
"self",
"::",
"$",
"mxValidateServer",
",",
"\"MAIL FROM: <\"",
".",
"self",
"::",
"$",
"mxValidateAddress",
".",
"\">\"",
",",
"\"RCPT TO: <{$address}>\"",
",",
"\"QUIT\"",
",",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"numberOfMx",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"socket",
"=",
"@",
"fsockopen",
"(",
"$",
"mx",
"[",
"$",
"i",
"]",
",",
"25",
",",
"$",
"errno",
"=",
"0",
",",
"$",
"errstr",
"=",
"0",
",",
"$",
"timeoutOpen",
")",
")",
"{",
"$",
"response",
"=",
"fgets",
"(",
"$",
"socket",
")",
";",
"stream_set_timeout",
"(",
"$",
"socket",
",",
"$",
"timeoutConnection",
")",
";",
"$",
"meta",
"=",
"stream_get_meta_data",
"(",
"$",
"socket",
")",
";",
"if",
"(",
"!",
"$",
"meta",
"[",
"'timed_out'",
"]",
"&&",
"!",
"preg_match",
"(",
"'/^2\\d\\d[ -]/'",
",",
"$",
"response",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"smtp",
"as",
"$",
"command",
")",
"{",
"fputs",
"(",
"$",
"socket",
",",
"\"{$command}\\r\\n\"",
")",
";",
"$",
"response",
"=",
"fgets",
"(",
"$",
"socket",
",",
"4096",
")",
";",
"if",
"(",
"!",
"$",
"meta",
"[",
"'timed_out'",
"]",
"&&",
"preg_match",
"(",
"'/^5\\d\\d[ -]/'",
",",
"$",
"response",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"fclose",
"(",
"$",
"socket",
")",
";",
"return",
"true",
";",
"}",
"elseif",
"(",
"$",
"i",
"===",
"$",
"numberOfMx",
"-",
"1",
")",
"{",
"// none of the mail servers could be contacted",
"return",
"false",
";",
"}",
"}",
"}",
"else",
"{",
"// no mail servers found",
"return",
"false",
";",
"}",
"}",
"}"
] | Checks if the email address $address is valid based on its MX records.
Steps:
- the MX records are fetched for the domain part of $address, along with
their weights
- the MX records are sorted based on the weights
- for each MX record a connection is open
- a test mail (RCPT TO) is tried to be sent to $address
- if one test mail succeeds, then the address is valid, else invalid
Set these values before calling this function, to ensure the MX record
checks work properly:
<code>
ezcMailTools::$mxValidateServer = 'your.mail.server'; // default 'smtp.ez.no'
ezcMailTools::$mxValidateAddress = '[email protected]'; // default '[email protected]'
</code>
MX record checking does not work on Windows due to the lack of getmxrr()
and checkdnsrr() PHP functions. The ezcBaseFunctionalityNotSupportedException
is thrown in this case.
@throws ezcBaseFunctionalityNotSupportedException
if getmxrr() or checkdnsrr() functions are missing (e.g. on Windows)
@param string $address
@return bool | [
"Checks",
"if",
"the",
"email",
"address",
"$address",
"is",
"valid",
"based",
"on",
"its",
"MX",
"records",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L412-L489 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.generateMessageId | public static function generateMessageId( $hostname )
{
if ( strpos( $hostname, '@' ) !== false )
{
$hostname = strstr( $hostname, '@' );
}
else
{
$hostname = '@' . $hostname;
}
return date( 'YmdGHjs' ) . '.' . getmypid() . '.' . self::$idCounter++ . $hostname;
} | php | public static function generateMessageId( $hostname )
{
if ( strpos( $hostname, '@' ) !== false )
{
$hostname = strstr( $hostname, '@' );
}
else
{
$hostname = '@' . $hostname;
}
return date( 'YmdGHjs' ) . '.' . getmypid() . '.' . self::$idCounter++ . $hostname;
} | [
"public",
"static",
"function",
"generateMessageId",
"(",
"$",
"hostname",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"hostname",
",",
"'@'",
")",
"!==",
"false",
")",
"{",
"$",
"hostname",
"=",
"strstr",
"(",
"$",
"hostname",
",",
"'@'",
")",
";",
"}",
"else",
"{",
"$",
"hostname",
"=",
"'@'",
".",
"$",
"hostname",
";",
"}",
"return",
"date",
"(",
"'YmdGHjs'",
")",
".",
"'.'",
".",
"getmypid",
"(",
")",
".",
"'.'",
".",
"self",
"::",
"$",
"idCounter",
"++",
".",
"$",
"hostname",
";",
"}"
] | Returns an unique message ID to be used for a mail message.
The hostname $hostname will be added to the unique ID as required by RFC822.
If an e-mail address is provided instead, the hostname is extracted and used.
The formula to generate the message ID is: [time_and_date].[process_id].[counter]
@param string $hostname
@return string | [
"Returns",
"an",
"unique",
"message",
"ID",
"to",
"be",
"used",
"for",
"a",
"mail",
"message",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L502-L513 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.mimeDecode | public static function mimeDecode( $text, $charset = 'utf-8' )
{
$origtext = $text;
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// something went wrong while decoding, let's see if we can fix it
// Try to fix lower case hex digits
$text = preg_replace_callback(
'/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/',
create_function( '$matches', 'return strtoupper($matches[0]);' ),
$origtext
);
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods
// are not understood (but only "B" and "Q")
$text = str_replace( array( '?b?', '?q?' ), array( '?B?', '?Q?' ), $origtext );
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Try it as latin 1 string
$text = preg_replace( '/=\?([^?]+)\?/', '=?iso-8859-1?', $origtext );
$text = iconv_mime_decode( $text, 0, $charset );
return $text;
} | php | public static function mimeDecode( $text, $charset = 'utf-8' )
{
$origtext = $text;
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// something went wrong while decoding, let's see if we can fix it
// Try to fix lower case hex digits
$text = preg_replace_callback(
'/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/',
create_function( '$matches', 'return strtoupper($matches[0]);' ),
$origtext
);
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods
// are not understood (but only "B" and "Q")
$text = str_replace( array( '?b?', '?q?' ), array( '?B?', '?Q?' ), $origtext );
$text = @iconv_mime_decode( $text, 0, $charset );
if ( $text !== false )
{
return $text;
}
// Try it as latin 1 string
$text = preg_replace( '/=\?([^?]+)\?/', '=?iso-8859-1?', $origtext );
$text = iconv_mime_decode( $text, 0, $charset );
return $text;
} | [
"public",
"static",
"function",
"mimeDecode",
"(",
"$",
"text",
",",
"$",
"charset",
"=",
"'utf-8'",
")",
"{",
"$",
"origtext",
"=",
"$",
"text",
";",
"$",
"text",
"=",
"@",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"text",
"!==",
"false",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// something went wrong while decoding, let's see if we can fix it",
"// Try to fix lower case hex digits",
"$",
"text",
"=",
"preg_replace_callback",
"(",
"'/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/'",
",",
"create_function",
"(",
"'$matches'",
",",
"'return strtoupper($matches[0]);'",
")",
",",
"$",
"origtext",
")",
";",
"$",
"text",
"=",
"@",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"text",
"!==",
"false",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// Workaround a bug in PHP 5.1.0-5.1.3 where the \"b\" and \"q\" methods",
"// are not understood (but only \"B\" and \"Q\")",
"$",
"text",
"=",
"str_replace",
"(",
"array",
"(",
"'?b?'",
",",
"'?q?'",
")",
",",
"array",
"(",
"'?B?'",
",",
"'?Q?'",
")",
",",
"$",
"origtext",
")",
";",
"$",
"text",
"=",
"@",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"text",
"!==",
"false",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// Try it as latin 1 string",
"$",
"text",
"=",
"preg_replace",
"(",
"'/=\\?([^?]+)\\?/'",
",",
"'=?iso-8859-1?'",
",",
"$",
"origtext",
")",
";",
"$",
"text",
"=",
"iconv_mime_decode",
"(",
"$",
"text",
",",
"0",
",",
"$",
"charset",
")",
";",
"return",
"$",
"text",
";",
"}"
] | Decodes mime encoded fields and tries to recover from errors.
Decodes the $text encoded as a MIME string to the $charset. In case the
strict conversion fails this method tries to workaround the issues by
trying to "fix" the original $text before trying to convert it.
@param string $text
@param string $charset
@return string | [
"Decodes",
"mime",
"encoded",
"fields",
"and",
"tries",
"to",
"recover",
"from",
"errors",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L568-L604 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.replyToMail | static public function replyToMail( ezcMail $mail, ezcMailAddress $from,
$type = self::REPLY_SENDER, $subjectPrefix = "Re: ",
$mailClass = "ezcMail" )
{
$reply = new $mailClass();
$reply->from = $from;
// To = Reply-To if set
if ( $mail->getHeader( 'Reply-To' ) != '' )
{
$reply->to = ezcMailTools::parseEmailAddresses( $mail->getHeader( 'Reply-To' ) );
}
else // Else To = From
{
$reply->to = array( $mail->from );
}
if ( $type == self::REPLY_ALL )
{
// Cc = Cc + To - your own address
$cc = array();
foreach ( $mail->to as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
foreach ( $mail->cc as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
$reply->cc = $cc;
}
$reply->subject = $subjectPrefix . $mail->subject;
if ( $mail->getHeader( 'Message-Id' ) )
{
// In-Reply-To = Message-Id
$reply->setHeader( 'In-Reply-To', $mail->getHeader( 'Message-ID' ) );
// References = References . Message-Id
if ( $mail->getHeader( 'References' ) != '' )
{
$reply->setHeader( 'References', $mail->getHeader( 'References' )
. ' ' . $mail->getHeader( 'Message-ID' ) );
}
else
{
$reply->setHeader( 'References', $mail->getHeader( 'Message-ID' ) );
}
}
else // original mail is borked. Let's support it anyway.
{
$reply->setHeader( 'References', $mail->getHeader( 'References' ) );
}
return $reply;
} | php | static public function replyToMail( ezcMail $mail, ezcMailAddress $from,
$type = self::REPLY_SENDER, $subjectPrefix = "Re: ",
$mailClass = "ezcMail" )
{
$reply = new $mailClass();
$reply->from = $from;
// To = Reply-To if set
if ( $mail->getHeader( 'Reply-To' ) != '' )
{
$reply->to = ezcMailTools::parseEmailAddresses( $mail->getHeader( 'Reply-To' ) );
}
else // Else To = From
{
$reply->to = array( $mail->from );
}
if ( $type == self::REPLY_ALL )
{
// Cc = Cc + To - your own address
$cc = array();
foreach ( $mail->to as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
foreach ( $mail->cc as $address )
{
if ( $address->email != $from->email )
{
$cc[] = $address;
}
}
$reply->cc = $cc;
}
$reply->subject = $subjectPrefix . $mail->subject;
if ( $mail->getHeader( 'Message-Id' ) )
{
// In-Reply-To = Message-Id
$reply->setHeader( 'In-Reply-To', $mail->getHeader( 'Message-ID' ) );
// References = References . Message-Id
if ( $mail->getHeader( 'References' ) != '' )
{
$reply->setHeader( 'References', $mail->getHeader( 'References' )
. ' ' . $mail->getHeader( 'Message-ID' ) );
}
else
{
$reply->setHeader( 'References', $mail->getHeader( 'Message-ID' ) );
}
}
else // original mail is borked. Let's support it anyway.
{
$reply->setHeader( 'References', $mail->getHeader( 'References' ) );
}
return $reply;
} | [
"static",
"public",
"function",
"replyToMail",
"(",
"ezcMail",
"$",
"mail",
",",
"ezcMailAddress",
"$",
"from",
",",
"$",
"type",
"=",
"self",
"::",
"REPLY_SENDER",
",",
"$",
"subjectPrefix",
"=",
"\"Re: \"",
",",
"$",
"mailClass",
"=",
"\"ezcMail\"",
")",
"{",
"$",
"reply",
"=",
"new",
"$",
"mailClass",
"(",
")",
";",
"$",
"reply",
"->",
"from",
"=",
"$",
"from",
";",
"// To = Reply-To if set",
"if",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'Reply-To'",
")",
"!=",
"''",
")",
"{",
"$",
"reply",
"->",
"to",
"=",
"ezcMailTools",
"::",
"parseEmailAddresses",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'Reply-To'",
")",
")",
";",
"}",
"else",
"// Else To = From",
"{",
"$",
"reply",
"->",
"to",
"=",
"array",
"(",
"$",
"mail",
"->",
"from",
")",
";",
"}",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"REPLY_ALL",
")",
"{",
"// Cc = Cc + To - your own address",
"$",
"cc",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mail",
"->",
"to",
"as",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"->",
"email",
"!=",
"$",
"from",
"->",
"email",
")",
"{",
"$",
"cc",
"[",
"]",
"=",
"$",
"address",
";",
"}",
"}",
"foreach",
"(",
"$",
"mail",
"->",
"cc",
"as",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"->",
"email",
"!=",
"$",
"from",
"->",
"email",
")",
"{",
"$",
"cc",
"[",
"]",
"=",
"$",
"address",
";",
"}",
"}",
"$",
"reply",
"->",
"cc",
"=",
"$",
"cc",
";",
"}",
"$",
"reply",
"->",
"subject",
"=",
"$",
"subjectPrefix",
".",
"$",
"mail",
"->",
"subject",
";",
"if",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-Id'",
")",
")",
"{",
"// In-Reply-To = Message-Id",
"$",
"reply",
"->",
"setHeader",
"(",
"'In-Reply-To'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-ID'",
")",
")",
";",
"// References = References . Message-Id",
"if",
"(",
"$",
"mail",
"->",
"getHeader",
"(",
"'References'",
")",
"!=",
"''",
")",
"{",
"$",
"reply",
"->",
"setHeader",
"(",
"'References'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'References'",
")",
".",
"' '",
".",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-ID'",
")",
")",
";",
"}",
"else",
"{",
"$",
"reply",
"->",
"setHeader",
"(",
"'References'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'Message-ID'",
")",
")",
";",
"}",
"}",
"else",
"// original mail is borked. Let's support it anyway.",
"{",
"$",
"reply",
"->",
"setHeader",
"(",
"'References'",
",",
"$",
"mail",
"->",
"getHeader",
"(",
"'References'",
")",
")",
";",
"}",
"return",
"$",
"reply",
";",
"}"
] | Returns a new mail object that is a reply to the current object.
The new mail will have the correct to, cc, bcc and reference headers set.
It will not have any body set.
By default the reply will only be sent to the sender of the original mail.
If $type is set to REPLY_ALL, all the original recipients will be included
in the reply.
Use $subjectPrefix to set the prefix to the subject of the mail. The default
is to prefix with 'Re: '.
@param ezcMail $mail
@param ezcMailAddress $from
@param int $type REPLY_SENDER or REPLY_ALL
@param string $subjectPrefix
@param string $mailClass
@return ezcMail | [
"Returns",
"a",
"new",
"mail",
"object",
"that",
"is",
"a",
"reply",
"to",
"the",
"current",
"object",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L626-L689 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.guessContentType | static public function guessContentType( $fileName, &$contentType, &$mimeType )
{
$extension = strtolower( pathinfo( $fileName, PATHINFO_EXTENSION ) );
switch ( $extension )
{
case 'gif':
$contentType = 'image';
$mimeType = 'gif';
break;
case 'jpg':
case 'jpe':
case 'jpeg':
$contentType = 'image';
$mimeType = 'jpeg';
break;
case 'png':
$contentType = 'image';
$mimeType = 'png';
break;
case 'bmp':
$contentType = 'image';
$mimeType = 'bmp';
break;
case 'tif':
case 'tiff':
$contentType = 'image';
$mimeType = 'tiff';
break;
default:
return false;
}
return true;
} | php | static public function guessContentType( $fileName, &$contentType, &$mimeType )
{
$extension = strtolower( pathinfo( $fileName, PATHINFO_EXTENSION ) );
switch ( $extension )
{
case 'gif':
$contentType = 'image';
$mimeType = 'gif';
break;
case 'jpg':
case 'jpe':
case 'jpeg':
$contentType = 'image';
$mimeType = 'jpeg';
break;
case 'png':
$contentType = 'image';
$mimeType = 'png';
break;
case 'bmp':
$contentType = 'image';
$mimeType = 'bmp';
break;
case 'tif':
case 'tiff':
$contentType = 'image';
$mimeType = 'tiff';
break;
default:
return false;
}
return true;
} | [
"static",
"public",
"function",
"guessContentType",
"(",
"$",
"fileName",
",",
"&",
"$",
"contentType",
",",
"&",
"$",
"mimeType",
")",
"{",
"$",
"extension",
"=",
"strtolower",
"(",
"pathinfo",
"(",
"$",
"fileName",
",",
"PATHINFO_EXTENSION",
")",
")",
";",
"switch",
"(",
"$",
"extension",
")",
"{",
"case",
"'gif'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'gif'",
";",
"break",
";",
"case",
"'jpg'",
":",
"case",
"'jpe'",
":",
"case",
"'jpeg'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'jpeg'",
";",
"break",
";",
"case",
"'png'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'png'",
";",
"break",
";",
"case",
"'bmp'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'bmp'",
";",
"break",
";",
"case",
"'tif'",
":",
"case",
"'tiff'",
":",
"$",
"contentType",
"=",
"'image'",
";",
"$",
"mimeType",
"=",
"'tiff'",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Guesses the content and mime type by using the file extension.
The content and mime types are returned through the $contentType
and $mimeType arguments.
For the moment only for image files.
@param string $fileName
@param string $contentType
@param string $mimeType | [
"Guesses",
"the",
"content",
"and",
"mime",
"type",
"by",
"using",
"the",
"file",
"extension",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L702-L739 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php | ezcMailTools.replaceContentIdRefs | static function replaceContentIdRefs( $htmlText, $contentIdArray )
{
preg_match_all( '@src=[\'"](cid:(.*?))[\'"]@', $htmlText, $matches );
for ( $i = 0; $i < count( $matches[0] ); $i++ )
{
if ( isset( $contentIdArray[$matches[2][$i]] ) )
{
$htmlText = str_replace( $matches[1][$i], $contentIdArray[$matches[2][$i]], $htmlText );
}
}
return $htmlText;
} | php | static function replaceContentIdRefs( $htmlText, $contentIdArray )
{
preg_match_all( '@src=[\'"](cid:(.*?))[\'"]@', $htmlText, $matches );
for ( $i = 0; $i < count( $matches[0] ); $i++ )
{
if ( isset( $contentIdArray[$matches[2][$i]] ) )
{
$htmlText = str_replace( $matches[1][$i], $contentIdArray[$matches[2][$i]], $htmlText );
}
}
return $htmlText;
} | [
"static",
"function",
"replaceContentIdRefs",
"(",
"$",
"htmlText",
",",
"$",
"contentIdArray",
")",
"{",
"preg_match_all",
"(",
"'@src=[\\'\"](cid:(.*?))[\\'\"]@'",
",",
"$",
"htmlText",
",",
"$",
"matches",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"contentIdArray",
"[",
"$",
"matches",
"[",
"2",
"]",
"[",
"$",
"i",
"]",
"]",
")",
")",
"{",
"$",
"htmlText",
"=",
"str_replace",
"(",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"i",
"]",
",",
"$",
"contentIdArray",
"[",
"$",
"matches",
"[",
"2",
"]",
"[",
"$",
"i",
"]",
"]",
",",
"$",
"htmlText",
")",
";",
"}",
"}",
"return",
"$",
"htmlText",
";",
"}"
] | Replaces HTML embedded "cid:" references with replacements from $contentIdArray.
The method matches all "cid:" references in the $htmlText and then loops
over each match. For each match the found content ID is looked-up as key
in the $contentIdArray and the value is then inserted as replacement for
the "cid:" reference.
<code>
<?php
$contentIdArray = array( 'consoletools-table.png@1421450' => 'http://localhost/consoletools-table.jpg' );
$text = "<html> Embedded image: <img src='cid:consoletools-table.png@1421450'/> </html>";
$htmlBody = ezcMailTools::replaceContentIdRefs( $text, $contentIdArray );
// $htmlBody is now:
// <html> Embedded image: <img src='http://localhost/consoletools-table.jpg'/> </html>
?>
</code>
The $contentIdArray can be build by iterating over all parts in the
mail, and for each ezcMailFilePart that you find: 1. copy the associated
file (fileName property of the ezcMailFilePart object) to your webroot;
2. add an element to the array with the key created from the contentId
property from the ezcMailFilePart object. See the tutorial for an
example of this.
@param string $htmlText
@param array(string=>string) $contentIdArray
@return string | [
"Replaces",
"HTML",
"embedded",
"cid",
":",
"references",
"with",
"replacements",
"from",
"$contentIdArray",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php#L770-L781 |
robrogers3/laraldap-auth | src/LdapUserProvider.php | LdapUserProvider.retrieveByToken | public function retrieveByToken($identifier, $token)
{
$model = $this->createModel();
return $model->newQuery()
->where($model->getAuthIdentifierName(), $identifier)
->where($model->getRememberTokenName(), $token)
->first();
} | php | public function retrieveByToken($identifier, $token)
{
$model = $this->createModel();
return $model->newQuery()
->where($model->getAuthIdentifierName(), $identifier)
->where($model->getRememberTokenName(), $token)
->first();
} | [
"public",
"function",
"retrieveByToken",
"(",
"$",
"identifier",
",",
"$",
"token",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"createModel",
"(",
")",
";",
"return",
"$",
"model",
"->",
"newQuery",
"(",
")",
"->",
"where",
"(",
"$",
"model",
"->",
"getAuthIdentifierName",
"(",
")",
",",
"$",
"identifier",
")",
"->",
"where",
"(",
"$",
"model",
"->",
"getRememberTokenName",
"(",
")",
",",
"$",
"token",
")",
"->",
"first",
"(",
")",
";",
"}"
] | Retrieve a user by their unique identifier and "remember me" token.
@param mixed $identifier
@param string $token
@return \Illuminate\Contracts\Auth\Authenticatable|null | [
"Retrieve",
"a",
"user",
"by",
"their",
"unique",
"identifier",
"and",
"remember",
"me",
"token",
"."
] | train | https://github.com/robrogers3/laraldap-auth/blob/f1b8d001f8b230389c7fbc5fdd59e39663d8ad36/src/LdapUserProvider.php#L99-L107 |
robrogers3/laraldap-auth | src/LdapUserProvider.php | LdapUserProvider.retrieveByCredentials | public function retrieveByCredentials(array $credentials)
{
if (empty($credentials)) {
return null;
}
$query = $this->createModel()->newQuery();
// Append the domain name to user's credentials if not set
// stores the email in the DB for potential usage like notifications.
if (false === strpos($credentials['email'], '@')) {
$credentials['email'] .= '@' . $this->domain;
}
$query->where('email', $credentials['email']);
$model = $query->first();
if ($model) {
return $model;
}
$model = $this->makeModel($credentials);
return $model;
} | php | public function retrieveByCredentials(array $credentials)
{
if (empty($credentials)) {
return null;
}
$query = $this->createModel()->newQuery();
// Append the domain name to user's credentials if not set
// stores the email in the DB for potential usage like notifications.
if (false === strpos($credentials['email'], '@')) {
$credentials['email'] .= '@' . $this->domain;
}
$query->where('email', $credentials['email']);
$model = $query->first();
if ($model) {
return $model;
}
$model = $this->makeModel($credentials);
return $model;
} | [
"public",
"function",
"retrieveByCredentials",
"(",
"array",
"$",
"credentials",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"credentials",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"createModel",
"(",
")",
"->",
"newQuery",
"(",
")",
";",
"// Append the domain name to user's credentials if not set",
"// stores the email in the DB for potential usage like notifications.",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"credentials",
"[",
"'email'",
"]",
",",
"'@'",
")",
")",
"{",
"$",
"credentials",
"[",
"'email'",
"]",
".=",
"'@'",
".",
"$",
"this",
"->",
"domain",
";",
"}",
"$",
"query",
"->",
"where",
"(",
"'email'",
",",
"$",
"credentials",
"[",
"'email'",
"]",
")",
";",
"$",
"model",
"=",
"$",
"query",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"model",
")",
"{",
"return",
"$",
"model",
";",
"}",
"$",
"model",
"=",
"$",
"this",
"->",
"makeModel",
"(",
"$",
"credentials",
")",
";",
"return",
"$",
"model",
";",
"}"
] | Retrieve a user by the given credentials.
@param array $credentials
@return \Illuminate\Contracts\Auth\Authenticatable|null | [
"Retrieve",
"a",
"user",
"by",
"the",
"given",
"credentials",
"."
] | train | https://github.com/robrogers3/laraldap-auth/blob/f1b8d001f8b230389c7fbc5fdd59e39663d8ad36/src/LdapUserProvider.php#L129-L155 |
robrogers3/laraldap-auth | src/LdapUserProvider.php | LdapUserProvider.validateCredentials | public function validateCredentials(Authenticatable $user, array $credentials)
{
//TODO determine if we even want to store the passowrd.
if (! $this->authenticate($user, $credentials)) {
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
return true;
} | php | public function validateCredentials(Authenticatable $user, array $credentials)
{
//TODO determine if we even want to store the passowrd.
if (! $this->authenticate($user, $credentials)) {
$plain = $credentials['password'];
return $this->hasher->check($plain, $user->getAuthPassword());
}
return true;
} | [
"public",
"function",
"validateCredentials",
"(",
"Authenticatable",
"$",
"user",
",",
"array",
"$",
"credentials",
")",
"{",
"//TODO determine if we even want to store the passowrd.",
"if",
"(",
"!",
"$",
"this",
"->",
"authenticate",
"(",
"$",
"user",
",",
"$",
"credentials",
")",
")",
"{",
"$",
"plain",
"=",
"$",
"credentials",
"[",
"'password'",
"]",
";",
"return",
"$",
"this",
"->",
"hasher",
"->",
"check",
"(",
"$",
"plain",
",",
"$",
"user",
"->",
"getAuthPassword",
"(",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Validate a user against the given credentials.
@param \Illuminate\Contracts\Auth\Authenticatable $user
@param array $credentials
@return bool | [
"Validate",
"a",
"user",
"against",
"the",
"given",
"credentials",
"."
] | train | https://github.com/robrogers3/laraldap-auth/blob/f1b8d001f8b230389c7fbc5fdd59e39663d8ad36/src/LdapUserProvider.php#L164-L174 |
robrogers3/laraldap-auth | src/LdapUserProvider.php | LdapUserProvider.authenticate | public function authenticate(Authenticatable $user, array $credentials)
{
$handler = ldap_connect($this->host);
if (! $handler) {
throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
}
try {
ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
} catch (\ErrorException $e) {
;
}
$username = strtok($user->email, '@');
$rdn = $this->makeRdn($username);
try {
$bind = ldap_bind($handler, $rdn, $credentials['password']);
} catch (\ErrorException $e) {
$bind = false;
}
if ($handler) {
ldap_close($handler);
unset($handler);
}
if ($bind) {
$user->save();
}
return $bind;
} | php | public function authenticate(Authenticatable $user, array $credentials)
{
$handler = ldap_connect($this->host);
if (! $handler) {
throw new RuntimeException("Connection fail! Check your server address: '{$this->host}'.");
}
try {
ldap_set_option($handler, LDAP_OPT_PROTOCOL_VERSION, 3);
} catch (\ErrorException $e) {
;
}
$username = strtok($user->email, '@');
$rdn = $this->makeRdn($username);
try {
$bind = ldap_bind($handler, $rdn, $credentials['password']);
} catch (\ErrorException $e) {
$bind = false;
}
if ($handler) {
ldap_close($handler);
unset($handler);
}
if ($bind) {
$user->save();
}
return $bind;
} | [
"public",
"function",
"authenticate",
"(",
"Authenticatable",
"$",
"user",
",",
"array",
"$",
"credentials",
")",
"{",
"$",
"handler",
"=",
"ldap_connect",
"(",
"$",
"this",
"->",
"host",
")",
";",
"if",
"(",
"!",
"$",
"handler",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Connection fail! Check your server address: '{$this->host}'.\"",
")",
";",
"}",
"try",
"{",
"ldap_set_option",
"(",
"$",
"handler",
",",
"LDAP_OPT_PROTOCOL_VERSION",
",",
"3",
")",
";",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
";",
"}",
"$",
"username",
"=",
"strtok",
"(",
"$",
"user",
"->",
"email",
",",
"'@'",
")",
";",
"$",
"rdn",
"=",
"$",
"this",
"->",
"makeRdn",
"(",
"$",
"username",
")",
";",
"try",
"{",
"$",
"bind",
"=",
"ldap_bind",
"(",
"$",
"handler",
",",
"$",
"rdn",
",",
"$",
"credentials",
"[",
"'password'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
"$",
"bind",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"handler",
")",
"{",
"ldap_close",
"(",
"$",
"handler",
")",
";",
"unset",
"(",
"$",
"handler",
")",
";",
"}",
"if",
"(",
"$",
"bind",
")",
"{",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"return",
"$",
"bind",
";",
"}"
] | Check user's credentials against LDAP server.
@param Authenticatable $user
@param array $credentials
@return bool | [
"Check",
"user",
"s",
"credentials",
"against",
"LDAP",
"server",
"."
] | train | https://github.com/robrogers3/laraldap-auth/blob/f1b8d001f8b230389c7fbc5fdd59e39663d8ad36/src/LdapUserProvider.php#L183-L219 |
phpnfe/tools | src/Certificado/Oids.php | Oids.getOid | public static function getOid($key)
{
if (isset(self::$oidsTable[$key])) {
return self::$oidsTable[$key];
}
return false;
} | php | public static function getOid($key)
{
if (isset(self::$oidsTable[$key])) {
return self::$oidsTable[$key];
}
return false;
} | [
"public",
"static",
"function",
"getOid",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"oidsTable",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"oidsTable",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | getOid.
@param type $key
@return mixed | [
"getOid",
"."
] | train | https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Oids.php#L878-L885 |
willhoffmann/domuserp-php | src/Resources/Companies/Companies.php | Companies.getList | public function getList(array $query = [])
{
$list = $this->execute(self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/empresas');
return $list;
} | php | public function getList(array $query = [])
{
$list = $this->execute(self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/empresas');
return $list;
} | [
"public",
"function",
"getList",
"(",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"execute",
"(",
"self",
"::",
"HTTP_GET",
",",
"self",
"::",
"DOMUSERP_API_PEDIDOVENDA",
".",
"'/empresas'",
")",
";",
"return",
"$",
"list",
";",
"}"
] | List of companies
@param array $query
@return array|string
@throws \GuzzleHttp\Exception\GuzzleException | [
"List",
"of",
"companies"
] | train | https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/Companies/Companies.php#L18-L23 |
wilgucki/php-csv | src/Writer.php | Writer.flush | public function flush()
{
rewind($this->handle);
$out = stream_get_contents($this->handle);
fseek($this->handle, 0, SEEK_END);
return $out;
} | php | public function flush()
{
rewind($this->handle);
$out = stream_get_contents($this->handle);
fseek($this->handle, 0, SEEK_END);
return $out;
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"rewind",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"out",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"fseek",
"(",
"$",
"this",
"->",
"handle",
",",
"0",
",",
"SEEK_END",
")",
";",
"return",
"$",
"out",
";",
"}"
] | Output all written data as string.
@return string | [
"Output",
"all",
"written",
"data",
"as",
"string",
"."
] | train | https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Writer.php#L60-L66 |
wilgucki/php-csv | src/Writer.php | Writer.write | private function write(array $row)
{
if ($this->encodingFrom !== null && $this->encodingTo !== null) {
foreach ($row as $k => $v) {
$row[$k] = iconv($this->encodingFrom, $this->encodingTo, $v);
}
}
return fputcsv($this->handle, $row, $this->delimiter, $this->enclosure, $this->escape);
} | php | private function write(array $row)
{
if ($this->encodingFrom !== null && $this->encodingTo !== null) {
foreach ($row as $k => $v) {
$row[$k] = iconv($this->encodingFrom, $this->encodingTo, $v);
}
}
return fputcsv($this->handle, $row, $this->delimiter, $this->enclosure, $this->escape);
} | [
"private",
"function",
"write",
"(",
"array",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"encodingFrom",
"!==",
"null",
"&&",
"$",
"this",
"->",
"encodingTo",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"row",
"[",
"$",
"k",
"]",
"=",
"iconv",
"(",
"$",
"this",
"->",
"encodingFrom",
",",
"$",
"this",
"->",
"encodingTo",
",",
"$",
"v",
")",
";",
"}",
"}",
"return",
"fputcsv",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"row",
",",
"$",
"this",
"->",
"delimiter",
",",
"$",
"this",
"->",
"enclosure",
",",
"$",
"this",
"->",
"escape",
")",
";",
"}"
] | Wrapper for fputcsv function
@param array $row
@return bool|int | [
"Wrapper",
"for",
"fputcsv",
"function"
] | train | https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Writer.php#L74-L83 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/utilities.php | ezcDbUtilities.createTemporaryTable | public function createTemporaryTable( $tableName, $tableDefinition )
{
$tableName = str_replace( '%', '', $tableName );
$tableName = $this->getPrefixedTableNames($tableName);
$this->db->exec( "CREATE TEMPORARY TABLE $tableName ($tableDefinition)" );
return $tableName;
} | php | public function createTemporaryTable( $tableName, $tableDefinition )
{
$tableName = str_replace( '%', '', $tableName );
$tableName = $this->getPrefixedTableNames($tableName);
$this->db->exec( "CREATE TEMPORARY TABLE $tableName ($tableDefinition)" );
return $tableName;
} | [
"public",
"function",
"createTemporaryTable",
"(",
"$",
"tableName",
",",
"$",
"tableDefinition",
")",
"{",
"$",
"tableName",
"=",
"str_replace",
"(",
"'%'",
",",
"''",
",",
"$",
"tableName",
")",
";",
"$",
"tableName",
"=",
"$",
"this",
"->",
"getPrefixedTableNames",
"(",
"$",
"tableName",
")",
";",
"$",
"this",
"->",
"db",
"->",
"exec",
"(",
"\"CREATE TEMPORARY TABLE $tableName ($tableDefinition)\"",
")",
";",
"return",
"$",
"tableName",
";",
"}"
] | Create temporary table.
Developers should use this method rather than creating temporary
tables by hand, executing the appropriate SQL queries.
If the specified table name contains percent character (%)
then it might be substituted with a unique number by some handlers.
For example, Oracle handler does this to guarantee uniqueness of
temporary tables names.
Handlers that do not need this just remove percent characters
from the table name.
Example of usage:
<code>
$actualTableName = $db->createTemporaryTable(
'my_tmp_%', 'field1 char(255), field2 int' );
$db->dropTemporaryTable( $actualTableName );
</code>
@see dropTemporaryTable()
@param string $tableName Name of temporary table user wants
to create.
@param string $tableDefinition Definition for the table, i.e.
everything that goes between braces after
CREATE TEMPORARY TABLE clause.
@return string Table name, that might have been changed
by the handler to guarantee its uniqueness. | [
"Create",
"temporary",
"table",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/utilities.php#L69-L75 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Helper/AbstractModelManager.php | Aoe_Layout_Helper_AbstractModelManager.getEditUrl | public function getEditUrl($model = null)
{
if (!$model instanceof Mage_Core_Model_Abstract) {
$model = $this->getCurrentRecord();
} else {
$expectedClass = get_class($this->getModel());
if (!is_a($model, $expectedClass)) {
throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
}
}
if ($model->isObjectNew()) {
return $this->_getUrl($this->getAddRoute());
} else {
return $this->_getUrl($this->getEditRoute(), [$model->getIdFieldName() => $model->getId()]);
}
} | php | public function getEditUrl($model = null)
{
if (!$model instanceof Mage_Core_Model_Abstract) {
$model = $this->getCurrentRecord();
} else {
$expectedClass = get_class($this->getModel());
if (!is_a($model, $expectedClass)) {
throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
}
}
if ($model->isObjectNew()) {
return $this->_getUrl($this->getAddRoute());
} else {
return $this->_getUrl($this->getEditRoute(), [$model->getIdFieldName() => $model->getId()]);
}
} | [
"public",
"function",
"getEditUrl",
"(",
"$",
"model",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"Mage_Core_Model_Abstract",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getCurrentRecord",
"(",
")",
";",
"}",
"else",
"{",
"$",
"expectedClass",
"=",
"get_class",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"model",
",",
"$",
"expectedClass",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid model class. Expected:%1$s Passed:%2$s'",
",",
"$",
"expectedClass",
",",
"get_class",
"(",
"$",
"model",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"model",
"->",
"isObjectNew",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_getUrl",
"(",
"$",
"this",
"->",
"getAddRoute",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_getUrl",
"(",
"$",
"this",
"->",
"getEditRoute",
"(",
")",
",",
"[",
"$",
"model",
"->",
"getIdFieldName",
"(",
")",
"=>",
"$",
"model",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}",
"}"
] | @param Mage_Core_Model_Abstract $model
@return string
@throws RuntimeException | [
"@param",
"Mage_Core_Model_Abstract",
"$model"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/AbstractModelManager.php#L44-L60 |
AOEpeople/Aoe_Layout | app/code/local/Aoe/Layout/Helper/AbstractModelManager.php | Aoe_Layout_Helper_AbstractModelManager.getDeleteUrl | public function getDeleteUrl($model = null)
{
if (!$model instanceof Mage_Core_Model_Abstract) {
$model = $this->getCurrentRecord();
} else {
$expectedClass = get_class($this->getModel());
if (!is_a($model, $expectedClass)) {
throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
}
}
return $this->_getUrl($this->getDeleteRoute(), [$model->getIdFieldName() => $model->getId()]);
} | php | public function getDeleteUrl($model = null)
{
if (!$model instanceof Mage_Core_Model_Abstract) {
$model = $this->getCurrentRecord();
} else {
$expectedClass = get_class($this->getModel());
if (!is_a($model, $expectedClass)) {
throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model)));
}
}
return $this->_getUrl($this->getDeleteRoute(), [$model->getIdFieldName() => $model->getId()]);
} | [
"public",
"function",
"getDeleteUrl",
"(",
"$",
"model",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"Mage_Core_Model_Abstract",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getCurrentRecord",
"(",
")",
";",
"}",
"else",
"{",
"$",
"expectedClass",
"=",
"get_class",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
")",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"model",
",",
"$",
"expectedClass",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"__",
"(",
"'Invalid model class. Expected:%1$s Passed:%2$s'",
",",
"$",
"expectedClass",
",",
"get_class",
"(",
"$",
"model",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_getUrl",
"(",
"$",
"this",
"->",
"getDeleteRoute",
"(",
")",
",",
"[",
"$",
"model",
"->",
"getIdFieldName",
"(",
")",
"=>",
"$",
"model",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}"
] | @param Mage_Core_Model_Abstract $model
@return string
@throws RuntimeException | [
"@param",
"Mage_Core_Model_Abstract",
"$model"
] | train | https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/AbstractModelManager.php#L77-L89 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Transport.php | Transport.getAdapterType | public function getAdapterType()
{
if($this->adapter instanceof Adapter)
{
$string = Str::factory(get_class($this->adapter));
return $string->substr($string->findLast("_"))->replace(array("_", " "), "")->toString();
}
return "Unknown";
} | php | public function getAdapterType()
{
if($this->adapter instanceof Adapter)
{
$string = Str::factory(get_class($this->adapter));
return $string->substr($string->findLast("_"))->replace(array("_", " "), "")->toString();
}
return "Unknown";
} | [
"public",
"function",
"getAdapterType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"adapter",
"instanceof",
"Adapter",
")",
"{",
"$",
"string",
"=",
"Str",
"::",
"factory",
"(",
"get_class",
"(",
"$",
"this",
"->",
"adapter",
")",
")",
";",
"return",
"$",
"string",
"->",
"substr",
"(",
"$",
"string",
"->",
"findLast",
"(",
"\"_\"",
")",
")",
"->",
"replace",
"(",
"array",
"(",
"\"_\"",
",",
"\" \"",
")",
",",
"\"\"",
")",
"->",
"toString",
"(",
")",
";",
"}",
"return",
"\"Unknown\"",
";",
"}"
] | Returns the adapter type.
@return string | [
"Returns",
"the",
"adapter",
"type",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Transport.php#L211-L221 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php | Dwoo_Adapters_ZendFramework_PluginProxy.handles | public function handles($name) {
try {
$this->view->getHelper($name);
} catch (Zend_Loader_PluginLoader_Exception $e) {
return false;
}
return true;
} | php | public function handles($name) {
try {
$this->view->getHelper($name);
} catch (Zend_Loader_PluginLoader_Exception $e) {
return false;
}
return true;
} | [
"public",
"function",
"handles",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"view",
"->",
"getHelper",
"(",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"Zend_Loader_PluginLoader_Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Called from Dwoo_Compiler to check if the requested plugin is available
@param string $name
@return bool | [
"Called",
"from",
"Dwoo_Compiler",
"to",
"check",
"if",
"the",
"requested",
"plugin",
"is",
"available"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/ZendFramework/PluginProxy.php#L43-L51 |
antaresproject/notifications | src/Decorator/SidebarItemDecorator.php | SidebarItemDecorator.decorate | public function decorate(Collection $items, $type = 'notification')
{
$view = config('antares/notifications::templates.' . $type);
if (is_null($view)) {
throw new RuntimeException('Unable to resolve notification partial view.');
}
$return = [];
foreach ($items as $item) {
$return[] = $this->item($item, $view);
}
return $return;
} | php | public function decorate(Collection $items, $type = 'notification')
{
$view = config('antares/notifications::templates.' . $type);
if (is_null($view)) {
throw new RuntimeException('Unable to resolve notification partial view.');
}
$return = [];
foreach ($items as $item) {
$return[] = $this->item($item, $view);
}
return $return;
} | [
"public",
"function",
"decorate",
"(",
"Collection",
"$",
"items",
",",
"$",
"type",
"=",
"'notification'",
")",
"{",
"$",
"view",
"=",
"config",
"(",
"'antares/notifications::templates.'",
".",
"$",
"type",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"view",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable to resolve notification partial view.'",
")",
";",
"}",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"this",
"->",
"item",
"(",
"$",
"item",
",",
"$",
"view",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Decorates notifications of alerts
@param Collection $items
@param String $type
@return array
@throws RuntimeException | [
"Decorates",
"notifications",
"of",
"alerts"
] | train | https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Decorator/SidebarItemDecorator.php#L39-L50 |
antaresproject/notifications | src/Decorator/SidebarItemDecorator.php | SidebarItemDecorator.item | public function item(Model $item, $view)
{
$content = $this->getVariablesAdapter()->get($item->content[0]->content, (array) $item->variables);
return view($view, [
'id' => $item->id,
'author' => $item->author,
'title' => $item->content[0]->title,
'value' => $content,
'priority' => priority_label($item->notification->severity->name),
'created_at' => $item->created_at
])->render();
} | php | public function item(Model $item, $view)
{
$content = $this->getVariablesAdapter()->get($item->content[0]->content, (array) $item->variables);
return view($view, [
'id' => $item->id,
'author' => $item->author,
'title' => $item->content[0]->title,
'value' => $content,
'priority' => priority_label($item->notification->severity->name),
'created_at' => $item->created_at
])->render();
} | [
"public",
"function",
"item",
"(",
"Model",
"$",
"item",
",",
"$",
"view",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getVariablesAdapter",
"(",
")",
"->",
"get",
"(",
"$",
"item",
"->",
"content",
"[",
"0",
"]",
"->",
"content",
",",
"(",
"array",
")",
"$",
"item",
"->",
"variables",
")",
";",
"return",
"view",
"(",
"$",
"view",
",",
"[",
"'id'",
"=>",
"$",
"item",
"->",
"id",
",",
"'author'",
"=>",
"$",
"item",
"->",
"author",
",",
"'title'",
"=>",
"$",
"item",
"->",
"content",
"[",
"0",
"]",
"->",
"title",
",",
"'value'",
"=>",
"$",
"content",
",",
"'priority'",
"=>",
"priority_label",
"(",
"$",
"item",
"->",
"notification",
"->",
"severity",
"->",
"name",
")",
",",
"'created_at'",
"=>",
"$",
"item",
"->",
"created_at",
"]",
")",
"->",
"render",
"(",
")",
";",
"}"
] | Decorates single item
@param Model $item
@param String $view
@return String | [
"Decorates",
"single",
"item"
] | train | https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Decorator/SidebarItemDecorator.php#L59-L71 |
odiaseo/pagebuilder | src/PageBuilder/Model/PageModel.php | PageModel.getActivePages | public function getActivePages($mode = AbstractQuery::HYDRATE_OBJECT)
{
$qb = $this->getEntityManager()->createQueryBuilder();
/** @var $query \Doctrine\ORM\Query */
$query = $qb->select('e')
->from($this->getEntity(), 'e')
->where('e.isVisible = 1')
->andWhere('e.parent NOT IN (12, 15)')
->andWhere('e.level > 0')
->getQuery();
$result = $query->getResult($mode);
return $result;
} | php | public function getActivePages($mode = AbstractQuery::HYDRATE_OBJECT)
{
$qb = $this->getEntityManager()->createQueryBuilder();
/** @var $query \Doctrine\ORM\Query */
$query = $qb->select('e')
->from($this->getEntity(), 'e')
->where('e.isVisible = 1')
->andWhere('e.parent NOT IN (12, 15)')
->andWhere('e.level > 0')
->getQuery();
$result = $query->getResult($mode);
return $result;
} | [
"public",
"function",
"getActivePages",
"(",
"$",
"mode",
"=",
"AbstractQuery",
"::",
"HYDRATE_OBJECT",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
";",
"/** @var $query \\Doctrine\\ORM\\Query */",
"$",
"query",
"=",
"$",
"qb",
"->",
"select",
"(",
"'e'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"getEntity",
"(",
")",
",",
"'e'",
")",
"->",
"where",
"(",
"'e.isVisible = 1'",
")",
"->",
"andWhere",
"(",
"'e.parent NOT IN (12, 15)'",
")",
"->",
"andWhere",
"(",
"'e.level > 0'",
")",
"->",
"getQuery",
"(",
")",
";",
"$",
"result",
"=",
"$",
"query",
"->",
"getResult",
"(",
"$",
"mode",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param int $mode
@return array | [
"@param",
"int",
"$mode"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/PageModel.php#L187-L202 |
odiaseo/pagebuilder | src/PageBuilder/Model/PageModel.php | PageModel.getMainPageById | public function getMainPageById($id, $mode = AbstractQuery::HYDRATE_ARRAY)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('e.id, t.layout', 'p.id as parentId', 't.id as templateId')
->from($this->getEntity(), 'e')
->leftJoin('e.template', 't')
->leftJoin('e.parent', 'p')
->where('e.id = :id')
->setParameters(
[
':id' => $id,
]
);
$qb->setEnableHydrationCache($this->enableResultCache);
$result = $qb->getQuery()->getOneOrNullResult($mode);
return $result;
} | php | public function getMainPageById($id, $mode = AbstractQuery::HYDRATE_ARRAY)
{
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('e.id, t.layout', 'p.id as parentId', 't.id as templateId')
->from($this->getEntity(), 'e')
->leftJoin('e.template', 't')
->leftJoin('e.parent', 'p')
->where('e.id = :id')
->setParameters(
[
':id' => $id,
]
);
$qb->setEnableHydrationCache($this->enableResultCache);
$result = $qb->getQuery()->getOneOrNullResult($mode);
return $result;
} | [
"public",
"function",
"getMainPageById",
"(",
"$",
"id",
",",
"$",
"mode",
"=",
"AbstractQuery",
"::",
"HYDRATE_ARRAY",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'e.id, t.layout'",
",",
"'p.id as parentId'",
",",
"'t.id as templateId'",
")",
"->",
"from",
"(",
"$",
"this",
"->",
"getEntity",
"(",
")",
",",
"'e'",
")",
"->",
"leftJoin",
"(",
"'e.template'",
",",
"'t'",
")",
"->",
"leftJoin",
"(",
"'e.parent'",
",",
"'p'",
")",
"->",
"where",
"(",
"'e.id = :id'",
")",
"->",
"setParameters",
"(",
"[",
"':id'",
"=>",
"$",
"id",
",",
"]",
")",
";",
"$",
"qb",
"->",
"setEnableHydrationCache",
"(",
"$",
"this",
"->",
"enableResultCache",
")",
";",
"$",
"result",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getOneOrNullResult",
"(",
"$",
"mode",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param $id
@param int $mode
@return mixed
@throws \Doctrine\ORM\NonUniqueResultException | [
"@param",
"$id",
"@param",
"int",
"$mode"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/PageModel.php#L211-L229 |
odiaseo/pagebuilder | src/PageBuilder/Model/PageModel.php | PageModel.getEntityNavigation | public function getEntityNavigation($rootPage = null, $mode = AbstractQuery::HYDRATE_ARRAY, $cacheKey = null)
{
/** @var $repo PageRepository */
$this->setCacheKey($cacheKey);
$repo = $this->getRepository();
$query = $this->addHints($repo->getNodesHierarchyQuery($rootPage));
$query = $this->setCacheFlag($query);
return $query->execute([], $mode);
} | php | public function getEntityNavigation($rootPage = null, $mode = AbstractQuery::HYDRATE_ARRAY, $cacheKey = null)
{
/** @var $repo PageRepository */
$this->setCacheKey($cacheKey);
$repo = $this->getRepository();
$query = $this->addHints($repo->getNodesHierarchyQuery($rootPage));
$query = $this->setCacheFlag($query);
return $query->execute([], $mode);
} | [
"public",
"function",
"getEntityNavigation",
"(",
"$",
"rootPage",
"=",
"null",
",",
"$",
"mode",
"=",
"AbstractQuery",
"::",
"HYDRATE_ARRAY",
",",
"$",
"cacheKey",
"=",
"null",
")",
"{",
"/** @var $repo PageRepository */",
"$",
"this",
"->",
"setCacheKey",
"(",
"$",
"cacheKey",
")",
";",
"$",
"repo",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"addHints",
"(",
"$",
"repo",
"->",
"getNodesHierarchyQuery",
"(",
"$",
"rootPage",
")",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"setCacheFlag",
"(",
"$",
"query",
")",
";",
"return",
"$",
"query",
"->",
"execute",
"(",
"[",
"]",
",",
"$",
"mode",
")",
";",
"}"
] | @param null $rootPage
@param int $mode
@param null $cacheKey
@return mixed | [
"@param",
"null",
"$rootPage",
"@param",
"int",
"$mode",
"@param",
"null",
"$cacheKey"
] | train | https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Model/PageModel.php#L254-L263 |
old-town/workflow-designer-server | src/View/WorkflowDescriptorApiRenderer.php | WorkflowDescriptorApiRenderer.render | public function render($nameOrModel, $values = null)
{
/** @var WorkflowDescriptor $data */
$data = $this->getRendererData($nameOrModel);
$output = $data->writeXml()->saveXML();
return $output;
} | php | public function render($nameOrModel, $values = null)
{
/** @var WorkflowDescriptor $data */
$data = $this->getRendererData($nameOrModel);
$output = $data->writeXml()->saveXML();
return $output;
} | [
"public",
"function",
"render",
"(",
"$",
"nameOrModel",
",",
"$",
"values",
"=",
"null",
")",
"{",
"/** @var WorkflowDescriptor $data */",
"$",
"data",
"=",
"$",
"this",
"->",
"getRendererData",
"(",
"$",
"nameOrModel",
")",
";",
"$",
"output",
"=",
"$",
"data",
"->",
"writeXml",
"(",
")",
"->",
"saveXML",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | @param string|\Zend\View\Model\ModelInterface $nameOrModel
@param null $values
@return string
@throws \OldTown\Workflow\Exception\InternalWorkflowException
@throws \OldTown\Workflow\Exception\InvalidDescriptorException
@throws \OldTown\Workflow\Exception\InvalidWriteWorkflowException
@throws \Zend\View\Exception\RuntimeException | [
"@param",
"string|",
"\\",
"Zend",
"\\",
"View",
"\\",
"Model",
"\\",
"ModelInterface",
"$nameOrModel",
"@param",
"null",
"$values"
] | train | https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/WorkflowDescriptorApiRenderer.php#L87-L96 |
old-town/workflow-designer-server | src/View/WorkflowDescriptorApiRenderer.php | WorkflowDescriptorApiRenderer.getRendererData | protected function getRendererData($nameOrModel)
{
if (!$nameOrModel instanceof WorkflowDescriptorApiModel) {
$errMsg = sprintf('Рендерер поддерживает только %s', WorkflowDescriptorApiModel::class);
throw new Exception\RuntimeException($errMsg);
}
if ($nameOrModel->isEntity()) {
/** @var Entity $payload */
$payload = $nameOrModel->getPayload();
$descriptor = call_user_func([$payload, '__get'], 'entity');
if ($descriptor instanceof WorkflowDescriptor) {
return $descriptor;
}
}
$errMsg = 'Ошибка в рендеринге';
throw new Exception\RuntimeException($errMsg);
} | php | protected function getRendererData($nameOrModel)
{
if (!$nameOrModel instanceof WorkflowDescriptorApiModel) {
$errMsg = sprintf('Рендерер поддерживает только %s', WorkflowDescriptorApiModel::class);
throw new Exception\RuntimeException($errMsg);
}
if ($nameOrModel->isEntity()) {
/** @var Entity $payload */
$payload = $nameOrModel->getPayload();
$descriptor = call_user_func([$payload, '__get'], 'entity');
if ($descriptor instanceof WorkflowDescriptor) {
return $descriptor;
}
}
$errMsg = 'Ошибка в рендеринге';
throw new Exception\RuntimeException($errMsg);
} | [
"protected",
"function",
"getRendererData",
"(",
"$",
"nameOrModel",
")",
"{",
"if",
"(",
"!",
"$",
"nameOrModel",
"instanceof",
"WorkflowDescriptorApiModel",
")",
"{",
"$",
"errMsg",
"=",
"sprintf",
"(",
"'Рендерер поддерживает только %s', WorkflowDescriptorApiMod",
"e",
"::class);",
"",
"",
"",
"",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"$",
"errMsg",
")",
";",
"}",
"if",
"(",
"$",
"nameOrModel",
"->",
"isEntity",
"(",
")",
")",
"{",
"/** @var Entity $payload */",
"$",
"payload",
"=",
"$",
"nameOrModel",
"->",
"getPayload",
"(",
")",
";",
"$",
"descriptor",
"=",
"call_user_func",
"(",
"[",
"$",
"payload",
",",
"'__get'",
"]",
",",
"'entity'",
")",
";",
"if",
"(",
"$",
"descriptor",
"instanceof",
"WorkflowDescriptor",
")",
"{",
"return",
"$",
"descriptor",
";",
"}",
"}",
"$",
"errMsg",
"=",
"'Ошибка в рендеринге';",
"",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"$",
"errMsg",
")",
";",
"}"
] | @param $nameOrModel
@return array|string|ApiProblem
@throws Exception\RuntimeException | [
"@param",
"$nameOrModel"
] | train | https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/WorkflowDescriptorApiRenderer.php#L105-L124 |
endroid/import-bundle | src/DependencyInjection/Compiler/ImporterCompilerPass.php | ImporterCompilerPass.process | public function process(ContainerBuilder $container)
{
$taggedServices = $container->findTaggedServiceIds('endroid.import.importer');
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $attributes) {
$name = $attributes['importer'];
$commandDefinition = new Definition(ImportCommand::class, ['endroid:import:'.$name, new Reference($id)]);
$commandDefinition->addTag('console.command');
$container->setDefinition('endroid_import.command.'.$name, $commandDefinition);
$container->setAlias('endroid_import.importer.'.$name, $id);
}
}
} | php | public function process(ContainerBuilder $container)
{
$taggedServices = $container->findTaggedServiceIds('endroid.import.importer');
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $attributes) {
$name = $attributes['importer'];
$commandDefinition = new Definition(ImportCommand::class, ['endroid:import:'.$name, new Reference($id)]);
$commandDefinition->addTag('console.command');
$container->setDefinition('endroid_import.command.'.$name, $commandDefinition);
$container->setAlias('endroid_import.importer.'.$name, $id);
}
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"taggedServices",
"=",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'endroid.import.importer'",
")",
";",
"foreach",
"(",
"$",
"taggedServices",
"as",
"$",
"id",
"=>",
"$",
"tags",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"attributes",
")",
"{",
"$",
"name",
"=",
"$",
"attributes",
"[",
"'importer'",
"]",
";",
"$",
"commandDefinition",
"=",
"new",
"Definition",
"(",
"ImportCommand",
"::",
"class",
",",
"[",
"'endroid:import:'",
".",
"$",
"name",
",",
"new",
"Reference",
"(",
"$",
"id",
")",
"]",
")",
";",
"$",
"commandDefinition",
"->",
"addTag",
"(",
"'console.command'",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"'endroid_import.command.'",
".",
"$",
"name",
",",
"$",
"commandDefinition",
")",
";",
"$",
"container",
"->",
"setAlias",
"(",
"'endroid_import.importer.'",
".",
"$",
"name",
",",
"$",
"id",
")",
";",
"}",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/endroid/import-bundle/blob/637f29720822432192efad6993f505adc9dd4af4/src/DependencyInjection/Compiler/ImporterCompilerPass.php#L25-L38 |
WellCommerce/AppBundle | Controller/Front/CurrencyController.php | CurrencyController.switchAction | public function switchAction(Request $request, string $currency) : RedirectResponse
{
$result = $this->get('currency.repository')->findOneBy(['code' => $currency]);
if (null !== $result) {
$request->getSession()->set('_currency', $currency);
}
return new RedirectResponse($request->headers->get('referer'));
} | php | public function switchAction(Request $request, string $currency) : RedirectResponse
{
$result = $this->get('currency.repository')->findOneBy(['code' => $currency]);
if (null !== $result) {
$request->getSession()->set('_currency', $currency);
}
return new RedirectResponse($request->headers->get('referer'));
} | [
"public",
"function",
"switchAction",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"currency",
")",
":",
"RedirectResponse",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"'currency.repository'",
")",
"->",
"findOneBy",
"(",
"[",
"'code'",
"=>",
"$",
"currency",
"]",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"result",
")",
"{",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"'_currency'",
",",
"$",
"currency",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'referer'",
")",
")",
";",
"}"
] | Sets new session currency
@param Request $request
@param string $currency
@return RedirectResponse | [
"Sets",
"new",
"session",
"currency"
] | train | https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Controller/Front/CurrencyController.php#L34-L42 |
romainbessugesmeusy/php-datagrid | library/RBM/Datagrid/DataGrid.php | DataGrid.addColumn | public function addColumn($name, $accessor = null)
{
$col = new\RBM\Datagrid\Column($this, $name, count($this->_columns), $accessor);
$this->_columns[$name] = $col;
$this->_columnsPositions[] = $name;
return $col;
} | php | public function addColumn($name, $accessor = null)
{
$col = new\RBM\Datagrid\Column($this, $name, count($this->_columns), $accessor);
$this->_columns[$name] = $col;
$this->_columnsPositions[] = $name;
return $col;
} | [
"public",
"function",
"addColumn",
"(",
"$",
"name",
",",
"$",
"accessor",
"=",
"null",
")",
"{",
"$",
"col",
"=",
"new",
"\\",
"RBM",
"\\",
"Datagrid",
"\\",
"Column",
"(",
"$",
"this",
",",
"$",
"name",
",",
"count",
"(",
"$",
"this",
"->",
"_columns",
")",
",",
"$",
"accessor",
")",
";",
"$",
"this",
"->",
"_columns",
"[",
"$",
"name",
"]",
"=",
"$",
"col",
";",
"$",
"this",
"->",
"_columnsPositions",
"[",
"]",
"=",
"$",
"name",
";",
"return",
"$",
"col",
";",
"}"
] | Ajoute une colonne au tableau. Crée un objet de type\RBM\Datagrid\Column et le retourne.
La colonne est par défaut visible.
@assert (null, null) throws InvalidArgumentException
@param $name
@param $accessor
@return\RBM\Datagrid\Column | [
"Ajoute",
"une",
"colonne",
"au",
"tableau",
".",
"Crée",
"un",
"objet",
"de",
"type",
"\\",
"RBM",
"\\",
"Datagrid",
"\\",
"Column",
"et",
"le",
"retourne",
".",
"La",
"colonne",
"est",
"par",
"défaut",
"visible",
"."
] | train | https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/DataGrid.php#L88-L94 |
romainbessugesmeusy/php-datagrid | library/RBM/Datagrid/DataGrid.php | DataGrid.getColumn | public function getColumn($columnName)
{
return isset($this->_columns[$columnName]) ? $this->_columns[$columnName] : null;
} | php | public function getColumn($columnName)
{
return isset($this->_columns[$columnName]) ? $this->_columns[$columnName] : null;
} | [
"public",
"function",
"getColumn",
"(",
"$",
"columnName",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_columns",
"[",
"$",
"columnName",
"]",
")",
"?",
"$",
"this",
"->",
"_columns",
"[",
"$",
"columnName",
"]",
":",
"null",
";",
"}"
] | Récupère un\RBM\Datagrid\Column en fonction de sa position
@assert (null) throws InvalidArgumentException
@assert (true) throws InvalidArgumentException
@assert (-1) throws OutOfRangeException
@param $columnName
@return\RBM\Datagrid\Column|null | [
"Récupère",
"un",
"\\",
"RBM",
"\\",
"Datagrid",
"\\",
"Column",
"en",
"fonction",
"de",
"sa",
"position"
] | train | https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/DataGrid.php#L104-L107 |
php-lug/lug | src/Component/Resource/Repository/Doctrine/ORM/RepositoryFactory.php | RepositoryFactory.getRepository | public function getRepository(EntityManagerInterface $entityManager, $entityName)
{
$metadata = $entityManager->getClassMetadata($entityName);
$hash = $metadata->getName().spl_object_hash($entityManager);
if (isset($this->cache[$hash])) {
return $this->cache[$hash];
}
return $this->cache[$hash] = $this->createRepository($entityManager, $entityName);
} | php | public function getRepository(EntityManagerInterface $entityManager, $entityName)
{
$metadata = $entityManager->getClassMetadata($entityName);
$hash = $metadata->getName().spl_object_hash($entityManager);
if (isset($this->cache[$hash])) {
return $this->cache[$hash];
}
return $this->cache[$hash] = $this->createRepository($entityManager, $entityName);
} | [
"public",
"function",
"getRepository",
"(",
"EntityManagerInterface",
"$",
"entityManager",
",",
"$",
"entityName",
")",
"{",
"$",
"metadata",
"=",
"$",
"entityManager",
"->",
"getClassMetadata",
"(",
"$",
"entityName",
")",
";",
"$",
"hash",
"=",
"$",
"metadata",
"->",
"getName",
"(",
")",
".",
"spl_object_hash",
"(",
"$",
"entityManager",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
"=",
"$",
"this",
"->",
"createRepository",
"(",
"$",
"entityManager",
",",
"$",
"entityName",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/ORM/RepositoryFactory.php#L48-L58 |
php-lug/lug | src/Component/Resource/Repository/Doctrine/ORM/RepositoryFactory.php | RepositoryFactory.createRepository | protected function createRepository(EntityManagerInterface $entityManager, $entityName)
{
$metadata = $entityManager->getClassMetadata($entityName);
$repository = $metadata->customRepositoryClassName;
if ($repository === null) {
$repository = $entityManager->getConfiguration()->getDefaultRepositoryClassName();
}
return $this->createResourceRepository(
$repository,
$entityManager,
$metadata,
$this->resolveResource($metadata->getName())
);
} | php | protected function createRepository(EntityManagerInterface $entityManager, $entityName)
{
$metadata = $entityManager->getClassMetadata($entityName);
$repository = $metadata->customRepositoryClassName;
if ($repository === null) {
$repository = $entityManager->getConfiguration()->getDefaultRepositoryClassName();
}
return $this->createResourceRepository(
$repository,
$entityManager,
$metadata,
$this->resolveResource($metadata->getName())
);
} | [
"protected",
"function",
"createRepository",
"(",
"EntityManagerInterface",
"$",
"entityManager",
",",
"$",
"entityName",
")",
"{",
"$",
"metadata",
"=",
"$",
"entityManager",
"->",
"getClassMetadata",
"(",
"$",
"entityName",
")",
";",
"$",
"repository",
"=",
"$",
"metadata",
"->",
"customRepositoryClassName",
";",
"if",
"(",
"$",
"repository",
"===",
"null",
")",
"{",
"$",
"repository",
"=",
"$",
"entityManager",
"->",
"getConfiguration",
"(",
")",
"->",
"getDefaultRepositoryClassName",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createResourceRepository",
"(",
"$",
"repository",
",",
"$",
"entityManager",
",",
"$",
"metadata",
",",
"$",
"this",
"->",
"resolveResource",
"(",
"$",
"metadata",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | @param EntityManagerInterface $entityManager
@param string $entityName
@return ObjectRepository | [
"@param",
"EntityManagerInterface",
"$entityManager",
"@param",
"string",
"$entityName"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/ORM/RepositoryFactory.php#L66-L81 |
php-lug/lug | src/Component/Resource/Repository/Doctrine/ORM/RepositoryFactory.php | RepositoryFactory.createResourceRepository | protected function createResourceRepository(
$class,
EntityManagerInterface $entityManager,
ClassMetadata $metadata,
ResourceInterface $resource = null
) {
if ($resource !== null && is_a($class, BaseRepositoryInterface::class, true)) {
return new $class($entityManager, $metadata, $resource);
}
return new $class($entityManager, $metadata);
} | php | protected function createResourceRepository(
$class,
EntityManagerInterface $entityManager,
ClassMetadata $metadata,
ResourceInterface $resource = null
) {
if ($resource !== null && is_a($class, BaseRepositoryInterface::class, true)) {
return new $class($entityManager, $metadata, $resource);
}
return new $class($entityManager, $metadata);
} | [
"protected",
"function",
"createResourceRepository",
"(",
"$",
"class",
",",
"EntityManagerInterface",
"$",
"entityManager",
",",
"ClassMetadata",
"$",
"metadata",
",",
"ResourceInterface",
"$",
"resource",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"resource",
"!==",
"null",
"&&",
"is_a",
"(",
"$",
"class",
",",
"BaseRepositoryInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"entityManager",
",",
"$",
"metadata",
",",
"$",
"resource",
")",
";",
"}",
"return",
"new",
"$",
"class",
"(",
"$",
"entityManager",
",",
"$",
"metadata",
")",
";",
"}"
] | @param string $class
@param EntityManagerInterface $entityManager
@param ClassMetadata $metadata
@param ResourceInterface|null $resource
@return ObjectRepository | [
"@param",
"string",
"$class",
"@param",
"EntityManagerInterface",
"$entityManager",
"@param",
"ClassMetadata",
"$metadata",
"@param",
"ResourceInterface|null",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Resource/Repository/Doctrine/ORM/RepositoryFactory.php#L91-L102 |
nabab/bbn | src/bbn/api/cloudmin.php | cloudmin.sanitize | private function sanitize($st){
$st = trim((string)$st);
if ( strpos($st, ';') !== false ){
return '';
}
if ( strpos($st, '<') !== false ){
return '';
}
if ( strpos($st, '"') !== false ){
return '';
}
if ( strpos($st, "'") !== false ){
return '';
}
return $st;
} | php | private function sanitize($st){
$st = trim((string)$st);
if ( strpos($st, ';') !== false ){
return '';
}
if ( strpos($st, '<') !== false ){
return '';
}
if ( strpos($st, '"') !== false ){
return '';
}
if ( strpos($st, "'") !== false ){
return '';
}
return $st;
} | [
"private",
"function",
"sanitize",
"(",
"$",
"st",
")",
"{",
"$",
"st",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"st",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"';'",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"'<'",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"'\"'",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"st",
",",
"\"'\"",
")",
"!==",
"false",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"st",
";",
"}"
] | This function is used to sanitize the strings which are given as parameters
@param string $st
@return string The the header url part to be executed | [
"This",
"function",
"is",
"used",
"to",
"sanitize",
"the",
"strings",
"which",
"are",
"given",
"as",
"parameters"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L222-L237 |
nabab/bbn | src/bbn/api/cloudmin.php | cloudmin.call_shell_exec | private function call_shell_exec($request){
//Executing the shell_exec
//die(var_dump($this->mode, $request));
if ( $result = shell_exec($request) ){
//Decoding the json result into an array
$result_array = json_decode($result, TRUE);
if ( isset($result_array['error']) ){
$this->error = $result_array['error'];
}
if ($result_array['status'] === 'success' ){
if (isset($result_array['data'])){
if ( isset($result_array['data'][0], $result_array['data'][0]['name']) &&
($result_array['data'][0]['name'] === 'Warning') ){
$result_array['data'] = \array_slice($result_array['data'], 1);
}
return $result_array['data'];
}
else if (isset($result_array['output'])){
return $result_array['output'];
}
}
}
return false;
} | php | private function call_shell_exec($request){
//Executing the shell_exec
//die(var_dump($this->mode, $request));
if ( $result = shell_exec($request) ){
//Decoding the json result into an array
$result_array = json_decode($result, TRUE);
if ( isset($result_array['error']) ){
$this->error = $result_array['error'];
}
if ($result_array['status'] === 'success' ){
if (isset($result_array['data'])){
if ( isset($result_array['data'][0], $result_array['data'][0]['name']) &&
($result_array['data'][0]['name'] === 'Warning') ){
$result_array['data'] = \array_slice($result_array['data'], 1);
}
return $result_array['data'];
}
else if (isset($result_array['output'])){
return $result_array['output'];
}
}
}
return false;
} | [
"private",
"function",
"call_shell_exec",
"(",
"$",
"request",
")",
"{",
"//Executing the shell_exec",
"//die(var_dump($this->mode, $request));",
"if",
"(",
"$",
"result",
"=",
"shell_exec",
"(",
"$",
"request",
")",
")",
"{",
"//Decoding the json result into an array",
"$",
"result_array",
"=",
"json_decode",
"(",
"$",
"result",
",",
"TRUE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result_array",
"[",
"'error'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"$",
"result_array",
"[",
"'error'",
"]",
";",
"}",
"if",
"(",
"$",
"result_array",
"[",
"'status'",
"]",
"===",
"'success'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result_array",
"[",
"'data'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result_array",
"[",
"'data'",
"]",
"[",
"0",
"]",
",",
"$",
"result_array",
"[",
"'data'",
"]",
"[",
"0",
"]",
"[",
"'name'",
"]",
")",
"&&",
"(",
"$",
"result_array",
"[",
"'data'",
"]",
"[",
"0",
"]",
"[",
"'name'",
"]",
"===",
"'Warning'",
")",
")",
"{",
"$",
"result_array",
"[",
"'data'",
"]",
"=",
"\\",
"array_slice",
"(",
"$",
"result_array",
"[",
"'data'",
"]",
",",
"1",
")",
";",
"}",
"return",
"$",
"result_array",
"[",
"'data'",
"]",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"result_array",
"[",
"'output'",
"]",
")",
")",
"{",
"return",
"$",
"result_array",
"[",
"'output'",
"]",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Executes the $request using shell_exec
@param string $request the command to be excecuted
@return array an array with the execution status and message | [
"Executes",
"the",
"$request",
"using",
"shell_exec"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L261-L284 |
nabab/bbn | src/bbn/api/cloudmin.php | cloudmin.process_parameters | private function process_parameters($param){
foreach ($param as $key => $val){
//$val is an array
if (\is_array($val)){
$param[$key] = $this->process_parameters($val);
}
else {
$param[$key] = $this->sanitize($val);
}
}
//Return the processed parameters
return $param;
} | php | private function process_parameters($param){
foreach ($param as $key => $val){
//$val is an array
if (\is_array($val)){
$param[$key] = $this->process_parameters($val);
}
else {
$param[$key] = $this->sanitize($val);
}
}
//Return the processed parameters
return $param;
} | [
"private",
"function",
"process_parameters",
"(",
"$",
"param",
")",
"{",
"foreach",
"(",
"$",
"param",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"//$val is an array",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"param",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"process_parameters",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"param",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"val",
")",
";",
"}",
"}",
"//Return the processed parameters",
"return",
"$",
"param",
";",
"}"
] | Sanitize each parameter
@param array $param the raw parameters
@return array the processed parameters | [
"Sanitize",
"each",
"parameter"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L291-L303 |
nabab/bbn | src/bbn/api/cloudmin.php | cloudmin.get_args | public function get_args($name){
if ( $this->checked ){
$cmd_name = str_replace('_', '-', $name);
return isset($this->commands[$cmd_name], $this->commands[$cmd_name]['args']) ? $this->commands[$cmd_name]['args'] : [];
}
} | php | public function get_args($name){
if ( $this->checked ){
$cmd_name = str_replace('_', '-', $name);
return isset($this->commands[$cmd_name], $this->commands[$cmd_name]['args']) ? $this->commands[$cmd_name]['args'] : [];
}
} | [
"public",
"function",
"get_args",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checked",
")",
"{",
"$",
"cmd_name",
"=",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"$",
"name",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd_name",
"]",
",",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd_name",
"]",
"[",
"'args'",
"]",
")",
"?",
"$",
"this",
"->",
"commands",
"[",
"$",
"cmd_name",
"]",
"[",
"'args'",
"]",
":",
"[",
"]",
";",
"}",
"}"
] | Returns the arguments description of a given command
@param $name The command name
@return array | [
"Returns",
"the",
"arguments",
"description",
"of",
"a",
"given",
"command"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L310-L315 |
nabab/bbn | src/bbn/api/cloudmin.php | cloudmin.list_commands | public function list_commands($param = []){
//Prepping, processing and validating the create user parameters
$param = $this->process_parameters($param);
//Setting the last action performed
$this->last_action = "list-commands";
//Defining the $url_part and the command to be executed
$url_part = "list-commands";
if (isset($param['short'])){//short parameter is set
$url_part .= "&short";
}
if (isset($param['nameonly'])){//nameonly parameter is set
$url_part .= "&nameonly";
}
//Concatenating the closing single quote
$url_part .="'";
//Concatenating the header url and $url_part to create the full url to be executed
$url_part = $this->get_header_url() . $url_part;
//Calling shell_exec and returning the result array
return $this->call_shell_exec($url_part);
} | php | public function list_commands($param = []){
//Prepping, processing and validating the create user parameters
$param = $this->process_parameters($param);
//Setting the last action performed
$this->last_action = "list-commands";
//Defining the $url_part and the command to be executed
$url_part = "list-commands";
if (isset($param['short'])){//short parameter is set
$url_part .= "&short";
}
if (isset($param['nameonly'])){//nameonly parameter is set
$url_part .= "&nameonly";
}
//Concatenating the closing single quote
$url_part .="'";
//Concatenating the header url and $url_part to create the full url to be executed
$url_part = $this->get_header_url() . $url_part;
//Calling shell_exec and returning the result array
return $this->call_shell_exec($url_part);
} | [
"public",
"function",
"list_commands",
"(",
"$",
"param",
"=",
"[",
"]",
")",
"{",
"//Prepping, processing and validating the create user parameters",
"$",
"param",
"=",
"$",
"this",
"->",
"process_parameters",
"(",
"$",
"param",
")",
";",
"//Setting the last action performed",
"$",
"this",
"->",
"last_action",
"=",
"\"list-commands\"",
";",
"//Defining the $url_part and the command to be executed",
"$",
"url_part",
"=",
"\"list-commands\"",
";",
"if",
"(",
"isset",
"(",
"$",
"param",
"[",
"'short'",
"]",
")",
")",
"{",
"//short parameter is set",
"$",
"url_part",
".=",
"\"&short\"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"param",
"[",
"'nameonly'",
"]",
")",
")",
"{",
"//nameonly parameter is set",
"$",
"url_part",
".=",
"\"&nameonly\"",
";",
"}",
"//Concatenating the closing single quote",
"$",
"url_part",
".=",
"\"'\"",
";",
"//Concatenating the header url and $url_part to create the full url to be executed",
"$",
"url_part",
"=",
"$",
"this",
"->",
"get_header_url",
"(",
")",
".",
"$",
"url_part",
";",
"//Calling shell_exec and returning the result array",
"return",
"$",
"this",
"->",
"call_shell_exec",
"(",
"$",
"url_part",
")",
";",
"}"
] | Gets all the commands directly from the API
@param array $param
@return array | [
"Gets",
"all",
"the",
"commands",
"directly",
"from",
"the",
"API"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L333-L354 |
nabab/bbn | src/bbn/api/cloudmin.php | cloudmin.generate | public function generate($command){
$perl_cmd = str_replace('_', '-', $command);
if ( isset($this->commands[$perl_cmd]) ){
$cmd = $this->commands[$perl_cmd];
$st = '$vm->'.$command.'(['.PHP_EOL;
foreach ( $cmd['args'] as $k => $v ){
$st .= "'$k' => ".($v['binary'] ? '0' : "''").PHP_EOL;
}
$st .= ']);';
return $st;
}
return false;
} | php | public function generate($command){
$perl_cmd = str_replace('_', '-', $command);
if ( isset($this->commands[$perl_cmd]) ){
$cmd = $this->commands[$perl_cmd];
$st = '$vm->'.$command.'(['.PHP_EOL;
foreach ( $cmd['args'] as $k => $v ){
$st .= "'$k' => ".($v['binary'] ? '0' : "''").PHP_EOL;
}
$st .= ']);';
return $st;
}
return false;
} | [
"public",
"function",
"generate",
"(",
"$",
"command",
")",
"{",
"$",
"perl_cmd",
"=",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"$",
"command",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"perl_cmd",
"]",
")",
")",
"{",
"$",
"cmd",
"=",
"$",
"this",
"->",
"commands",
"[",
"$",
"perl_cmd",
"]",
";",
"$",
"st",
"=",
"'$vm->'",
".",
"$",
"command",
".",
"'(['",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"cmd",
"[",
"'args'",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"st",
".=",
"\"'$k' => \"",
".",
"(",
"$",
"v",
"[",
"'binary'",
"]",
"?",
"'0'",
":",
"\"''\"",
")",
".",
"PHP_EOL",
";",
"}",
"$",
"st",
".=",
"']);'",
";",
"return",
"$",
"st",
";",
"}",
"return",
"false",
";",
"}"
] | Returns a string of PHP code for executing a given command with all its possible parameters pre-populated
@param $command
@return bool|string | [
"Returns",
"a",
"string",
"of",
"PHP",
"code",
"for",
"executing",
"a",
"given",
"command",
"with",
"all",
"its",
"possible",
"parameters",
"pre",
"-",
"populated"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L380-L392 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.openFiscalReceipt | public function openFiscalReceipt( $tipo_ticket ){
$tipo_ticket = $this->arrayMapTipoTicket[$tipo_ticket];
return "@".$this->cm('FS').$tipo_ticket.$this->cm('FS')."T";
} | php | public function openFiscalReceipt( $tipo_ticket ){
$tipo_ticket = $this->arrayMapTipoTicket[$tipo_ticket];
return "@".$this->cm('FS').$tipo_ticket.$this->cm('FS')."T";
} | [
"public",
"function",
"openFiscalReceipt",
"(",
"$",
"tipo_ticket",
")",
"{",
"$",
"tipo_ticket",
"=",
"$",
"this",
"->",
"arrayMapTipoTicket",
"[",
"$",
"tipo_ticket",
"]",
";",
"return",
"\"@\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"tipo_ticket",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"\"T\"",
";",
"}"
] | Me abre un documento fiscal
@param $tipo_ticket el topo de ticket que quiero abrir
las psobilidades son:
"T": abre un ticket
"A": abre ticket factura 'A'
"B": abre ticket factura 'B' o 'C'
"a": abre recibo 'A'
"b": abre recibo 'B'
"D": Nota de Débito 'A'
"E": Nota de Débito B/C | [
"Me",
"abre",
"un",
"documento",
"fiscal"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L47-L51 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.printFiscalText | public function printFiscalText($texto, $doble_ancho = false ,$display = 0){
$texto = substr($texto,0,30);
if($doble_ancho){
$texto = $this->cm('DOBLE_ANCHO').$texto;
}
return "A".$this->cm('FS').$texto.$this->cm('FS').$display;
} | php | public function printFiscalText($texto, $doble_ancho = false ,$display = 0){
$texto = substr($texto,0,30);
if($doble_ancho){
$texto = $this->cm('DOBLE_ANCHO').$texto;
}
return "A".$this->cm('FS').$texto.$this->cm('FS').$display;
} | [
"public",
"function",
"printFiscalText",
"(",
"$",
"texto",
",",
"$",
"doble_ancho",
"=",
"false",
",",
"$",
"display",
"=",
"0",
")",
"{",
"$",
"texto",
"=",
"substr",
"(",
"$",
"texto",
",",
"0",
",",
"30",
")",
";",
"if",
"(",
"$",
"doble_ancho",
")",
"{",
"$",
"texto",
"=",
"$",
"this",
"->",
"cm",
"(",
"'DOBLE_ANCHO'",
")",
".",
"$",
"texto",
";",
"}",
"return",
"\"A\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"texto",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"display",
";",
"}"
] | Imprime texto fiscal que se muestra por lo general antes de los articulos.
No puede contener la palabra TOTAL, porque se puede bloquear la impresora | [
"Imprime",
"texto",
"fiscal",
"que",
"se",
"muestra",
"por",
"lo",
"general",
"antes",
"de",
"los",
"articulos",
".",
"No",
"puede",
"contener",
"la",
"palabra",
"TOTAL",
"porque",
"se",
"puede",
"bloquear",
"la",
"impresora"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L57-L63 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.printLineItem | public function printLineItem($descripcion_articulo, $cantidad, $monto, $porcentaje_iva = null, $suma = true, $impuesto_interno = 0, $display = 0, $precio_total = true){
$defaultPorcentajeIva = Configure::read('Afip.default_iva_porcentaje');
if ( empty($porcentaje_iva) && $defaultPorcentajeIva ){
$porcentaje_iva = $defaultPorcentajeIva;
}
$fs = $this->cm('FS');
$descripcion_articulo = substr($descripcion_articulo,0,23);
if(!is_numeric($cantidad)) return false;
if(!is_numeric($monto)) return false;
$suma_monto = $suma?'M':'m';
$precio_total = $precio_total?'T':'B';
$comando = "B".$fs.$descripcion_articulo.$fs.$cantidad.$fs.$monto.$fs.$porcentaje_iva.$fs.$suma_monto.$fs.$impuesto_interno.$fs.$display.$fs.$precio_total;
return $comando;
} | php | public function printLineItem($descripcion_articulo, $cantidad, $monto, $porcentaje_iva = null, $suma = true, $impuesto_interno = 0, $display = 0, $precio_total = true){
$defaultPorcentajeIva = Configure::read('Afip.default_iva_porcentaje');
if ( empty($porcentaje_iva) && $defaultPorcentajeIva ){
$porcentaje_iva = $defaultPorcentajeIva;
}
$fs = $this->cm('FS');
$descripcion_articulo = substr($descripcion_articulo,0,23);
if(!is_numeric($cantidad)) return false;
if(!is_numeric($monto)) return false;
$suma_monto = $suma?'M':'m';
$precio_total = $precio_total?'T':'B';
$comando = "B".$fs.$descripcion_articulo.$fs.$cantidad.$fs.$monto.$fs.$porcentaje_iva.$fs.$suma_monto.$fs.$impuesto_interno.$fs.$display.$fs.$precio_total;
return $comando;
} | [
"public",
"function",
"printLineItem",
"(",
"$",
"descripcion_articulo",
",",
"$",
"cantidad",
",",
"$",
"monto",
",",
"$",
"porcentaje_iva",
"=",
"null",
",",
"$",
"suma",
"=",
"true",
",",
"$",
"impuesto_interno",
"=",
"0",
",",
"$",
"display",
"=",
"0",
",",
"$",
"precio_total",
"=",
"true",
")",
"{",
"$",
"defaultPorcentajeIva",
"=",
"Configure",
"::",
"read",
"(",
"'Afip.default_iva_porcentaje'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"porcentaje_iva",
")",
"&&",
"$",
"defaultPorcentajeIva",
")",
"{",
"$",
"porcentaje_iva",
"=",
"$",
"defaultPorcentajeIva",
";",
"}",
"$",
"fs",
"=",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
";",
"$",
"descripcion_articulo",
"=",
"substr",
"(",
"$",
"descripcion_articulo",
",",
"0",
",",
"23",
")",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"cantidad",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"monto",
")",
")",
"return",
"false",
";",
"$",
"suma_monto",
"=",
"$",
"suma",
"?",
"'M'",
":",
"'m'",
";",
"$",
"precio_total",
"=",
"$",
"precio_total",
"?",
"'T'",
":",
"'B'",
";",
"$",
"comando",
"=",
"\"B\"",
".",
"$",
"fs",
".",
"$",
"descripcion_articulo",
".",
"$",
"fs",
".",
"$",
"cantidad",
".",
"$",
"fs",
".",
"$",
"monto",
".",
"$",
"fs",
".",
"$",
"porcentaje_iva",
".",
"$",
"fs",
".",
"$",
"suma_monto",
".",
"$",
"fs",
".",
"$",
"impuesto_interno",
".",
"$",
"fs",
".",
"$",
"display",
".",
"$",
"fs",
".",
"$",
"precio_total",
";",
"return",
"$",
"comando",
";",
"}"
] | Imprime un articulo, o sea una linea del articulo con su description y su precio, cantidad, etc
@param string $descripcion_articulo descripcion del articulo EJ: Coca-Cola hasta 23 caracteres
@param number $cantidad puede ser un entero o un float depende de la impresora
@param number $monto float o integer depende de laimpresora
@param number $porcentaje_iva depende de la impresora algunas hay queponerle el porcentaje estilo 21.00, y otras va un 0.21
@param boolean $suma dice si el item suma o resta
@param number $impuesto_interno puede ser float o integer dependiendo laimpresora
@param number $display si la impresora tiene display aca va un digito especial para que sepa que mostrar en el display
@param boolean $precio_totalsi es precio tital quiere decir que el precio que le pasé como parametro tiene el IVA incluido, caso contrario, el precio es sin IVA y la impresora se lo va a sumar automaticamente de acuerdo al IVA qe se le pasó cmo parametro | [
"Imprime",
"un",
"articulo",
"o",
"sea",
"una",
"linea",
"del",
"articulo",
"con",
"su",
"description",
"y",
"su",
"precio",
"cantidad",
"etc"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L78-L93 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.totalTender | public function totalTender($texto, $monto_pagado, $operacion = "T", $display = 0){
$texto = substr($texto,0,28);
$operacion = strtoupper($operacion);
if( is_numeric($monto_pagado) &&
($operacion == 'C' || $operacion == 'T' || $operacion == 'R'))
{
$comando = "D".$this->cm('FS').$texto.$this->cm('FS').$monto_pagado.$this->cm('FS').$operacion.$this->cm('FS').$display;
}
else{
$comando = false;
}
return $comando;
} | php | public function totalTender($texto, $monto_pagado, $operacion = "T", $display = 0){
$texto = substr($texto,0,28);
$operacion = strtoupper($operacion);
if( is_numeric($monto_pagado) &&
($operacion == 'C' || $operacion == 'T' || $operacion == 'R'))
{
$comando = "D".$this->cm('FS').$texto.$this->cm('FS').$monto_pagado.$this->cm('FS').$operacion.$this->cm('FS').$display;
}
else{
$comando = false;
}
return $comando;
} | [
"public",
"function",
"totalTender",
"(",
"$",
"texto",
",",
"$",
"monto_pagado",
",",
"$",
"operacion",
"=",
"\"T\"",
",",
"$",
"display",
"=",
"0",
")",
"{",
"$",
"texto",
"=",
"substr",
"(",
"$",
"texto",
",",
"0",
",",
"28",
")",
";",
"$",
"operacion",
"=",
"strtoupper",
"(",
"$",
"operacion",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"monto_pagado",
")",
"&&",
"(",
"$",
"operacion",
"==",
"'C'",
"||",
"$",
"operacion",
"==",
"'T'",
"||",
"$",
"operacion",
"==",
"'R'",
")",
")",
"{",
"$",
"comando",
"=",
"\"D\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"texto",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"monto_pagado",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"operacion",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"display",
";",
"}",
"else",
"{",
"$",
"comando",
"=",
"false",
";",
"}",
"return",
"$",
"comando",
";",
"}"
] | TotalPago
@param string $texto Ejemplo: "Pago en efectivo"
@param number $monto_pagado integer o float dependiendo de la impresora
@param $operacion las piopsibilidades son:
'C': Cancela el ticket
'T': pago parcial o total
'R': devolucion de pago
@param $display para las impresoras que tengan display | [
"TotalPago"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L107-L121 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.generalDiscount | public function generalDiscount($importe_descuento = 0){
$comando = "T".$this->cm('FS').
'Descuento'.$this->cm('FS').
$importe_descuento.$this->cm('FS').
'm'.$this->cm('FS').
'0'.$this->cm('FS').
'T';
return $comando;
} | php | public function generalDiscount($importe_descuento = 0){
$comando = "T".$this->cm('FS').
'Descuento'.$this->cm('FS').
$importe_descuento.$this->cm('FS').
'm'.$this->cm('FS').
'0'.$this->cm('FS').
'T';
return $comando;
} | [
"public",
"function",
"generalDiscount",
"(",
"$",
"importe_descuento",
"=",
"0",
")",
"{",
"$",
"comando",
"=",
"\"T\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"'Descuento'",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"importe_descuento",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"'m'",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"'0'",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"'T'",
";",
"return",
"$",
"comando",
";",
"}"
] | Responde:
a. Imprimiendo una línea donde se muestra: descripción del descuento (o recargo), impuestos y monto del
descuento (o recargo) -con posterioridad a la impresión de la línea con la leyenda “Descuento (o Recargo)
general”-;
b. Restando
@param float $importe_descuento
@return string comando | [
"Responde",
":",
"a",
".",
"Imprimiendo",
"una",
"línea",
"donde",
"se",
"muestra",
":",
"descripción",
"del",
"descuento",
"(",
"o",
"recargo",
")",
"impuestos",
"y",
"monto",
"del",
"descuento",
"(",
"o",
"recargo",
")",
"-",
"con",
"posterioridad",
"a",
"la",
"impresión",
"de",
"la",
"línea",
"con",
"la",
"leyenda",
"“Descuento",
"(",
"o",
"Recargo",
")",
"general”",
"-",
";",
"b",
".",
"Restando"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L133-L141 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.setDateTime | public function setDateTime($fecha = 'now', $hora = 'now'){
$ymd = date("ymd",strtotime($fecha)) ;
$his = date("His",strtotime($hora)) ;
return "X".$this->cm('FS').$ymd.$this->cm('FS').$his;
} | php | public function setDateTime($fecha = 'now', $hora = 'now'){
$ymd = date("ymd",strtotime($fecha)) ;
$his = date("His",strtotime($hora)) ;
return "X".$this->cm('FS').$ymd.$this->cm('FS').$his;
} | [
"public",
"function",
"setDateTime",
"(",
"$",
"fecha",
"=",
"'now'",
",",
"$",
"hora",
"=",
"'now'",
")",
"{",
"$",
"ymd",
"=",
"date",
"(",
"\"ymd\"",
",",
"strtotime",
"(",
"$",
"fecha",
")",
")",
";",
"$",
"his",
"=",
"date",
"(",
"\"His\"",
",",
"strtotime",
"(",
"$",
"hora",
")",
")",
";",
"return",
"\"X\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"ymd",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"his",
";",
"}"
] | Setea fecha y hora | [
"Setea",
"fecha",
"y",
"hora"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L189-L193 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.setHeaderTrailer | public function setHeaderTrailer($numero_de_linea,$texto = "-",$doble_ancho = false){
$texto = substr($texto,0,45);
if ($numero_de_linea > -3 && $numero_de_linea <= 0){
$comando = "]".$this->cm('FS').$numero_de_linea;
}
if ($numero_de_linea > 0 && $numero_de_linea < 21){
if($doble_ancho){
$texto = $this->cm('DOBLE_ANCHO').$texto;
}
$comando = "]".$this->cm('FS').$numero_de_linea.$this->cm('FS').$texto;
}
else{
$comando = false;
}
return $comando;
} | php | public function setHeaderTrailer($numero_de_linea,$texto = "-",$doble_ancho = false){
$texto = substr($texto,0,45);
if ($numero_de_linea > -3 && $numero_de_linea <= 0){
$comando = "]".$this->cm('FS').$numero_de_linea;
}
if ($numero_de_linea > 0 && $numero_de_linea < 21){
if($doble_ancho){
$texto = $this->cm('DOBLE_ANCHO').$texto;
}
$comando = "]".$this->cm('FS').$numero_de_linea.$this->cm('FS').$texto;
}
else{
$comando = false;
}
return $comando;
} | [
"public",
"function",
"setHeaderTrailer",
"(",
"$",
"numero_de_linea",
",",
"$",
"texto",
"=",
"\"-\"",
",",
"$",
"doble_ancho",
"=",
"false",
")",
"{",
"$",
"texto",
"=",
"substr",
"(",
"$",
"texto",
",",
"0",
",",
"45",
")",
";",
"if",
"(",
"$",
"numero_de_linea",
">",
"-",
"3",
"&&",
"$",
"numero_de_linea",
"<=",
"0",
")",
"{",
"$",
"comando",
"=",
"\"]\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"numero_de_linea",
";",
"}",
"if",
"(",
"$",
"numero_de_linea",
">",
"0",
"&&",
"$",
"numero_de_linea",
"<",
"21",
")",
"{",
"if",
"(",
"$",
"doble_ancho",
")",
"{",
"$",
"texto",
"=",
"$",
"this",
"->",
"cm",
"(",
"'DOBLE_ANCHO'",
")",
".",
"$",
"texto",
";",
"}",
"$",
"comando",
"=",
"\"]\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"numero_de_linea",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"texto",
";",
"}",
"else",
"{",
"$",
"comando",
"=",
"false",
";",
"}",
"return",
"$",
"comando",
";",
"}"
] | Setea el encabezado y el pie de pagina
@param integer $numero_de_linea
ENCABEZADO: linea 1 - 10
COLA: linea 11 - 20
BORRA ENCABEZADO Y COLA: linea = 0
BORRA ENCABEZADO: numero linea = -1
BORRA COLA: numero linea = -2
@param $texto 45 caracteres maximo | [
"Setea",
"el",
"encabezado",
"y",
"el",
"pie",
"de",
"pagina"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L208-L223 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.setTrailer | public function setTrailer($linea ,$texto,$doble_ancho = false){
//COLA: linea 11 - 20
$texto = substr($texto,0,45);
$comando = '';
if ($linea > -1 && $linea < 10){
if($doble_ancho){
$texto = $this->cm('DOBLE_ANCHO').$texto;
}
$numero_de_linea = 11+$linea;
$comando = "]" . $this->cm('FS') . $numero_de_linea . $this->cm('FS') . $texto;
}
return $comando;
} | php | public function setTrailer($linea ,$texto,$doble_ancho = false){
//COLA: linea 11 - 20
$texto = substr($texto,0,45);
$comando = '';
if ($linea > -1 && $linea < 10){
if($doble_ancho){
$texto = $this->cm('DOBLE_ANCHO').$texto;
}
$numero_de_linea = 11+$linea;
$comando = "]" . $this->cm('FS') . $numero_de_linea . $this->cm('FS') . $texto;
}
return $comando;
} | [
"public",
"function",
"setTrailer",
"(",
"$",
"linea",
",",
"$",
"texto",
",",
"$",
"doble_ancho",
"=",
"false",
")",
"{",
"//COLA: \t\tlinea 11 - 20",
"$",
"texto",
"=",
"substr",
"(",
"$",
"texto",
",",
"0",
",",
"45",
")",
";",
"$",
"comando",
"=",
"''",
";",
"if",
"(",
"$",
"linea",
">",
"-",
"1",
"&&",
"$",
"linea",
"<",
"10",
")",
"{",
"if",
"(",
"$",
"doble_ancho",
")",
"{",
"$",
"texto",
"=",
"$",
"this",
"->",
"cm",
"(",
"'DOBLE_ANCHO'",
")",
".",
"$",
"texto",
";",
"}",
"$",
"numero_de_linea",
"=",
"11",
"+",
"$",
"linea",
";",
"$",
"comando",
"=",
"\"]\"",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"numero_de_linea",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"texto",
";",
"}",
"return",
"$",
"comando",
";",
"}"
] | Setea el pie de pagina
@param integer $linea de 0 a 9
@param string $texto 45 caracteres maximo | [
"Setea",
"el",
"pie",
"de",
"pagina"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L285-L297 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.setEmbarkNumber | public function setEmbarkNumber($numeroTicket, $nlinea = 1){
return chr(147).$this->cm('FS') . $nlinea . $this->cm('FS') . trim($numeroTicket);
} | php | public function setEmbarkNumber($numeroTicket, $nlinea = 1){
return chr(147).$this->cm('FS') . $nlinea . $this->cm('FS') . trim($numeroTicket);
} | [
"public",
"function",
"setEmbarkNumber",
"(",
"$",
"numeroTicket",
",",
"$",
"nlinea",
"=",
"1",
")",
"{",
"return",
"chr",
"(",
"147",
")",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"nlinea",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"trim",
"(",
"$",
"numeroTicket",
")",
";",
"}"
] | Longitud
ô (93H - ASCII 147)
FS
No de línea de comprobante original (1-2)
0: borra ambas líneas (sólo modelos SMH/P-PR5F -versión 2.01-, SMH/P-715F
-versiones 3.02 y posteriores-, y SMH/P-441F)
FS
Texto de hasta 20 caracteres
Ejemplo: ô∟1∟00000118 | [
"Longitud",
"ô",
"(",
"93H",
"-",
"ASCII",
"147",
")",
"FS",
"No",
"de",
"línea",
"de",
"comprobante",
"original",
"(",
"1",
"-",
"2",
")",
"0",
":",
"borra",
"ambas",
"líneas",
"(",
"sólo",
"modelos",
"SMH",
"/",
"P",
"-",
"PR5F",
"-",
"versión",
"2",
".",
"01",
"-",
"SMH",
"/",
"P",
"-",
"715F",
"-",
"versiones",
"3",
".",
"02",
"y",
"posteriores",
"-",
"y",
"SMH",
"/",
"P",
"-",
"441F",
")",
"FS",
"Texto",
"de",
"hasta",
"20",
"caracteres"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L365-L367 |
alevilar/ristorantino-vendor | Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php | Hasar441FiscalHelper.openDNFH | public function openDNFH($tipoDocumento, $identificacion = 0){
$comando = chr(128). $this->cm('FS') .$tipoDocumento . $this->cm('FS') ."T";
if (!empty ($identificacion)){
$comando .= $this->cm('FS') .$identificacion;
}
return $comando;
} | php | public function openDNFH($tipoDocumento, $identificacion = 0){
$comando = chr(128). $this->cm('FS') .$tipoDocumento . $this->cm('FS') ."T";
if (!empty ($identificacion)){
$comando .= $this->cm('FS') .$identificacion;
}
return $comando;
} | [
"public",
"function",
"openDNFH",
"(",
"$",
"tipoDocumento",
",",
"$",
"identificacion",
"=",
"0",
")",
"{",
"$",
"comando",
"=",
"chr",
"(",
"128",
")",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"tipoDocumento",
".",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"\"T\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"identificacion",
")",
")",
"{",
"$",
"comando",
".=",
"$",
"this",
"->",
"cm",
"(",
"'FS'",
")",
".",
"$",
"identificacion",
";",
"}",
"return",
"$",
"comando",
";",
"}"
] | Tipo de documento
R: Nota de crédito ‘A’
S: Nota de crédito ‘B/C’
x: Tique recibo ‘X’
<: Tique pagaré
,: Tique presupuesto
-: Comp. de entrega
.: Talón Estacionamiento
/: Cobro de Servicios
0: Ingreso de Dinero
1: Retiro de Dinero
2: Talón de Cambio
3: Talón de reparto
4: Talón de regalo
5: Cuenta Corriente
6: Avisode Operación de Crédito
7: Cupón de Promoción
8: Uso Interno Farmacia
Ejemplo: Ç∟R∟T∟1211241 | [
"Tipo",
"de",
"documento",
"R",
":",
"Nota",
"de",
"crédito",
"‘A’",
"S",
":",
"Nota",
"de",
"crédito",
"‘B",
"/",
"C’",
"x",
":",
"Tique",
"recibo",
"‘X’",
"<",
":",
"Tique",
"pagaré",
":",
"Tique",
"presupuesto",
"-",
":",
"Comp",
".",
"de",
"entrega",
".",
":",
"Talón",
"Estacionamiento",
"/",
":",
"Cobro",
"de",
"Servicios",
"0",
":",
"Ingreso",
"de",
"Dinero",
"1",
":",
"Retiro",
"de",
"Dinero",
"2",
":",
"Talón",
"de",
"Cambio",
"3",
":",
"Talón",
"de",
"reparto",
"4",
":",
"Talón",
"de",
"regalo",
"5",
":",
"Cuenta",
"Corriente",
"6",
":",
"Avisode",
"Operación",
"de",
"Crédito",
"7",
":",
"Cupón",
"de",
"Promoción",
"8",
":",
"Uso",
"Interno",
"Farmacia"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L394-L400 |
songshenzong/log | src/DataCollector/ViewCollector.php | ViewCollector.addView | public function addView(View $view)
{
$name = $view->getName();
$path = $view->getPath();
if (!is_object($path)) {
if ($path) {
$path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
}
if (substr($path, -10) == '.blade.php') {
$type = 'blade';
} else {
$type = pathinfo($path, PATHINFO_EXTENSION);
}
} else {
$type = get_class($view);
$path = '';
}
if (!$this->collect_data) {
$params = array_keys($view->getData());
} else {
$data = [];
foreach ($view->getData() as $key => $value) {
$data[$key] = $this->exporter->exportValue($value);
}
$params = $data;
}
$this->templates[] = [
'name' => $path ? sprintf('%s (%s)', $name, $path) : $name,
'param_count' => count($params),
'params' => $params,
'type' => $type,
];
} | php | public function addView(View $view)
{
$name = $view->getName();
$path = $view->getPath();
if (!is_object($path)) {
if ($path) {
$path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
}
if (substr($path, -10) == '.blade.php') {
$type = 'blade';
} else {
$type = pathinfo($path, PATHINFO_EXTENSION);
}
} else {
$type = get_class($view);
$path = '';
}
if (!$this->collect_data) {
$params = array_keys($view->getData());
} else {
$data = [];
foreach ($view->getData() as $key => $value) {
$data[$key] = $this->exporter->exportValue($value);
}
$params = $data;
}
$this->templates[] = [
'name' => $path ? sprintf('%s (%s)', $name, $path) : $name,
'param_count' => count($params),
'params' => $params,
'type' => $type,
];
} | [
"public",
"function",
"addView",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"name",
"=",
"$",
"view",
"->",
"getName",
"(",
")",
";",
"$",
"path",
"=",
"$",
"view",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"ltrim",
"(",
"str_replace",
"(",
"base_path",
"(",
")",
",",
"''",
",",
"realpath",
"(",
"$",
"path",
")",
")",
",",
"'/'",
")",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"10",
")",
"==",
"'.blade.php'",
")",
"{",
"$",
"type",
"=",
"'blade'",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_EXTENSION",
")",
";",
"}",
"}",
"else",
"{",
"$",
"type",
"=",
"get_class",
"(",
"$",
"view",
")",
";",
"$",
"path",
"=",
"''",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"collect_data",
")",
"{",
"$",
"params",
"=",
"array_keys",
"(",
"$",
"view",
"->",
"getData",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"view",
"->",
"getData",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"exporter",
"->",
"exportValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"params",
"=",
"$",
"data",
";",
"}",
"$",
"this",
"->",
"templates",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"path",
"?",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"name",
",",
"$",
"path",
")",
":",
"$",
"name",
",",
"'param_count'",
"=>",
"count",
"(",
"$",
"params",
")",
",",
"'params'",
"=>",
"$",
"params",
",",
"'type'",
"=>",
"$",
"type",
",",
"]",
";",
"}"
] | Add a View instance to the Collector
@param \Illuminate\View\View $view | [
"Add",
"a",
"View",
"instance",
"to",
"the",
"Collector"
] | train | https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/ViewCollector.php#L52-L88 |
RhubarbPHP/Module.RestApi | src/Resources/ModelRestResource.php | ModelRestResource.transformModelToArray | protected function transformModelToArray($columns)
{
$model = $this->getModel();
$extract = [];
$relationships = null;
foreach ($columns as $label => $column) {
$columnModel = $model;
$modifier = "";
$urlSuffix = false;
$apiLabel = (is_numeric($label)) ? $column : $label;
if (is_callable($column)) {
$value = $column();
} else {
if (stripos($column, ":") !== false) {
$parts = explode(":", $column);
$column = $parts[0];
if (is_numeric($label)) {
$apiLabel = $column;
}
$modifier = strtolower($parts[1]);
if (sizeof($parts) > 2) {
$urlSuffix = $parts[2];
}
}
if (stripos($column, ".") !== false) {
$parts = explode(".", $column, 2);
$column = $parts[0];
$columnModel = $columnModel->$column;
$column = $parts[1];
if (is_numeric($label)) {
$apiLabel = $parts[1];
}
}
if ($columnModel) {
$value = $columnModel->$column;
} else {
$value = "";
}
}
if (is_object($value)) {
// We can't pass objects back through the API! Let's get a JSON friendly structure instead.
if (!($value instanceof Model) && !($value instanceof Collection)) {
// This seems strange however if we just used json_encode we'd be passing the encoded version
// back as a string. We decode to get the original structure back again.
$value = json_decode(json_encode($value));
} else {
$navigationResource = false;
$navigationResourceIsCollection = false;
if ($value instanceof Model) {
$navigationResource = $this->getRestResourceForModel($value);
if ($navigationResource === false) {
throw new RestImplementationException(print_r($value, true));
continue;
}
}
if ($value instanceof Collection) {
$navigationResource = $this->getRestResourceForModelName(SolutionSchema::getModelNameFromClass($value->getModelClassName()));
if ($navigationResource === false) {
continue;
}
$navigationResourceIsCollection = true;
$navigationResource->setModelCollection($value);
}
if ($navigationResource) {
switch ($modifier) {
case "summary":
$value = $navigationResource->summary();
break;
case "link":
$link = $navigationResource->link();
if (!isset($link->href) || $navigationResourceIsCollection) {
if (!$urlSuffix) {
throw new RestImplementationException("No canonical URL for " . get_class($navigationResource) . " and no URL suffix supplied for property " . $apiLabel);
}
$ourHref = $this->getHref();
// Override the href with this appendage instead.
$link->href = $ourHref . $urlSuffix;
}
$value = $link;
break;
default:
$value = $navigationResource->get();
break;
}
}
}
}
if ($value !== null || $this->includeNullItems) {
$extract[$apiLabel] = $value;
}
}
return $extract;
} | php | protected function transformModelToArray($columns)
{
$model = $this->getModel();
$extract = [];
$relationships = null;
foreach ($columns as $label => $column) {
$columnModel = $model;
$modifier = "";
$urlSuffix = false;
$apiLabel = (is_numeric($label)) ? $column : $label;
if (is_callable($column)) {
$value = $column();
} else {
if (stripos($column, ":") !== false) {
$parts = explode(":", $column);
$column = $parts[0];
if (is_numeric($label)) {
$apiLabel = $column;
}
$modifier = strtolower($parts[1]);
if (sizeof($parts) > 2) {
$urlSuffix = $parts[2];
}
}
if (stripos($column, ".") !== false) {
$parts = explode(".", $column, 2);
$column = $parts[0];
$columnModel = $columnModel->$column;
$column = $parts[1];
if (is_numeric($label)) {
$apiLabel = $parts[1];
}
}
if ($columnModel) {
$value = $columnModel->$column;
} else {
$value = "";
}
}
if (is_object($value)) {
// We can't pass objects back through the API! Let's get a JSON friendly structure instead.
if (!($value instanceof Model) && !($value instanceof Collection)) {
// This seems strange however if we just used json_encode we'd be passing the encoded version
// back as a string. We decode to get the original structure back again.
$value = json_decode(json_encode($value));
} else {
$navigationResource = false;
$navigationResourceIsCollection = false;
if ($value instanceof Model) {
$navigationResource = $this->getRestResourceForModel($value);
if ($navigationResource === false) {
throw new RestImplementationException(print_r($value, true));
continue;
}
}
if ($value instanceof Collection) {
$navigationResource = $this->getRestResourceForModelName(SolutionSchema::getModelNameFromClass($value->getModelClassName()));
if ($navigationResource === false) {
continue;
}
$navigationResourceIsCollection = true;
$navigationResource->setModelCollection($value);
}
if ($navigationResource) {
switch ($modifier) {
case "summary":
$value = $navigationResource->summary();
break;
case "link":
$link = $navigationResource->link();
if (!isset($link->href) || $navigationResourceIsCollection) {
if (!$urlSuffix) {
throw new RestImplementationException("No canonical URL for " . get_class($navigationResource) . " and no URL suffix supplied for property " . $apiLabel);
}
$ourHref = $this->getHref();
// Override the href with this appendage instead.
$link->href = $ourHref . $urlSuffix;
}
$value = $link;
break;
default:
$value = $navigationResource->get();
break;
}
}
}
}
if ($value !== null || $this->includeNullItems) {
$extract[$apiLabel] = $value;
}
}
return $extract;
} | [
"protected",
"function",
"transformModelToArray",
"(",
"$",
"columns",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"extract",
"=",
"[",
"]",
";",
"$",
"relationships",
"=",
"null",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"label",
"=>",
"$",
"column",
")",
"{",
"$",
"columnModel",
"=",
"$",
"model",
";",
"$",
"modifier",
"=",
"\"\"",
";",
"$",
"urlSuffix",
"=",
"false",
";",
"$",
"apiLabel",
"=",
"(",
"is_numeric",
"(",
"$",
"label",
")",
")",
"?",
"$",
"column",
":",
"$",
"label",
";",
"if",
"(",
"is_callable",
"(",
"$",
"column",
")",
")",
"{",
"$",
"value",
"=",
"$",
"column",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"stripos",
"(",
"$",
"column",
",",
"\":\"",
")",
"!==",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"column",
")",
";",
"$",
"column",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"label",
")",
")",
"{",
"$",
"apiLabel",
"=",
"$",
"column",
";",
"}",
"$",
"modifier",
"=",
"strtolower",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"parts",
")",
">",
"2",
")",
"{",
"$",
"urlSuffix",
"=",
"$",
"parts",
"[",
"2",
"]",
";",
"}",
"}",
"if",
"(",
"stripos",
"(",
"$",
"column",
",",
"\".\"",
")",
"!==",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\".\"",
",",
"$",
"column",
",",
"2",
")",
";",
"$",
"column",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"columnModel",
"=",
"$",
"columnModel",
"->",
"$",
"column",
";",
"$",
"column",
"=",
"$",
"parts",
"[",
"1",
"]",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"label",
")",
")",
"{",
"$",
"apiLabel",
"=",
"$",
"parts",
"[",
"1",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"columnModel",
")",
"{",
"$",
"value",
"=",
"$",
"columnModel",
"->",
"$",
"column",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"\"\"",
";",
"}",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"// We can't pass objects back through the API! Let's get a JSON friendly structure instead.",
"if",
"(",
"!",
"(",
"$",
"value",
"instanceof",
"Model",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"Collection",
")",
")",
"{",
"// This seems strange however if we just used json_encode we'd be passing the encoded version",
"// back as a string. We decode to get the original structure back again.",
"$",
"value",
"=",
"json_decode",
"(",
"json_encode",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"navigationResource",
"=",
"false",
";",
"$",
"navigationResourceIsCollection",
"=",
"false",
";",
"if",
"(",
"$",
"value",
"instanceof",
"Model",
")",
"{",
"$",
"navigationResource",
"=",
"$",
"this",
"->",
"getRestResourceForModel",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"navigationResource",
"===",
"false",
")",
"{",
"throw",
"new",
"RestImplementationException",
"(",
"print_r",
"(",
"$",
"value",
",",
"true",
")",
")",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Collection",
")",
"{",
"$",
"navigationResource",
"=",
"$",
"this",
"->",
"getRestResourceForModelName",
"(",
"SolutionSchema",
"::",
"getModelNameFromClass",
"(",
"$",
"value",
"->",
"getModelClassName",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"navigationResource",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"$",
"navigationResourceIsCollection",
"=",
"true",
";",
"$",
"navigationResource",
"->",
"setModelCollection",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"navigationResource",
")",
"{",
"switch",
"(",
"$",
"modifier",
")",
"{",
"case",
"\"summary\"",
":",
"$",
"value",
"=",
"$",
"navigationResource",
"->",
"summary",
"(",
")",
";",
"break",
";",
"case",
"\"link\"",
":",
"$",
"link",
"=",
"$",
"navigationResource",
"->",
"link",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"link",
"->",
"href",
")",
"||",
"$",
"navigationResourceIsCollection",
")",
"{",
"if",
"(",
"!",
"$",
"urlSuffix",
")",
"{",
"throw",
"new",
"RestImplementationException",
"(",
"\"No canonical URL for \"",
".",
"get_class",
"(",
"$",
"navigationResource",
")",
".",
"\" and no URL suffix supplied for property \"",
".",
"$",
"apiLabel",
")",
";",
"}",
"$",
"ourHref",
"=",
"$",
"this",
"->",
"getHref",
"(",
")",
";",
"// Override the href with this appendage instead.",
"$",
"link",
"->",
"href",
"=",
"$",
"ourHref",
".",
"$",
"urlSuffix",
";",
"}",
"$",
"value",
"=",
"$",
"link",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"$",
"navigationResource",
"->",
"get",
"(",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"value",
"!==",
"null",
"||",
"$",
"this",
"->",
"includeNullItems",
")",
"{",
"$",
"extract",
"[",
"$",
"apiLabel",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"extract",
";",
"}"
] | Turns a model into a flat array structure ready for returning as a resource response.
@param string[] $columns The columns to extract
@return array A key/value pairing of columns and values
@throws RestImplementationException | [
"Turns",
"a",
"model",
"into",
"a",
"flat",
"array",
"structure",
"ready",
"for",
"returning",
"as",
"a",
"resource",
"response",
"."
] | train | https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/Resources/ModelRestResource.php#L80-L203 |
RhubarbPHP/Module.RestApi | src/Resources/ModelRestResource.php | ModelRestResource.getSummaryColumns | protected function getSummaryColumns()
{
$columns = [];
$model = $this->getSampleModel();
$columnName = $model->getLabelColumnName();
if ($columnName != "") {
$columns[] = $columnName;
}
return $columns;
} | php | protected function getSummaryColumns()
{
$columns = [];
$model = $this->getSampleModel();
$columnName = $model->getLabelColumnName();
if ($columnName != "") {
$columns[] = $columnName;
}
return $columns;
} | [
"protected",
"function",
"getSummaryColumns",
"(",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getSampleModel",
"(",
")",
";",
"$",
"columnName",
"=",
"$",
"model",
"->",
"getLabelColumnName",
"(",
")",
";",
"if",
"(",
"$",
"columnName",
"!=",
"\"\"",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"columnName",
";",
"}",
"return",
"$",
"columns",
";",
"}"
] | Override to control the columns returned in HEAD requests
@return string[] | [
"Override",
"to",
"control",
"the",
"columns",
"returned",
"in",
"HEAD",
"requests"
] | train | https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/Resources/ModelRestResource.php#L210-L222 |
RhubarbPHP/Module.RestApi | src/Resources/ModelRestResource.php | ModelRestResource.createItemResource | public function createItemResource($resourceIdentifier)
{
try {
$model = SolutionSchema::getModel($this->getModelName(), $resourceIdentifier);
} catch (RecordNotFoundException $er) {
throw new RestResourceNotFoundException(self::class, $resourceIdentifier);
}
return $this->getItemResourceForModel($model);
} | php | public function createItemResource($resourceIdentifier)
{
try {
$model = SolutionSchema::getModel($this->getModelName(), $resourceIdentifier);
} catch (RecordNotFoundException $er) {
throw new RestResourceNotFoundException(self::class, $resourceIdentifier);
}
return $this->getItemResourceForModel($model);
} | [
"public",
"function",
"createItemResource",
"(",
"$",
"resourceIdentifier",
")",
"{",
"try",
"{",
"$",
"model",
"=",
"SolutionSchema",
"::",
"getModel",
"(",
"$",
"this",
"->",
"getModelName",
"(",
")",
",",
"$",
"resourceIdentifier",
")",
";",
"}",
"catch",
"(",
"RecordNotFoundException",
"$",
"er",
")",
"{",
"throw",
"new",
"RestResourceNotFoundException",
"(",
"self",
"::",
"class",
",",
"$",
"resourceIdentifier",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getItemResourceForModel",
"(",
"$",
"model",
")",
";",
"}"
] | Returns the ItemRestResource for the $resourceIdentifier contained in this collection.
@param $resourceIdentifier
@return ItemRestResource
@throws RestImplementationException Thrown if the item could not be found. | [
"Returns",
"the",
"ItemRestResource",
"for",
"the",
"$resourceIdentifier",
"contained",
"in",
"this",
"collection",
"."
] | train | https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/Resources/ModelRestResource.php#L671-L680 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/auto_increment_index.php | ezcDbSchemaAutoIncrementIndexValidator.validate | static public function validate( ezcDbSchema $schema )
{
$errors = array();
/* For each table we check all auto increment fields. */
foreach ( $schema->getSchema() as $tableName => $table )
{
foreach ( $table->fields as $fieldName => $field )
{
if ( $field->autoIncrement === true )
{
$found = false;
// Loop over de indexes to see if there is a primary
foreach ( $table->indexes as $indexName => $index )
{
if ( $index->primary === true )
{
$found = true;
break;
}
}
if ( !$found )
{
$errors[] = "Field '$tableName:$fieldName' is auto increment but there is no primary index defined.";
}
}
}
}
return $errors;
} | php | static public function validate( ezcDbSchema $schema )
{
$errors = array();
/* For each table we check all auto increment fields. */
foreach ( $schema->getSchema() as $tableName => $table )
{
foreach ( $table->fields as $fieldName => $field )
{
if ( $field->autoIncrement === true )
{
$found = false;
// Loop over de indexes to see if there is a primary
foreach ( $table->indexes as $indexName => $index )
{
if ( $index->primary === true )
{
$found = true;
break;
}
}
if ( !$found )
{
$errors[] = "Field '$tableName:$fieldName' is auto increment but there is no primary index defined.";
}
}
}
}
return $errors;
} | [
"static",
"public",
"function",
"validate",
"(",
"ezcDbSchema",
"$",
"schema",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"/* For each table we check all auto increment fields. */",
"foreach",
"(",
"$",
"schema",
"->",
"getSchema",
"(",
")",
"as",
"$",
"tableName",
"=>",
"$",
"table",
")",
"{",
"foreach",
"(",
"$",
"table",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"autoIncrement",
"===",
"true",
")",
"{",
"$",
"found",
"=",
"false",
";",
"// Loop over de indexes to see if there is a primary",
"foreach",
"(",
"$",
"table",
"->",
"indexes",
"as",
"$",
"indexName",
"=>",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
"->",
"primary",
"===",
"true",
")",
"{",
"$",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"\"Field '$tableName:$fieldName' is auto increment but there is no primary index defined.\"",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] | Validates if all the types used in the $schema are supported.
This method loops over all the fields in a table and checks whether the
type that is used for each field is supported. It will return an array
containing error strings for each non-supported type that it finds.
@param ezcDbSchema $schema
@return array(string) | [
"Validates",
"if",
"all",
"the",
"types",
"used",
"in",
"the",
"$schema",
"are",
"supported",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/validators/auto_increment_index.php#L30-L62 |
hametuha/wpametu | src/WPametu/UI/Field/GeoPoint.php | GeoPoint.get_field | protected function get_field( \WP_Post $post ){
$field = parent::get_field($post);
$automatic = $this->original_callback ? ' original' : '';
$geocder = $this->show_geocoder ? $this->geocoder() : '';
return <<<HTML
{$field}
<div id="{$this->name}-map" class="wpametu-map{$automatic}"></div>
{$geocder}
HTML;
} | php | protected function get_field( \WP_Post $post ){
$field = parent::get_field($post);
$automatic = $this->original_callback ? ' original' : '';
$geocder = $this->show_geocoder ? $this->geocoder() : '';
return <<<HTML
{$field}
<div id="{$this->name}-map" class="wpametu-map{$automatic}"></div>
{$geocder}
HTML;
} | [
"protected",
"function",
"get_field",
"(",
"\\",
"WP_Post",
"$",
"post",
")",
"{",
"$",
"field",
"=",
"parent",
"::",
"get_field",
"(",
"$",
"post",
")",
";",
"$",
"automatic",
"=",
"$",
"this",
"->",
"original_callback",
"?",
"' original'",
":",
"''",
";",
"$",
"geocder",
"=",
"$",
"this",
"->",
"show_geocoder",
"?",
"$",
"this",
"->",
"geocoder",
"(",
")",
":",
"''",
";",
"return",
" <<<HTML\n {$field}\n <div id=\"{$this->name}-map\" class=\"wpametu-map{$automatic}\"></div>\n {$geocder}\nHTML",
";",
"}"
] | Add map canvas
@param \WP_Post $post
@return string | [
"Add",
"map",
"canvas"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/GeoPoint.php#L51-L61 |
hametuha/wpametu | src/WPametu/UI/Field/GeoPoint.php | GeoPoint.geocoder | protected function geocoder(){
$helper = $this->__('Input address');
$btn = $this->__('Move point');
$fail = esc_attr($this->__('Sorry, but nothing found with input address'));
return <<<HTML
<p>
<input type="text" class="gmap-geocoder regular-text" placeholder="{$helper}" />
<a class="button gmap-geocoder-btn" href="#" data-failure="{$fail}">{$btn}</a>
</p>
HTML;
} | php | protected function geocoder(){
$helper = $this->__('Input address');
$btn = $this->__('Move point');
$fail = esc_attr($this->__('Sorry, but nothing found with input address'));
return <<<HTML
<p>
<input type="text" class="gmap-geocoder regular-text" placeholder="{$helper}" />
<a class="button gmap-geocoder-btn" href="#" data-failure="{$fail}">{$btn}</a>
</p>
HTML;
} | [
"protected",
"function",
"geocoder",
"(",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"__",
"(",
"'Input address'",
")",
";",
"$",
"btn",
"=",
"$",
"this",
"->",
"__",
"(",
"'Move point'",
")",
";",
"$",
"fail",
"=",
"esc_attr",
"(",
"$",
"this",
"->",
"__",
"(",
"'Sorry, but nothing found with input address'",
")",
")",
";",
"return",
" <<<HTML\n <p>\n <input type=\"text\" class=\"gmap-geocoder regular-text\" placeholder=\"{$helper}\" />\n <a class=\"button gmap-geocoder-btn\" href=\"#\" data-failure=\"{$fail}\">{$btn}</a>\n </p>\nHTML",
";",
"}"
] | Get GeoCoder input
@return string | [
"Get",
"GeoCoder",
"input"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/GeoPoint.php#L103-L114 |
WellCommerce/StandardEditionBundle | DataFixtures/ORM/LoadProductStatusData.php | LoadProductStatusData.load | public function load(ObjectManager $manager)
{
if (!$this->isEnabled()) {
return;
}
$bestseller = new ProductStatus();
$bestseller->setSymbol('bestseller');
foreach ($this->getLocales() as $locale) {
$bestseller->translate($locale->getCode())->setName('Bestsellers');
$bestseller->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'bestseller');
$bestseller->translate($locale->getCode())->setCssClass('bestseller');
$bestseller->translate($locale->getCode())->getMeta()->setTitle('Bestselling products');
}
$bestseller->mergeNewTranslations();
$manager->persist($bestseller);
$this->addReference('product_status_bestseller', $bestseller);
$featured = new ProductStatus();
$featured->setSymbol('featured');
foreach ($this->getLocales() as $locale) {
$featured->translate($locale->getCode())->setName('Featured');
$featured->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'featured');
$featured->translate($locale->getCode())->setCssClass('featured');
$featured->translate($locale->getCode())->getMeta()->setTitle('Featured products');
}
$featured->mergeNewTranslations();
$manager->persist($featured);
$this->addReference('product_status_featured', $featured);
$novelty = new ProductStatus();
$novelty->setSymbol('novelty');
foreach ($this->getLocales() as $locale) {
$novelty->translate($locale->getCode())->setName('New products');
$novelty->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'novelty');
$novelty->translate($locale->getCode())->setCssClass('novelty');
$novelty->translate($locale->getCode())->getMeta()->setTitle('New products');
}
$novelty->mergeNewTranslations();
$manager->persist($novelty);
$this->addReference('product_status_novelty', $novelty);
$promotion = new ProductStatus();
$promotion->setSymbol('promotion');
foreach ($this->getLocales() as $locale) {
$promotion->translate($locale->getCode())->setName('Promotions');
$promotion->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'promotion');
$promotion->translate($locale->getCode())->setCssClass('promotion');
$promotion->translate($locale->getCode())->getMeta()->setTitle('Promotions & special offers');
}
$promotion->mergeNewTranslations();
$manager->persist($promotion);
$this->addReference('product_status_promotion', $promotion);
$manager->flush();
$this->createLayoutBoxes($manager, [
'bestsellers' => [
'type' => 'ProductStatus',
'name' => 'Bestsellers',
'settings' => [
'status' => $this->getReference('product_status_bestseller')->getId(),
],
],
'new_products' => [
'type' => 'ProductStatus',
'name' => 'New arrivals',
'settings' => [
'status' => $this->getReference('product_status_novelty')->getId(),
],
],
'featured_products' => [
'type' => 'ProductStatus',
'name' => 'Featured products',
'settings' => [
'status' => $this->getReference('product_status_featured')->getId(),
],
],
'promotions' => [
'type' => 'ProductStatus',
'name' => 'Promotions',
'settings' => [
'status' => $this->getReference('product_status_promotion')->getId(),
],
],
'dynamic_status' => [
'type' => 'ProductStatus',
'name' => 'Dynamic product status box',
],
]);
$manager->flush();
} | php | public function load(ObjectManager $manager)
{
if (!$this->isEnabled()) {
return;
}
$bestseller = new ProductStatus();
$bestseller->setSymbol('bestseller');
foreach ($this->getLocales() as $locale) {
$bestseller->translate($locale->getCode())->setName('Bestsellers');
$bestseller->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'bestseller');
$bestseller->translate($locale->getCode())->setCssClass('bestseller');
$bestseller->translate($locale->getCode())->getMeta()->setTitle('Bestselling products');
}
$bestseller->mergeNewTranslations();
$manager->persist($bestseller);
$this->addReference('product_status_bestseller', $bestseller);
$featured = new ProductStatus();
$featured->setSymbol('featured');
foreach ($this->getLocales() as $locale) {
$featured->translate($locale->getCode())->setName('Featured');
$featured->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'featured');
$featured->translate($locale->getCode())->setCssClass('featured');
$featured->translate($locale->getCode())->getMeta()->setTitle('Featured products');
}
$featured->mergeNewTranslations();
$manager->persist($featured);
$this->addReference('product_status_featured', $featured);
$novelty = new ProductStatus();
$novelty->setSymbol('novelty');
foreach ($this->getLocales() as $locale) {
$novelty->translate($locale->getCode())->setName('New products');
$novelty->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'novelty');
$novelty->translate($locale->getCode())->setCssClass('novelty');
$novelty->translate($locale->getCode())->getMeta()->setTitle('New products');
}
$novelty->mergeNewTranslations();
$manager->persist($novelty);
$this->addReference('product_status_novelty', $novelty);
$promotion = new ProductStatus();
$promotion->setSymbol('promotion');
foreach ($this->getLocales() as $locale) {
$promotion->translate($locale->getCode())->setName('Promotions');
$promotion->translate($locale->getCode())->setSlug($locale->getCode() . '/' . 'promotion');
$promotion->translate($locale->getCode())->setCssClass('promotion');
$promotion->translate($locale->getCode())->getMeta()->setTitle('Promotions & special offers');
}
$promotion->mergeNewTranslations();
$manager->persist($promotion);
$this->addReference('product_status_promotion', $promotion);
$manager->flush();
$this->createLayoutBoxes($manager, [
'bestsellers' => [
'type' => 'ProductStatus',
'name' => 'Bestsellers',
'settings' => [
'status' => $this->getReference('product_status_bestseller')->getId(),
],
],
'new_products' => [
'type' => 'ProductStatus',
'name' => 'New arrivals',
'settings' => [
'status' => $this->getReference('product_status_novelty')->getId(),
],
],
'featured_products' => [
'type' => 'ProductStatus',
'name' => 'Featured products',
'settings' => [
'status' => $this->getReference('product_status_featured')->getId(),
],
],
'promotions' => [
'type' => 'ProductStatus',
'name' => 'Promotions',
'settings' => [
'status' => $this->getReference('product_status_promotion')->getId(),
],
],
'dynamic_status' => [
'type' => 'ProductStatus',
'name' => 'Dynamic product status box',
],
]);
$manager->flush();
} | [
"public",
"function",
"load",
"(",
"ObjectManager",
"$",
"manager",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"bestseller",
"=",
"new",
"ProductStatus",
"(",
")",
";",
"$",
"bestseller",
"->",
"setSymbol",
"(",
"'bestseller'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"$",
"bestseller",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setName",
"(",
"'Bestsellers'",
")",
";",
"$",
"bestseller",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setSlug",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
".",
"'/'",
".",
"'bestseller'",
")",
";",
"$",
"bestseller",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setCssClass",
"(",
"'bestseller'",
")",
";",
"$",
"bestseller",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"getMeta",
"(",
")",
"->",
"setTitle",
"(",
"'Bestselling products'",
")",
";",
"}",
"$",
"bestseller",
"->",
"mergeNewTranslations",
"(",
")",
";",
"$",
"manager",
"->",
"persist",
"(",
"$",
"bestseller",
")",
";",
"$",
"this",
"->",
"addReference",
"(",
"'product_status_bestseller'",
",",
"$",
"bestseller",
")",
";",
"$",
"featured",
"=",
"new",
"ProductStatus",
"(",
")",
";",
"$",
"featured",
"->",
"setSymbol",
"(",
"'featured'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"$",
"featured",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setName",
"(",
"'Featured'",
")",
";",
"$",
"featured",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setSlug",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
".",
"'/'",
".",
"'featured'",
")",
";",
"$",
"featured",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setCssClass",
"(",
"'featured'",
")",
";",
"$",
"featured",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"getMeta",
"(",
")",
"->",
"setTitle",
"(",
"'Featured products'",
")",
";",
"}",
"$",
"featured",
"->",
"mergeNewTranslations",
"(",
")",
";",
"$",
"manager",
"->",
"persist",
"(",
"$",
"featured",
")",
";",
"$",
"this",
"->",
"addReference",
"(",
"'product_status_featured'",
",",
"$",
"featured",
")",
";",
"$",
"novelty",
"=",
"new",
"ProductStatus",
"(",
")",
";",
"$",
"novelty",
"->",
"setSymbol",
"(",
"'novelty'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"$",
"novelty",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setName",
"(",
"'New products'",
")",
";",
"$",
"novelty",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setSlug",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
".",
"'/'",
".",
"'novelty'",
")",
";",
"$",
"novelty",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setCssClass",
"(",
"'novelty'",
")",
";",
"$",
"novelty",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"getMeta",
"(",
")",
"->",
"setTitle",
"(",
"'New products'",
")",
";",
"}",
"$",
"novelty",
"->",
"mergeNewTranslations",
"(",
")",
";",
"$",
"manager",
"->",
"persist",
"(",
"$",
"novelty",
")",
";",
"$",
"this",
"->",
"addReference",
"(",
"'product_status_novelty'",
",",
"$",
"novelty",
")",
";",
"$",
"promotion",
"=",
"new",
"ProductStatus",
"(",
")",
";",
"$",
"promotion",
"->",
"setSymbol",
"(",
"'promotion'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"$",
"promotion",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setName",
"(",
"'Promotions'",
")",
";",
"$",
"promotion",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setSlug",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
".",
"'/'",
".",
"'promotion'",
")",
";",
"$",
"promotion",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"setCssClass",
"(",
"'promotion'",
")",
";",
"$",
"promotion",
"->",
"translate",
"(",
"$",
"locale",
"->",
"getCode",
"(",
")",
")",
"->",
"getMeta",
"(",
")",
"->",
"setTitle",
"(",
"'Promotions & special offers'",
")",
";",
"}",
"$",
"promotion",
"->",
"mergeNewTranslations",
"(",
")",
";",
"$",
"manager",
"->",
"persist",
"(",
"$",
"promotion",
")",
";",
"$",
"this",
"->",
"addReference",
"(",
"'product_status_promotion'",
",",
"$",
"promotion",
")",
";",
"$",
"manager",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"createLayoutBoxes",
"(",
"$",
"manager",
",",
"[",
"'bestsellers'",
"=>",
"[",
"'type'",
"=>",
"'ProductStatus'",
",",
"'name'",
"=>",
"'Bestsellers'",
",",
"'settings'",
"=>",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"getReference",
"(",
"'product_status_bestseller'",
")",
"->",
"getId",
"(",
")",
",",
"]",
",",
"]",
",",
"'new_products'",
"=>",
"[",
"'type'",
"=>",
"'ProductStatus'",
",",
"'name'",
"=>",
"'New arrivals'",
",",
"'settings'",
"=>",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"getReference",
"(",
"'product_status_novelty'",
")",
"->",
"getId",
"(",
")",
",",
"]",
",",
"]",
",",
"'featured_products'",
"=>",
"[",
"'type'",
"=>",
"'ProductStatus'",
",",
"'name'",
"=>",
"'Featured products'",
",",
"'settings'",
"=>",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"getReference",
"(",
"'product_status_featured'",
")",
"->",
"getId",
"(",
")",
",",
"]",
",",
"]",
",",
"'promotions'",
"=>",
"[",
"'type'",
"=>",
"'ProductStatus'",
",",
"'name'",
"=>",
"'Promotions'",
",",
"'settings'",
"=>",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"getReference",
"(",
"'product_status_promotion'",
")",
"->",
"getId",
"(",
")",
",",
"]",
",",
"]",
",",
"'dynamic_status'",
"=>",
"[",
"'type'",
"=>",
"'ProductStatus'",
",",
"'name'",
"=>",
"'Dynamic product status box'",
",",
"]",
",",
"]",
")",
";",
"$",
"manager",
"->",
"flush",
"(",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadProductStatusData.php#L29-L124 |
skmetaly/laravel-twitch-restful-api | src/API/Channels.php | Channels.channel | public function channel($channel)
{
$channel = $this->client->get(config('twitch-api.api_url') . '/kraken/channels/' . $channel);
return $channel->json();
} | php | public function channel($channel)
{
$channel = $this->client->get(config('twitch-api.api_url') . '/kraken/channels/' . $channel);
return $channel->json();
} | [
"public",
"function",
"channel",
"(",
"$",
"channel",
")",
"{",
"$",
"channel",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/channels/'",
".",
"$",
"channel",
")",
";",
"return",
"$",
"channel",
"->",
"json",
"(",
")",
";",
"}"
] | Returns a channel object.
@param $channel
@return mixed | [
"Returns",
"a",
"channel",
"object",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Channels.php#L25-L30 |
skmetaly/laravel-twitch-restful-api | src/API/Channels.php | Channels.authenticatedChannel | public function authenticatedChannel($token = null)
{
$token = $this->getToken();
$request = $this->createRequest('GET', config('twitch-api.api_url') . '/kraken/channel', $token);
$channelInfo = $this->client->send($request);
return $channelInfo->json();
} | php | public function authenticatedChannel($token = null)
{
$token = $this->getToken();
$request = $this->createRequest('GET', config('twitch-api.api_url') . '/kraken/channel', $token);
$channelInfo = $this->client->send($request);
return $channelInfo->json();
} | [
"public",
"function",
"authenticatedChannel",
"(",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'GET'",
",",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/channel'",
",",
"$",
"token",
")",
";",
"$",
"channelInfo",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"return",
"$",
"channelInfo",
"->",
"json",
"(",
")",
";",
"}"
] | Returns a channel object of authenticated user. Channel object includes stream key.
Authenticated, required scope: channel_read
@param null $token
@return mixed
@throws \Skmetaly\TwitchApi\Exceptions\RequestRequiresAuthenticationException | [
"Returns",
"a",
"channel",
"object",
"of",
"authenticated",
"user",
".",
"Channel",
"object",
"includes",
"stream",
"key",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Channels.php#L42-L51 |
skmetaly/laravel-twitch-restful-api | src/API/Channels.php | Channels.deleteStreamKey | public function deleteStreamKey($channel, $token = null)
{
$token = $this->getToken($token);
$url = config('twitch-api.api_url') . '/kraken/channels/' . $channel . '/stream_key';
$request = $this->createRequest('DELETE', $url, $token);
$response = $this->client->send($request);
return $response->json();
} | php | public function deleteStreamKey($channel, $token = null)
{
$token = $this->getToken($token);
$url = config('twitch-api.api_url') . '/kraken/channels/' . $channel . '/stream_key';
$request = $this->createRequest('DELETE', $url, $token);
$response = $this->client->send($request);
return $response->json();
} | [
"public",
"function",
"deleteStreamKey",
"(",
"$",
"channel",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"url",
"=",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/channels/'",
".",
"$",
"channel",
".",
"'/stream_key'",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'DELETE'",
",",
"$",
"url",
",",
"$",
"token",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Resets channel's stream key.
Authenticated, required scope: channel_stream
@param $channel
@param null $token
@return json | [
"Resets",
"channel",
"s",
"stream",
"key",
".",
"Authenticated",
"required",
"scope",
":",
"channel_stream"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Channels.php#L113-L124 |
skmetaly/laravel-twitch-restful-api | src/API/Channels.php | Channels.postCommercial | public function postCommercial($channel, $length = 30, $token = null)
{
$token = $this->getToken($token);
$url = config('twitch-api.api_url') . '/channels/' . $channel . '/commercial';
$options = $this->getDefaultHeaders($token);
$options[ 'body' ] = ['length' => $length];
$request = $this->client->createRequest('POST', $url, $options);
$response = $this->client->send($request);
$response->json();
} | php | public function postCommercial($channel, $length = 30, $token = null)
{
$token = $this->getToken($token);
$url = config('twitch-api.api_url') . '/channels/' . $channel . '/commercial';
$options = $this->getDefaultHeaders($token);
$options[ 'body' ] = ['length' => $length];
$request = $this->client->createRequest('POST', $url, $options);
$response = $this->client->send($request);
$response->json();
} | [
"public",
"function",
"postCommercial",
"(",
"$",
"channel",
",",
"$",
"length",
"=",
"30",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"url",
"=",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/channels/'",
".",
"$",
"channel",
".",
"'/commercial'",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"getDefaultHeaders",
"(",
"$",
"token",
")",
";",
"$",
"options",
"[",
"'body'",
"]",
"=",
"[",
"'length'",
"=>",
"$",
"length",
"]",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"client",
"->",
"createRequest",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Start commercial on channel.
Authenticated, required scope: channel_commercial
@param $channel
@param int $length
@param null $token | [
"Start",
"commercial",
"on",
"channel",
".",
"Authenticated",
"required",
"scope",
":",
"channel_commercial"
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Channels.php#L134-L149 |
ekuiter/feature-php | FeaturePhp/ProductLine/ProductLine.php | ProductLine.getGeneratorSettings | public function getGeneratorSettings($generator) {
return $this->settings->getOptional("generators", $generator, fphp\Generator\Settings::emptyInstance());
} | php | public function getGeneratorSettings($generator) {
return $this->settings->getOptional("generators", $generator, fphp\Generator\Settings::emptyInstance());
} | [
"public",
"function",
"getGeneratorSettings",
"(",
"$",
"generator",
")",
"{",
"return",
"$",
"this",
"->",
"settings",
"->",
"getOptional",
"(",
"\"generators\"",
",",
"$",
"generator",
",",
"fphp",
"\\",
"Generator",
"\\",
"Settings",
"::",
"emptyInstance",
"(",
")",
")",
";",
"}"
] | Returns the product line's settings for a generator.
@param string $generator
@return \FeaturePhp\Generator\Settings | [
"Returns",
"the",
"product",
"line",
"s",
"settings",
"for",
"a",
"generator",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L88-L90 |
ekuiter/feature-php | FeaturePhp/ProductLine/ProductLine.php | ProductLine.getProduct | public function getProduct($configuration = null) {
if (!$configuration)
$configuration = $this->getDefaultConfiguration();
return new Product($this, $configuration);
} | php | public function getProduct($configuration = null) {
if (!$configuration)
$configuration = $this->getDefaultConfiguration();
return new Product($this, $configuration);
} | [
"public",
"function",
"getProduct",
"(",
"$",
"configuration",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"configuration",
")",
"$",
"configuration",
"=",
"$",
"this",
"->",
"getDefaultConfiguration",
"(",
")",
";",
"return",
"new",
"Product",
"(",
"$",
"this",
",",
"$",
"configuration",
")",
";",
"}"
] | Returns a product of the product line for a configuration.
If the configuration is omitted, the default configuration is used.
@param \FeaturePhp\Model\Configuration $configuration
@return Product | [
"Returns",
"a",
"product",
"of",
"the",
"product",
"line",
"for",
"a",
"configuration",
".",
"If",
"the",
"configuration",
"is",
"omitted",
"the",
"default",
"configuration",
"is",
"used",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L98-L102 |
ekuiter/feature-php | FeaturePhp/ProductLine/ProductLine.php | ProductLine.trace | public function trace($artifact) {
$featureName = str_replace("\"", """, $artifact->getFeature()->getName());
$xmlConfiguration = fphp\Model\XmlConfiguration::fromString(
'<configuration><feature name="' . $featureName . '" automatic="undefined" manual="selected"/></configuration>');
$configuration = new fphp\Model\Configuration($this->getModel(), $xmlConfiguration);
$product = new Product($this, $configuration, true);
return $product->trace();
} | php | public function trace($artifact) {
$featureName = str_replace("\"", """, $artifact->getFeature()->getName());
$xmlConfiguration = fphp\Model\XmlConfiguration::fromString(
'<configuration><feature name="' . $featureName . '" automatic="undefined" manual="selected"/></configuration>');
$configuration = new fphp\Model\Configuration($this->getModel(), $xmlConfiguration);
$product = new Product($this, $configuration, true);
return $product->trace();
} | [
"public",
"function",
"trace",
"(",
"$",
"artifact",
")",
"{",
"$",
"featureName",
"=",
"str_replace",
"(",
"\"\\\"\"",
",",
"\""\"",
",",
"$",
"artifact",
"->",
"getFeature",
"(",
")",
"->",
"getName",
"(",
")",
")",
";",
"$",
"xmlConfiguration",
"=",
"fphp",
"\\",
"Model",
"\\",
"XmlConfiguration",
"::",
"fromString",
"(",
"'<configuration><feature name=\"'",
".",
"$",
"featureName",
".",
"'\" automatic=\"undefined\" manual=\"selected\"/></configuration>'",
")",
";",
"$",
"configuration",
"=",
"new",
"fphp",
"\\",
"Model",
"\\",
"Configuration",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
",",
"$",
"xmlConfiguration",
")",
";",
"$",
"product",
"=",
"new",
"Product",
"(",
"$",
"this",
",",
"$",
"configuration",
",",
"true",
")",
";",
"return",
"$",
"product",
"->",
"trace",
"(",
")",
";",
"}"
] | Returns tracing links for an artifact.
@param \FeaturePhp\Artifact\Artifact $artifact
@return \FeaturePhp\Artifact\TracingLink[] | [
"Returns",
"tracing",
"links",
"for",
"an",
"artifact",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L109-L116 |
ekuiter/feature-php | FeaturePhp/ProductLine/ProductLine.php | ProductLine.renderTracingLinkAnalysis | public function renderTracingLinkAnalysis($artifact, $textOnly = false) {
return (new fphp\Artifact\TracingLinkRenderer($this->trace($artifact)))->render($textOnly);
} | php | public function renderTracingLinkAnalysis($artifact, $textOnly = false) {
return (new fphp\Artifact\TracingLinkRenderer($this->trace($artifact)))->render($textOnly);
} | [
"public",
"function",
"renderTracingLinkAnalysis",
"(",
"$",
"artifact",
",",
"$",
"textOnly",
"=",
"false",
")",
"{",
"return",
"(",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLinkRenderer",
"(",
"$",
"this",
"->",
"trace",
"(",
"$",
"artifact",
")",
")",
")",
"->",
"render",
"(",
"$",
"textOnly",
")",
";",
"}"
] | Analyzes an artifact's tracing links by returning a web page.
@param \FeaturePhp\Artifact\Artifact $artifact
@param bool $textOnly whether to render text or HTML
@return string | [
"Analyzes",
"an",
"artifact",
"s",
"tracing",
"links",
"by",
"returning",
"a",
"web",
"page",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L124-L126 |
accompli/chrono | src/Adapter/GitAdapter.php | GitAdapter.supportsRepository | public function supportsRepository()
{
$result = $this->processExecutor->execute('git --version');
if ($result->isSuccessful() === false) {
return false;
}
if (preg_match('#(^git://|\.git$|git(?:olite)?@|//git\.|//github.com/)#i', $this->repositoryUrl) === 1) {
return true;
}
$result = $this->processExecutor->execute(sprintf('git ls-remote --heads %s', ProcessUtils::escapeArgument($this->repositoryUrl)), null, $this->getEnvironmentVariables());
if ($result->isSuccessful()) {
return true;
}
return false;
} | php | public function supportsRepository()
{
$result = $this->processExecutor->execute('git --version');
if ($result->isSuccessful() === false) {
return false;
}
if (preg_match('#(^git://|\.git$|git(?:olite)?@|//git\.|//github.com/)#i', $this->repositoryUrl) === 1) {
return true;
}
$result = $this->processExecutor->execute(sprintf('git ls-remote --heads %s', ProcessUtils::escapeArgument($this->repositoryUrl)), null, $this->getEnvironmentVariables());
if ($result->isSuccessful()) {
return true;
}
return false;
} | [
"public",
"function",
"supportsRepository",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"'git --version'",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'#(^git://|\\.git$|git(?:olite)?@|//git\\.|//github.com/)#i'",
",",
"$",
"this",
"->",
"repositoryUrl",
")",
"===",
"1",
")",
"{",
"return",
"true",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"sprintf",
"(",
"'git ls-remote --heads %s'",
",",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"repositoryUrl",
")",
")",
",",
"null",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/GitAdapter.php#L17-L34 |
accompli/chrono | src/Adapter/GitAdapter.php | GitAdapter.getBranches | public function getBranches()
{
$branches = array();
$result = $this->processExecutor->execute(sprintf('git ls-remote --heads %s', ProcessUtils::escapeArgument($this->repositoryUrl)), null, $this->getEnvironmentVariables());
if ($result->isSuccessful()) {
foreach ($result->getOutputAsArray() as $branch) {
$matches = array();
if (preg_match('#^([a-f0-9]{40})\s+refs\/heads\/(\S+)$#', $branch, $matches) === 1) {
$branches[$matches[1]] = $matches[2];
}
}
}
return $branches;
} | php | public function getBranches()
{
$branches = array();
$result = $this->processExecutor->execute(sprintf('git ls-remote --heads %s', ProcessUtils::escapeArgument($this->repositoryUrl)), null, $this->getEnvironmentVariables());
if ($result->isSuccessful()) {
foreach ($result->getOutputAsArray() as $branch) {
$matches = array();
if (preg_match('#^([a-f0-9]{40})\s+refs\/heads\/(\S+)$#', $branch, $matches) === 1) {
$branches[$matches[1]] = $matches[2];
}
}
}
return $branches;
} | [
"public",
"function",
"getBranches",
"(",
")",
"{",
"$",
"branches",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"sprintf",
"(",
"'git ls-remote --heads %s'",
",",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"repositoryUrl",
")",
")",
",",
"null",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"result",
"->",
"getOutputAsArray",
"(",
")",
"as",
"$",
"branch",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'#^([a-f0-9]{40})\\s+refs\\/heads\\/(\\S+)$#'",
",",
"$",
"branch",
",",
"$",
"matches",
")",
"===",
"1",
")",
"{",
"$",
"branches",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"branches",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/GitAdapter.php#L39-L54 |
accompli/chrono | src/Adapter/GitAdapter.php | GitAdapter.getTags | public function getTags()
{
$tags = array();
$result = $this->processExecutor->execute(sprintf('git ls-remote --tags %s', ProcessUtils::escapeArgument($this->repositoryUrl)), null, $this->getEnvironmentVariables());
if ($result->isSuccessful()) {
foreach ($result->getOutputAsArray() as $tag) {
$matches = array();
if (preg_match('#^([a-f0-9]{40})\s+refs\/tags\/([\S]+)\^{}$#', $tag, $matches) === 1) {
$tags[$matches[1]] = $matches[2];
}
}
}
return $tags;
} | php | public function getTags()
{
$tags = array();
$result = $this->processExecutor->execute(sprintf('git ls-remote --tags %s', ProcessUtils::escapeArgument($this->repositoryUrl)), null, $this->getEnvironmentVariables());
if ($result->isSuccessful()) {
foreach ($result->getOutputAsArray() as $tag) {
$matches = array();
if (preg_match('#^([a-f0-9]{40})\s+refs\/tags\/([\S]+)\^{}$#', $tag, $matches) === 1) {
$tags[$matches[1]] = $matches[2];
}
}
}
return $tags;
} | [
"public",
"function",
"getTags",
"(",
")",
"{",
"$",
"tags",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"sprintf",
"(",
"'git ls-remote --tags %s'",
",",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"repositoryUrl",
")",
")",
",",
"null",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"result",
"->",
"getOutputAsArray",
"(",
")",
"as",
"$",
"tag",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'#^([a-f0-9]{40})\\s+refs\\/tags\\/([\\S]+)\\^{}$#'",
",",
"$",
"tag",
",",
"$",
"matches",
")",
"===",
"1",
")",
"{",
"$",
"tags",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"tags",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/GitAdapter.php#L59-L74 |
accompli/chrono | src/Adapter/GitAdapter.php | GitAdapter.checkout | public function checkout($version)
{
$checkoutSuccesful = false;
$escapedVersion = ProcessUtils::escapeArgument($version);
if ($this->processExecutor->isDirectory($this->repositoryDirectory) && $this->processExecutor->execute('git rev-parse --is-inside-work-tree', $this->repositoryDirectory)->isSuccessful()) {
$commands = array(
'git fetch',
sprintf('git checkout %s', $escapedVersion),
);
$checkoutSuccesful = true;
foreach ($commands as $command) {
$result = $this->processExecutor->execute($command, $this->repositoryDirectory, $this->getEnvironmentVariables());
if ($result->isSuccessful() === false) {
$checkoutSuccesful = false;
break;
}
}
$result = $this->processExecutor->execute('git branch', $this->repositoryDirectory, $this->getEnvironmentVariables());
$checkoutSuccesful = $checkoutSuccesful && $result->isSuccessful();
if (preg_match('#^ \*.*(?:no branch|HEAD detached at)#', $result->getOutput()) === 0) {
$checkoutSuccesful = $checkoutSuccesful && $this->processExecutor->execute('git pull', $this->repositoryDirectory, $this->getEnvironmentVariables())->isSuccessful();
}
} else {
$escapedRepositoryUrl = ProcessUtils::escapeArgument($this->repositoryUrl);
$escapedRepositoryDirectory = ProcessUtils::escapeArgument($this->repositoryDirectory);
$result = $this->processExecutor->execute(sprintf('git clone -b %s --single-branch %s %s', $escapedVersion, $escapedRepositoryUrl, $escapedRepositoryDirectory), null, $this->getEnvironmentVariables());
$checkoutSuccesful = $result->isSuccessful();
}
return $checkoutSuccesful;
} | php | public function checkout($version)
{
$checkoutSuccesful = false;
$escapedVersion = ProcessUtils::escapeArgument($version);
if ($this->processExecutor->isDirectory($this->repositoryDirectory) && $this->processExecutor->execute('git rev-parse --is-inside-work-tree', $this->repositoryDirectory)->isSuccessful()) {
$commands = array(
'git fetch',
sprintf('git checkout %s', $escapedVersion),
);
$checkoutSuccesful = true;
foreach ($commands as $command) {
$result = $this->processExecutor->execute($command, $this->repositoryDirectory, $this->getEnvironmentVariables());
if ($result->isSuccessful() === false) {
$checkoutSuccesful = false;
break;
}
}
$result = $this->processExecutor->execute('git branch', $this->repositoryDirectory, $this->getEnvironmentVariables());
$checkoutSuccesful = $checkoutSuccesful && $result->isSuccessful();
if (preg_match('#^ \*.*(?:no branch|HEAD detached at)#', $result->getOutput()) === 0) {
$checkoutSuccesful = $checkoutSuccesful && $this->processExecutor->execute('git pull', $this->repositoryDirectory, $this->getEnvironmentVariables())->isSuccessful();
}
} else {
$escapedRepositoryUrl = ProcessUtils::escapeArgument($this->repositoryUrl);
$escapedRepositoryDirectory = ProcessUtils::escapeArgument($this->repositoryDirectory);
$result = $this->processExecutor->execute(sprintf('git clone -b %s --single-branch %s %s', $escapedVersion, $escapedRepositoryUrl, $escapedRepositoryDirectory), null, $this->getEnvironmentVariables());
$checkoutSuccesful = $result->isSuccessful();
}
return $checkoutSuccesful;
} | [
"public",
"function",
"checkout",
"(",
"$",
"version",
")",
"{",
"$",
"checkoutSuccesful",
"=",
"false",
";",
"$",
"escapedVersion",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"version",
")",
";",
"if",
"(",
"$",
"this",
"->",
"processExecutor",
"->",
"isDirectory",
"(",
"$",
"this",
"->",
"repositoryDirectory",
")",
"&&",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"'git rev-parse --is-inside-work-tree'",
",",
"$",
"this",
"->",
"repositoryDirectory",
")",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"$",
"commands",
"=",
"array",
"(",
"'git fetch'",
",",
"sprintf",
"(",
"'git checkout %s'",
",",
"$",
"escapedVersion",
")",
",",
")",
";",
"$",
"checkoutSuccesful",
"=",
"true",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"command",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"$",
"command",
",",
"$",
"this",
"->",
"repositoryDirectory",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
"===",
"false",
")",
"{",
"$",
"checkoutSuccesful",
"=",
"false",
";",
"break",
";",
"}",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"'git branch'",
",",
"$",
"this",
"->",
"repositoryDirectory",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
";",
"$",
"checkoutSuccesful",
"=",
"$",
"checkoutSuccesful",
"&&",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'#^ \\*.*(?:no branch|HEAD detached at)#'",
",",
"$",
"result",
"->",
"getOutput",
"(",
")",
")",
"===",
"0",
")",
"{",
"$",
"checkoutSuccesful",
"=",
"$",
"checkoutSuccesful",
"&&",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"'git pull'",
",",
"$",
"this",
"->",
"repositoryDirectory",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
"->",
"isSuccessful",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"escapedRepositoryUrl",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"repositoryUrl",
")",
";",
"$",
"escapedRepositoryDirectory",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"this",
"->",
"repositoryDirectory",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"processExecutor",
"->",
"execute",
"(",
"sprintf",
"(",
"'git clone -b %s --single-branch %s %s'",
",",
"$",
"escapedVersion",
",",
"$",
"escapedRepositoryUrl",
",",
"$",
"escapedRepositoryDirectory",
")",
",",
"null",
",",
"$",
"this",
"->",
"getEnvironmentVariables",
"(",
")",
")",
";",
"$",
"checkoutSuccesful",
"=",
"$",
"result",
"->",
"isSuccessful",
"(",
")",
";",
"}",
"return",
"$",
"checkoutSuccesful",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/GitAdapter.php#L79-L115 |
eghojansu/moe | src/tools/Basket.php | Basket.copyfrom | function copyfrom($var) {
if (is_string($var))
$var=Base::instance()->get($var);
foreach ($var as $key=>$val)
$this->item[$key]=$val;
} | php | function copyfrom($var) {
if (is_string($var))
$var=Base::instance()->get($var);
foreach ($var as $key=>$val)
$this->item[$key]=$val;
} | [
"function",
"copyfrom",
"(",
"$",
"var",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"var",
")",
")",
"$",
"var",
"=",
"Base",
"::",
"instance",
"(",
")",
"->",
"get",
"(",
"$",
"var",
")",
";",
"foreach",
"(",
"$",
"var",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"$",
"this",
"->",
"item",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}"
] | Hydrate item using hive array variable
@return NULL
@param $var array|string | [
"Hydrate",
"item",
"using",
"hive",
"array",
"variable"
] | train | https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Basket.php#L185-L190 |
php-lug/lug | src/Bundle/GridBundle/Form/Type/GridFiltersType.php | GridFiltersType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($options['grid']->getFilters() as $filter) {
$builder->add(
$filter->getName(),
$filter->getForm(),
array_merge(['filter' => $filter], $filter->getFormOptions())
);
}
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
foreach ($options['grid']->getFilters() as $filter) {
$builder->add(
$filter->getName(),
$filter->getForm(),
array_merge(['filter' => $filter], $filter->getFormOptions())
);
}
} | [
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"[",
"'grid'",
"]",
"->",
"getFilters",
"(",
")",
"as",
"$",
"filter",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"$",
"filter",
"->",
"getName",
"(",
")",
",",
"$",
"filter",
"->",
"getForm",
"(",
")",
",",
"array_merge",
"(",
"[",
"'filter'",
"=>",
"$",
"filter",
"]",
",",
"$",
"filter",
"->",
"getFormOptions",
"(",
")",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Form/Type/GridFiltersType.php#L27-L36 |
giftcards/Encryption | Doctrine/Configuration/Metadata/Driver/AnnotationDriver.php | AnnotationDriver.loadMetadataForClass | public function loadMetadataForClass($className, ClassMetadata $metadata)
{
/* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */
$metadata->hasEncryptedProperties = false;
$metadata->encryptedProperties = array();
$class = $metadata->getReflectionClass();
foreach ($class->getProperties() as $name => $property) {
/** @var \Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted $annotation */
$annotation = $this->reader->getPropertyAnnotation(
$property,
'Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted'
);
if (!$annotation) {
continue;
}
$metadata->hasEncryptedProperties = true;
$metadata->encryptedProperties[$property->getName()] = array(
'profile' => $annotation->profile,
'ignored_values' => $annotation->ignoredValues
);
}
} | php | public function loadMetadataForClass($className, ClassMetadata $metadata)
{
/* @var $metadata \Doctrine\ORM\Mapping\ClassMetadataInfo */
$metadata->hasEncryptedProperties = false;
$metadata->encryptedProperties = array();
$class = $metadata->getReflectionClass();
foreach ($class->getProperties() as $name => $property) {
/** @var \Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted $annotation */
$annotation = $this->reader->getPropertyAnnotation(
$property,
'Giftcards\Encryption\Doctrine\Configuration\Annotation\Encrypted'
);
if (!$annotation) {
continue;
}
$metadata->hasEncryptedProperties = true;
$metadata->encryptedProperties[$property->getName()] = array(
'profile' => $annotation->profile,
'ignored_values' => $annotation->ignoredValues
);
}
} | [
"public",
"function",
"loadMetadataForClass",
"(",
"$",
"className",
",",
"ClassMetadata",
"$",
"metadata",
")",
"{",
"/* @var $metadata \\Doctrine\\ORM\\Mapping\\ClassMetadataInfo */",
"$",
"metadata",
"->",
"hasEncryptedProperties",
"=",
"false",
";",
"$",
"metadata",
"->",
"encryptedProperties",
"=",
"array",
"(",
")",
";",
"$",
"class",
"=",
"$",
"metadata",
"->",
"getReflectionClass",
"(",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"getProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"property",
")",
"{",
"/** @var \\Giftcards\\Encryption\\Doctrine\\Configuration\\Annotation\\Encrypted $annotation */",
"$",
"annotation",
"=",
"$",
"this",
"->",
"reader",
"->",
"getPropertyAnnotation",
"(",
"$",
"property",
",",
"'Giftcards\\Encryption\\Doctrine\\Configuration\\Annotation\\Encrypted'",
")",
";",
"if",
"(",
"!",
"$",
"annotation",
")",
"{",
"continue",
";",
"}",
"$",
"metadata",
"->",
"hasEncryptedProperties",
"=",
"true",
";",
"$",
"metadata",
"->",
"encryptedProperties",
"[",
"$",
"property",
"->",
"getName",
"(",
")",
"]",
"=",
"array",
"(",
"'profile'",
"=>",
"$",
"annotation",
"->",
"profile",
",",
"'ignored_values'",
"=>",
"$",
"annotation",
"->",
"ignoredValues",
")",
";",
"}",
"}"
] | Loads the metadata for the specified class into the provided container.
@param string $className
@param ClassMetadata $metadata
@return void | [
"Loads",
"the",
"metadata",
"for",
"the",
"specified",
"class",
"into",
"the",
"provided",
"container",
"."
] | train | https://github.com/giftcards/Encryption/blob/a48f92408538e2ffe1c8603f168d57803aad7100/Doctrine/Configuration/Metadata/Driver/AnnotationDriver.php#L24-L47 |
windwork/wf-logger | lib/adapter/File.php | File.log | public function log($level, $message, array $context = array())
{
if (!$this->checkLevel($level)) {
return;
}
if (!is_scalar($message)) {
$message = var_export($message, 1);
}
$time = time();
$yearMonth = date('Y-m', $time);
$logFile = $this->logDir . "/log.{$level}.php";
// 日志文件超过限定大小将分文件保存
if(@is_file($logFile) && filesize($logFile) > self::LOG_SIZE) {
$archiveTime = date('YmdHis', $time);
$logFileArchive = $this->logDir . "/log.{$level}-{$archiveTime}.php";
// 文件是否正在保存,如果正在保存,其他请求就不再保存
if(!is_file($logFileArchive)) {
@rename($logFile, $logFileArchive);
}
}
// 新添加的文件前添加浏览保护信息
$pre = "<?php exit?>";
$pre .= date('Y-m-d H:i:s');
$message = trim($message);
if(!file_put_contents($logFile, "{$pre} {$level} {$message}\n", FILE_APPEND)) {
throw new \wf\logger\Exception($logFile. ' can\'t write.');
}
} | php | public function log($level, $message, array $context = array())
{
if (!$this->checkLevel($level)) {
return;
}
if (!is_scalar($message)) {
$message = var_export($message, 1);
}
$time = time();
$yearMonth = date('Y-m', $time);
$logFile = $this->logDir . "/log.{$level}.php";
// 日志文件超过限定大小将分文件保存
if(@is_file($logFile) && filesize($logFile) > self::LOG_SIZE) {
$archiveTime = date('YmdHis', $time);
$logFileArchive = $this->logDir . "/log.{$level}-{$archiveTime}.php";
// 文件是否正在保存,如果正在保存,其他请求就不再保存
if(!is_file($logFileArchive)) {
@rename($logFile, $logFileArchive);
}
}
// 新添加的文件前添加浏览保护信息
$pre = "<?php exit?>";
$pre .= date('Y-m-d H:i:s');
$message = trim($message);
if(!file_put_contents($logFile, "{$pre} {$level} {$message}\n", FILE_APPEND)) {
throw new \wf\logger\Exception($logFile. ' can\'t write.');
}
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkLevel",
"(",
"$",
"level",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"var_export",
"(",
"$",
"message",
",",
"1",
")",
";",
"}",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"yearMonth",
"=",
"date",
"(",
"'Y-m'",
",",
"$",
"time",
")",
";",
"$",
"logFile",
"=",
"$",
"this",
"->",
"logDir",
".",
"\"/log.{$level}.php\"",
";",
"// 日志文件超过限定大小将分文件保存",
"if",
"(",
"@",
"is_file",
"(",
"$",
"logFile",
")",
"&&",
"filesize",
"(",
"$",
"logFile",
")",
">",
"self",
"::",
"LOG_SIZE",
")",
"{",
"$",
"archiveTime",
"=",
"date",
"(",
"'YmdHis'",
",",
"$",
"time",
")",
";",
"$",
"logFileArchive",
"=",
"$",
"this",
"->",
"logDir",
".",
"\"/log.{$level}-{$archiveTime}.php\"",
";",
"// 文件是否正在保存,如果正在保存,其他请求就不再保存",
"if",
"(",
"!",
"is_file",
"(",
"$",
"logFileArchive",
")",
")",
"{",
"@",
"rename",
"(",
"$",
"logFile",
",",
"$",
"logFileArchive",
")",
";",
"}",
"}",
"// 新添加的文件前添加浏览保护信息",
"$",
"pre",
"=",
"\"<?php exit?>\"",
";",
"$",
"pre",
".=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"message",
"=",
"trim",
"(",
"$",
"message",
")",
";",
"if",
"(",
"!",
"file_put_contents",
"(",
"$",
"logFile",
",",
"\"{$pre} {$level} {$message}\\n\"",
",",
"FILE_APPEND",
")",
")",
"{",
"throw",
"new",
"\\",
"wf",
"\\",
"logger",
"\\",
"Exception",
"(",
"$",
"logFile",
".",
"' can\\'t write.'",
")",
";",
"}",
"}"
] | {@inheritDoc}
@see \wf\logger\LoggerAbstract::log() | [
"{"
] | train | https://github.com/windwork/wf-logger/blob/60cd331d4106296610ef0b827fce38f357231958/lib/adapter/File.php#L32-L64 |
php-lug/lug | src/Component/Grid/Sort/Type/AbstractType.php | AbstractType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('field', function (Options $options, $field) {
return $field ?: $options['sort']->getName();
})
->setAllowedTypes('field', 'string');
} | php | public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('field', function (Options $options, $field) {
return $field ?: $options['sort']->getName();
})
->setAllowedTypes('field', 'string');
} | [
"public",
"function",
"configureOptions",
"(",
"OptionsResolver",
"$",
"resolver",
")",
"{",
"$",
"resolver",
"->",
"setDefault",
"(",
"'field'",
",",
"function",
"(",
"Options",
"$",
"options",
",",
"$",
"field",
")",
"{",
"return",
"$",
"field",
"?",
":",
"$",
"options",
"[",
"'sort'",
"]",
"->",
"getName",
"(",
")",
";",
"}",
")",
"->",
"setAllowedTypes",
"(",
"'field'",
",",
"'string'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Sort/Type/AbstractType.php#L25-L32 |
thecodingmachine/mvc.splash-common | src/Mouf/Mvc/Splash/Services/MoufExplorerUrlProvider.php | MoufExplorerUrlProvider.getUrlsList | public function getUrlsList($instanceName)
{
$moufManager = MoufManager::getMoufManager();
$instanceNames = $moufManager->findInstances(UrlProviderInterface::class);
$urls = array();
foreach ($instanceNames as $instanceName) {
$urlProvider = $moufManager->getInstance($instanceName);
/* @var $urlProvider UrlProviderInterface */
if ($urlProvider === $this) {
continue;
}
$tmpUrlList = $urlProvider->getUrlsList($instanceName);
$urls = array_merge($urls, $tmpUrlList);
}
return $urls;
} | php | public function getUrlsList($instanceName)
{
$moufManager = MoufManager::getMoufManager();
$instanceNames = $moufManager->findInstances(UrlProviderInterface::class);
$urls = array();
foreach ($instanceNames as $instanceName) {
$urlProvider = $moufManager->getInstance($instanceName);
/* @var $urlProvider UrlProviderInterface */
if ($urlProvider === $this) {
continue;
}
$tmpUrlList = $urlProvider->getUrlsList($instanceName);
$urls = array_merge($urls, $tmpUrlList);
}
return $urls;
} | [
"public",
"function",
"getUrlsList",
"(",
"$",
"instanceName",
")",
"{",
"$",
"moufManager",
"=",
"MoufManager",
"::",
"getMoufManager",
"(",
")",
";",
"$",
"instanceNames",
"=",
"$",
"moufManager",
"->",
"findInstances",
"(",
"UrlProviderInterface",
"::",
"class",
")",
";",
"$",
"urls",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"instanceNames",
"as",
"$",
"instanceName",
")",
"{",
"$",
"urlProvider",
"=",
"$",
"moufManager",
"->",
"getInstance",
"(",
"$",
"instanceName",
")",
";",
"/* @var $urlProvider UrlProviderInterface */",
"if",
"(",
"$",
"urlProvider",
"===",
"$",
"this",
")",
"{",
"continue",
";",
"}",
"$",
"tmpUrlList",
"=",
"$",
"urlProvider",
"->",
"getUrlsList",
"(",
"$",
"instanceName",
")",
";",
"$",
"urls",
"=",
"array_merge",
"(",
"$",
"urls",
",",
"$",
"tmpUrlList",
")",
";",
"}",
"return",
"$",
"urls",
";",
"}"
] | Returns the list of URLs that can be accessed, and the function/method that should be called when the URL is called.
@param string $instanceName The identifier for this object in the container.
@return SplashRoute[] | [
"Returns",
"the",
"list",
"of",
"URLs",
"that",
"can",
"be",
"accessed",
"and",
"the",
"function",
"/",
"method",
"that",
"should",
"be",
"called",
"when",
"the",
"URL",
"is",
"called",
"."
] | train | https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Services/MoufExplorerUrlProvider.php#L22-L40 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/Broker.php | Broker.initializeObject | public function initializeObject()
{
$this->queue = new \SplQueue();
$this->synchronousEventMap = $this->cache->get('DispatcherConfiguration_Synchronous');
$this->asynchronousEventMap = $this->cache->get('DispatcherConfiguration_Asynchronous');
if (FALSE === ($this->synchronousEventMap || $this->asynchronousEventMap))
{
$this->buildEventMap();
$this->cache->set('DispatcherConfiguration_Asynchronous', $this->asynchronousEventMap);
$this->cache->set('DispatcherConfiguration_Synchronous', $this->synchronousEventMap);
}
} | php | public function initializeObject()
{
$this->queue = new \SplQueue();
$this->synchronousEventMap = $this->cache->get('DispatcherConfiguration_Synchronous');
$this->asynchronousEventMap = $this->cache->get('DispatcherConfiguration_Asynchronous');
if (FALSE === ($this->synchronousEventMap || $this->asynchronousEventMap))
{
$this->buildEventMap();
$this->cache->set('DispatcherConfiguration_Asynchronous', $this->asynchronousEventMap);
$this->cache->set('DispatcherConfiguration_Synchronous', $this->synchronousEventMap);
}
} | [
"public",
"function",
"initializeObject",
"(",
")",
"{",
"$",
"this",
"->",
"queue",
"=",
"new",
"\\",
"SplQueue",
"(",
")",
";",
"$",
"this",
"->",
"synchronousEventMap",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"'DispatcherConfiguration_Synchronous'",
")",
";",
"$",
"this",
"->",
"asynchronousEventMap",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"'DispatcherConfiguration_Asynchronous'",
")",
";",
"if",
"(",
"FALSE",
"===",
"(",
"$",
"this",
"->",
"synchronousEventMap",
"||",
"$",
"this",
"->",
"asynchronousEventMap",
")",
")",
"{",
"$",
"this",
"->",
"buildEventMap",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'DispatcherConfiguration_Asynchronous'",
",",
"$",
"this",
"->",
"asynchronousEventMap",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"'DispatcherConfiguration_Synchronous'",
",",
"$",
"this",
"->",
"synchronousEventMap",
")",
";",
"}",
"}"
] | Initializes the broker. Loads the dispatching configuration from cache or builds it. | [
"Initializes",
"the",
"broker",
".",
"Loads",
"the",
"dispatching",
"configuration",
"from",
"cache",
"or",
"builds",
"it",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L75-L89 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/Broker.php | Broker.queueEvent | public function queueEvent($event)
{
$this->queue->enqueue($event);
$class = get_class($event);
foreach ($this->synchronousEventMap->getListenersForEvent($class) as $listener)
{
$this->invokeListener($listener, $event);
}
} | php | public function queueEvent($event)
{
$this->queue->enqueue($event);
$class = get_class($event);
foreach ($this->synchronousEventMap->getListenersForEvent($class) as $listener)
{
$this->invokeListener($listener, $event);
}
} | [
"public",
"function",
"queueEvent",
"(",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"queue",
"->",
"enqueue",
"(",
"$",
"event",
")",
";",
"$",
"class",
"=",
"get_class",
"(",
"$",
"event",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"synchronousEventMap",
"->",
"getListenersForEvent",
"(",
"$",
"class",
")",
"as",
"$",
"listener",
")",
"{",
"$",
"this",
"->",
"invokeListener",
"(",
"$",
"listener",
",",
"$",
"event",
")",
";",
"}",
"}"
] | Enqueues an arbitrary event.
@param mixed $event The event object to publish.
@return void | [
"Enqueues",
"an",
"arbitrary",
"event",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L99-L108 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/Broker.php | Broker.flush | public function flush()
{
$this->queue->setIteratorMode(\SplQueue::IT_MODE_DELETE);
foreach ($this->queue as $event)
{
$class = get_class($event);
foreach ($this->asynchronousEventMap->getListenersForEvent($class) as $listener)
{
$this->invokeListener($listener, $event);
}
}
} | php | public function flush()
{
$this->queue->setIteratorMode(\SplQueue::IT_MODE_DELETE);
foreach ($this->queue as $event)
{
$class = get_class($event);
foreach ($this->asynchronousEventMap->getListenersForEvent($class) as $listener)
{
$this->invokeListener($listener, $event);
}
}
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"this",
"->",
"queue",
"->",
"setIteratorMode",
"(",
"\\",
"SplQueue",
"::",
"IT_MODE_DELETE",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"queue",
"as",
"$",
"event",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"event",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"asynchronousEventMap",
"->",
"getListenersForEvent",
"(",
"$",
"class",
")",
"as",
"$",
"listener",
")",
"{",
"$",
"this",
"->",
"invokeListener",
"(",
"$",
"listener",
",",
"$",
"event",
")",
";",
"}",
"}",
"}"
] | Publishes queued events.
@return void | [
"Publishes",
"queued",
"events",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L117-L130 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/Broker.php | Broker.invokeListener | private function invokeListener($listener, $event)
{
if (is_array($listener))
{
list($listenerClass, $method) = $listener;
$listenerInstance = $this->objectManager->get($listenerClass);
$listenerInstance->{$method}($event);
}
else
{
call_user_func($listener, $event);
}
} | php | private function invokeListener($listener, $event)
{
if (is_array($listener))
{
list($listenerClass, $method) = $listener;
$listenerInstance = $this->objectManager->get($listenerClass);
$listenerInstance->{$method}($event);
}
else
{
call_user_func($listener, $event);
}
} | [
"private",
"function",
"invokeListener",
"(",
"$",
"listener",
",",
"$",
"event",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"listener",
")",
")",
"{",
"list",
"(",
"$",
"listenerClass",
",",
"$",
"method",
")",
"=",
"$",
"listener",
";",
"$",
"listenerInstance",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"$",
"listenerClass",
")",
";",
"$",
"listenerInstance",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"event",
")",
";",
"}",
"else",
"{",
"call_user_func",
"(",
"$",
"listener",
",",
"$",
"event",
")",
";",
"}",
"}"
] | Invokes a listener for an event.
@param callable $listener Any type of callable.
@param object $event The event object.
@return void
@throws UnknownObjectException May be thrown when the listener class cannot be instantiated. | [
"Invokes",
"a",
"listener",
"for",
"an",
"event",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L143-L156 |
martin-helmich/flow-eventbroker | Classes/Helmich/EventBroker/Broker/Broker.php | Broker.buildEventMap | private function buildEventMap()
{
$this->synchronousEventMap = new EventMapping();
$this->asynchronousEventMap = new EventMapping();
$eventMap = NULL;
$annotationName = 'Helmich\\EventBroker\\Annotations\\Listener';
$classes = $this->reflectionService->getClassesContainingMethodsAnnotatedWith($annotationName);
foreach ($classes as $class)
{
$classReflection = new ClassReflection($class);
/** @var MethodReflection $method */
foreach ($classReflection->getMethods() as $method)
{
if ($this->reflectionService->isMethodAnnotatedWith($class, $method->getName(), $annotationName))
{
/** @var Listener $annotation */
$annotation = $this->reflectionService->getMethodAnnotation(
$class,
$method->getName(),
$annotationName
);
$event = $annotation->event;
$this
->getEventMap($annotation->synchronous)
->addListenerForEvent($event, [$class, $method->getName()]);
}
}
}
} | php | private function buildEventMap()
{
$this->synchronousEventMap = new EventMapping();
$this->asynchronousEventMap = new EventMapping();
$eventMap = NULL;
$annotationName = 'Helmich\\EventBroker\\Annotations\\Listener';
$classes = $this->reflectionService->getClassesContainingMethodsAnnotatedWith($annotationName);
foreach ($classes as $class)
{
$classReflection = new ClassReflection($class);
/** @var MethodReflection $method */
foreach ($classReflection->getMethods() as $method)
{
if ($this->reflectionService->isMethodAnnotatedWith($class, $method->getName(), $annotationName))
{
/** @var Listener $annotation */
$annotation = $this->reflectionService->getMethodAnnotation(
$class,
$method->getName(),
$annotationName
);
$event = $annotation->event;
$this
->getEventMap($annotation->synchronous)
->addListenerForEvent($event, [$class, $method->getName()]);
}
}
}
} | [
"private",
"function",
"buildEventMap",
"(",
")",
"{",
"$",
"this",
"->",
"synchronousEventMap",
"=",
"new",
"EventMapping",
"(",
")",
";",
"$",
"this",
"->",
"asynchronousEventMap",
"=",
"new",
"EventMapping",
"(",
")",
";",
"$",
"eventMap",
"=",
"NULL",
";",
"$",
"annotationName",
"=",
"'Helmich\\\\EventBroker\\\\Annotations\\\\Listener'",
";",
"$",
"classes",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getClassesContainingMethodsAnnotatedWith",
"(",
"$",
"annotationName",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"classReflection",
"=",
"new",
"ClassReflection",
"(",
"$",
"class",
")",
";",
"/** @var MethodReflection $method */",
"foreach",
"(",
"$",
"classReflection",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reflectionService",
"->",
"isMethodAnnotatedWith",
"(",
"$",
"class",
",",
"$",
"method",
"->",
"getName",
"(",
")",
",",
"$",
"annotationName",
")",
")",
"{",
"/** @var Listener $annotation */",
"$",
"annotation",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getMethodAnnotation",
"(",
"$",
"class",
",",
"$",
"method",
"->",
"getName",
"(",
")",
",",
"$",
"annotationName",
")",
";",
"$",
"event",
"=",
"$",
"annotation",
"->",
"event",
";",
"$",
"this",
"->",
"getEventMap",
"(",
"$",
"annotation",
"->",
"synchronous",
")",
"->",
"addListenerForEvent",
"(",
"$",
"event",
",",
"[",
"$",
"class",
",",
"$",
"method",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"}",
"}",
"}"
] | Builds the event dispatching configuration. | [
"Builds",
"the",
"event",
"dispatching",
"configuration",
"."
] | train | https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L163-L194 |
j-d/draggy | src/Draggy/Autocode/Templates/Base/TemplateBase.php | TemplateBase.setIndentation | public function setIndentation($indentation)
{
if (!is_string($indentation)) {
throw new \InvalidArgumentException('The attribute indentation on the class Template has to be string (' . gettype($indentation) . ('object' === gettype($indentation) ? ' ' . get_class($indentation) : '') . ' given).');
}
$this->indentation = $indentation;
return $this;
} | php | public function setIndentation($indentation)
{
if (!is_string($indentation)) {
throw new \InvalidArgumentException('The attribute indentation on the class Template has to be string (' . gettype($indentation) . ('object' === gettype($indentation) ? ' ' . get_class($indentation) : '') . ' given).');
}
$this->indentation = $indentation;
return $this;
} | [
"public",
"function",
"setIndentation",
"(",
"$",
"indentation",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"indentation",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute indentation on the class Template has to be string ('",
".",
"gettype",
"(",
"$",
"indentation",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"indentation",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"indentation",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"indentation",
"=",
"$",
"indentation",
";",
"return",
"$",
"this",
";",
"}"
] | Set indentation
@param string $indentation
@return Template
@throws \InvalidArgumentException | [
"Set",
"indentation"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Base/TemplateBase.php#L54-L63 |
j-d/draggy | src/Draggy/Autocode/Templates/Base/TemplateBase.php | TemplateBase.setIndentationCount | public function setIndentationCount($indentationCount)
{
if (!is_int($indentationCount)) {
throw new \InvalidArgumentException('The attribute indentationCount on the class Template has to be integer (' . gettype($indentationCount) . ('object' === gettype($indentationCount) ? ' ' . get_class($indentationCount) : '') . ' given).');
}
$this->indentationCount = $indentationCount;
return $this;
} | php | public function setIndentationCount($indentationCount)
{
if (!is_int($indentationCount)) {
throw new \InvalidArgumentException('The attribute indentationCount on the class Template has to be integer (' . gettype($indentationCount) . ('object' === gettype($indentationCount) ? ' ' . get_class($indentationCount) : '') . ' given).');
}
$this->indentationCount = $indentationCount;
return $this;
} | [
"public",
"function",
"setIndentationCount",
"(",
"$",
"indentationCount",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"indentationCount",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute indentationCount on the class Template has to be integer ('",
".",
"gettype",
"(",
"$",
"indentationCount",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"indentationCount",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"indentationCount",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"indentationCount",
"=",
"$",
"indentationCount",
";",
"return",
"$",
"this",
";",
"}"
] | Set indentationCount
@param integer $indentationCount
@return Template
@throws \InvalidArgumentException | [
"Set",
"indentationCount"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Base/TemplateBase.php#L84-L93 |
j-d/draggy | src/Draggy/Autocode/Templates/Base/TemplateBase.php | TemplateBase.setEol | public function setEol($eol)
{
if (!is_string($eol)) {
throw new \InvalidArgumentException('The attribute eol on the class Template has to be string (' . gettype($eol) . ('object' === gettype($eol) ? ' ' . get_class($eol) : '') . ' given).');
}
$this->eol = $eol;
return $this;
} | php | public function setEol($eol)
{
if (!is_string($eol)) {
throw new \InvalidArgumentException('The attribute eol on the class Template has to be string (' . gettype($eol) . ('object' === gettype($eol) ? ' ' . get_class($eol) : '') . ' given).');
}
$this->eol = $eol;
return $this;
} | [
"public",
"function",
"setEol",
"(",
"$",
"eol",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"eol",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute eol on the class Template has to be string ('",
".",
"gettype",
"(",
"$",
"eol",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"eol",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"eol",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"eol",
"=",
"$",
"eol",
";",
"return",
"$",
"this",
";",
"}"
] | Set eol
@param string $eol
@return Template
@throws \InvalidArgumentException | [
"Set",
"eol"
] | train | https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/Base/TemplateBase.php#L114-L123 |
fccn/oai-pmh-core | src/schemas/ands_lom.php | ANDS_LOM.create_regObjects | protected function create_regObjects()
{
$this->working_node = $this->oai_pmh->addChild($this->working_node, 'lom:lom');
$this->working_node->setAttribute('xmlns:lom', "http://ltsc.ieee.org/xsd/LOM");
$this->working_node->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/");
} | php | protected function create_regObjects()
{
$this->working_node = $this->oai_pmh->addChild($this->working_node, 'lom:lom');
$this->working_node->setAttribute('xmlns:lom', "http://ltsc.ieee.org/xsd/LOM");
$this->working_node->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/");
} | [
"protected",
"function",
"create_regObjects",
"(",
")",
"{",
"$",
"this",
"->",
"working_node",
"=",
"$",
"this",
"->",
"oai_pmh",
"->",
"addChild",
"(",
"$",
"this",
"->",
"working_node",
",",
"'lom:lom'",
")",
";",
"$",
"this",
"->",
"working_node",
"->",
"setAttribute",
"(",
"'xmlns:lom'",
",",
"\"http://ltsc.ieee.org/xsd/LOM\"",
")",
";",
"$",
"this",
"->",
"working_node",
"->",
"setAttribute",
"(",
"'xmlns:dc'",
",",
"\"http://purl.org/dc/elements/1.1/\"",
")",
";",
"}"
] | Override create registry objects to use oai_lom as holder | [
"Override",
"create",
"registry",
"objects",
"to",
"use",
"oai_lom",
"as",
"holder"
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L92-L97 |
fccn/oai-pmh-core | src/schemas/ands_lom.php | ANDS_LOM.generate_metadata | public function generate_metadata($lom_identifier, $res)
{
debug_message('****** In '.__FILE__.' function '.__FUNCTION__.' was called.');
$lom_data = new LOM_DataHolder();
$lom_data->setIdentifiers($lom_identifier, $this->def_catalog);
//debug_var_dump('lom_data->lomdata', $lom_data->lomdata['general']);
//debug_var_dump('result', $res->fetch(PDO::FETCH_OBJ));
$res->setFetchMode(\PDO::FETCH_CLASS, LOM_DataHolder::getKlass());
while ($row = $res->fetch()) {
// debug_var_dump('lom_data', $lom_data);
// debug_var_dump('query row', $row);
$lom_data->combine($row);
}
$res->closeCursor();
//debug_var_dump('lom_data', $lom_data);
//write metadata to XML
$this->write_xml_meta($lom_data->to_array());
} | php | public function generate_metadata($lom_identifier, $res)
{
debug_message('****** In '.__FILE__.' function '.__FUNCTION__.' was called.');
$lom_data = new LOM_DataHolder();
$lom_data->setIdentifiers($lom_identifier, $this->def_catalog);
//debug_var_dump('lom_data->lomdata', $lom_data->lomdata['general']);
//debug_var_dump('result', $res->fetch(PDO::FETCH_OBJ));
$res->setFetchMode(\PDO::FETCH_CLASS, LOM_DataHolder::getKlass());
while ($row = $res->fetch()) {
// debug_var_dump('lom_data', $lom_data);
// debug_var_dump('query row', $row);
$lom_data->combine($row);
}
$res->closeCursor();
//debug_var_dump('lom_data', $lom_data);
//write metadata to XML
$this->write_xml_meta($lom_data->to_array());
} | [
"public",
"function",
"generate_metadata",
"(",
"$",
"lom_identifier",
",",
"$",
"res",
")",
"{",
"debug_message",
"(",
"'****** In '",
".",
"__FILE__",
".",
"' function '",
".",
"__FUNCTION__",
".",
"' was called.'",
")",
";",
"$",
"lom_data",
"=",
"new",
"LOM_DataHolder",
"(",
")",
";",
"$",
"lom_data",
"->",
"setIdentifiers",
"(",
"$",
"lom_identifier",
",",
"$",
"this",
"->",
"def_catalog",
")",
";",
"//debug_var_dump('lom_data->lomdata', $lom_data->lomdata['general']);",
"//debug_var_dump('result', $res->fetch(PDO::FETCH_OBJ));",
"$",
"res",
"->",
"setFetchMode",
"(",
"\\",
"PDO",
"::",
"FETCH_CLASS",
",",
"LOM_DataHolder",
"::",
"getKlass",
"(",
")",
")",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"res",
"->",
"fetch",
"(",
")",
")",
"{",
"// debug_var_dump('lom_data', $lom_data);",
"// debug_var_dump('query row', $row);",
"$",
"lom_data",
"->",
"combine",
"(",
"$",
"row",
")",
";",
"}",
"$",
"res",
"->",
"closeCursor",
"(",
")",
";",
"//debug_var_dump('lom_data', $lom_data);",
"//write metadata to XML",
"$",
"this",
"->",
"write_xml_meta",
"(",
"$",
"lom_data",
"->",
"to_array",
"(",
")",
")",
";",
"}"
] | Generates metadata xml | [
"Generates",
"metadata",
"xml"
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L102-L120 |
fccn/oai-pmh-core | src/schemas/ands_lom.php | ANDS_LOM.create_lom_node | protected function create_lom_node($top_node, $tag, $value = '')
{
$tag_atts = explode('?', $tag);
$name = array_shift($tag_atts);
$node = '';
if (empty($value)) {
debug_message('tag ::'.$name.':: no value');
$node = $this->addChild($top_node, "lom:".$name);
} else {
debug_message('tag ::'.$name.':: value ::'.$value);
$node = $this->addChild($top_node, "lom:".$name, utf8_encode($value));
}
if (!empty($tag_atts)) {
foreach ($tag_atts as $composite_att) {
$att = explode('=', $composite_att);
debug_message("setting attribute: $att[0] = $att[1] to tag: $name ");
$node->setAttribute($att[0], $att[1]);
}
}
return $node;
} | php | protected function create_lom_node($top_node, $tag, $value = '')
{
$tag_atts = explode('?', $tag);
$name = array_shift($tag_atts);
$node = '';
if (empty($value)) {
debug_message('tag ::'.$name.':: no value');
$node = $this->addChild($top_node, "lom:".$name);
} else {
debug_message('tag ::'.$name.':: value ::'.$value);
$node = $this->addChild($top_node, "lom:".$name, utf8_encode($value));
}
if (!empty($tag_atts)) {
foreach ($tag_atts as $composite_att) {
$att = explode('=', $composite_att);
debug_message("setting attribute: $att[0] = $att[1] to tag: $name ");
$node->setAttribute($att[0], $att[1]);
}
}
return $node;
} | [
"protected",
"function",
"create_lom_node",
"(",
"$",
"top_node",
",",
"$",
"tag",
",",
"$",
"value",
"=",
"''",
")",
"{",
"$",
"tag_atts",
"=",
"explode",
"(",
"'?'",
",",
"$",
"tag",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"tag_atts",
")",
";",
"$",
"node",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"debug_message",
"(",
"'tag ::'",
".",
"$",
"name",
".",
"':: no value'",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"top_node",
",",
"\"lom:\"",
".",
"$",
"name",
")",
";",
"}",
"else",
"{",
"debug_message",
"(",
"'tag ::'",
".",
"$",
"name",
".",
"':: value ::'",
".",
"$",
"value",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"top_node",
",",
"\"lom:\"",
".",
"$",
"name",
",",
"utf8_encode",
"(",
"$",
"value",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"tag_atts",
")",
")",
"{",
"foreach",
"(",
"$",
"tag_atts",
"as",
"$",
"composite_att",
")",
"{",
"$",
"att",
"=",
"explode",
"(",
"'='",
",",
"$",
"composite_att",
")",
";",
"debug_message",
"(",
"\"setting attribute: $att[0] = $att[1] to tag: $name \"",
")",
";",
"$",
"node",
"->",
"setAttribute",
"(",
"$",
"att",
"[",
"0",
"]",
",",
"$",
"att",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"$",
"node",
";",
"}"
] | Creates a generic lom:element node | [
"Creates",
"a",
"generic",
"lom",
":",
"element",
"node"
] | train | https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L125-L145 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.