id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,100
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Client.php
|
Client.translateArray
|
public function translateArray(array $texts, $to, $from = null, $contentType = 'text/plain', $category = 'general')
{
$requestXml = "<TranslateArrayRequest>"."<AppId/>"."<From>$from</From>"."<Options>"."<Category xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\">$category</Category>"."<ContentType xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\">$contentType</ContentType>"."<ReservedFlags xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."<State xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."<Uri xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."<User xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."</Options>"."<Texts>";
foreach ($texts as $text) {
$requestXml .= "<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"><![CDATA[$text]]></string>";
}
$requestXml .= "</Texts>"."<To>$to</To>"."</TranslateArrayRequest>";
return $this->post('/TranslateArray', [], $requestXml, true, $texts);
}
|
php
|
public function translateArray(array $texts, $to, $from = null, $contentType = 'text/plain', $category = 'general')
{
$requestXml = "<TranslateArrayRequest>"."<AppId/>"."<From>$from</From>"."<Options>"."<Category xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\">$category</Category>"."<ContentType xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\">$contentType</ContentType>"."<ReservedFlags xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."<State xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."<Uri xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."<User xmlns=\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\" />"."</Options>"."<Texts>";
foreach ($texts as $text) {
$requestXml .= "<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\"><![CDATA[$text]]></string>";
}
$requestXml .= "</Texts>"."<To>$to</To>"."</TranslateArrayRequest>";
return $this->post('/TranslateArray', [], $requestXml, true, $texts);
}
|
[
"public",
"function",
"translateArray",
"(",
"array",
"$",
"texts",
",",
"$",
"to",
",",
"$",
"from",
"=",
"null",
",",
"$",
"contentType",
"=",
"'text/plain'",
",",
"$",
"category",
"=",
"'general'",
")",
"{",
"$",
"requestXml",
"=",
"\"<TranslateArrayRequest>\"",
".",
"\"<AppId/>\"",
".",
"\"<From>$from</From>\"",
".",
"\"<Options>\"",
".",
"\"<Category xmlns=\\\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\\\">$category</Category>\"",
".",
"\"<ContentType xmlns=\\\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\\\">$contentType</ContentType>\"",
".",
"\"<ReservedFlags xmlns=\\\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\\\" />\"",
".",
"\"<State xmlns=\\\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\\\" />\"",
".",
"\"<Uri xmlns=\\\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\\\" />\"",
".",
"\"<User xmlns=\\\"http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2\\\" />\"",
".",
"\"</Options>\"",
".",
"\"<Texts>\"",
";",
"foreach",
"(",
"$",
"texts",
"as",
"$",
"text",
")",
"{",
"$",
"requestXml",
".=",
"\"<string xmlns=\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\"><![CDATA[$text]]></string>\"",
";",
"}",
"$",
"requestXml",
".=",
"\"</Texts>\"",
".",
"\"<To>$to</To>\"",
".",
"\"</TranslateArrayRequest>\"",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'/TranslateArray'",
",",
"[",
"]",
",",
"$",
"requestXml",
",",
"true",
",",
"$",
"texts",
")",
";",
"}"
] |
Use the TranslateArray method to retrieve translations for multiple source texts.
@param array $texts Required. An array containing the texts for translation. All strings must be of
the same language. The total of all texts to be translated must not exceed 10000
characters. The maximum number of array elements is 2000.
@param string $to Required. A string representing the language code to translate the text into.
@param string|null $from Optional. A string representing the language code of the translation text.
@param string $contentType Optional. The format of the text being translated. The supported formats are
"text/plain" and "text/html". Any HTML needs to be well-formed.
@param string $category Optional. A string containing the category (domain) of the translation. Defaults
to "general".
The language codes are available at https://msdn.microsoft.com/en-us/library/hh456380.aspx
The API endpoint documentation is available at https://msdn.microsoft.com/en-us/library/ff512422.aspx
@return \MicrosoftTranslator\Response
@throws \MicrosoftTranslator\Exception
|
[
"Use",
"the",
"TranslateArray",
"method",
"to",
"retrieve",
"translations",
"for",
"multiple",
"source",
"texts",
"."
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Client.php#L253-L262
|
235,101
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Client.php
|
Client.getLanguageNames
|
public function getLanguageNames($locale, $languageCodes)
{
if (is_string($languageCodes)) {
$languageCodes = [$languageCodes];
}
/** @noinspection XmlUnusedNamespaceDeclaration */
$requestXml = '<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">';
if (sizeof($languageCodes) > 0) {
foreach ($languageCodes as $codes) {
$requestXml .= "<string>$codes</string>";
}
} else {
throw new Exception('$languageCodes array is empty.');
}
$requestXml .= '</ArrayOfstring>';
return $this->post('/GetLanguageNames?locale='.$locale, [], $requestXml, true, $languageCodes);
}
|
php
|
public function getLanguageNames($locale, $languageCodes)
{
if (is_string($languageCodes)) {
$languageCodes = [$languageCodes];
}
/** @noinspection XmlUnusedNamespaceDeclaration */
$requestXml = '<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">';
if (sizeof($languageCodes) > 0) {
foreach ($languageCodes as $codes) {
$requestXml .= "<string>$codes</string>";
}
} else {
throw new Exception('$languageCodes array is empty.');
}
$requestXml .= '</ArrayOfstring>';
return $this->post('/GetLanguageNames?locale='.$locale, [], $requestXml, true, $languageCodes);
}
|
[
"public",
"function",
"getLanguageNames",
"(",
"$",
"locale",
",",
"$",
"languageCodes",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"languageCodes",
")",
")",
"{",
"$",
"languageCodes",
"=",
"[",
"$",
"languageCodes",
"]",
";",
"}",
"/** @noinspection XmlUnusedNamespaceDeclaration */",
"$",
"requestXml",
"=",
"'<ArrayOfstring xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">'",
";",
"if",
"(",
"sizeof",
"(",
"$",
"languageCodes",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"languageCodes",
"as",
"$",
"codes",
")",
"{",
"$",
"requestXml",
".=",
"\"<string>$codes</string>\"",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'$languageCodes array is empty.'",
")",
";",
"}",
"$",
"requestXml",
".=",
"'</ArrayOfstring>'",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'/GetLanguageNames?locale='",
".",
"$",
"locale",
",",
"[",
"]",
",",
"$",
"requestXml",
",",
"true",
",",
"$",
"languageCodes",
")",
";",
"}"
] |
Retrieves friendly names for the languages passed in as the parameter languageCodes, and localized using the
passed locale language.
@param string $locale Required. A string representing a combination of an ISO 639 two-letter
lowercase culture code associated with a language and an ISO 3166 two-letter
uppercase subculture code to localize the language names or a ISO 639
lowercase culture code by itself.
@param string|array $languageCodes Required. A string or an array representing the ISO 639-1 language codes to
retrieve the friendly name for.
The language codes are available at https://msdn.microsoft.com/en-us/library/hh456380.aspx
The API endpoint documentation is available at https://msdn.microsoft.com/en-us/library/ff512414.aspx
@return \MicrosoftTranslator\Response
@throws \MicrosoftTranslator\Exception
|
[
"Retrieves",
"friendly",
"names",
"for",
"the",
"languages",
"passed",
"in",
"as",
"the",
"parameter",
"languageCodes",
"and",
"localized",
"using",
"the",
"passed",
"locale",
"language",
"."
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Client.php#L282-L300
|
235,102
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Client.php
|
Client.detectArray
|
public function detectArray(array $texts)
{
/** @noinspection XmlUnusedNamespaceDeclaration */
$requestXml = '<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">';
if (sizeof($texts) > 0) {
foreach ($texts as $str) {
$requestXml .= "<string>$str</string>";
}
} else {
throw new Exception('$texts array is empty.');
}
$requestXml .= '</ArrayOfstring>';
return $this->post('/DetectArray', [], $requestXml, true, $texts);
}
|
php
|
public function detectArray(array $texts)
{
/** @noinspection XmlUnusedNamespaceDeclaration */
$requestXml = '<ArrayOfstring xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">';
if (sizeof($texts) > 0) {
foreach ($texts as $str) {
$requestXml .= "<string>$str</string>";
}
} else {
throw new Exception('$texts array is empty.');
}
$requestXml .= '</ArrayOfstring>';
return $this->post('/DetectArray', [], $requestXml, true, $texts);
}
|
[
"public",
"function",
"detectArray",
"(",
"array",
"$",
"texts",
")",
"{",
"/** @noinspection XmlUnusedNamespaceDeclaration */",
"$",
"requestXml",
"=",
"'<ArrayOfstring xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">'",
";",
"if",
"(",
"sizeof",
"(",
"$",
"texts",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"texts",
"as",
"$",
"str",
")",
"{",
"$",
"requestXml",
".=",
"\"<string>$str</string>\"",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'$texts array is empty.'",
")",
";",
"}",
"$",
"requestXml",
".=",
"'</ArrayOfstring>'",
";",
"return",
"$",
"this",
"->",
"post",
"(",
"'/DetectArray'",
",",
"[",
"]",
",",
"$",
"requestXml",
",",
"true",
",",
"$",
"texts",
")",
";",
"}"
] |
Use the DetectArray Method to identify the language of an array of string at once. Performs independent
detection of each individual array element and returns a result for each row of the array.
@param array $texts Required. A string array representing the text from an unknown language. The size of the
text must not exceed 10000 characters.
The API endpoint documentation is available at https://msdn.microsoft.com/en-us/library/ff512412.aspx
@return \MicrosoftTranslator\Response
@throws \MicrosoftTranslator\Exception
|
[
"Use",
"the",
"DetectArray",
"Method",
"to",
"identify",
"the",
"language",
"of",
"an",
"array",
"of",
"string",
"at",
"once",
".",
"Performs",
"independent",
"detection",
"of",
"each",
"individual",
"array",
"element",
"and",
"returns",
"a",
"result",
"for",
"each",
"row",
"of",
"the",
"array",
"."
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Client.php#L345-L359
|
235,103
|
potsky/microsoft-translator-php-sdk
|
src/MicrosoftTranslator/Client.php
|
Client.buildUrl
|
private function buildUrl($endpoint, $url_parameters = [], $special_url = null)
{
foreach ($url_parameters as $key => $value) {
//@codeCoverageIgnoreStart
$endpoint = str_replace('{'.$key.'}', $value, $endpoint);
//@codeCoverageIgnoreEnd
}
if (is_null($special_url)) {
$url = trim($this->api_base_url, "/ \t\n\r\0\x0B");
} else {
$url = $special_url;
}
$url = $url.'/'.trim($endpoint, "/ \t\n\r\0\x0B");
return $url;
}
|
php
|
private function buildUrl($endpoint, $url_parameters = [], $special_url = null)
{
foreach ($url_parameters as $key => $value) {
//@codeCoverageIgnoreStart
$endpoint = str_replace('{'.$key.'}', $value, $endpoint);
//@codeCoverageIgnoreEnd
}
if (is_null($special_url)) {
$url = trim($this->api_base_url, "/ \t\n\r\0\x0B");
} else {
$url = $special_url;
}
$url = $url.'/'.trim($endpoint, "/ \t\n\r\0\x0B");
return $url;
}
|
[
"private",
"function",
"buildUrl",
"(",
"$",
"endpoint",
",",
"$",
"url_parameters",
"=",
"[",
"]",
",",
"$",
"special_url",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"url_parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//@codeCoverageIgnoreStart",
"$",
"endpoint",
"=",
"str_replace",
"(",
"'{'",
".",
"$",
"key",
".",
"'}'",
",",
"$",
"value",
",",
"$",
"endpoint",
")",
";",
"//@codeCoverageIgnoreEnd",
"}",
"if",
"(",
"is_null",
"(",
"$",
"special_url",
")",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"this",
"->",
"api_base_url",
",",
"\"/ \\t\\n\\r\\0\\x0B\"",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"$",
"special_url",
";",
"}",
"$",
"url",
"=",
"$",
"url",
".",
"'/'",
".",
"trim",
"(",
"$",
"endpoint",
",",
"\"/ \\t\\n\\r\\0\\x0B\"",
")",
";",
"return",
"$",
"url",
";",
"}"
] |
Build the URL according to endpoint by replacing URL parameters
@param string $endpoint
@param array $url_parameters
@param string|null $special_url
@return string
|
[
"Build",
"the",
"URL",
"according",
"to",
"endpoint",
"by",
"replacing",
"URL",
"parameters"
] |
102f2411be5abb0e57a73c475f8e9e185a9f4859
|
https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Client.php#L370-L386
|
235,104
|
platformsh/console-form
|
src/Field/Field.php
|
Field.set
|
public function set($key, $value)
{
switch ($key) {
case 'validator':
$this->validators[] = $value;
break;
case 'normalizer':
$this->normalizers[] = $value;
break;
default:
if (!property_exists($this, $key)) {
throw new \InvalidArgumentException("Unrecognized config key: $key");
}
$this->$key = $value;
}
return $this;
}
|
php
|
public function set($key, $value)
{
switch ($key) {
case 'validator':
$this->validators[] = $value;
break;
case 'normalizer':
$this->normalizers[] = $value;
break;
default:
if (!property_exists($this, $key)) {
throw new \InvalidArgumentException("Unrecognized config key: $key");
}
$this->$key = $value;
}
return $this;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'validator'",
":",
"$",
"this",
"->",
"validators",
"[",
"]",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'normalizer'",
":",
"$",
"this",
"->",
"normalizers",
"[",
"]",
"=",
"$",
"value",
";",
"break",
";",
"default",
":",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"this",
",",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unrecognized config key: $key\"",
")",
";",
"}",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set or modify a configuration value.
@param string $key
@param mixed $value
@return self
|
[
"Set",
"or",
"modify",
"a",
"configuration",
"value",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L191-L210
|
235,105
|
platformsh/console-form
|
src/Field/Field.php
|
Field.normalize
|
protected function normalize($value)
{
if ($value === null) {
return $value;
}
foreach ($this->normalizers as $normalizer) {
$value = $normalizer($value);
}
return $value;
}
|
php
|
protected function normalize($value)
{
if ($value === null) {
return $value;
}
foreach ($this->normalizers as $normalizer) {
$value = $normalizer($value);
}
return $value;
}
|
[
"protected",
"function",
"normalize",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"normalizers",
"as",
"$",
"normalizer",
")",
"{",
"$",
"value",
"=",
"$",
"normalizer",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Normalize user input.
@param mixed $value
@return mixed
|
[
"Normalize",
"user",
"input",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L256-L266
|
235,106
|
platformsh/console-form
|
src/Field/Field.php
|
Field.getAsOption
|
public function getAsOption()
{
return new InputOption(
$this->getOptionName(),
$this->shortcut,
$this->getOptionMode(),
$this->getDescription(),
$this->default
);
}
|
php
|
public function getAsOption()
{
return new InputOption(
$this->getOptionName(),
$this->shortcut,
$this->getOptionMode(),
$this->getDescription(),
$this->default
);
}
|
[
"public",
"function",
"getAsOption",
"(",
")",
"{",
"return",
"new",
"InputOption",
"(",
"$",
"this",
"->",
"getOptionName",
"(",
")",
",",
"$",
"this",
"->",
"shortcut",
",",
"$",
"this",
"->",
"getOptionMode",
"(",
")",
",",
"$",
"this",
"->",
"getDescription",
"(",
")",
",",
"$",
"this",
"->",
"default",
")",
";",
"}"
] |
Get the field as a Console input option.
@return InputOption
|
[
"Get",
"the",
"field",
"as",
"a",
"Console",
"input",
"option",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L320-L329
|
235,107
|
platformsh/console-form
|
src/Field/Field.php
|
Field.getQuestionHeader
|
protected function getQuestionHeader($includeDefault = true)
{
$header = '';
if ($this->isRequired()) {
$header .= $this->requiredMarker;
}
$header .= '<fg=green>' . $this->name . '</> (--' . $this->getOptionName() . ')';
if ($this->questionLine === null && !empty($this->description)) {
$header .= "\n" . $this->description;
} elseif (!empty($this->questionLine)) {
$header .= "\n" . $this->questionLine;
}
if ($includeDefault && $this->default !== null) {
$header .= "\n" . 'Default: <question>' . $this->formatDefault($this->default) . '</question>';
}
return $header;
}
|
php
|
protected function getQuestionHeader($includeDefault = true)
{
$header = '';
if ($this->isRequired()) {
$header .= $this->requiredMarker;
}
$header .= '<fg=green>' . $this->name . '</> (--' . $this->getOptionName() . ')';
if ($this->questionLine === null && !empty($this->description)) {
$header .= "\n" . $this->description;
} elseif (!empty($this->questionLine)) {
$header .= "\n" . $this->questionLine;
}
if ($includeDefault && $this->default !== null) {
$header .= "\n" . 'Default: <question>' . $this->formatDefault($this->default) . '</question>';
}
return $header;
}
|
[
"protected",
"function",
"getQuestionHeader",
"(",
"$",
"includeDefault",
"=",
"true",
")",
"{",
"$",
"header",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"header",
".=",
"$",
"this",
"->",
"requiredMarker",
";",
"}",
"$",
"header",
".=",
"'<fg=green>'",
".",
"$",
"this",
"->",
"name",
".",
"'</> (--'",
".",
"$",
"this",
"->",
"getOptionName",
"(",
")",
".",
"')'",
";",
"if",
"(",
"$",
"this",
"->",
"questionLine",
"===",
"null",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"description",
")",
")",
"{",
"$",
"header",
".=",
"\"\\n\"",
".",
"$",
"this",
"->",
"description",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"questionLine",
")",
")",
"{",
"$",
"header",
".=",
"\"\\n\"",
".",
"$",
"this",
"->",
"questionLine",
";",
"}",
"if",
"(",
"$",
"includeDefault",
"&&",
"$",
"this",
"->",
"default",
"!==",
"null",
")",
"{",
"$",
"header",
".=",
"\"\\n\"",
".",
"'Default: <question>'",
".",
"$",
"this",
"->",
"formatDefault",
"(",
"$",
"this",
"->",
"default",
")",
".",
"'</question>'",
";",
"}",
"return",
"$",
"header",
";",
"}"
] |
Get the header text for an interactive question.
@param bool $includeDefault
@return string
|
[
"Get",
"the",
"header",
"text",
"for",
"an",
"interactive",
"question",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L348-L365
|
235,108
|
platformsh/console-form
|
src/Field/Field.php
|
Field.getAsQuestion
|
public function getAsQuestion()
{
$question = new Question($this->getQuestionText(), $this->default);
$question->setMaxAttempts($this->maxAttempts);
$question->setValidator(function ($value) {
if ($this->isEmpty($value) && $this->isRequired()) {
throw new MissingValueException("'{$this->name}' is required");
}
$this->validate($value);
return $value;
});
$question->setAutocompleterValues($this->autoCompleterValues);
return $question;
}
|
php
|
public function getAsQuestion()
{
$question = new Question($this->getQuestionText(), $this->default);
$question->setMaxAttempts($this->maxAttempts);
$question->setValidator(function ($value) {
if ($this->isEmpty($value) && $this->isRequired()) {
throw new MissingValueException("'{$this->name}' is required");
}
$this->validate($value);
return $value;
});
$question->setAutocompleterValues($this->autoCompleterValues);
return $question;
}
|
[
"public",
"function",
"getAsQuestion",
"(",
")",
"{",
"$",
"question",
"=",
"new",
"Question",
"(",
"$",
"this",
"->",
"getQuestionText",
"(",
")",
",",
"$",
"this",
"->",
"default",
")",
";",
"$",
"question",
"->",
"setMaxAttempts",
"(",
"$",
"this",
"->",
"maxAttempts",
")",
";",
"$",
"question",
"->",
"setValidator",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
"$",
"value",
")",
"&&",
"$",
"this",
"->",
"isRequired",
"(",
")",
")",
"{",
"throw",
"new",
"MissingValueException",
"(",
"\"'{$this->name}' is required\"",
")",
";",
"}",
"$",
"this",
"->",
"validate",
"(",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}",
")",
";",
"$",
"question",
"->",
"setAutocompleterValues",
"(",
"$",
"this",
"->",
"autoCompleterValues",
")",
";",
"return",
"$",
"question",
";",
"}"
] |
Get the field as a Console question.
@return Question
|
[
"Get",
"the",
"field",
"as",
"a",
"Console",
"question",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L372-L387
|
235,109
|
platformsh/console-form
|
src/Field/Field.php
|
Field.getValueFromInput
|
public function getValueFromInput(InputInterface $input, $normalize = true)
{
$optionName = $this->getOptionName();
if (!$input->hasOption($optionName)) {
return null;
}
$value = $input->getOption($optionName);
if ($this->isEmpty($value)) {
return null;
}
if ($input->getParameterOption('--' . $optionName) === false && $value === $this->default) {
return null;
}
return $normalize ? $this->normalize($value) : $value;
}
|
php
|
public function getValueFromInput(InputInterface $input, $normalize = true)
{
$optionName = $this->getOptionName();
if (!$input->hasOption($optionName)) {
return null;
}
$value = $input->getOption($optionName);
if ($this->isEmpty($value)) {
return null;
}
if ($input->getParameterOption('--' . $optionName) === false && $value === $this->default) {
return null;
}
return $normalize ? $this->normalize($value) : $value;
}
|
[
"public",
"function",
"getValueFromInput",
"(",
"InputInterface",
"$",
"input",
",",
"$",
"normalize",
"=",
"true",
")",
"{",
"$",
"optionName",
"=",
"$",
"this",
"->",
"getOptionName",
"(",
")",
";",
"if",
"(",
"!",
"$",
"input",
"->",
"hasOption",
"(",
"$",
"optionName",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"value",
"=",
"$",
"input",
"->",
"getOption",
"(",
"$",
"optionName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isEmpty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"input",
"->",
"getParameterOption",
"(",
"'--'",
".",
"$",
"optionName",
")",
"===",
"false",
"&&",
"$",
"value",
"===",
"$",
"this",
"->",
"default",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"normalize",
"?",
"$",
"this",
"->",
"normalize",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"}"
] |
Get the value the user entered for this field.
@param InputInterface $input
@param bool $normalize
@return mixed|null
The raw value, or null if the user did not enter anything. The value
will be normalized if $normalize is set.
|
[
"Get",
"the",
"value",
"the",
"user",
"entered",
"for",
"this",
"field",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L449-L464
|
235,110
|
platformsh/console-form
|
src/Field/Field.php
|
Field.onChange
|
public function onChange(array $previousValues)
{
if (isset($this->defaultCallback)) {
$callback = $this->defaultCallback;
$this->default = $callback($previousValues);
}
}
|
php
|
public function onChange(array $previousValues)
{
if (isset($this->defaultCallback)) {
$callback = $this->defaultCallback;
$this->default = $callback($previousValues);
}
}
|
[
"public",
"function",
"onChange",
"(",
"array",
"$",
"previousValues",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"defaultCallback",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"defaultCallback",
";",
"$",
"this",
"->",
"default",
"=",
"$",
"callback",
"(",
"$",
"previousValues",
")",
";",
"}",
"}"
] |
React to a change in user input.
@param array $previousValues
|
[
"React",
"to",
"a",
"change",
"in",
"user",
"input",
"."
] |
5263fe8c6c976e10f4495c9e00c92cc2d410a673
|
https://github.com/platformsh/console-form/blob/5263fe8c6c976e10f4495c9e00c92cc2d410a673/src/Field/Field.php#L504-L510
|
235,111
|
runcmf/runbb
|
src/RunBB/Core/Parser.php
|
Parser.configureParser
|
private function configureParser()
{
$renderer = $parser = null;
$model = new \RunBB\Model\Admin\Parser();
$configurator = new \s9e\TextFormatter\Configurator();
$plugins = unserialize(User::get()->g_parser_plugins);
$useSmilies = false;
foreach ($plugins as $k => $plugin) {
$configurator->plugins->load($plugin);
if ($plugin === 'Emoticons') {
$useSmilies = true;
}
}
if ($useSmilies) {
foreach ($model->getSmilies() as $k => $v) {
$configurator->Emoticons->add($k, $v['html']);
}
}
$configurator->registeredVars['cacheDir'] = ForumEnv::get('FORUM_CACHE_DIR');
// Get an instance of the parser and the renderer
extract($configurator->finalize());
// We save the parser and the renderer to the disk for easy reuse
Utils::checkDir($this->cacheDir);
file_put_contents($this->cacheDir.'/'.User::get()->g_title.'Parser.php', serialize($parser));
file_put_contents($this->cacheDir.'/'.User::get()->g_title.'Renderer.php', serialize($renderer));
$this->parser = $parser;
$this->renderer = $renderer;
}
|
php
|
private function configureParser()
{
$renderer = $parser = null;
$model = new \RunBB\Model\Admin\Parser();
$configurator = new \s9e\TextFormatter\Configurator();
$plugins = unserialize(User::get()->g_parser_plugins);
$useSmilies = false;
foreach ($plugins as $k => $plugin) {
$configurator->plugins->load($plugin);
if ($plugin === 'Emoticons') {
$useSmilies = true;
}
}
if ($useSmilies) {
foreach ($model->getSmilies() as $k => $v) {
$configurator->Emoticons->add($k, $v['html']);
}
}
$configurator->registeredVars['cacheDir'] = ForumEnv::get('FORUM_CACHE_DIR');
// Get an instance of the parser and the renderer
extract($configurator->finalize());
// We save the parser and the renderer to the disk for easy reuse
Utils::checkDir($this->cacheDir);
file_put_contents($this->cacheDir.'/'.User::get()->g_title.'Parser.php', serialize($parser));
file_put_contents($this->cacheDir.'/'.User::get()->g_title.'Renderer.php', serialize($renderer));
$this->parser = $parser;
$this->renderer = $renderer;
}
|
[
"private",
"function",
"configureParser",
"(",
")",
"{",
"$",
"renderer",
"=",
"$",
"parser",
"=",
"null",
";",
"$",
"model",
"=",
"new",
"\\",
"RunBB",
"\\",
"Model",
"\\",
"Admin",
"\\",
"Parser",
"(",
")",
";",
"$",
"configurator",
"=",
"new",
"\\",
"s9e",
"\\",
"TextFormatter",
"\\",
"Configurator",
"(",
")",
";",
"$",
"plugins",
"=",
"unserialize",
"(",
"User",
"::",
"get",
"(",
")",
"->",
"g_parser_plugins",
")",
";",
"$",
"useSmilies",
"=",
"false",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"k",
"=>",
"$",
"plugin",
")",
"{",
"$",
"configurator",
"->",
"plugins",
"->",
"load",
"(",
"$",
"plugin",
")",
";",
"if",
"(",
"$",
"plugin",
"===",
"'Emoticons'",
")",
"{",
"$",
"useSmilies",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"useSmilies",
")",
"{",
"foreach",
"(",
"$",
"model",
"->",
"getSmilies",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"configurator",
"->",
"Emoticons",
"->",
"add",
"(",
"$",
"k",
",",
"$",
"v",
"[",
"'html'",
"]",
")",
";",
"}",
"}",
"$",
"configurator",
"->",
"registeredVars",
"[",
"'cacheDir'",
"]",
"=",
"ForumEnv",
"::",
"get",
"(",
"'FORUM_CACHE_DIR'",
")",
";",
"// Get an instance of the parser and the renderer",
"extract",
"(",
"$",
"configurator",
"->",
"finalize",
"(",
")",
")",
";",
"// We save the parser and the renderer to the disk for easy reuse",
"Utils",
"::",
"checkDir",
"(",
"$",
"this",
"->",
"cacheDir",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"cacheDir",
".",
"'/'",
".",
"User",
"::",
"get",
"(",
")",
"->",
"g_title",
".",
"'Parser.php'",
",",
"serialize",
"(",
"$",
"parser",
")",
")",
";",
"file_put_contents",
"(",
"$",
"this",
"->",
"cacheDir",
".",
"'/'",
".",
"User",
"::",
"get",
"(",
")",
"->",
"g_title",
".",
"'Renderer.php'",
",",
"serialize",
"(",
"$",
"renderer",
")",
")",
";",
"$",
"this",
"->",
"parser",
"=",
"$",
"parser",
";",
"$",
"this",
"->",
"renderer",
"=",
"$",
"renderer",
";",
"}"
] |
Build bundle for user group
|
[
"Build",
"bundle",
"for",
"user",
"group"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Parser.php#L46-L81
|
235,112
|
runcmf/runbb
|
src/RunBB/Core/Parser.php
|
Parser.parseMessage
|
public function parseMessage($text, $hide_smilies = 0)
{
if (ForumSettings::get('o_censoring') == '1') {
$text = Utils::censor($text);
}
// FIXME check text length
if ($hide_smilies) {
$this->parser->disablePlugin('Emoticons');
}
if (ForumSettings::get('p_message_img_tag') !== '1' ||
ForumSettings::get('p_sig_img_tag') !== '1' ||
User::get()['show_img'] !== '1' ||
User::get()['show_img_sig'] !== '1'
) {
$this->parser->disablePlugin('Autoimage');
$this->parser->disablePlugin('Autovideo');
}
$xml = $this->parser->parse($text);
$html = $this->renderer->render($xml);
return $html;
}
|
php
|
public function parseMessage($text, $hide_smilies = 0)
{
if (ForumSettings::get('o_censoring') == '1') {
$text = Utils::censor($text);
}
// FIXME check text length
if ($hide_smilies) {
$this->parser->disablePlugin('Emoticons');
}
if (ForumSettings::get('p_message_img_tag') !== '1' ||
ForumSettings::get('p_sig_img_tag') !== '1' ||
User::get()['show_img'] !== '1' ||
User::get()['show_img_sig'] !== '1'
) {
$this->parser->disablePlugin('Autoimage');
$this->parser->disablePlugin('Autovideo');
}
$xml = $this->parser->parse($text);
$html = $this->renderer->render($xml);
return $html;
}
|
[
"public",
"function",
"parseMessage",
"(",
"$",
"text",
",",
"$",
"hide_smilies",
"=",
"0",
")",
"{",
"if",
"(",
"ForumSettings",
"::",
"get",
"(",
"'o_censoring'",
")",
"==",
"'1'",
")",
"{",
"$",
"text",
"=",
"Utils",
"::",
"censor",
"(",
"$",
"text",
")",
";",
"}",
"// FIXME check text length",
"if",
"(",
"$",
"hide_smilies",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"disablePlugin",
"(",
"'Emoticons'",
")",
";",
"}",
"if",
"(",
"ForumSettings",
"::",
"get",
"(",
"'p_message_img_tag'",
")",
"!==",
"'1'",
"||",
"ForumSettings",
"::",
"get",
"(",
"'p_sig_img_tag'",
")",
"!==",
"'1'",
"||",
"User",
"::",
"get",
"(",
")",
"[",
"'show_img'",
"]",
"!==",
"'1'",
"||",
"User",
"::",
"get",
"(",
")",
"[",
"'show_img_sig'",
"]",
"!==",
"'1'",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"disablePlugin",
"(",
"'Autoimage'",
")",
";",
"$",
"this",
"->",
"parser",
"->",
"disablePlugin",
"(",
"'Autovideo'",
")",
";",
"}",
"$",
"xml",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"text",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"renderer",
"->",
"render",
"(",
"$",
"xml",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Parse message, post or signature message text.
@param string $text
@param integer $hide_smilies
@return string html
|
[
"Parse",
"message",
"post",
"or",
"signature",
"message",
"text",
"."
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Parser.php#L90-L112
|
235,113
|
runcmf/runbb
|
src/RunBB/Core/Parser.php
|
Parser.parseForSave
|
public function parseForSave($text, &$errors, $is_signature = false)
{
// FIXME check text length
if ($is_signature && (ForumSettings::get('p_sig_img_tag') !== '1' || User::get()['show_img_sig'] !== '1')) {
$this->parser->disablePlugin('Autoimage');
$this->parser->disablePlugin('Autovideo');
}
$xml = $this->parser->parse($text);
// $html = $this->renderer->render($xml);
// TODO check parser errors ??? not found problems in parser
// TODO check nestingLimit ??? not found problems in parser
// TODO check $is_signature limits
// $parserErrors = $this->parser->getLogger()->get();
// if (!empty($parserErrors)) {
//tdie($parserErrors);
// }
return \s9e\TextFormatter\Unparser::unparse($xml);
}
|
php
|
public function parseForSave($text, &$errors, $is_signature = false)
{
// FIXME check text length
if ($is_signature && (ForumSettings::get('p_sig_img_tag') !== '1' || User::get()['show_img_sig'] !== '1')) {
$this->parser->disablePlugin('Autoimage');
$this->parser->disablePlugin('Autovideo');
}
$xml = $this->parser->parse($text);
// $html = $this->renderer->render($xml);
// TODO check parser errors ??? not found problems in parser
// TODO check nestingLimit ??? not found problems in parser
// TODO check $is_signature limits
// $parserErrors = $this->parser->getLogger()->get();
// if (!empty($parserErrors)) {
//tdie($parserErrors);
// }
return \s9e\TextFormatter\Unparser::unparse($xml);
}
|
[
"public",
"function",
"parseForSave",
"(",
"$",
"text",
",",
"&",
"$",
"errors",
",",
"$",
"is_signature",
"=",
"false",
")",
"{",
"// FIXME check text length",
"if",
"(",
"$",
"is_signature",
"&&",
"(",
"ForumSettings",
"::",
"get",
"(",
"'p_sig_img_tag'",
")",
"!==",
"'1'",
"||",
"User",
"::",
"get",
"(",
")",
"[",
"'show_img_sig'",
"]",
"!==",
"'1'",
")",
")",
"{",
"$",
"this",
"->",
"parser",
"->",
"disablePlugin",
"(",
"'Autoimage'",
")",
";",
"$",
"this",
"->",
"parser",
"->",
"disablePlugin",
"(",
"'Autovideo'",
")",
";",
"}",
"$",
"xml",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"text",
")",
";",
"// $html = $this->renderer->render($xml);",
"// TODO check parser errors ??? not found problems in parser",
"// TODO check nestingLimit ??? not found problems in parser",
"// TODO check $is_signature limits",
"// $parserErrors = $this->parser->getLogger()->get();",
"// if (!empty($parserErrors)) {",
"//tdie($parserErrors);",
"// }",
"return",
"\\",
"s9e",
"\\",
"TextFormatter",
"\\",
"Unparser",
"::",
"unparse",
"(",
"$",
"xml",
")",
";",
"}"
] |
Parse message, post or signature message text.
Check errors
@param string $text
@return string
|
[
"Parse",
"message",
"post",
"or",
"signature",
"message",
"text",
".",
"Check",
"errors"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Parser.php#L121-L140
|
235,114
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Controller/SitemapController.php
|
SitemapController.displayAction
|
public function displayAction($display = 'html')
{
$site = $this->get('ucms_site.manager')->getContext();
$menus = $this->get('umenu.menu_storage')->loadWithConditions(['site_id' => $site->getId()]);
if ('xml' === $display) {
return $this->displayXML($menus);
}
return $this->displayHTML($menus);
}
|
php
|
public function displayAction($display = 'html')
{
$site = $this->get('ucms_site.manager')->getContext();
$menus = $this->get('umenu.menu_storage')->loadWithConditions(['site_id' => $site->getId()]);
if ('xml' === $display) {
return $this->displayXML($menus);
}
return $this->displayHTML($menus);
}
|
[
"public",
"function",
"displayAction",
"(",
"$",
"display",
"=",
"'html'",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"get",
"(",
"'ucms_site.manager'",
")",
"->",
"getContext",
"(",
")",
";",
"$",
"menus",
"=",
"$",
"this",
"->",
"get",
"(",
"'umenu.menu_storage'",
")",
"->",
"loadWithConditions",
"(",
"[",
"'site_id'",
"=>",
"$",
"site",
"->",
"getId",
"(",
")",
"]",
")",
";",
"if",
"(",
"'xml'",
"===",
"$",
"display",
")",
"{",
"return",
"$",
"this",
"->",
"displayXML",
"(",
"$",
"menus",
")",
";",
"}",
"return",
"$",
"this",
"->",
"displayHTML",
"(",
"$",
"menus",
")",
";",
"}"
] |
Display site map action
|
[
"Display",
"site",
"map",
"action"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Controller/SitemapController.php#L26-L36
|
235,115
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Controller/SitemapController.php
|
SitemapController.displayXML
|
private function displayXML($menus)
{
$treeList = [];
$manager = $this->getTreeManager();
/** @var \MakinaCorpus\Umenu\Menu $menu */
foreach ($menus as $menu) {
$tree = $manager->buildTree($menu->getId(), true);
if (!$tree->isEmpty()) {
$treeList[] = $tree;
}
}
$output = $this->renderView('@ucms_seo/views/sitemap.xml.twig', ['menus_tree' => $treeList]);
return new Response($output, 200, ['content-type' => 'application/xml']);
}
|
php
|
private function displayXML($menus)
{
$treeList = [];
$manager = $this->getTreeManager();
/** @var \MakinaCorpus\Umenu\Menu $menu */
foreach ($menus as $menu) {
$tree = $manager->buildTree($menu->getId(), true);
if (!$tree->isEmpty()) {
$treeList[] = $tree;
}
}
$output = $this->renderView('@ucms_seo/views/sitemap.xml.twig', ['menus_tree' => $treeList]);
return new Response($output, 200, ['content-type' => 'application/xml']);
}
|
[
"private",
"function",
"displayXML",
"(",
"$",
"menus",
")",
"{",
"$",
"treeList",
"=",
"[",
"]",
";",
"$",
"manager",
"=",
"$",
"this",
"->",
"getTreeManager",
"(",
")",
";",
"/** @var \\MakinaCorpus\\Umenu\\Menu $menu */",
"foreach",
"(",
"$",
"menus",
"as",
"$",
"menu",
")",
"{",
"$",
"tree",
"=",
"$",
"manager",
"->",
"buildTree",
"(",
"$",
"menu",
"->",
"getId",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"tree",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"treeList",
"[",
"]",
"=",
"$",
"tree",
";",
"}",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"renderView",
"(",
"'@ucms_seo/views/sitemap.xml.twig'",
",",
"[",
"'menus_tree'",
"=>",
"$",
"treeList",
"]",
")",
";",
"return",
"new",
"Response",
"(",
"$",
"output",
",",
"200",
",",
"[",
"'content-type'",
"=>",
"'application/xml'",
"]",
")",
";",
"}"
] |
Display site map as XML
@param Menu[]
@return string
|
[
"Display",
"site",
"map",
"as",
"XML"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Controller/SitemapController.php#L45-L61
|
235,116
|
makinacorpus/drupal-ucms
|
ucms_seo/src/Controller/SitemapController.php
|
SitemapController.displayHTML
|
private function displayHTML($menus)
{
$build = [];
$manager = $this->getTreeManager();
/** @var \MakinaCorpus\Umenu\Menu $menu */
foreach ($menus as $menu) {
if ($menu->isSiteMain() || !$menu->hasRole()) {
$tree = $manager->buildTree($menu->getId(), true);
if (!$tree->isEmpty()) {
$build[$menu->getTitle()] = $tree;
}
}
}
return theme('ucms_seo_sitemap', ['menus' => $build]);
}
|
php
|
private function displayHTML($menus)
{
$build = [];
$manager = $this->getTreeManager();
/** @var \MakinaCorpus\Umenu\Menu $menu */
foreach ($menus as $menu) {
if ($menu->isSiteMain() || !$menu->hasRole()) {
$tree = $manager->buildTree($menu->getId(), true);
if (!$tree->isEmpty()) {
$build[$menu->getTitle()] = $tree;
}
}
}
return theme('ucms_seo_sitemap', ['menus' => $build]);
}
|
[
"private",
"function",
"displayHTML",
"(",
"$",
"menus",
")",
"{",
"$",
"build",
"=",
"[",
"]",
";",
"$",
"manager",
"=",
"$",
"this",
"->",
"getTreeManager",
"(",
")",
";",
"/** @var \\MakinaCorpus\\Umenu\\Menu $menu */",
"foreach",
"(",
"$",
"menus",
"as",
"$",
"menu",
")",
"{",
"if",
"(",
"$",
"menu",
"->",
"isSiteMain",
"(",
")",
"||",
"!",
"$",
"menu",
"->",
"hasRole",
"(",
")",
")",
"{",
"$",
"tree",
"=",
"$",
"manager",
"->",
"buildTree",
"(",
"$",
"menu",
"->",
"getId",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"tree",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"build",
"[",
"$",
"menu",
"->",
"getTitle",
"(",
")",
"]",
"=",
"$",
"tree",
";",
"}",
"}",
"}",
"return",
"theme",
"(",
"'ucms_seo_sitemap'",
",",
"[",
"'menus'",
"=>",
"$",
"build",
"]",
")",
";",
"}"
] |
Display site map as HTML
@param Menu[]
@return string
|
[
"Display",
"site",
"map",
"as",
"HTML"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Controller/SitemapController.php#L70-L86
|
235,117
|
makinacorpus/drupal-ucms
|
ucms_seo/src/EventDispatcher/SiteEventSubscriber.php
|
SiteEventSubscriber.onInit
|
public function onInit(SiteInitEvent $event)
{
// Naive alias lookup for the current page
$site = $event->getSite();
$request = $event->getRequest();
$incomming = $request->query->get('q');
$nodeId = $this->service->getAliasManager()->matchPath($incomming, $site->getId());
if ($nodeId) {
// $_GET['q'] reference will be useless for Drupal 8
$_GET['q'] = $incomming = 'node/' . $nodeId;
$request->query->set('q', $incomming);
$request->attributes->set('_route', $incomming);
}
// Set current context to the alias manager
$this
->service
->getAliasCacheLookup()
->setEnvironment(
$site->getId(),
$incomming,
$request->query->all()
)
;
}
|
php
|
public function onInit(SiteInitEvent $event)
{
// Naive alias lookup for the current page
$site = $event->getSite();
$request = $event->getRequest();
$incomming = $request->query->get('q');
$nodeId = $this->service->getAliasManager()->matchPath($incomming, $site->getId());
if ($nodeId) {
// $_GET['q'] reference will be useless for Drupal 8
$_GET['q'] = $incomming = 'node/' . $nodeId;
$request->query->set('q', $incomming);
$request->attributes->set('_route', $incomming);
}
// Set current context to the alias manager
$this
->service
->getAliasCacheLookup()
->setEnvironment(
$site->getId(),
$incomming,
$request->query->all()
)
;
}
|
[
"public",
"function",
"onInit",
"(",
"SiteInitEvent",
"$",
"event",
")",
"{",
"// Naive alias lookup for the current page",
"$",
"site",
"=",
"$",
"event",
"->",
"getSite",
"(",
")",
";",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"incomming",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'q'",
")",
";",
"$",
"nodeId",
"=",
"$",
"this",
"->",
"service",
"->",
"getAliasManager",
"(",
")",
"->",
"matchPath",
"(",
"$",
"incomming",
",",
"$",
"site",
"->",
"getId",
"(",
")",
")",
";",
"if",
"(",
"$",
"nodeId",
")",
"{",
"// $_GET['q'] reference will be useless for Drupal 8",
"$",
"_GET",
"[",
"'q'",
"]",
"=",
"$",
"incomming",
"=",
"'node/'",
".",
"$",
"nodeId",
";",
"$",
"request",
"->",
"query",
"->",
"set",
"(",
"'q'",
",",
"$",
"incomming",
")",
";",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'_route'",
",",
"$",
"incomming",
")",
";",
"}",
"// Set current context to the alias manager",
"$",
"this",
"->",
"service",
"->",
"getAliasCacheLookup",
"(",
")",
"->",
"setEnvironment",
"(",
"$",
"site",
"->",
"getId",
"(",
")",
",",
"$",
"incomming",
",",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
Site is being initialized, and hopefully at this stage current menu
item has never been loaded, so alter the current path to something
else, before Drupal router gets to us.
|
[
"Site",
"is",
"being",
"initialized",
"and",
"hopefully",
"at",
"this",
"stage",
"current",
"menu",
"item",
"has",
"never",
"been",
"loaded",
"so",
"alter",
"the",
"current",
"path",
"to",
"something",
"else",
"before",
"Drupal",
"router",
"gets",
"to",
"us",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/EventDispatcher/SiteEventSubscriber.php#L55-L80
|
235,118
|
makinacorpus/drupal-ucms
|
ucms_seo/src/EventDispatcher/SiteEventSubscriber.php
|
SiteEventSubscriber.onMasterInit
|
public function onMasterInit(MasterInitEvent $event)
{
$request = $event->getRequest();
$this
->service
->getAliasCacheLookup()
->setEnvironment(
null,
$request->query->get('q'),
$request->query->all()
)
;
}
|
php
|
public function onMasterInit(MasterInitEvent $event)
{
$request = $event->getRequest();
$this
->service
->getAliasCacheLookup()
->setEnvironment(
null,
$request->query->get('q'),
$request->query->all()
)
;
}
|
[
"public",
"function",
"onMasterInit",
"(",
"MasterInitEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"this",
"->",
"service",
"->",
"getAliasCacheLookup",
"(",
")",
"->",
"setEnvironment",
"(",
"null",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'q'",
")",
",",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
We have no site context, we are in admin.
|
[
"We",
"have",
"no",
"site",
"context",
"we",
"are",
"in",
"admin",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/EventDispatcher/SiteEventSubscriber.php#L85-L98
|
235,119
|
makinacorpus/drupal-ucms
|
ucms_search/src/Lucene/CollectionQuery.php
|
CollectionQuery.setOperator
|
public function setOperator($operator)
{
if ($operator !== null && $operator !== Query::OP_AND && $operator !== Query::OP_OR) {
throw new \InvalidArgumentException("Operator must be Query::OP_AND or Query::OP_OR");
}
$this->operator = $operator;
return $this;
}
|
php
|
public function setOperator($operator)
{
if ($operator !== null && $operator !== Query::OP_AND && $operator !== Query::OP_OR) {
throw new \InvalidArgumentException("Operator must be Query::OP_AND or Query::OP_OR");
}
$this->operator = $operator;
return $this;
}
|
[
"public",
"function",
"setOperator",
"(",
"$",
"operator",
")",
"{",
"if",
"(",
"$",
"operator",
"!==",
"null",
"&&",
"$",
"operator",
"!==",
"Query",
"::",
"OP_AND",
"&&",
"$",
"operator",
"!==",
"Query",
"::",
"OP_OR",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Operator must be Query::OP_AND or Query::OP_OR\"",
")",
";",
"}",
"$",
"this",
"->",
"operator",
"=",
"$",
"operator",
";",
"return",
"$",
"this",
";",
"}"
] |
Set default operator
@param string $operator
@return CollectionQuery
|
[
"Set",
"default",
"operator"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Lucene/CollectionQuery.php#L80-L89
|
235,120
|
despark/ignicms
|
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Exceptions.php
|
CI_Exceptions.show_404
|
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
|
php
|
function show_404($page = '', $log_error = TRUE)
{
$heading = "404 Page Not Found";
$message = "The page you requested was not found.";
// By default we log this, but allow a dev to skip it
if ($log_error)
{
log_message('error', '404 Page Not Found --> '.$page);
}
echo $this->show_error($heading, $message, 'error_404', 404);
exit;
}
|
[
"function",
"show_404",
"(",
"$",
"page",
"=",
"''",
",",
"$",
"log_error",
"=",
"TRUE",
")",
"{",
"$",
"heading",
"=",
"\"404 Page Not Found\"",
";",
"$",
"message",
"=",
"\"The page you requested was not found.\"",
";",
"// By default we log this, but allow a dev to skip it",
"if",
"(",
"$",
"log_error",
")",
"{",
"log_message",
"(",
"'error'",
",",
"'404 Page Not Found --> '",
".",
"$",
"page",
")",
";",
"}",
"echo",
"$",
"this",
"->",
"show_error",
"(",
"$",
"heading",
",",
"$",
"message",
",",
"'error_404'",
",",
"404",
")",
";",
"exit",
";",
"}"
] |
404 Page Not Found Handler
@access private
@param string the page
@param bool log error yes/no
@return string
|
[
"404",
"Page",
"Not",
"Found",
"Handler"
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Exceptions.php#L104-L117
|
235,121
|
despark/ignicms
|
public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Exceptions.php
|
CI_Exceptions.show_php_error
|
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/error_php.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
|
php
|
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/error_php.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
|
[
"function",
"show_php_error",
"(",
"$",
"severity",
",",
"$",
"message",
",",
"$",
"filepath",
",",
"$",
"line",
")",
"{",
"$",
"severity",
"=",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"levels",
"[",
"$",
"severity",
"]",
")",
")",
"?",
"$",
"severity",
":",
"$",
"this",
"->",
"levels",
"[",
"$",
"severity",
"]",
";",
"$",
"filepath",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"filepath",
")",
";",
"// For safety reasons we do not show the full file path",
"if",
"(",
"FALSE",
"!==",
"strpos",
"(",
"$",
"filepath",
",",
"'/'",
")",
")",
"{",
"$",
"x",
"=",
"explode",
"(",
"'/'",
",",
"$",
"filepath",
")",
";",
"$",
"filepath",
"=",
"$",
"x",
"[",
"count",
"(",
"$",
"x",
")",
"-",
"2",
"]",
".",
"'/'",
".",
"end",
"(",
"$",
"x",
")",
";",
"}",
"if",
"(",
"ob_get_level",
"(",
")",
">",
"$",
"this",
"->",
"ob_level",
"+",
"1",
")",
"{",
"ob_end_flush",
"(",
")",
";",
"}",
"ob_start",
"(",
")",
";",
"include",
"(",
"APPPATH",
".",
"'errors/error_php.php'",
")",
";",
"$",
"buffer",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"echo",
"$",
"buffer",
";",
"}"
] |
Native PHP error handler
@access private
@param string the error severity
@param string the error string
@param string the error filepath
@param string the error line number
@return string
|
[
"Native",
"PHP",
"error",
"handler"
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Exceptions.php#L164-L186
|
235,122
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.getNodeAliasMap
|
protected function getNodeAliasMap(array $nodeIdList) : array
{
return $this
->database
->select('ucms_seo_node', 'n')
->fields('n', ['nid', 'alias_segment'])
->condition('n.nid', $nodeIdList)
->execute()
->fetchAllKeyed()
;
}
|
php
|
protected function getNodeAliasMap(array $nodeIdList) : array
{
return $this
->database
->select('ucms_seo_node', 'n')
->fields('n', ['nid', 'alias_segment'])
->condition('n.nid', $nodeIdList)
->execute()
->fetchAllKeyed()
;
}
|
[
"protected",
"function",
"getNodeAliasMap",
"(",
"array",
"$",
"nodeIdList",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"database",
"->",
"select",
"(",
"'ucms_seo_node'",
",",
"'n'",
")",
"->",
"fields",
"(",
"'n'",
",",
"[",
"'nid'",
",",
"'alias_segment'",
"]",
")",
"->",
"condition",
"(",
"'n.nid'",
",",
"$",
"nodeIdList",
")",
"->",
"execute",
"(",
")",
"->",
"fetchAllKeyed",
"(",
")",
";",
"}"
] |
Get aliases for the given nodes
@return string[]
Keys are node identifiers, values are alias segment for each node,
order is no guaranted, non existing nodes or node without a segment
will be excluded from the return array
|
[
"Get",
"aliases",
"for",
"the",
"given",
"nodes"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L125-L135
|
235,123
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.userCanEditSiteSeo
|
public function userCanEditSiteSeo(AccountInterface $account, Site $site) : bool
{
return
$this->isGranted(Permission::VIEW, $site, $account) && (
$account->hasPermission(SeoService::PERM_SEO_GLOBAL) ||
$account->hasPermission(SeoService::PERM_SEO_CONTENT_ALL) ||
$this->siteManager->getAccess()->userIsWebmaster($account, $site)
)
;
}
|
php
|
public function userCanEditSiteSeo(AccountInterface $account, Site $site) : bool
{
return
$this->isGranted(Permission::VIEW, $site, $account) && (
$account->hasPermission(SeoService::PERM_SEO_GLOBAL) ||
$account->hasPermission(SeoService::PERM_SEO_CONTENT_ALL) ||
$this->siteManager->getAccess()->userIsWebmaster($account, $site)
)
;
}
|
[
"public",
"function",
"userCanEditSiteSeo",
"(",
"AccountInterface",
"$",
"account",
",",
"Site",
"$",
"site",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"isGranted",
"(",
"Permission",
"::",
"VIEW",
",",
"$",
"site",
",",
"$",
"account",
")",
"&&",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"SeoService",
"::",
"PERM_SEO_GLOBAL",
")",
"||",
"$",
"account",
"->",
"hasPermission",
"(",
"SeoService",
"::",
"PERM_SEO_CONTENT_ALL",
")",
"||",
"$",
"this",
"->",
"siteManager",
"->",
"getAccess",
"(",
")",
"->",
"userIsWebmaster",
"(",
"$",
"account",
",",
"$",
"site",
")",
")",
";",
"}"
] |
Can user edit SEO parameters for site
|
[
"Can",
"user",
"edit",
"SEO",
"parameters",
"for",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L140-L149
|
235,124
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.userCanEditNodeSeo
|
public function userCanEditNodeSeo(AccountInterface $account, NodeInterface $node) : bool
{
return
!$this->isNodeBlacklisted($node) && (
($account->hasPermission(SeoService::PERM_SEO_CONTENT_OWN) && $node->access('update', $account)) ||
($account->hasPermission(SeoService::PERM_SEO_CONTENT_ALL) && $node->access('view', $account))
)
;
}
|
php
|
public function userCanEditNodeSeo(AccountInterface $account, NodeInterface $node) : bool
{
return
!$this->isNodeBlacklisted($node) && (
($account->hasPermission(SeoService::PERM_SEO_CONTENT_OWN) && $node->access('update', $account)) ||
($account->hasPermission(SeoService::PERM_SEO_CONTENT_ALL) && $node->access('view', $account))
)
;
}
|
[
"public",
"function",
"userCanEditNodeSeo",
"(",
"AccountInterface",
"$",
"account",
",",
"NodeInterface",
"$",
"node",
")",
":",
"bool",
"{",
"return",
"!",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
"&&",
"(",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"SeoService",
"::",
"PERM_SEO_CONTENT_OWN",
")",
"&&",
"$",
"node",
"->",
"access",
"(",
"'update'",
",",
"$",
"account",
")",
")",
"||",
"(",
"$",
"account",
"->",
"hasPermission",
"(",
"SeoService",
"::",
"PERM_SEO_CONTENT_ALL",
")",
"&&",
"$",
"node",
"->",
"access",
"(",
"'view'",
",",
"$",
"account",
")",
")",
")",
";",
"}"
] |
Can user edit SEO parameters for node
|
[
"Can",
"user",
"edit",
"SEO",
"parameters",
"for",
"node"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L154-L162
|
235,125
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.isNodeTypeBlacklisted
|
public function isNodeTypeBlacklisted(string $type) : bool
{
return $this->nodeTypeBlacklist && isset($this->nodeTypeBlacklist[$type]);
}
|
php
|
public function isNodeTypeBlacklisted(string $type) : bool
{
return $this->nodeTypeBlacklist && isset($this->nodeTypeBlacklist[$type]);
}
|
[
"public",
"function",
"isNodeTypeBlacklisted",
"(",
"string",
"$",
"type",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"nodeTypeBlacklist",
"&&",
"isset",
"(",
"$",
"this",
"->",
"nodeTypeBlacklist",
"[",
"$",
"type",
"]",
")",
";",
"}"
] |
Is node type blacklisted for SEO handling
|
[
"Is",
"node",
"type",
"blacklisted",
"for",
"SEO",
"handling"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L167-L170
|
235,126
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.isNodeBlacklisted
|
public function isNodeBlacklisted(NodeInterface $node) : bool
{
return $this->nodeTypeBlacklist && isset($this->nodeTypeBlacklist[$node->bundle()]);
}
|
php
|
public function isNodeBlacklisted(NodeInterface $node) : bool
{
return $this->nodeTypeBlacklist && isset($this->nodeTypeBlacklist[$node->bundle()]);
}
|
[
"public",
"function",
"isNodeBlacklisted",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"nodeTypeBlacklist",
"&&",
"isset",
"(",
"$",
"this",
"->",
"nodeTypeBlacklist",
"[",
"$",
"node",
"->",
"bundle",
"(",
")",
"]",
")",
";",
"}"
] |
Is node blacklisted for SEO handling
|
[
"Is",
"node",
"blacklisted",
"for",
"SEO",
"handling"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L175-L178
|
235,127
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.setNodeMeta
|
public function setNodeMeta(NodeInterface $node, array $values = []) : void
{
if ($this->isNodeBlacklisted($node)) {
return;
}
$sqlValues = [];
foreach ($values as $key => $value) {
if (empty($value)) {
$value = null;
}
switch ($key) {
case 'title':
case 'description':
$sqlValues['meta_' . $key] = $value;
break;
default:
continue;
}
}
if (empty($values)) {
return;
}
$this
->database
->update('ucms_seo_node')
->fields($sqlValues)
->condition('nid', $node->id())
->execute()
;
// @todo clear page cache
}
|
php
|
public function setNodeMeta(NodeInterface $node, array $values = []) : void
{
if ($this->isNodeBlacklisted($node)) {
return;
}
$sqlValues = [];
foreach ($values as $key => $value) {
if (empty($value)) {
$value = null;
}
switch ($key) {
case 'title':
case 'description':
$sqlValues['meta_' . $key] = $value;
break;
default:
continue;
}
}
if (empty($values)) {
return;
}
$this
->database
->update('ucms_seo_node')
->fields($sqlValues)
->condition('nid', $node->id())
->execute()
;
// @todo clear page cache
}
|
[
"public",
"function",
"setNodeMeta",
"(",
"NodeInterface",
"$",
"node",
",",
"array",
"$",
"values",
"=",
"[",
"]",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
")",
"{",
"return",
";",
"}",
"$",
"sqlValues",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'title'",
":",
"case",
"'description'",
":",
"$",
"sqlValues",
"[",
"'meta_'",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"break",
";",
"default",
":",
"continue",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"database",
"->",
"update",
"(",
"'ucms_seo_node'",
")",
"->",
"fields",
"(",
"$",
"sqlValues",
")",
"->",
"condition",
"(",
"'nid'",
",",
"$",
"node",
"->",
"id",
"(",
")",
")",
"->",
"execute",
"(",
")",
";",
"// @todo clear page cache",
"}"
] |
Set node meta information
@param NodeInterface $node
@param string[] $values
Keys are meta tag title, values are meta tag content
|
[
"Set",
"node",
"meta",
"information"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L187-L226
|
235,128
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.getNodeMeta
|
public function getNodeMeta(NodeInterface $node) : array
{
if ($this->isNodeBlacklisted($node)) {
return [];
}
return (array)$this->database->query("SELECT meta_title AS title, meta_description AS description FROM {ucms_seo_node} WHERE nid = ?", [$node->id()])->fetchAssoc();
}
|
php
|
public function getNodeMeta(NodeInterface $node) : array
{
if ($this->isNodeBlacklisted($node)) {
return [];
}
return (array)$this->database->query("SELECT meta_title AS title, meta_description AS description FROM {ucms_seo_node} WHERE nid = ?", [$node->id()])->fetchAssoc();
}
|
[
"public",
"function",
"getNodeMeta",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"(",
"array",
")",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"\"SELECT meta_title AS title, meta_description AS description FROM {ucms_seo_node} WHERE nid = ?\"",
",",
"[",
"$",
"node",
"->",
"id",
"(",
")",
"]",
")",
"->",
"fetchAssoc",
"(",
")",
";",
"}"
] |
Get node meta information
@param NodeInterface $node
@return string[] $values
Keys are meta tag title, values are meta tag content
|
[
"Get",
"node",
"meta",
"information"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L236-L243
|
235,129
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.getNodeLocalCanonical
|
public function getNodeLocalCanonical(NodeInterface $node) : ?string
{
if ($this->isNodeBlacklisted($node)) {
return 'node/' . $node->id();
}
if ($this->siteManager->hasContext()) {
return $this->aliasManager->getPathAlias($node->id(), $this->siteManager->getContext()->getId());
}
}
|
php
|
public function getNodeLocalCanonical(NodeInterface $node) : ?string
{
if ($this->isNodeBlacklisted($node)) {
return 'node/' . $node->id();
}
if ($this->siteManager->hasContext()) {
return $this->aliasManager->getPathAlias($node->id(), $this->siteManager->getContext()->getId());
}
}
|
[
"public",
"function",
"getNodeLocalCanonical",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
")",
"{",
"return",
"'node/'",
".",
"$",
"node",
"->",
"id",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"siteManager",
"->",
"hasContext",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"aliasManager",
"->",
"getPathAlias",
"(",
"$",
"node",
"->",
"id",
"(",
")",
",",
"$",
"this",
"->",
"siteManager",
"->",
"getContext",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"}"
] |
Get node canonical alias for the current site
|
[
"Get",
"node",
"canonical",
"alias",
"for",
"the",
"current",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L248-L257
|
235,130
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.getNodeCanonical
|
public function getNodeCanonical(NodeInterface $node) : ?string
{
if ($this->isNodeBlacklisted($node)) {
return null;
}
$site = null;
$alias = null;
if ($this->shareCanonicalAcrossSites) {
$storage = $this->siteManager->getStorage();
// Very fist site is the right one for canonical URL
if ($node->site_id) {
$site = $storage->findOne($node->site_id);
if ($site->getState() !== SiteState::ON) {
$site = null;
}
}
}
// If no site, fetch on the current site
if (!$site) {
if ($this->siteManager->hasContext()) {
$site = $this->siteManager->getContext();
}
}
if ($site) {
$alias = $this->aliasManager->getPathAlias($node->id(), $site->getId());
}
if (!$alias) {
// No alias at all means that the canonical is the node URL in the
// current site, I am sorry I can't provide more any magic here...
return url('node/' . $node->id(), ['absolute' => true]);
}
return $this->siteManager->getUrlGenerator()->generateUrl($site, $alias, ['absolute' => true], true);
}
|
php
|
public function getNodeCanonical(NodeInterface $node) : ?string
{
if ($this->isNodeBlacklisted($node)) {
return null;
}
$site = null;
$alias = null;
if ($this->shareCanonicalAcrossSites) {
$storage = $this->siteManager->getStorage();
// Very fist site is the right one for canonical URL
if ($node->site_id) {
$site = $storage->findOne($node->site_id);
if ($site->getState() !== SiteState::ON) {
$site = null;
}
}
}
// If no site, fetch on the current site
if (!$site) {
if ($this->siteManager->hasContext()) {
$site = $this->siteManager->getContext();
}
}
if ($site) {
$alias = $this->aliasManager->getPathAlias($node->id(), $site->getId());
}
if (!$alias) {
// No alias at all means that the canonical is the node URL in the
// current site, I am sorry I can't provide more any magic here...
return url('node/' . $node->id(), ['absolute' => true]);
}
return $this->siteManager->getUrlGenerator()->generateUrl($site, $alias, ['absolute' => true], true);
}
|
[
"public",
"function",
"getNodeCanonical",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"site",
"=",
"null",
";",
"$",
"alias",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"shareCanonicalAcrossSites",
")",
"{",
"$",
"storage",
"=",
"$",
"this",
"->",
"siteManager",
"->",
"getStorage",
"(",
")",
";",
"// Very fist site is the right one for canonical URL",
"if",
"(",
"$",
"node",
"->",
"site_id",
")",
"{",
"$",
"site",
"=",
"$",
"storage",
"->",
"findOne",
"(",
"$",
"node",
"->",
"site_id",
")",
";",
"if",
"(",
"$",
"site",
"->",
"getState",
"(",
")",
"!==",
"SiteState",
"::",
"ON",
")",
"{",
"$",
"site",
"=",
"null",
";",
"}",
"}",
"}",
"// If no site, fetch on the current site",
"if",
"(",
"!",
"$",
"site",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"siteManager",
"->",
"hasContext",
"(",
")",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"siteManager",
"->",
"getContext",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"site",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"aliasManager",
"->",
"getPathAlias",
"(",
"$",
"node",
"->",
"id",
"(",
")",
",",
"$",
"site",
"->",
"getId",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"alias",
")",
"{",
"// No alias at all means that the canonical is the node URL in the",
"// current site, I am sorry I can't provide more any magic here...",
"return",
"url",
"(",
"'node/'",
".",
"$",
"node",
"->",
"id",
"(",
")",
",",
"[",
"'absolute'",
"=>",
"true",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"siteManager",
"->",
"getUrlGenerator",
"(",
")",
"->",
"generateUrl",
"(",
"$",
"site",
",",
"$",
"alias",
",",
"[",
"'absolute'",
"=>",
"true",
"]",
",",
"true",
")",
";",
"}"
] |
Get node canonical URL
|
[
"Get",
"node",
"canonical",
"URL"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L262-L301
|
235,131
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.getNodeSegment
|
public function getNodeSegment(NodeInterface $node) : ?string
{
if ($node->isNew()) {
return null;
}
if ($this->isNodeBlacklisted($node)) {
return null;
}
$map = $this->getNodeAliasMap([$node->id()]);
if ($map) {
return reset($map);
}
}
|
php
|
public function getNodeSegment(NodeInterface $node) : ?string
{
if ($node->isNew()) {
return null;
}
if ($this->isNodeBlacklisted($node)) {
return null;
}
$map = $this->getNodeAliasMap([$node->id()]);
if ($map) {
return reset($map);
}
}
|
[
"public",
"function",
"getNodeSegment",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"?",
"string",
"{",
"if",
"(",
"$",
"node",
"->",
"isNew",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"map",
"=",
"$",
"this",
"->",
"getNodeAliasMap",
"(",
"[",
"$",
"node",
"->",
"id",
"(",
")",
"]",
")",
";",
"if",
"(",
"$",
"map",
")",
"{",
"return",
"reset",
"(",
"$",
"map",
")",
";",
"}",
"}"
] |
Get node alias segment
@param NodeInterface $node
@return string
|
[
"Get",
"node",
"alias",
"segment"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L310-L325
|
235,132
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.normalizeSegment
|
public function normalizeSegment(string $value, int $maxLength = UCMS_SEO_SEGMENT_TRIM_LENGTH) : string
{
// Transliterate first
if (class_exists('URLify')) {
$value = \URLify::filter($value, $maxLength);
}
// Only lowercase characters
$value = strtolower($value);
// All special characters to be replaced by '-' and doubles stripped
// to only one occurence
$value = preg_replace('/[^a-z0-9\-]+/', '-', $value);
$value = preg_replace('/-+/', '-', $value);
// Trim leading and trailing '-' characters
$value = trim($value, '-');
// @todo stopwords
return $value;
}
|
php
|
public function normalizeSegment(string $value, int $maxLength = UCMS_SEO_SEGMENT_TRIM_LENGTH) : string
{
// Transliterate first
if (class_exists('URLify')) {
$value = \URLify::filter($value, $maxLength);
}
// Only lowercase characters
$value = strtolower($value);
// All special characters to be replaced by '-' and doubles stripped
// to only one occurence
$value = preg_replace('/[^a-z0-9\-]+/', '-', $value);
$value = preg_replace('/-+/', '-', $value);
// Trim leading and trailing '-' characters
$value = trim($value, '-');
// @todo stopwords
return $value;
}
|
[
"public",
"function",
"normalizeSegment",
"(",
"string",
"$",
"value",
",",
"int",
"$",
"maxLength",
"=",
"UCMS_SEO_SEGMENT_TRIM_LENGTH",
")",
":",
"string",
"{",
"// Transliterate first",
"if",
"(",
"class_exists",
"(",
"'URLify'",
")",
")",
"{",
"$",
"value",
"=",
"\\",
"URLify",
"::",
"filter",
"(",
"$",
"value",
",",
"$",
"maxLength",
")",
";",
"}",
"// Only lowercase characters",
"$",
"value",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"// All special characters to be replaced by '-' and doubles stripped",
"// to only one occurence",
"$",
"value",
"=",
"preg_replace",
"(",
"'/[^a-z0-9\\-]+/'",
",",
"'-'",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"'/-+/'",
",",
"'-'",
",",
"$",
"value",
")",
";",
"// Trim leading and trailing '-' characters",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
",",
"'-'",
")",
";",
"// @todo stopwords",
"return",
"$",
"value",
";",
"}"
] |
Normalize given URL segment
@param string $value
@param int $maxLength
@return string
|
[
"Normalize",
"given",
"URL",
"segment"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L335-L356
|
235,133
|
makinacorpus/drupal-ucms
|
ucms_seo/src/SeoService.php
|
SeoService.setNodeSegment
|
public function setNodeSegment(NodeInterface $node, string $segment, ?string $previous = null) : void
{
if ($this->isNodeBlacklisted($node)) {
return;
}
if (!$previous) {
$previous = $this->getNodeSegment($node);
}
if (empty($segment)) {
$segment = null;
}
if ($previous === $segment) {
return; // Nothing to do
}
$this
->database
->merge('ucms_seo_node')
->key(['nid' => $node->id()])
->fields(['alias_segment' => $segment])
->execute()
;
if (empty($segment)) {
$this->onAliasChange([$node->id()]);
} else {
$this->onAliasChange([$node->id()]);
}
}
|
php
|
public function setNodeSegment(NodeInterface $node, string $segment, ?string $previous = null) : void
{
if ($this->isNodeBlacklisted($node)) {
return;
}
if (!$previous) {
$previous = $this->getNodeSegment($node);
}
if (empty($segment)) {
$segment = null;
}
if ($previous === $segment) {
return; // Nothing to do
}
$this
->database
->merge('ucms_seo_node')
->key(['nid' => $node->id()])
->fields(['alias_segment' => $segment])
->execute()
;
if (empty($segment)) {
$this->onAliasChange([$node->id()]);
} else {
$this->onAliasChange([$node->id()]);
}
}
|
[
"public",
"function",
"setNodeSegment",
"(",
"NodeInterface",
"$",
"node",
",",
"string",
"$",
"segment",
",",
"?",
"string",
"$",
"previous",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isNodeBlacklisted",
"(",
"$",
"node",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"previous",
")",
"{",
"$",
"previous",
"=",
"$",
"this",
"->",
"getNodeSegment",
"(",
"$",
"node",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"segment",
")",
")",
"{",
"$",
"segment",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"previous",
"===",
"$",
"segment",
")",
"{",
"return",
";",
"// Nothing to do",
"}",
"$",
"this",
"->",
"database",
"->",
"merge",
"(",
"'ucms_seo_node'",
")",
"->",
"key",
"(",
"[",
"'nid'",
"=>",
"$",
"node",
"->",
"id",
"(",
")",
"]",
")",
"->",
"fields",
"(",
"[",
"'alias_segment'",
"=>",
"$",
"segment",
"]",
")",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"segment",
")",
")",
"{",
"$",
"this",
"->",
"onAliasChange",
"(",
"[",
"$",
"node",
"->",
"id",
"(",
")",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"onAliasChange",
"(",
"[",
"$",
"node",
"->",
"id",
"(",
")",
"]",
")",
";",
"}",
"}"
] |
Change the node segment
@param NodeInterface $node
@param string $segment
New node segment
@param string $previous
If by any chance you are sure you know the previous one, set it here
to save a SQL query
|
[
"Change",
"the",
"node",
"segment"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/SeoService.php#L368-L398
|
235,134
|
makinacorpus/drupal-ucms
|
ucms_site/src/SiteUrlGenerator.php
|
SiteUrlGenerator.forceSiteUrl
|
public function forceSiteUrl(&$options, $site)
{
if (!$site instanceof Site) {
$site = $this->storage->findOne($site);
}
if ($GLOBALS['is_https']) {
$options['https'] = !$site->isHttpsAllowed();
} else if (variable_get('https', false)) {
$options['https'] = !$site->isHttpAllowed();
} else {
// Sorry, HTTPS is disabled at the Drupal level, note that it is not
// mandatory to this because url() will do the check by itself, but
// because there is in here one code path in which we are going to
// manually set the base URL, we need to compute that by ourselves.
$options['https'] = false;
}
// Warning, this is a INTERNAL url() function behavior, so we have
// to reproduce a few other behaviours to go along with it, such as
// manual http vs https handling. Please see the variable_get('https')
// documentation above.
$options['base_url'] = ($options['https'] ? 'https://' : 'http://') . $site->getHostname();
$options['absolute'] = true;
}
|
php
|
public function forceSiteUrl(&$options, $site)
{
if (!$site instanceof Site) {
$site = $this->storage->findOne($site);
}
if ($GLOBALS['is_https']) {
$options['https'] = !$site->isHttpsAllowed();
} else if (variable_get('https', false)) {
$options['https'] = !$site->isHttpAllowed();
} else {
// Sorry, HTTPS is disabled at the Drupal level, note that it is not
// mandatory to this because url() will do the check by itself, but
// because there is in here one code path in which we are going to
// manually set the base URL, we need to compute that by ourselves.
$options['https'] = false;
}
// Warning, this is a INTERNAL url() function behavior, so we have
// to reproduce a few other behaviours to go along with it, such as
// manual http vs https handling. Please see the variable_get('https')
// documentation above.
$options['base_url'] = ($options['https'] ? 'https://' : 'http://') . $site->getHostname();
$options['absolute'] = true;
}
|
[
"public",
"function",
"forceSiteUrl",
"(",
"&",
"$",
"options",
",",
"$",
"site",
")",
"{",
"if",
"(",
"!",
"$",
"site",
"instanceof",
"Site",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"storage",
"->",
"findOne",
"(",
"$",
"site",
")",
";",
"}",
"if",
"(",
"$",
"GLOBALS",
"[",
"'is_https'",
"]",
")",
"{",
"$",
"options",
"[",
"'https'",
"]",
"=",
"!",
"$",
"site",
"->",
"isHttpsAllowed",
"(",
")",
";",
"}",
"else",
"if",
"(",
"variable_get",
"(",
"'https'",
",",
"false",
")",
")",
"{",
"$",
"options",
"[",
"'https'",
"]",
"=",
"!",
"$",
"site",
"->",
"isHttpAllowed",
"(",
")",
";",
"}",
"else",
"{",
"// Sorry, HTTPS is disabled at the Drupal level, note that it is not",
"// mandatory to this because url() will do the check by itself, but",
"// because there is in here one code path in which we are going to",
"// manually set the base URL, we need to compute that by ourselves.",
"$",
"options",
"[",
"'https'",
"]",
"=",
"false",
";",
"}",
"// Warning, this is a INTERNAL url() function behavior, so we have",
"// to reproduce a few other behaviours to go along with it, such as",
"// manual http vs https handling. Please see the variable_get('https')",
"// documentation above.",
"$",
"options",
"[",
"'base_url'",
"]",
"=",
"(",
"$",
"options",
"[",
"'https'",
"]",
"?",
"'https://'",
":",
"'http://'",
")",
".",
"$",
"site",
"->",
"getHostname",
"(",
")",
";",
"$",
"options",
"[",
"'absolute'",
"]",
"=",
"true",
";",
"}"
] |
Alter parameters for the url outbound alter hook
@param mixed[] $options
Link options, see url()
@param int|Site $site
Site identifier, if site is null
|
[
"Alter",
"parameters",
"for",
"the",
"url",
"outbound",
"alter",
"hook"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/SiteUrlGenerator.php#L38-L62
|
235,135
|
despark/ignicms
|
src/Http/Controllers/Admin/AdminController.php
|
AdminController.setSidebar
|
public function setSidebar()
{
$this->sidebarItems = config('admin.sidebar');
$responses = \Event::fire(new AfterSidebarSet($this->sidebarItems));
if (is_array($responses)) {
foreach ($responses as $response) {
if (is_array($response)) {
$this->sidebarItems = array_merge($this->sidebarItems, $response);
}
}
}
}
|
php
|
public function setSidebar()
{
$this->sidebarItems = config('admin.sidebar');
$responses = \Event::fire(new AfterSidebarSet($this->sidebarItems));
if (is_array($responses)) {
foreach ($responses as $response) {
if (is_array($response)) {
$this->sidebarItems = array_merge($this->sidebarItems, $response);
}
}
}
}
|
[
"public",
"function",
"setSidebar",
"(",
")",
"{",
"$",
"this",
"->",
"sidebarItems",
"=",
"config",
"(",
"'admin.sidebar'",
")",
";",
"$",
"responses",
"=",
"\\",
"Event",
"::",
"fire",
"(",
"new",
"AfterSidebarSet",
"(",
"$",
"this",
"->",
"sidebarItems",
")",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"responses",
")",
")",
"{",
"foreach",
"(",
"$",
"responses",
"as",
"$",
"response",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"response",
")",
")",
"{",
"$",
"this",
"->",
"sidebarItems",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"sidebarItems",
",",
"$",
"response",
")",
";",
"}",
"}",
"}",
"}"
] |
set sidebarMenu.
|
[
"set",
"sidebarMenu",
"."
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Http/Controllers/Admin/AdminController.php#L180-L191
|
235,136
|
despark/ignicms
|
src/Admin/Traits/AdminModelTrait.php
|
AdminModelTrait.renderTableRow
|
public function renderTableRow($record, $col)
{
switch (array_get($col, 'type', 'text')) {
case 'yes_no':
return $record->yes_no($record->{$col['db_field']});
break;
case 'format_default_date':
return $record->formatDefaultData($record->{$col['db_field']});
break;
case 'sort':
return '<div class="fa fa-sort sortable-handle"></div>';
break;
case 'relation':
return $record->{$col['relation']}->{$col['db_field']};
break;
case 'translation':
$locale = config('app.locale', 'en');
$i18n = I18n::select('id')->where('locale', $locale)->first();
if ($i18n) {
$i18nId = $i18n->id;
return $record->translate(1)->{$col['db_field']};
}
return 'No translation';
break;
default:
return $record->{$col['db_field']};
break;
}
}
|
php
|
public function renderTableRow($record, $col)
{
switch (array_get($col, 'type', 'text')) {
case 'yes_no':
return $record->yes_no($record->{$col['db_field']});
break;
case 'format_default_date':
return $record->formatDefaultData($record->{$col['db_field']});
break;
case 'sort':
return '<div class="fa fa-sort sortable-handle"></div>';
break;
case 'relation':
return $record->{$col['relation']}->{$col['db_field']};
break;
case 'translation':
$locale = config('app.locale', 'en');
$i18n = I18n::select('id')->where('locale', $locale)->first();
if ($i18n) {
$i18nId = $i18n->id;
return $record->translate(1)->{$col['db_field']};
}
return 'No translation';
break;
default:
return $record->{$col['db_field']};
break;
}
}
|
[
"public",
"function",
"renderTableRow",
"(",
"$",
"record",
",",
"$",
"col",
")",
"{",
"switch",
"(",
"array_get",
"(",
"$",
"col",
",",
"'type'",
",",
"'text'",
")",
")",
"{",
"case",
"'yes_no'",
":",
"return",
"$",
"record",
"->",
"yes_no",
"(",
"$",
"record",
"->",
"{",
"$",
"col",
"[",
"'db_field'",
"]",
"}",
")",
";",
"break",
";",
"case",
"'format_default_date'",
":",
"return",
"$",
"record",
"->",
"formatDefaultData",
"(",
"$",
"record",
"->",
"{",
"$",
"col",
"[",
"'db_field'",
"]",
"}",
")",
";",
"break",
";",
"case",
"'sort'",
":",
"return",
"'<div class=\"fa fa-sort sortable-handle\"></div>'",
";",
"break",
";",
"case",
"'relation'",
":",
"return",
"$",
"record",
"->",
"{",
"$",
"col",
"[",
"'relation'",
"]",
"}",
"->",
"{",
"$",
"col",
"[",
"'db_field'",
"]",
"}",
";",
"break",
";",
"case",
"'translation'",
":",
"$",
"locale",
"=",
"config",
"(",
"'app.locale'",
",",
"'en'",
")",
";",
"$",
"i18n",
"=",
"I18n",
"::",
"select",
"(",
"'id'",
")",
"->",
"where",
"(",
"'locale'",
",",
"$",
"locale",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"i18n",
")",
"{",
"$",
"i18nId",
"=",
"$",
"i18n",
"->",
"id",
";",
"return",
"$",
"record",
"->",
"translate",
"(",
"1",
")",
"->",
"{",
"$",
"col",
"[",
"'db_field'",
"]",
"}",
";",
"}",
"return",
"'No translation'",
";",
"break",
";",
"default",
":",
"return",
"$",
"record",
"->",
"{",
"$",
"col",
"[",
"'db_field'",
"]",
"}",
";",
"break",
";",
"}",
"}"
] |
return model fields in proper way.
@param $record
@param $col
@return mixed
|
[
"return",
"model",
"fields",
"in",
"proper",
"way",
"."
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Admin/Traits/AdminModelTrait.php#L108-L138
|
235,137
|
despark/ignicms
|
src/Admin/Traits/AdminModelTrait.php
|
AdminModelTrait.searchText
|
public function searchText()
{
$query = $this->newQuery();
if (Request::get('admin_text_search')) {
foreach ($this->adminFilters['text_search']['db_fields'] as $field) {
$query->orWhere($field, 'LIKE', '%'.Request::get('admin_text_search').'%');
}
}
return $query;
}
|
php
|
public function searchText()
{
$query = $this->newQuery();
if (Request::get('admin_text_search')) {
foreach ($this->adminFilters['text_search']['db_fields'] as $field) {
$query->orWhere($field, 'LIKE', '%'.Request::get('admin_text_search').'%');
}
}
return $query;
}
|
[
"public",
"function",
"searchText",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"newQuery",
"(",
")",
";",
"if",
"(",
"Request",
"::",
"get",
"(",
"'admin_text_search'",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"adminFilters",
"[",
"'text_search'",
"]",
"[",
"'db_fields'",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"query",
"->",
"orWhere",
"(",
"$",
"field",
",",
"'LIKE'",
",",
"'%'",
".",
"Request",
"::",
"get",
"(",
"'admin_text_search'",
")",
".",
"'%'",
")",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] |
create query for list page.
|
[
"create",
"query",
"for",
"list",
"page",
"."
] |
d55775a4656a7e99017d2ef3f8160599d600d2a7
|
https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Admin/Traits/AdminModelTrait.php#L153-L163
|
235,138
|
accompli/accompli
|
src/Task/FilePermissionTask.php
|
FilePermissionTask.onInstallReleaseUpdateFilePermissions
|
public function onInstallReleaseUpdateFilePermissions(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$host = $event->getRelease()->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updating permissions for the configured paths...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$releasePath = $event->getRelease()->getPath();
$result = true;
foreach ($this->paths as $path => $pathSettings) {
$result = $result && $this->updateFilePermissions($connection, $releasePath, $path, $pathSettings);
}
if ($result === true) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updated permissions for the configured paths.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
throw new TaskRuntimeException('Failed updating the permissions for the configured paths.', $this);
}
}
|
php
|
public function onInstallReleaseUpdateFilePermissions(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$host = $event->getRelease()->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updating permissions for the configured paths...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$releasePath = $event->getRelease()->getPath();
$result = true;
foreach ($this->paths as $path => $pathSettings) {
$result = $result && $this->updateFilePermissions($connection, $releasePath, $path, $pathSettings);
}
if ($result === true) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updated permissions for the configured paths.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
throw new TaskRuntimeException('Failed updating the permissions for the configured paths.', $this);
}
}
|
[
"public",
"function",
"onInstallReleaseUpdateFilePermissions",
"(",
"InstallReleaseEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"host",
"=",
"$",
"event",
"->",
"getRelease",
"(",
")",
"->",
"getWorkspace",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"ensureConnection",
"(",
"$",
"host",
")",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"'Updating permissions for the configured paths...'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"array",
"(",
"'event.task.action'",
"=>",
"TaskInterface",
"::",
"ACTION_IN_PROGRESS",
")",
")",
")",
";",
"$",
"releasePath",
"=",
"$",
"event",
"->",
"getRelease",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"paths",
"as",
"$",
"path",
"=>",
"$",
"pathSettings",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"&&",
"$",
"this",
"->",
"updateFilePermissions",
"(",
"$",
"connection",
",",
"$",
"releasePath",
",",
"$",
"path",
",",
"$",
"pathSettings",
")",
";",
"}",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"'Updated permissions for the configured paths.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"array",
"(",
"'event.task.action'",
"=>",
"TaskInterface",
"::",
"ACTION_COMPLETED",
",",
"'output.resetLine'",
"=>",
"true",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"TaskRuntimeException",
"(",
"'Failed updating the permissions for the configured paths.'",
",",
"$",
"this",
")",
";",
"}",
"}"
] |
Sets the correct permissions and group for the configured path.
@param InstallReleaseEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher
@throws TaskRuntimeException
|
[
"Sets",
"the",
"correct",
"permissions",
"and",
"group",
"for",
"the",
"configured",
"path",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/FilePermissionTask.php#L59-L78
|
235,139
|
accompli/accompli
|
src/Task/FilePermissionTask.php
|
FilePermissionTask.updateFilePermissions
|
private function updateFilePermissions(ConnectionAdapterInterface $connection, $releasePath, $path, $pathSettings)
{
$path = $releasePath.'/'.$path;
if (isset($pathSettings['permissions']) === false) {
return false;
}
$permissions = FilePermissionCalculator::fromStringRepresentation(str_pad($pathSettings['permissions'], 10, '-'))->getMode();
$recursive = false;
if (isset($pathSettings['recursive'])) {
$recursive = $pathSettings['recursive'];
}
return $connection->changePermissions($path, $permissions, $recursive);
}
|
php
|
private function updateFilePermissions(ConnectionAdapterInterface $connection, $releasePath, $path, $pathSettings)
{
$path = $releasePath.'/'.$path;
if (isset($pathSettings['permissions']) === false) {
return false;
}
$permissions = FilePermissionCalculator::fromStringRepresentation(str_pad($pathSettings['permissions'], 10, '-'))->getMode();
$recursive = false;
if (isset($pathSettings['recursive'])) {
$recursive = $pathSettings['recursive'];
}
return $connection->changePermissions($path, $permissions, $recursive);
}
|
[
"private",
"function",
"updateFilePermissions",
"(",
"ConnectionAdapterInterface",
"$",
"connection",
",",
"$",
"releasePath",
",",
"$",
"path",
",",
"$",
"pathSettings",
")",
"{",
"$",
"path",
"=",
"$",
"releasePath",
".",
"'/'",
".",
"$",
"path",
";",
"if",
"(",
"isset",
"(",
"$",
"pathSettings",
"[",
"'permissions'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"permissions",
"=",
"FilePermissionCalculator",
"::",
"fromStringRepresentation",
"(",
"str_pad",
"(",
"$",
"pathSettings",
"[",
"'permissions'",
"]",
",",
"10",
",",
"'-'",
")",
")",
"->",
"getMode",
"(",
")",
";",
"$",
"recursive",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"pathSettings",
"[",
"'recursive'",
"]",
")",
")",
"{",
"$",
"recursive",
"=",
"$",
"pathSettings",
"[",
"'recursive'",
"]",
";",
"}",
"return",
"$",
"connection",
"->",
"changePermissions",
"(",
"$",
"path",
",",
"$",
"permissions",
",",
"$",
"recursive",
")",
";",
"}"
] |
Update the file permissions per configured path.
@param ConnectionAdapterInterface $connection
@param string $releasePath
@param string $path
@param string $pathSettings
@return bool
|
[
"Update",
"the",
"file",
"permissions",
"per",
"configured",
"path",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/FilePermissionTask.php#L90-L106
|
235,140
|
makinacorpus/drupal-ucms
|
ucms_widget/src/DependencyInjection/WidgetRegistry.php
|
WidgetRegistry.registerAll
|
public function registerAll($map)
{
foreach ($map as $type => $id) {
if (isset($this->services[$type])) {
if ($this->debug) {
trigger_error(sprintf("Widget type '%s' redefinition, ignoring", $type), E_USER_ERROR);
}
}
$this->services[$type] = $id;
}
}
|
php
|
public function registerAll($map)
{
foreach ($map as $type => $id) {
if (isset($this->services[$type])) {
if ($this->debug) {
trigger_error(sprintf("Widget type '%s' redefinition, ignoring", $type), E_USER_ERROR);
}
}
$this->services[$type] = $id;
}
}
|
[
"public",
"function",
"registerAll",
"(",
"$",
"map",
")",
"{",
"foreach",
"(",
"$",
"map",
"as",
"$",
"type",
"=>",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"services",
"[",
"$",
"type",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"\"Widget type '%s' redefinition, ignoring\"",
",",
"$",
"type",
")",
",",
"E_USER_ERROR",
")",
";",
"}",
"}",
"$",
"this",
"->",
"services",
"[",
"$",
"type",
"]",
"=",
"$",
"id",
";",
"}",
"}"
] |
Register a single instance
@param string[] $map
Keys are widget identifiers, values are service identifiers
|
[
"Register",
"a",
"single",
"instance"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/DependencyInjection/WidgetRegistry.php#L42-L52
|
235,141
|
makinacorpus/drupal-ucms
|
ucms_list/src/AbstractContentList.php
|
AbstractContentList.getViewModeList
|
private function getViewModeList()
{
$ret = [];
$entityInfo = entity_get_info('node');
foreach ($entityInfo['view modes'] as $viewMode => $info) {
$ret[$viewMode] = $info['label'];
}
return $ret;
}
|
php
|
private function getViewModeList()
{
$ret = [];
$entityInfo = entity_get_info('node');
foreach ($entityInfo['view modes'] as $viewMode => $info) {
$ret[$viewMode] = $info['label'];
}
return $ret;
}
|
[
"private",
"function",
"getViewModeList",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"entityInfo",
"=",
"entity_get_info",
"(",
"'node'",
")",
";",
"foreach",
"(",
"$",
"entityInfo",
"[",
"'view modes'",
"]",
"as",
"$",
"viewMode",
"=>",
"$",
"info",
")",
"{",
"$",
"ret",
"[",
"$",
"viewMode",
"]",
"=",
"$",
"info",
"[",
"'label'",
"]",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Get view mode list
@return string[]
|
[
"Get",
"view",
"mode",
"list"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/AbstractContentList.php#L105-L115
|
235,142
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Database/Query.php
|
Query.setStartInsert
|
public function setStartInsert(array $data)
{
$columnsAndMarkers = $this->getColumnsAndGetMarkersForInsert($data);
$this->setStart(
"INSERT INTO ".$this->model->getDbTable()." (".$columnsAndMarkers['columns'].")
VALUES (".$columnsAndMarkers['markers'].")"
);
}
|
php
|
public function setStartInsert(array $data)
{
$columnsAndMarkers = $this->getColumnsAndGetMarkersForInsert($data);
$this->setStart(
"INSERT INTO ".$this->model->getDbTable()." (".$columnsAndMarkers['columns'].")
VALUES (".$columnsAndMarkers['markers'].")"
);
}
|
[
"public",
"function",
"setStartInsert",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"columnsAndMarkers",
"=",
"$",
"this",
"->",
"getColumnsAndGetMarkersForInsert",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setStart",
"(",
"\"INSERT INTO \"",
".",
"$",
"this",
"->",
"model",
"->",
"getDbTable",
"(",
")",
".",
"\" (\"",
".",
"$",
"columnsAndMarkers",
"[",
"'columns'",
"]",
".",
"\")\r\n VALUES (\"",
".",
"$",
"columnsAndMarkers",
"[",
"'markers'",
"]",
".",
"\")\"",
")",
";",
"}"
] |
Initialiser une request SQL INSERT INTO
@param array $data - Colonnes où faire le INSERT, et valeurs à insérer
|
[
"Initialiser",
"une",
"request",
"SQL",
"INSERT",
"INTO"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L269-L277
|
235,143
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Database/Query.php
|
Query.setStartUpdate
|
public function setStartUpdate(array $data)
{
$this->setStart("UPDATE ".$this->model->getDbTable()." SET ".$this->getColumnsForUpdate($data));
}
|
php
|
public function setStartUpdate(array $data)
{
$this->setStart("UPDATE ".$this->model->getDbTable()." SET ".$this->getColumnsForUpdate($data));
}
|
[
"public",
"function",
"setStartUpdate",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"setStart",
"(",
"\"UPDATE \"",
".",
"$",
"this",
"->",
"model",
"->",
"getDbTable",
"(",
")",
".",
"\" SET \"",
".",
"$",
"this",
"->",
"getColumnsForUpdate",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
Initialiser une request SQL UPDATE
@param array $data - Colonnes où faire le UPDATE, et valeurs à insérer
|
[
"Initialiser",
"une",
"request",
"SQL",
"UPDATE"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L284-L287
|
235,144
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Database/Query.php
|
Query.bindLimit
|
public function bindLimit()
{
if ($this->limit !== null) {
$this->sqlQuery->bindValue($this->positioningMarker, $this->limit, PDO::PARAM_INT);
$this->positioningMarker++;
$this->sqlQuery->bindValue($this->positioningMarker, $this->offset, PDO::PARAM_INT);
}
return $this;
}
|
php
|
public function bindLimit()
{
if ($this->limit !== null) {
$this->sqlQuery->bindValue($this->positioningMarker, $this->limit, PDO::PARAM_INT);
$this->positioningMarker++;
$this->sqlQuery->bindValue($this->positioningMarker, $this->offset, PDO::PARAM_INT);
}
return $this;
}
|
[
"public",
"function",
"bindLimit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"limit",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"sqlQuery",
"->",
"bindValue",
"(",
"$",
"this",
"->",
"positioningMarker",
",",
"$",
"this",
"->",
"limit",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"$",
"this",
"->",
"positioningMarker",
"++",
";",
"$",
"this",
"->",
"sqlQuery",
"->",
"bindValue",
"(",
"$",
"this",
"->",
"positioningMarker",
",",
"$",
"this",
"->",
"offset",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Les bindValue du Limit
@return $this
|
[
"Les",
"bindValue",
"du",
"Limit"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L669-L678
|
235,145
|
stephweb/daw-php-orm
|
src/DawPhpOrm/Database/Query.php
|
Query.bindDataType
|
private function bindDataType($value)
{
switch (true) {
case is_string($value):
return PDO::PARAM_STR;
case is_int($value):
return PDO::PARAM_INT;
case is_bool($value):
return PDO::PARAM_BOOL;
case is_null($value):
return PDO::PARAM_NULL;
default:
return false;
}
}
|
php
|
private function bindDataType($value)
{
switch (true) {
case is_string($value):
return PDO::PARAM_STR;
case is_int($value):
return PDO::PARAM_INT;
case is_bool($value):
return PDO::PARAM_BOOL;
case is_null($value):
return PDO::PARAM_NULL;
default:
return false;
}
}
|
[
"private",
"function",
"bindDataType",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_string",
"(",
"$",
"value",
")",
":",
"return",
"PDO",
"::",
"PARAM_STR",
";",
"case",
"is_int",
"(",
"$",
"value",
")",
":",
"return",
"PDO",
"::",
"PARAM_INT",
";",
"case",
"is_bool",
"(",
"$",
"value",
")",
":",
"return",
"PDO",
"::",
"PARAM_BOOL",
";",
"case",
"is_null",
"(",
"$",
"value",
")",
":",
"return",
"PDO",
"::",
"PARAM_NULL",
";",
"default",
":",
"return",
"false",
";",
"}",
"}"
] |
Utile pour les bindValue des requetes SQL
@param string|int|bool|null $value
@return bool|int
|
[
"Utile",
"pour",
"les",
"bindValue",
"des",
"requetes",
"SQL"
] |
0c37e3baa1420cf9e3feff122016329de3764bcc
|
https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L713-L727
|
235,146
|
accompli/accompli
|
src/Task/DeployReleaseTask.php
|
DeployReleaseTask.onDeployOrRollbackReleaseLinkRelease
|
public function onDeployOrRollbackReleaseLinkRelease(DeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$release = $event->getRelease();
$host = $release->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$releasePath = $host->getPath().'/'.$host->getStage();
$context = array('linkTarget' => $releasePath, 'releaseVersion' => $release->getVersion(), 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
if ($connection->isLink($releasePath) === false || $connection->readLink($releasePath) !== $release->getPath()) {
if ($connection->isLink($releasePath)) {
$connection->delete($releasePath, false);
}
if ($connection->link($release->getPath(), $releasePath)) {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linked "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
} else {
$context['event.task.action'] = TaskInterface::ACTION_FAILED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}" failed.', $eventName, $this, $context));
throw new TaskRuntimeException(sprintf('Linking "%s" to release "%s" failed.', $context['linkTarget'], $context['releaseVersion']), $this);
}
} else {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Link "{linkTarget}" to release "{releaseVersion}" already exists.', $eventName, $this, $context));
}
}
|
php
|
public function onDeployOrRollbackReleaseLinkRelease(DeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$release = $event->getRelease();
$host = $release->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$releasePath = $host->getPath().'/'.$host->getStage();
$context = array('linkTarget' => $releasePath, 'releaseVersion' => $release->getVersion(), 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
if ($connection->isLink($releasePath) === false || $connection->readLink($releasePath) !== $release->getPath()) {
if ($connection->isLink($releasePath)) {
$connection->delete($releasePath, false);
}
if ($connection->link($release->getPath(), $releasePath)) {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linked "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
} else {
$context['event.task.action'] = TaskInterface::ACTION_FAILED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}" failed.', $eventName, $this, $context));
throw new TaskRuntimeException(sprintf('Linking "%s" to release "%s" failed.', $context['linkTarget'], $context['releaseVersion']), $this);
}
} else {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Link "{linkTarget}" to release "{releaseVersion}" already exists.', $eventName, $this, $context));
}
}
|
[
"public",
"function",
"onDeployOrRollbackReleaseLinkRelease",
"(",
"DeployReleaseEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"release",
"=",
"$",
"event",
"->",
"getRelease",
"(",
")",
";",
"$",
"host",
"=",
"$",
"release",
"->",
"getWorkspace",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"ensureConnection",
"(",
"$",
"host",
")",
";",
"$",
"releasePath",
"=",
"$",
"host",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"host",
"->",
"getStage",
"(",
")",
";",
"$",
"context",
"=",
"array",
"(",
"'linkTarget'",
"=>",
"$",
"releasePath",
",",
"'releaseVersion'",
"=>",
"$",
"release",
"->",
"getVersion",
"(",
")",
",",
"'event.task.action'",
"=>",
"TaskInterface",
"::",
"ACTION_IN_PROGRESS",
")",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"'Linking \"{linkTarget}\" to release \"{releaseVersion}\".'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"if",
"(",
"$",
"connection",
"->",
"isLink",
"(",
"$",
"releasePath",
")",
"===",
"false",
"||",
"$",
"connection",
"->",
"readLink",
"(",
"$",
"releasePath",
")",
"!==",
"$",
"release",
"->",
"getPath",
"(",
")",
")",
"{",
"if",
"(",
"$",
"connection",
"->",
"isLink",
"(",
"$",
"releasePath",
")",
")",
"{",
"$",
"connection",
"->",
"delete",
"(",
"$",
"releasePath",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"connection",
"->",
"link",
"(",
"$",
"release",
"->",
"getPath",
"(",
")",
",",
"$",
"releasePath",
")",
")",
"{",
"$",
"context",
"[",
"'event.task.action'",
"]",
"=",
"TaskInterface",
"::",
"ACTION_COMPLETED",
";",
"$",
"context",
"[",
"'output.resetLine'",
"]",
"=",
"true",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"'Linked \"{linkTarget}\" to release \"{releaseVersion}\".'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"}",
"else",
"{",
"$",
"context",
"[",
"'event.task.action'",
"]",
"=",
"TaskInterface",
"::",
"ACTION_FAILED",
";",
"$",
"context",
"[",
"'output.resetLine'",
"]",
"=",
"true",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"'Linking \"{linkTarget}\" to release \"{releaseVersion}\" failed.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"throw",
"new",
"TaskRuntimeException",
"(",
"sprintf",
"(",
"'Linking \"%s\" to release \"%s\" failed.'",
",",
"$",
"context",
"[",
"'linkTarget'",
"]",
",",
"$",
"context",
"[",
"'releaseVersion'",
"]",
")",
",",
"$",
"this",
")",
";",
"}",
"}",
"else",
"{",
"$",
"context",
"[",
"'event.task.action'",
"]",
"=",
"TaskInterface",
"::",
"ACTION_COMPLETED",
";",
"$",
"context",
"[",
"'output.resetLine'",
"]",
"=",
"true",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"NOTICE",
",",
"'Link \"{linkTarget}\" to release \"{releaseVersion}\" already exists.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"}",
"}"
] |
Links the release being deployed.
@param DeployReleaseEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher
|
[
"Links",
"the",
"release",
"being",
"deployed",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/DeployReleaseTask.php#L84-L119
|
235,147
|
makinacorpus/drupal-ucms
|
ucms_group/src/EventDispatcher/GroupContextSubscriber.php
|
GroupContextSubscriber.onSiteInit
|
public function onSiteInit(SiteInitEvent $event)
{
$group = $this->groupManager->getSiteGroup($event->getSite());
if ($group) {
$this->siteManager->setDependentContext('group', $group);
}
}
|
php
|
public function onSiteInit(SiteInitEvent $event)
{
$group = $this->groupManager->getSiteGroup($event->getSite());
if ($group) {
$this->siteManager->setDependentContext('group', $group);
}
}
|
[
"public",
"function",
"onSiteInit",
"(",
"SiteInitEvent",
"$",
"event",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"groupManager",
"->",
"getSiteGroup",
"(",
"$",
"event",
"->",
"getSite",
"(",
")",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"$",
"this",
"->",
"siteManager",
"->",
"setDependentContext",
"(",
"'group'",
",",
"$",
"group",
")",
";",
"}",
"}"
] |
Set current group context
|
[
"Set",
"current",
"group",
"context"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/EventDispatcher/GroupContextSubscriber.php#L56-L63
|
235,148
|
NicolasMahe/Laravel-SlackOutput
|
src/Library/ScheduledCommand.php
|
ScheduledCommand.output
|
static public function output(Event $event, $channel)
{
preg_match("/(artisan |'artisan' )(.*)/us", $event->command, $matches);
$eventCommand = $matches[2];
$event->sendOutputTo(base_path() . '/storage/logs/' . $eventCommand . '.txt');
if (is_null($event->output)) {
//if no output, don't send anything
return;
}
$event->then(function () use ($event, $eventCommand, $channel) {
$message = file_get_contents($event->output);
Artisan::call('slack:post', [
'to' => $channel,
'attach' => [
'color' => 'grey',
'title' => $eventCommand,
'text' => $message
]
]);
});
}
|
php
|
static public function output(Event $event, $channel)
{
preg_match("/(artisan |'artisan' )(.*)/us", $event->command, $matches);
$eventCommand = $matches[2];
$event->sendOutputTo(base_path() . '/storage/logs/' . $eventCommand . '.txt');
if (is_null($event->output)) {
//if no output, don't send anything
return;
}
$event->then(function () use ($event, $eventCommand, $channel) {
$message = file_get_contents($event->output);
Artisan::call('slack:post', [
'to' => $channel,
'attach' => [
'color' => 'grey',
'title' => $eventCommand,
'text' => $message
]
]);
});
}
|
[
"static",
"public",
"function",
"output",
"(",
"Event",
"$",
"event",
",",
"$",
"channel",
")",
"{",
"preg_match",
"(",
"\"/(artisan |'artisan' )(.*)/us\"",
",",
"$",
"event",
"->",
"command",
",",
"$",
"matches",
")",
";",
"$",
"eventCommand",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"event",
"->",
"sendOutputTo",
"(",
"base_path",
"(",
")",
".",
"'/storage/logs/'",
".",
"$",
"eventCommand",
".",
"'.txt'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"event",
"->",
"output",
")",
")",
"{",
"//if no output, don't send anything",
"return",
";",
"}",
"$",
"event",
"->",
"then",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"event",
",",
"$",
"eventCommand",
",",
"$",
"channel",
")",
"{",
"$",
"message",
"=",
"file_get_contents",
"(",
"$",
"event",
"->",
"output",
")",
";",
"Artisan",
"::",
"call",
"(",
"'slack:post'",
",",
"[",
"'to'",
"=>",
"$",
"channel",
",",
"'attach'",
"=>",
"[",
"'color'",
"=>",
"'grey'",
",",
"'title'",
"=>",
"$",
"eventCommand",
",",
"'text'",
"=>",
"$",
"message",
"]",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Send to slack the results of a scheduled command.
@todo: add success tag to adjust the color
@param Event $event
@param $channel
@return void
|
[
"Send",
"to",
"slack",
"the",
"results",
"of",
"a",
"scheduled",
"command",
"."
] |
fc3722ba64a0ce4d833555bb1a27513e13959b34
|
https://github.com/NicolasMahe/Laravel-SlackOutput/blob/fc3722ba64a0ce4d833555bb1a27513e13959b34/src/Library/ScheduledCommand.php#L21-L44
|
235,149
|
runcmf/runbb
|
src/RunBB/Core/Cache.php
|
Cache.isCached
|
public function isCached($key)
{
if ($cachedData = $this->loadCache()) {
if (isset($cachedData[$key])) {
if (!$this->isExpired($cachedData[$key]['time'], $cachedData[$key]['expire'])) {
return true;
}
}
}
return false; // If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached
}
|
php
|
public function isCached($key)
{
if ($cachedData = $this->loadCache()) {
if (isset($cachedData[$key])) {
if (!$this->isExpired($cachedData[$key]['time'], $cachedData[$key]['expire'])) {
return true;
}
}
}
return false; // If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached
}
|
[
"public",
"function",
"isCached",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"cachedData",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cachedData",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isExpired",
"(",
"$",
"cachedData",
"[",
"$",
"key",
"]",
"[",
"'time'",
"]",
",",
"$",
"cachedData",
"[",
"$",
"key",
"]",
"[",
"'expire'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"// If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached",
"}"
] |
Check whether data is associated with a key
@param string $key
@return boolean
|
[
"Check",
"whether",
"data",
"is",
"associated",
"with",
"a",
"key"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L68-L78
|
235,150
|
runcmf/runbb
|
src/RunBB/Core/Cache.php
|
Cache.retrieve
|
public function retrieve($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
if (!$this->isExpired($cache[$key]['time'], $cache[$key]['expire'])) {
return unserialize($cache[$key]['data']);
}
}
}
return null;
}
|
php
|
public function retrieve($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
if (!$this->isExpired($cache[$key]['time'], $cache[$key]['expire'])) {
return unserialize($cache[$key]['data']);
}
}
}
return null;
}
|
[
"public",
"function",
"retrieve",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isExpired",
"(",
"$",
"cache",
"[",
"$",
"key",
"]",
"[",
"'time'",
"]",
",",
"$",
"cache",
"[",
"$",
"key",
"]",
"[",
"'expire'",
"]",
")",
")",
"{",
"return",
"unserialize",
"(",
"$",
"cache",
"[",
"$",
"key",
"]",
"[",
"'data'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Retrieve cached data by key
@param string $key
@param boolean [optional] $timestamp
@return string
|
[
"Retrieve",
"cached",
"data",
"by",
"key"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L115-L126
|
235,151
|
runcmf/runbb
|
src/RunBB/Core/Cache.php
|
Cache.delete
|
public function delete($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
unset($cache[$key]);
$this->saveCache($cache);
return $this;
}
}
throw new RunBBException("Error: delete() - Key '{$key}' not found.");
}
|
php
|
public function delete($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
unset($cache[$key]);
$this->saveCache($cache);
return $this;
}
}
throw new RunBBException("Error: delete() - Key '{$key}' not found.");
}
|
[
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"cache",
"[",
"$",
"key",
"]",
")",
";",
"$",
"this",
"->",
"saveCache",
"(",
"$",
"cache",
")",
";",
"return",
"$",
"this",
";",
"}",
"}",
"throw",
"new",
"RunBBException",
"(",
"\"Error: delete() - Key '{$key}' not found.\"",
")",
";",
"}"
] |
Delete cached entry by its key
@param string $key
@return object
@throws RunBBException for error delete cached key.
|
[
"Delete",
"cached",
"entry",
"by",
"its",
"key"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L157-L168
|
235,152
|
runcmf/runbb
|
src/RunBB/Core/Cache.php
|
Cache.saveCache
|
private function saveCache(array $data)
{
$this->cache = $data; // Save new data in object to avoid useless I/O access
$opt = '';
if (ForumEnv::get('FEATHER_DEBUG')) {
$opt = JSON_PRETTY_PRINT;
}
return file_put_contents($this->getCacheFile(), json_encode($data, $opt));
}
|
php
|
private function saveCache(array $data)
{
$this->cache = $data; // Save new data in object to avoid useless I/O access
$opt = '';
if (ForumEnv::get('FEATHER_DEBUG')) {
$opt = JSON_PRETTY_PRINT;
}
return file_put_contents($this->getCacheFile(), json_encode($data, $opt));
}
|
[
"private",
"function",
"saveCache",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"$",
"data",
";",
"// Save new data in object to avoid useless I/O access",
"$",
"opt",
"=",
"''",
";",
"if",
"(",
"ForumEnv",
"::",
"get",
"(",
"'FEATHER_DEBUG'",
")",
")",
"{",
"$",
"opt",
"=",
"JSON_PRETTY_PRINT",
";",
"}",
"return",
"file_put_contents",
"(",
"$",
"this",
"->",
"getCacheFile",
"(",
")",
",",
"json_encode",
"(",
"$",
"data",
",",
"$",
"opt",
")",
")",
";",
"}"
] |
Save cache file
@param array $data
@return mixed number of bytes that were written to the file, or FALSE on failure.
|
[
"Save",
"cache",
"file"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L270-L278
|
235,153
|
aimeos/ai-admin-extadm
|
controller/extjs/src/Controller/ExtJS/Service/Standard.php
|
Standard.saveItems
|
public function saveItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$ids = [];
$manager = $this->getManager();
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $entry )
{
$item = $manager->createItem();
$item->fromArray( (array) $this->transformValues( $entry ) );
$item = $manager->saveItem( $item );
$ids[] = $item->getId();
}
$this->clearCache( $ids );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'service.id', $ids ) );
$search->setSlice( 0, count( $ids ) );
$result = $manager->searchItems( $search );
foreach( $result as $item ) {
$this->checkConfig( $item );
}
$items = $this->toArray( $result );
return array(
'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
'success' => true,
);
}
|
php
|
public function saveItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$ids = [];
$manager = $this->getManager();
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $entry )
{
$item = $manager->createItem();
$item->fromArray( (array) $this->transformValues( $entry ) );
$item = $manager->saveItem( $item );
$ids[] = $item->getId();
}
$this->clearCache( $ids );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'service.id', $ids ) );
$search->setSlice( 0, count( $ids ) );
$result = $manager->searchItems( $search );
foreach( $result as $item ) {
$this->checkConfig( $item );
}
$items = $this->toArray( $result );
return array(
'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
'success' => true,
);
}
|
[
"public",
"function",
"saveItems",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
"->",
"site",
")",
";",
"$",
"ids",
"=",
"[",
"]",
";",
"$",
"manager",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
";",
"$",
"items",
"=",
"(",
"!",
"is_array",
"(",
"$",
"params",
"->",
"items",
")",
"?",
"array",
"(",
"$",
"params",
"->",
"items",
")",
":",
"$",
"params",
"->",
"items",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"entry",
")",
"{",
"$",
"item",
"=",
"$",
"manager",
"->",
"createItem",
"(",
")",
";",
"$",
"item",
"->",
"fromArray",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"transformValues",
"(",
"$",
"entry",
")",
")",
";",
"$",
"item",
"=",
"$",
"manager",
"->",
"saveItem",
"(",
"$",
"item",
")",
";",
"$",
"ids",
"[",
"]",
"=",
"$",
"item",
"->",
"getId",
"(",
")",
";",
"}",
"$",
"this",
"->",
"clearCache",
"(",
"$",
"ids",
")",
";",
"$",
"search",
"=",
"$",
"manager",
"->",
"createSearch",
"(",
")",
";",
"$",
"search",
"->",
"setConditions",
"(",
"$",
"search",
"->",
"compare",
"(",
"'=='",
",",
"'service.id'",
",",
"$",
"ids",
")",
")",
";",
"$",
"search",
"->",
"setSlice",
"(",
"0",
",",
"count",
"(",
"$",
"ids",
")",
")",
";",
"$",
"result",
"=",
"$",
"manager",
"->",
"searchItems",
"(",
"$",
"search",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"checkConfig",
"(",
"$",
"item",
")",
";",
"}",
"$",
"items",
"=",
"$",
"this",
"->",
"toArray",
"(",
"$",
"result",
")",
";",
"return",
"array",
"(",
"'items'",
"=>",
"(",
"!",
"is_array",
"(",
"$",
"params",
"->",
"items",
")",
"?",
"reset",
"(",
"$",
"items",
")",
":",
"$",
"items",
")",
",",
"'success'",
"=>",
"true",
",",
")",
";",
"}"
] |
Creates a new service item or updates an existing one or a list thereof.
@param \stdClass $params Associative array containing the service properties
@return array Associative list with nodes and success value
|
[
"Creates",
"a",
"new",
"service",
"item",
"or",
"updates",
"an",
"existing",
"one",
"or",
"a",
"list",
"thereof",
"."
] |
594ee7cec90fd63a4773c05c93f353e66d9b3408
|
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Service/Standard.php#L45-L79
|
235,154
|
aimeos/ai-admin-extadm
|
controller/extjs/src/Controller/ExtJS/Service/Standard.php
|
Standard.checkConfig
|
protected function checkConfig( \Aimeos\MShop\Service\Item\Iface $item )
{
$msg = '';
$provider = $this->manager->getProvider( $item );
$result = $provider->checkConfigBE( $item->getConfig() );
foreach( $result as $key => $message )
{
if( $message !== null ) {
$msg .= sprintf( "- %1\$s : %2\$s\n", $key, $message );
}
}
if( $msg !== '' ) {
throw new \Aimeos\Controller\ExtJS\Exception( "Invalid configuration:\n" . $msg );
}
}
|
php
|
protected function checkConfig( \Aimeos\MShop\Service\Item\Iface $item )
{
$msg = '';
$provider = $this->manager->getProvider( $item );
$result = $provider->checkConfigBE( $item->getConfig() );
foreach( $result as $key => $message )
{
if( $message !== null ) {
$msg .= sprintf( "- %1\$s : %2\$s\n", $key, $message );
}
}
if( $msg !== '' ) {
throw new \Aimeos\Controller\ExtJS\Exception( "Invalid configuration:\n" . $msg );
}
}
|
[
"protected",
"function",
"checkConfig",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Service",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
")",
"{",
"$",
"msg",
"=",
"''",
";",
"$",
"provider",
"=",
"$",
"this",
"->",
"manager",
"->",
"getProvider",
"(",
"$",
"item",
")",
";",
"$",
"result",
"=",
"$",
"provider",
"->",
"checkConfigBE",
"(",
"$",
"item",
"->",
"getConfig",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"!==",
"null",
")",
"{",
"$",
"msg",
".=",
"sprintf",
"(",
"\"- %1\\$s : %2\\$s\\n\"",
",",
"$",
"key",
",",
"$",
"message",
")",
";",
"}",
"}",
"if",
"(",
"$",
"msg",
"!==",
"''",
")",
"{",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"ExtJS",
"\\",
"Exception",
"(",
"\"Invalid configuration:\\n\"",
".",
"$",
"msg",
")",
";",
"}",
"}"
] |
Tests the configuration and throws an exception if it's invalid
@param \Aimeos\MShop\Service\Item\Iface $item Service item object
@throws \Aimeos\Controller\ExtJS\Exception If configuration is invalid
|
[
"Tests",
"the",
"configuration",
"and",
"throws",
"an",
"exception",
"if",
"it",
"s",
"invalid"
] |
594ee7cec90fd63a4773c05c93f353e66d9b3408
|
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Service/Standard.php#L116-L132
|
235,155
|
BugBuster1701/botdetection
|
src/modules/ModuleBotDetection.php
|
ModuleBotDetection.BD_CheckBotAgent
|
public function BD_CheckBotAgent($UserAgent = false)
{
// Check if user agent present
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentSimple::checkAgent( $UserAgent );
}
|
php
|
public function BD_CheckBotAgent($UserAgent = false)
{
// Check if user agent present
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentSimple::checkAgent( $UserAgent );
}
|
[
"public",
"function",
"BD_CheckBotAgent",
"(",
"$",
"UserAgent",
"=",
"false",
")",
"{",
"// Check if user agent present",
"if",
"(",
"$",
"UserAgent",
"===",
"false",
")",
"{",
"$",
"UserAgent",
"=",
"trim",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpUserAgent'",
")",
")",
";",
"}",
"return",
"\\",
"BugBuster",
"\\",
"BotDetection",
"\\",
"CheckBotAgentSimple",
"::",
"checkAgent",
"(",
"$",
"UserAgent",
")",
";",
"}"
] |
Spider Bot Agent Check
@param string UserAgent, optional for tests
@return boolean true when bot found
@deprecated Use the CheckBotAgentSimple class instead or the method checkBotAllTests
|
[
"Spider",
"Bot",
"Agent",
"Check"
] |
b27cc1d80932af7d29b9f345da9132842d2adbce
|
https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L130-L138
|
235,156
|
BugBuster1701/botdetection
|
src/modules/ModuleBotDetection.php
|
ModuleBotDetection.BD_CheckBotIP
|
public function BD_CheckBotIP($UserIP = false)
{
// Check if IP present
if ($UserIP === false)
{
if (strpos(\Environment::get('ip'), ',') !== false) //first IP
{
$UserIP = trim(substr(\Environment::get('ip'), 0, strpos(\Environment::get('ip'), ',')));
}
else
{
$UserIP = trim(\Environment::get('ip'));
}
}
\BugBuster\BotDetection\CheckBotIp::setBotIpv4List(TL_ROOT . self::BOT_IP4_LIST);
\BugBuster\BotDetection\CheckBotIp::setBotIpv6List(TL_ROOT . self::BOT_IP6_LIST);
return \BugBuster\BotDetection\CheckBotIp::checkIP( $UserIP );
}
|
php
|
public function BD_CheckBotIP($UserIP = false)
{
// Check if IP present
if ($UserIP === false)
{
if (strpos(\Environment::get('ip'), ',') !== false) //first IP
{
$UserIP = trim(substr(\Environment::get('ip'), 0, strpos(\Environment::get('ip'), ',')));
}
else
{
$UserIP = trim(\Environment::get('ip'));
}
}
\BugBuster\BotDetection\CheckBotIp::setBotIpv4List(TL_ROOT . self::BOT_IP4_LIST);
\BugBuster\BotDetection\CheckBotIp::setBotIpv6List(TL_ROOT . self::BOT_IP6_LIST);
return \BugBuster\BotDetection\CheckBotIp::checkIP( $UserIP );
}
|
[
"public",
"function",
"BD_CheckBotIP",
"(",
"$",
"UserIP",
"=",
"false",
")",
"{",
"// Check if IP present",
"if",
"(",
"$",
"UserIP",
"===",
"false",
")",
"{",
"if",
"(",
"strpos",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'ip'",
")",
",",
"','",
")",
"!==",
"false",
")",
"//first IP",
"{",
"$",
"UserIP",
"=",
"trim",
"(",
"substr",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'ip'",
")",
",",
"0",
",",
"strpos",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'ip'",
")",
",",
"','",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"UserIP",
"=",
"trim",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'ip'",
")",
")",
";",
"}",
"}",
"\\",
"BugBuster",
"\\",
"BotDetection",
"\\",
"CheckBotIp",
"::",
"setBotIpv4List",
"(",
"TL_ROOT",
".",
"self",
"::",
"BOT_IP4_LIST",
")",
";",
"\\",
"BugBuster",
"\\",
"BotDetection",
"\\",
"CheckBotIp",
"::",
"setBotIpv6List",
"(",
"TL_ROOT",
".",
"self",
"::",
"BOT_IP6_LIST",
")",
";",
"return",
"\\",
"BugBuster",
"\\",
"BotDetection",
"\\",
"CheckBotIp",
"::",
"checkIP",
"(",
"$",
"UserIP",
")",
";",
"}"
] |
Spider Bot IP Check
@param string User IP, optional for tests
@return boolean true when bot found over IP
@deprecated Use the CheckBotIp class instead
|
[
"Spider",
"Bot",
"IP",
"Check"
] |
b27cc1d80932af7d29b9f345da9132842d2adbce
|
https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L147-L164
|
235,157
|
BugBuster1701/botdetection
|
src/modules/ModuleBotDetection.php
|
ModuleBotDetection.BD_CheckBotAgentAdvanced
|
public function BD_CheckBotAgentAdvanced($UserAgent = false)
{
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentExtended::checkAgentName( $UserAgent );
}
|
php
|
public function BD_CheckBotAgentAdvanced($UserAgent = false)
{
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentExtended::checkAgentName( $UserAgent );
}
|
[
"public",
"function",
"BD_CheckBotAgentAdvanced",
"(",
"$",
"UserAgent",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"UserAgent",
"===",
"false",
")",
"{",
"$",
"UserAgent",
"=",
"trim",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpUserAgent'",
")",
")",
";",
"}",
"return",
"\\",
"BugBuster",
"\\",
"BotDetection",
"\\",
"CheckBotAgentExtended",
"::",
"checkAgentName",
"(",
"$",
"UserAgent",
")",
";",
"}"
] |
Spider Bot Agent Check Advanced
@param string UserAgent, optional for tests
@return bool false (not bot) or true (bot), in old version the short Bot-Agentname
@deprecated Use the CheckBotAgentExtended class instead or the method checkBotAllTests
|
[
"Spider",
"Bot",
"Agent",
"Check",
"Advanced"
] |
b27cc1d80932af7d29b9f345da9132842d2adbce
|
https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L173-L180
|
235,158
|
makinacorpus/drupal-ucms
|
ucms_group/src/EventDispatcher/NodeEventSubscriber.php
|
NodeEventSubscriber.onNodePrepare
|
public function onNodePrepare(NodeEvent $event)
{
$node = $event->getNode();
if (!empty($node->group_id)) {
return; // Someone took care of this for us
}
$node->group_id = $this->findMostRelevantGroupId();
$node->is_ghost = (int)$this->findMostRelevantGhostValue($node);
}
|
php
|
public function onNodePrepare(NodeEvent $event)
{
$node = $event->getNode();
if (!empty($node->group_id)) {
return; // Someone took care of this for us
}
$node->group_id = $this->findMostRelevantGroupId();
$node->is_ghost = (int)$this->findMostRelevantGhostValue($node);
}
|
[
"public",
"function",
"onNodePrepare",
"(",
"NodeEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"->",
"group_id",
")",
")",
"{",
"return",
";",
"// Someone took care of this for us",
"}",
"$",
"node",
"->",
"group_id",
"=",
"$",
"this",
"->",
"findMostRelevantGroupId",
"(",
")",
";",
"$",
"node",
"->",
"is_ghost",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"findMostRelevantGhostValue",
"(",
"$",
"node",
")",
";",
"}"
] |
Sets the most relevant 'group_id' and 'is_ghost' property values
|
[
"Sets",
"the",
"most",
"relevant",
"group_id",
"and",
"is_ghost",
"property",
"values"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/EventDispatcher/NodeEventSubscriber.php#L34-L44
|
235,159
|
makinacorpus/drupal-ucms
|
ucms_group/src/EventDispatcher/NodeEventSubscriber.php
|
NodeEventSubscriber.onNodePresave
|
public function onNodePresave(NodeEvent $event)
{
$node = $event->getNode();
// When coming from the node form, node form has already been submitted
// case in which, if relevant, a group identifier has already been set
// and this code won't be execute. In the other hand, if the prepare
// hook has not been invoked, this will run and set things right.
// There is still a use case where the node comes from the node form but
// there is no contextual group, case in which this code will wrongly
// run, but hopefuly since it is just setting defaults, it won't change
// the normal behavior.
if (empty($node->group_id)) {
$groupId = $this->findMostRelevantGroupId();
if ($groupId) {
$node->group_id = $groupId;
}
$node->is_ghost = $this->findMostRelevantGhostValue($node);
}
}
|
php
|
public function onNodePresave(NodeEvent $event)
{
$node = $event->getNode();
// When coming from the node form, node form has already been submitted
// case in which, if relevant, a group identifier has already been set
// and this code won't be execute. In the other hand, if the prepare
// hook has not been invoked, this will run and set things right.
// There is still a use case where the node comes from the node form but
// there is no contextual group, case in which this code will wrongly
// run, but hopefuly since it is just setting defaults, it won't change
// the normal behavior.
if (empty($node->group_id)) {
$groupId = $this->findMostRelevantGroupId();
if ($groupId) {
$node->group_id = $groupId;
}
$node->is_ghost = $this->findMostRelevantGhostValue($node);
}
}
|
[
"public",
"function",
"onNodePresave",
"(",
"NodeEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"// When coming from the node form, node form has already been submitted",
"// case in which, if relevant, a group identifier has already been set",
"// and this code won't be execute. In the other hand, if the prepare",
"// hook has not been invoked, this will run and set things right.",
"// There is still a use case where the node comes from the node form but",
"// there is no contextual group, case in which this code will wrongly",
"// run, but hopefuly since it is just setting defaults, it won't change",
"// the normal behavior.",
"if",
"(",
"empty",
"(",
"$",
"node",
"->",
"group_id",
")",
")",
"{",
"$",
"groupId",
"=",
"$",
"this",
"->",
"findMostRelevantGroupId",
"(",
")",
";",
"if",
"(",
"$",
"groupId",
")",
"{",
"$",
"node",
"->",
"group_id",
"=",
"$",
"groupId",
";",
"}",
"$",
"node",
"->",
"is_ghost",
"=",
"$",
"this",
"->",
"findMostRelevantGhostValue",
"(",
"$",
"node",
")",
";",
"}",
"}"
] |
Prepare hook is no always called, this is why we do reproduce what does
happen during the prepare hook in the presave hook, if no value has
already been provided
|
[
"Prepare",
"hook",
"is",
"no",
"always",
"called",
"this",
"is",
"why",
"we",
"do",
"reproduce",
"what",
"does",
"happen",
"during",
"the",
"prepare",
"hook",
"in",
"the",
"presave",
"hook",
"if",
"no",
"value",
"has",
"already",
"been",
"provided"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/EventDispatcher/NodeEventSubscriber.php#L51-L72
|
235,160
|
PHPixie/HTTP
|
src/PHPixie/HTTP/Builder.php
|
Builder.cookiesUpdate
|
public function cookiesUpdate(
$name,
$value,
$expires = null,
$path = '/',
$domain = null,
$secure = false,
$httpOnly = false
)
{
return new Context\Cookies\Update(
$name,
$value,
$expires,
$path,
$domain,
$secure,
$httpOnly
);
}
|
php
|
public function cookiesUpdate(
$name,
$value,
$expires = null,
$path = '/',
$domain = null,
$secure = false,
$httpOnly = false
)
{
return new Context\Cookies\Update(
$name,
$value,
$expires,
$path,
$domain,
$secure,
$httpOnly
);
}
|
[
"public",
"function",
"cookiesUpdate",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
"=",
"null",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"secure",
"=",
"false",
",",
"$",
"httpOnly",
"=",
"false",
")",
"{",
"return",
"new",
"Context",
"\\",
"Cookies",
"\\",
"Update",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
",",
"$",
"path",
",",
"$",
"domain",
",",
"$",
"secure",
",",
"$",
"httpOnly",
")",
";",
"}"
] |
Build a single cookie update
@param $name
@param $value
@param null $expires
@param string $path
@param null $domain
@param bool $secure
@param bool $httpOnly
@return Context\Cookies\Update
|
[
"Build",
"a",
"single",
"cookie",
"update"
] |
581c0df452fd07ca4ea0b3e24e8ddee8dddc2912
|
https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Builder.php#L149-L168
|
235,161
|
runcmf/runbb
|
src/RunBB/Core/Track.php
|
Track.setTrackedTopics
|
public static function setTrackedTopics($tracked_topics = null)
{
if (!empty($tracked_topics)) {
// Sort the arrays (latest read first)
arsort($tracked_topics['topics'], SORT_NUMERIC);
arsort($tracked_topics['forums'], SORT_NUMERIC);
} else {
$tracked_topics = ['topics' => [], 'forums' => []];
}
return setcookie(
ForumSettings::get('cookie_name') . '_track',
json_encode($tracked_topics),
time() + ForumSettings::get('o_timeout_visit'),
'/',
'',
false,
true
);
}
|
php
|
public static function setTrackedTopics($tracked_topics = null)
{
if (!empty($tracked_topics)) {
// Sort the arrays (latest read first)
arsort($tracked_topics['topics'], SORT_NUMERIC);
arsort($tracked_topics['forums'], SORT_NUMERIC);
} else {
$tracked_topics = ['topics' => [], 'forums' => []];
}
return setcookie(
ForumSettings::get('cookie_name') . '_track',
json_encode($tracked_topics),
time() + ForumSettings::get('o_timeout_visit'),
'/',
'',
false,
true
);
}
|
[
"public",
"static",
"function",
"setTrackedTopics",
"(",
"$",
"tracked_topics",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"tracked_topics",
")",
")",
"{",
"// Sort the arrays (latest read first)",
"arsort",
"(",
"$",
"tracked_topics",
"[",
"'topics'",
"]",
",",
"SORT_NUMERIC",
")",
";",
"arsort",
"(",
"$",
"tracked_topics",
"[",
"'forums'",
"]",
",",
"SORT_NUMERIC",
")",
";",
"}",
"else",
"{",
"$",
"tracked_topics",
"=",
"[",
"'topics'",
"=>",
"[",
"]",
",",
"'forums'",
"=>",
"[",
"]",
"]",
";",
"}",
"return",
"setcookie",
"(",
"ForumSettings",
"::",
"get",
"(",
"'cookie_name'",
")",
".",
"'_track'",
",",
"json_encode",
"(",
"$",
"tracked_topics",
")",
",",
"time",
"(",
")",
"+",
"ForumSettings",
"::",
"get",
"(",
"'o_timeout_visit'",
")",
",",
"'/'",
",",
"''",
",",
"false",
",",
"true",
")",
";",
"}"
] |
Save array of tracked topics in cookie
@param null $tracked_topics
@return bool
|
[
"Save",
"array",
"of",
"tracked",
"topics",
"in",
"cookie"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Track.php#L19-L38
|
235,162
|
runcmf/runbb
|
src/RunBB/Core/Track.php
|
Track.getTrackedTopics
|
public static function getTrackedTopics()
{
$cookie_raw = Container::get('cookie')->get(ForumSettings::get('cookie_name').'_track');
if (isset($cookie_raw)) {
$cookie_data = json_decode($cookie_raw, true);
return $cookie_data;
}
return ['topics' => [], 'forums' => []];
}
|
php
|
public static function getTrackedTopics()
{
$cookie_raw = Container::get('cookie')->get(ForumSettings::get('cookie_name').'_track');
if (isset($cookie_raw)) {
$cookie_data = json_decode($cookie_raw, true);
return $cookie_data;
}
return ['topics' => [], 'forums' => []];
}
|
[
"public",
"static",
"function",
"getTrackedTopics",
"(",
")",
"{",
"$",
"cookie_raw",
"=",
"Container",
"::",
"get",
"(",
"'cookie'",
")",
"->",
"get",
"(",
"ForumSettings",
"::",
"get",
"(",
"'cookie_name'",
")",
".",
"'_track'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"cookie_raw",
")",
")",
"{",
"$",
"cookie_data",
"=",
"json_decode",
"(",
"$",
"cookie_raw",
",",
"true",
")",
";",
"return",
"$",
"cookie_data",
";",
"}",
"return",
"[",
"'topics'",
"=>",
"[",
"]",
",",
"'forums'",
"=>",
"[",
"]",
"]",
";",
"}"
] |
Extract array of tracked topics from cookie
@return array|mixed
|
[
"Extract",
"array",
"of",
"tracked",
"topics",
"from",
"cookie"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Track.php#L44-L53
|
235,163
|
phlib/db
|
src/Adapter.php
|
Adapter.setCharset
|
public function setCharset($charset)
{
if ($this->config->getCharset() !== $charset) {
$this->config->setCharset($charset);
if ($this->connection) {
$this->query('SET NAMES ?', [$charset]);
}
}
return $this;
}
|
php
|
public function setCharset($charset)
{
if ($this->config->getCharset() !== $charset) {
$this->config->setCharset($charset);
if ($this->connection) {
$this->query('SET NAMES ?', [$charset]);
}
}
return $this;
}
|
[
"public",
"function",
"setCharset",
"(",
"$",
"charset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"getCharset",
"(",
")",
"!==",
"$",
"charset",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"setCharset",
"(",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"this",
"->",
"connection",
")",
"{",
"$",
"this",
"->",
"query",
"(",
"'SET NAMES ?'",
",",
"[",
"$",
"charset",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the character set on the connection.
@param string $charset
@return Adapter
|
[
"Set",
"the",
"character",
"set",
"on",
"the",
"connection",
"."
] |
30c0fce5fb268766265cb03492c4209bcf916a40
|
https://github.com/phlib/db/blob/30c0fce5fb268766265cb03492c4209bcf916a40/src/Adapter.php#L177-L187
|
235,164
|
makinacorpus/drupal-ucms
|
ucms_site/src/Controller/DashboardController.php
|
DashboardController.siteArchiveListAction
|
public function siteArchiveListAction(Request $request)
{
$baseQuery = ['s.state' => SiteState::ARCHIVE];
if (!$this->isGranted([Access::PERM_SITE_GOD, Access::PERM_SITE_MANAGE_ALL, Access::PERM_SITE_VIEW_ALL])) {
$baseQuery['uid'] = $this->getCurrentUserId();
}
return $this->renderPage('ucms_site.list_all', $request, [
'base_query' => [
'uid' => $baseQuery,
],
]);
}
|
php
|
public function siteArchiveListAction(Request $request)
{
$baseQuery = ['s.state' => SiteState::ARCHIVE];
if (!$this->isGranted([Access::PERM_SITE_GOD, Access::PERM_SITE_MANAGE_ALL, Access::PERM_SITE_VIEW_ALL])) {
$baseQuery['uid'] = $this->getCurrentUserId();
}
return $this->renderPage('ucms_site.list_all', $request, [
'base_query' => [
'uid' => $baseQuery,
],
]);
}
|
[
"public",
"function",
"siteArchiveListAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"baseQuery",
"=",
"[",
"'s.state'",
"=>",
"SiteState",
"::",
"ARCHIVE",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isGranted",
"(",
"[",
"Access",
"::",
"PERM_SITE_GOD",
",",
"Access",
"::",
"PERM_SITE_MANAGE_ALL",
",",
"Access",
"::",
"PERM_SITE_VIEW_ALL",
"]",
")",
")",
"{",
"$",
"baseQuery",
"[",
"'uid'",
"]",
"=",
"$",
"this",
"->",
"getCurrentUserId",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"renderPage",
"(",
"'ucms_site.list_all'",
",",
"$",
"request",
",",
"[",
"'base_query'",
"=>",
"[",
"'uid'",
"=>",
"$",
"baseQuery",
",",
"]",
",",
"]",
")",
";",
"}"
] |
List archived sites
|
[
"List",
"archived",
"sites"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Controller/DashboardController.php#L62-L75
|
235,165
|
makinacorpus/drupal-ucms
|
ucms_site/src/Controller/DashboardController.php
|
DashboardController.webmasterListAction
|
public function webmasterListAction(Request $request, Site $site)
{
return $this->renderPage('ucms_site.list_members', $request, [
'base_query' => [
'site_id' => $site->getId(),
],
]);
}
|
php
|
public function webmasterListAction(Request $request, Site $site)
{
return $this->renderPage('ucms_site.list_members', $request, [
'base_query' => [
'site_id' => $site->getId(),
],
]);
}
|
[
"public",
"function",
"webmasterListAction",
"(",
"Request",
"$",
"request",
",",
"Site",
"$",
"site",
")",
"{",
"return",
"$",
"this",
"->",
"renderPage",
"(",
"'ucms_site.list_members'",
",",
"$",
"request",
",",
"[",
"'base_query'",
"=>",
"[",
"'site_id'",
"=>",
"$",
"site",
"->",
"getId",
"(",
")",
",",
"]",
",",
"]",
")",
";",
"}"
] |
List current user site
|
[
"List",
"current",
"user",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Controller/DashboardController.php#L80-L87
|
235,166
|
makinacorpus/drupal-ucms
|
ucms_site/src/Controller/DashboardController.php
|
DashboardController.viewAction
|
public function viewAction(Site $site)
{
$requester = user_load($site->uid);
if (!$requester) {
$requester = drupal_anonymous_user();
}
$template = null;
if ($site->template_id) {
try {
$template = $this->getSiteManager()->getStorage()->findOne($site->template_id);
$template = l($template->title, 'admin/dashboard/site/' . $template->id);
} catch (\Exception $e) {
$template = '<span class="text-muted>' . t("Template does not exist anymore") . '</span>';
}
} else {
$template = '';
}
$states = SiteState::getList();
$uri = 'http://' . $site->http_host;
$table = $this->createAdminTable('ucms_site_details', ['site' => $site])
->addHeader(t("Identification"))
->addRow(t("HTTP hostname"), l($uri, $uri))
->addRow(t("State"), t($states[$site->state]))
->addRow(t("Title"), check_plain($site->title))
->addRow(t("Created at"), format_date($site->ts_created->getTimestamp()))
->addRow(t("Lastest update"), format_date($site->ts_changed->getTimestamp()))
->addRow(t("Requester"), check_plain(format_username($requester)))
->addHeader(t("Description"))
->addRow(t("Description"), check_markup($site->title_admin))
->addRow(t("Replaces"), check_markup($site->replacement_of))
->addRow(t("HTTP redirections"), check_markup($site->http_redirects))
->addHeader(t("Display information"))
->addRow(t("Theme"), check_plain($site->theme))
->addRow(t("Is a template"), $site->is_template ? '<strong>' . t("yes") . '</strong>' : t("No"))
;
if ($template) {
$table->addRow(t("Site template"), $template);
}
$this->addArbitraryAttributesToTable($table, $site->getAttributes());
return $table->render();
}
|
php
|
public function viewAction(Site $site)
{
$requester = user_load($site->uid);
if (!$requester) {
$requester = drupal_anonymous_user();
}
$template = null;
if ($site->template_id) {
try {
$template = $this->getSiteManager()->getStorage()->findOne($site->template_id);
$template = l($template->title, 'admin/dashboard/site/' . $template->id);
} catch (\Exception $e) {
$template = '<span class="text-muted>' . t("Template does not exist anymore") . '</span>';
}
} else {
$template = '';
}
$states = SiteState::getList();
$uri = 'http://' . $site->http_host;
$table = $this->createAdminTable('ucms_site_details', ['site' => $site])
->addHeader(t("Identification"))
->addRow(t("HTTP hostname"), l($uri, $uri))
->addRow(t("State"), t($states[$site->state]))
->addRow(t("Title"), check_plain($site->title))
->addRow(t("Created at"), format_date($site->ts_created->getTimestamp()))
->addRow(t("Lastest update"), format_date($site->ts_changed->getTimestamp()))
->addRow(t("Requester"), check_plain(format_username($requester)))
->addHeader(t("Description"))
->addRow(t("Description"), check_markup($site->title_admin))
->addRow(t("Replaces"), check_markup($site->replacement_of))
->addRow(t("HTTP redirections"), check_markup($site->http_redirects))
->addHeader(t("Display information"))
->addRow(t("Theme"), check_plain($site->theme))
->addRow(t("Is a template"), $site->is_template ? '<strong>' . t("yes") . '</strong>' : t("No"))
;
if ($template) {
$table->addRow(t("Site template"), $template);
}
$this->addArbitraryAttributesToTable($table, $site->getAttributes());
return $table->render();
}
|
[
"public",
"function",
"viewAction",
"(",
"Site",
"$",
"site",
")",
"{",
"$",
"requester",
"=",
"user_load",
"(",
"$",
"site",
"->",
"uid",
")",
";",
"if",
"(",
"!",
"$",
"requester",
")",
"{",
"$",
"requester",
"=",
"drupal_anonymous_user",
"(",
")",
";",
"}",
"$",
"template",
"=",
"null",
";",
"if",
"(",
"$",
"site",
"->",
"template_id",
")",
"{",
"try",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getSiteManager",
"(",
")",
"->",
"getStorage",
"(",
")",
"->",
"findOne",
"(",
"$",
"site",
"->",
"template_id",
")",
";",
"$",
"template",
"=",
"l",
"(",
"$",
"template",
"->",
"title",
",",
"'admin/dashboard/site/'",
".",
"$",
"template",
"->",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"template",
"=",
"'<span class=\"text-muted>'",
".",
"t",
"(",
"\"Template does not exist anymore\"",
")",
".",
"'</span>'",
";",
"}",
"}",
"else",
"{",
"$",
"template",
"=",
"''",
";",
"}",
"$",
"states",
"=",
"SiteState",
"::",
"getList",
"(",
")",
";",
"$",
"uri",
"=",
"'http://'",
".",
"$",
"site",
"->",
"http_host",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"createAdminTable",
"(",
"'ucms_site_details'",
",",
"[",
"'site'",
"=>",
"$",
"site",
"]",
")",
"->",
"addHeader",
"(",
"t",
"(",
"\"Identification\"",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"HTTP hostname\"",
")",
",",
"l",
"(",
"$",
"uri",
",",
"$",
"uri",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"State\"",
")",
",",
"t",
"(",
"$",
"states",
"[",
"$",
"site",
"->",
"state",
"]",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Title\"",
")",
",",
"check_plain",
"(",
"$",
"site",
"->",
"title",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Created at\"",
")",
",",
"format_date",
"(",
"$",
"site",
"->",
"ts_created",
"->",
"getTimestamp",
"(",
")",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Lastest update\"",
")",
",",
"format_date",
"(",
"$",
"site",
"->",
"ts_changed",
"->",
"getTimestamp",
"(",
")",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Requester\"",
")",
",",
"check_plain",
"(",
"format_username",
"(",
"$",
"requester",
")",
")",
")",
"->",
"addHeader",
"(",
"t",
"(",
"\"Description\"",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Description\"",
")",
",",
"check_markup",
"(",
"$",
"site",
"->",
"title_admin",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Replaces\"",
")",
",",
"check_markup",
"(",
"$",
"site",
"->",
"replacement_of",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"HTTP redirections\"",
")",
",",
"check_markup",
"(",
"$",
"site",
"->",
"http_redirects",
")",
")",
"->",
"addHeader",
"(",
"t",
"(",
"\"Display information\"",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Theme\"",
")",
",",
"check_plain",
"(",
"$",
"site",
"->",
"theme",
")",
")",
"->",
"addRow",
"(",
"t",
"(",
"\"Is a template\"",
")",
",",
"$",
"site",
"->",
"is_template",
"?",
"'<strong>'",
".",
"t",
"(",
"\"yes\"",
")",
".",
"'</strong>'",
":",
"t",
"(",
"\"No\"",
")",
")",
";",
"if",
"(",
"$",
"template",
")",
"{",
"$",
"table",
"->",
"addRow",
"(",
"t",
"(",
"\"Site template\"",
")",
",",
"$",
"template",
")",
";",
"}",
"$",
"this",
"->",
"addArbitraryAttributesToTable",
"(",
"$",
"table",
",",
"$",
"site",
"->",
"getAttributes",
"(",
")",
")",
";",
"return",
"$",
"table",
"->",
"render",
"(",
")",
";",
"}"
] |
View site details action
|
[
"View",
"site",
"details",
"action"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Controller/DashboardController.php#L92-L139
|
235,167
|
hmlb/ddd
|
src/Persistence/PersistentMessageCapabilities.php
|
PersistentMessageCapabilities.getId
|
public function getId(): Identity
{
if (null === $this->id) {
throw new PersistentMessageWithoutIdentityException(get_class($this).'::$id has not been initialized');
}
return $this->id;
}
|
php
|
public function getId(): Identity
{
if (null === $this->id) {
throw new PersistentMessageWithoutIdentityException(get_class($this).'::$id has not been initialized');
}
return $this->id;
}
|
[
"public",
"function",
"getId",
"(",
")",
":",
"Identity",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"PersistentMessageWithoutIdentityException",
"(",
"get_class",
"(",
"$",
"this",
")",
".",
"'::$id has not been initialized'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"id",
";",
"}"
] |
Returns the message's identity.
@return Identity
@throws PersistentMessageWithoutIdentityException
|
[
"Returns",
"the",
"message",
"s",
"identity",
"."
] |
f0796b909d189aac81df4ae42c0d5c80b6c86b0b
|
https://github.com/hmlb/ddd/blob/f0796b909d189aac81df4ae42c0d5c80b6c86b0b/src/Persistence/PersistentMessageCapabilities.php#L26-L33
|
235,168
|
BugBuster1701/botdetection
|
src/classes/CheckBotAgentExtended.php
|
CheckBotAgentExtended.getBrowscapInfo
|
protected static function getBrowscapInfo($UserAgent=false)
{
// Check if user agent present
if ($UserAgent === false)
{
return false; // No user agent, no search.
}
// set an own cache directory (otherwise the system temp directory is used)
\Crossjoin\Browscap\Cache\File::setCacheDirectory(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache');
//Large sonst fehlt Browser_Type / Crawler um Bots zu erkennen
\Crossjoin\Browscap\Browscap::setDatasetType(\Crossjoin\Browscap\Browscap::DATASET_TYPE_LARGE);
// disable automatic updates
$updater = new \Crossjoin\Browscap\Updater\None();
\Crossjoin\Browscap\Browscap::setUpdater($updater);
$browscap = new \Crossjoin\Browscap\Browscap(false); //autoUpdate = false
$settings = $browscap->getBrowser($UserAgent)->getData();
return $settings;
/*
stdClass Object
(
[browser_name_regex] => /^Yandex\/1\.01\.001 \(compatible; Win16; .*\)$/
[browser_name_pattern] => Yandex/1.01.001 (compatible; Win16; *)
[parent] => Yandex
[comment] => Yandex
[browser] => Yandex
[browser_type] => Bot/Crawler
[browser_maker] => Yandex
[crawler] => true
.....
stdClass Object
(
[browser_name_regex] => /^Googlebot\-Image.*$/
[browser_name_pattern] => Googlebot-Image*
[parent] => Googlebot
[browser] => Googlebot-Image
[comment] => Googlebot
[browser_type] => Bot/Crawler
[browser_maker] => Google Inc
[crawler] => true
.....
*/
}
|
php
|
protected static function getBrowscapInfo($UserAgent=false)
{
// Check if user agent present
if ($UserAgent === false)
{
return false; // No user agent, no search.
}
// set an own cache directory (otherwise the system temp directory is used)
\Crossjoin\Browscap\Cache\File::setCacheDirectory(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache');
//Large sonst fehlt Browser_Type / Crawler um Bots zu erkennen
\Crossjoin\Browscap\Browscap::setDatasetType(\Crossjoin\Browscap\Browscap::DATASET_TYPE_LARGE);
// disable automatic updates
$updater = new \Crossjoin\Browscap\Updater\None();
\Crossjoin\Browscap\Browscap::setUpdater($updater);
$browscap = new \Crossjoin\Browscap\Browscap(false); //autoUpdate = false
$settings = $browscap->getBrowser($UserAgent)->getData();
return $settings;
/*
stdClass Object
(
[browser_name_regex] => /^Yandex\/1\.01\.001 \(compatible; Win16; .*\)$/
[browser_name_pattern] => Yandex/1.01.001 (compatible; Win16; *)
[parent] => Yandex
[comment] => Yandex
[browser] => Yandex
[browser_type] => Bot/Crawler
[browser_maker] => Yandex
[crawler] => true
.....
stdClass Object
(
[browser_name_regex] => /^Googlebot\-Image.*$/
[browser_name_pattern] => Googlebot-Image*
[parent] => Googlebot
[browser] => Googlebot-Image
[comment] => Googlebot
[browser_type] => Bot/Crawler
[browser_maker] => Google Inc
[crawler] => true
.....
*/
}
|
[
"protected",
"static",
"function",
"getBrowscapInfo",
"(",
"$",
"UserAgent",
"=",
"false",
")",
"{",
"// Check if user agent present",
"if",
"(",
"$",
"UserAgent",
"===",
"false",
")",
"{",
"return",
"false",
";",
"// No user agent, no search.",
"}",
"// set an own cache directory (otherwise the system temp directory is used)",
"\\",
"Crossjoin",
"\\",
"Browscap",
"\\",
"Cache",
"\\",
"File",
"::",
"setCacheDirectory",
"(",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
"DIRECTORY_SEPARATOR",
".",
"'cache'",
")",
";",
"//Large sonst fehlt Browser_Type / Crawler um Bots zu erkennen",
"\\",
"Crossjoin",
"\\",
"Browscap",
"\\",
"Browscap",
"::",
"setDatasetType",
"(",
"\\",
"Crossjoin",
"\\",
"Browscap",
"\\",
"Browscap",
"::",
"DATASET_TYPE_LARGE",
")",
";",
"// disable automatic updates ",
"$",
"updater",
"=",
"new",
"\\",
"Crossjoin",
"\\",
"Browscap",
"\\",
"Updater",
"\\",
"None",
"(",
")",
";",
"\\",
"Crossjoin",
"\\",
"Browscap",
"\\",
"Browscap",
"::",
"setUpdater",
"(",
"$",
"updater",
")",
";",
"$",
"browscap",
"=",
"new",
"\\",
"Crossjoin",
"\\",
"Browscap",
"\\",
"Browscap",
"(",
"false",
")",
";",
"//autoUpdate = false",
"$",
"settings",
"=",
"$",
"browscap",
"->",
"getBrowser",
"(",
"$",
"UserAgent",
")",
"->",
"getData",
"(",
")",
";",
"return",
"$",
"settings",
";",
"/*\n stdClass Object\n (\n [browser_name_regex] => /^Yandex\\/1\\.01\\.001 \\(compatible; Win16; .*\\)$/\n [browser_name_pattern] => Yandex/1.01.001 (compatible; Win16; *)\n [parent] => Yandex\n [comment] => Yandex\n [browser] => Yandex\n [browser_type] => Bot/Crawler\n [browser_maker] => Yandex\n [crawler] => true\n .....\n stdClass Object\n (\n [browser_name_regex] => /^Googlebot\\-Image.*$/\n [browser_name_pattern] => Googlebot-Image*\n [parent] => Googlebot\n [browser] => Googlebot-Image\n [comment] => Googlebot\n [browser_type] => Bot/Crawler\n [browser_maker] => Google Inc\n [crawler] => true\n .....\n */",
"}"
] |
Get Browscap info for the user agent string
@param string $UserAgent
@return stdClass Object
|
[
"Get",
"Browscap",
"info",
"for",
"the",
"user",
"agent",
"string"
] |
b27cc1d80932af7d29b9f345da9132842d2adbce
|
https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/classes/CheckBotAgentExtended.php#L125-L171
|
235,169
|
accompli/accompli
|
src/Deployment/Workspace.php
|
Workspace.getOtherDirectories
|
public function getOtherDirectories()
{
$directories = array();
foreach ($this->otherDirectories as $directory) {
$directories[] = sprintf('%s/%s', $this->getHost()->getPath(), $directory);
}
return $directories;
}
|
php
|
public function getOtherDirectories()
{
$directories = array();
foreach ($this->otherDirectories as $directory) {
$directories[] = sprintf('%s/%s', $this->getHost()->getPath(), $directory);
}
return $directories;
}
|
[
"public",
"function",
"getOtherDirectories",
"(",
")",
"{",
"$",
"directories",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"otherDirectories",
"as",
"$",
"directory",
")",
"{",
"$",
"directories",
"[",
"]",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getHost",
"(",
")",
"->",
"getPath",
"(",
")",
",",
"$",
"directory",
")",
";",
"}",
"return",
"$",
"directories",
";",
"}"
] |
Returns the array with absolute paths to other directories.
@return array
|
[
"Returns",
"the",
"array",
"with",
"absolute",
"paths",
"to",
"other",
"directories",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Workspace.php#L109-L117
|
235,170
|
runcmf/runbb
|
src/RunBB/Controller/Admin/Users.php
|
Users.ipstats
|
public function ipstats($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.users.ipstats');
// Fetch ip count
$num_ips = $this->model->getNumIp($args['id']);
// Determine the ip offset (based on $_GET['p'])
$num_pages = ceil($num_ips / 50);
$p = (!Input::query('p') || Input::query('p') <= 1 || Input::query('p') > $num_pages) ?
1 : intval(Input::query('p'));
$start_from = 50 * ($p - 1);
return View::setPageInfo([
'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'),
__('Users'), __('Results head')],
'active_page' => 'admin',
'admin_console' => true,
'page' => $p,
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' .
Url::paginateOld($num_pages, $p, '?ip_stats=' . $args['id']),
'start_from' => $start_from,
'ip_data' => $this->model->getIpStats($args['id'], $start_from),
])->display('@forum/admin/users/search_ip');
}
|
php
|
public function ipstats($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.users.ipstats');
// Fetch ip count
$num_ips = $this->model->getNumIp($args['id']);
// Determine the ip offset (based on $_GET['p'])
$num_pages = ceil($num_ips / 50);
$p = (!Input::query('p') || Input::query('p') <= 1 || Input::query('p') > $num_pages) ?
1 : intval(Input::query('p'));
$start_from = 50 * ($p - 1);
return View::setPageInfo([
'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'),
__('Users'), __('Results head')],
'active_page' => 'admin',
'admin_console' => true,
'page' => $p,
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' .
Url::paginateOld($num_pages, $p, '?ip_stats=' . $args['id']),
'start_from' => $start_from,
'ip_data' => $this->model->getIpStats($args['id'], $start_from),
])->display('@forum/admin/users/search_ip');
}
|
[
"public",
"function",
"ipstats",
"(",
"$",
"req",
",",
"$",
"res",
",",
"$",
"args",
")",
"{",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'controller.admin.users.ipstats'",
")",
";",
"// Fetch ip count",
"$",
"num_ips",
"=",
"$",
"this",
"->",
"model",
"->",
"getNumIp",
"(",
"$",
"args",
"[",
"'id'",
"]",
")",
";",
"// Determine the ip offset (based on $_GET['p'])",
"$",
"num_pages",
"=",
"ceil",
"(",
"$",
"num_ips",
"/",
"50",
")",
";",
"$",
"p",
"=",
"(",
"!",
"Input",
"::",
"query",
"(",
"'p'",
")",
"||",
"Input",
"::",
"query",
"(",
"'p'",
")",
"<=",
"1",
"||",
"Input",
"::",
"query",
"(",
"'p'",
")",
">",
"$",
"num_pages",
")",
"?",
"1",
":",
"intval",
"(",
"Input",
"::",
"query",
"(",
"'p'",
")",
")",
";",
"$",
"start_from",
"=",
"50",
"*",
"(",
"$",
"p",
"-",
"1",
")",
";",
"return",
"View",
"::",
"setPageInfo",
"(",
"[",
"'title'",
"=>",
"[",
"Utils",
"::",
"escape",
"(",
"ForumSettings",
"::",
"get",
"(",
"'o_board_title'",
")",
")",
",",
"__",
"(",
"'Admin'",
")",
",",
"__",
"(",
"'Users'",
")",
",",
"__",
"(",
"'Results head'",
")",
"]",
",",
"'active_page'",
"=>",
"'admin'",
",",
"'admin_console'",
"=>",
"true",
",",
"'page'",
"=>",
"$",
"p",
",",
"'paging_links'",
"=>",
"'<span class=\"pages-label\">'",
".",
"__",
"(",
"'Pages'",
")",
".",
"' </span>'",
".",
"Url",
"::",
"paginateOld",
"(",
"$",
"num_pages",
",",
"$",
"p",
",",
"'?ip_stats='",
".",
"$",
"args",
"[",
"'id'",
"]",
")",
",",
"'start_from'",
"=>",
"$",
"start_from",
",",
"'ip_data'",
"=>",
"$",
"this",
"->",
"model",
"->",
"getIpStats",
"(",
"$",
"args",
"[",
"'id'",
"]",
",",
"$",
"start_from",
")",
",",
"]",
")",
"->",
"display",
"(",
"'@forum/admin/users/search_ip'",
")",
";",
"}"
] |
Show IP statistics for a certain user ID
|
[
"Show",
"IP",
"statistics",
"for",
"a",
"certain",
"user",
"ID"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Controller/Admin/Users.php#L146-L171
|
235,171
|
runcmf/runbb
|
src/RunBB/Controller/Admin/Users.php
|
Users.showusers
|
public function showusers($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.users.showusers');
$search_ip = $args['ip'];
if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $search_ip) &&
!@preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:'.
'[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|'.
'(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:'.
'([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:)'.
'{0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|'.
'(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:)'.
'{0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|'.
'(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|'.
'(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::'.
'([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|'.
'(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $search_ip)) {
throw new RunBBException(__('Bad IP message'), 400);
}
// Fetch user count
$num_users = $this->model->getNumUsersIp($search_ip);
// Determine the user offset (based on $_GET['p'])
$num_pages = ceil($num_users / 50);
$p = (!Input::query('p') || Input::query('p') <= 1 || Input::query('p') > $num_pages) ?
1 : intval(Input::query('p'));
$start_from = 50 * ($p - 1);
return View::setPageInfo([
'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'),
__('Users'), __('Results head')],
'active_page' => 'admin',
'admin_console' => true,
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' .
Url::paginateOld($num_pages, $p, '?ip_stats=' . $search_ip),
'page' => $p,
'start_from' => $start_from,
'info' => $this->model->getInfoPoster($search_ip, $start_from),
])->display('@forum/admin/users/show_users');
}
|
php
|
public function showusers($req, $res, $args)
{
Container::get('hooks')->fire('controller.admin.users.showusers');
$search_ip = $args['ip'];
if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $search_ip) &&
!@preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:'.
'[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|'.
'(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:'.
'([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:)'.
'{0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|'.
'(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:)'.
'{0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|'.
'(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|'.
'(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::'.
'([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|'.
'(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $search_ip)) {
throw new RunBBException(__('Bad IP message'), 400);
}
// Fetch user count
$num_users = $this->model->getNumUsersIp($search_ip);
// Determine the user offset (based on $_GET['p'])
$num_pages = ceil($num_users / 50);
$p = (!Input::query('p') || Input::query('p') <= 1 || Input::query('p') > $num_pages) ?
1 : intval(Input::query('p'));
$start_from = 50 * ($p - 1);
return View::setPageInfo([
'title' => [Utils::escape(ForumSettings::get('o_board_title')), __('Admin'),
__('Users'), __('Results head')],
'active_page' => 'admin',
'admin_console' => true,
'paging_links' => '<span class="pages-label">' . __('Pages') . ' </span>' .
Url::paginateOld($num_pages, $p, '?ip_stats=' . $search_ip),
'page' => $p,
'start_from' => $start_from,
'info' => $this->model->getInfoPoster($search_ip, $start_from),
])->display('@forum/admin/users/show_users');
}
|
[
"public",
"function",
"showusers",
"(",
"$",
"req",
",",
"$",
"res",
",",
"$",
"args",
")",
"{",
"Container",
"::",
"get",
"(",
"'hooks'",
")",
"->",
"fire",
"(",
"'controller.admin.users.showusers'",
")",
";",
"$",
"search_ip",
"=",
"$",
"args",
"[",
"'ip'",
"]",
";",
"if",
"(",
"!",
"@",
"preg_match",
"(",
"'%^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$%'",
",",
"$",
"search_ip",
")",
"&&",
"!",
"@",
"preg_match",
"(",
"'%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:'",
".",
"'[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|'",
".",
"'(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:'",
".",
"'([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:)'",
".",
"'{0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|'",
".",
"'(\\d{1,2}))\\b)\\.){3}(\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b))|(([0-9A-Fa-f]{1,4}:)'",
".",
"'{0,5}:((\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b)\\.){3}(\\b((25[0-5])|(1\\d{2})|'",
".",
"'(2[0-4]\\d)|(\\d{1,2}))\\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|'",
".",
"'(\\d{1,2}))\\b)\\.){3}(\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b))|([0-9A-Fa-f]{1,4}::'",
".",
"'([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|'",
".",
"'(([0-9A-Fa-f]{1,4}:){1,7}:))$%'",
",",
"$",
"search_ip",
")",
")",
"{",
"throw",
"new",
"RunBBException",
"(",
"__",
"(",
"'Bad IP message'",
")",
",",
"400",
")",
";",
"}",
"// Fetch user count",
"$",
"num_users",
"=",
"$",
"this",
"->",
"model",
"->",
"getNumUsersIp",
"(",
"$",
"search_ip",
")",
";",
"// Determine the user offset (based on $_GET['p'])",
"$",
"num_pages",
"=",
"ceil",
"(",
"$",
"num_users",
"/",
"50",
")",
";",
"$",
"p",
"=",
"(",
"!",
"Input",
"::",
"query",
"(",
"'p'",
")",
"||",
"Input",
"::",
"query",
"(",
"'p'",
")",
"<=",
"1",
"||",
"Input",
"::",
"query",
"(",
"'p'",
")",
">",
"$",
"num_pages",
")",
"?",
"1",
":",
"intval",
"(",
"Input",
"::",
"query",
"(",
"'p'",
")",
")",
";",
"$",
"start_from",
"=",
"50",
"*",
"(",
"$",
"p",
"-",
"1",
")",
";",
"return",
"View",
"::",
"setPageInfo",
"(",
"[",
"'title'",
"=>",
"[",
"Utils",
"::",
"escape",
"(",
"ForumSettings",
"::",
"get",
"(",
"'o_board_title'",
")",
")",
",",
"__",
"(",
"'Admin'",
")",
",",
"__",
"(",
"'Users'",
")",
",",
"__",
"(",
"'Results head'",
")",
"]",
",",
"'active_page'",
"=>",
"'admin'",
",",
"'admin_console'",
"=>",
"true",
",",
"'paging_links'",
"=>",
"'<span class=\"pages-label\">'",
".",
"__",
"(",
"'Pages'",
")",
".",
"' </span>'",
".",
"Url",
"::",
"paginateOld",
"(",
"$",
"num_pages",
",",
"$",
"p",
",",
"'?ip_stats='",
".",
"$",
"search_ip",
")",
",",
"'page'",
"=>",
"$",
"p",
",",
"'start_from'",
"=>",
"$",
"start_from",
",",
"'info'",
"=>",
"$",
"this",
"->",
"model",
"->",
"getInfoPoster",
"(",
"$",
"search_ip",
",",
"$",
"start_from",
")",
",",
"]",
")",
"->",
"display",
"(",
"'@forum/admin/users/show_users'",
")",
";",
"}"
] |
Show IP statistics for a certain user IP
|
[
"Show",
"IP",
"statistics",
"for",
"a",
"certain",
"user",
"IP"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Controller/Admin/Users.php#L174-L216
|
235,172
|
runcmf/runbb
|
src/RunBB/Core/Remote.php
|
Remote.getLangRepoList
|
public function getLangRepoList()
{
$data = json_decode(
$this->getRemoteContents($this->translationsInfoUrl)
);
$content = $data->encoding === 'base64' ? base64_decode($data->content) : [];
return json_decode($content);
}
|
php
|
public function getLangRepoList()
{
$data = json_decode(
$this->getRemoteContents($this->translationsInfoUrl)
);
$content = $data->encoding === 'base64' ? base64_decode($data->content) : [];
return json_decode($content);
}
|
[
"public",
"function",
"getLangRepoList",
"(",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"getRemoteContents",
"(",
"$",
"this",
"->",
"translationsInfoUrl",
")",
")",
";",
"$",
"content",
"=",
"$",
"data",
"->",
"encoding",
"===",
"'base64'",
"?",
"base64_decode",
"(",
"$",
"data",
"->",
"content",
")",
":",
"[",
"]",
";",
"return",
"json_decode",
"(",
"$",
"content",
")",
";",
"}"
] |
Get language list from repo
@return array
|
[
"Get",
"language",
"list",
"from",
"repo"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Remote.php#L48-L56
|
235,173
|
runcmf/runbb
|
src/RunBB/Core/Remote.php
|
Remote.getExtensionsInfoList
|
public function getExtensionsInfoList()
{
$data = json_decode(
$this->getRemoteContents($this->extensionsInfofoUrl)
);
$content = $data->encoding === 'base64' ? base64_decode($data->content) : [];
return json_decode($content, true);// true to array
}
|
php
|
public function getExtensionsInfoList()
{
$data = json_decode(
$this->getRemoteContents($this->extensionsInfofoUrl)
);
$content = $data->encoding === 'base64' ? base64_decode($data->content) : [];
return json_decode($content, true);// true to array
}
|
[
"public",
"function",
"getExtensionsInfoList",
"(",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"getRemoteContents",
"(",
"$",
"this",
"->",
"extensionsInfofoUrl",
")",
")",
";",
"$",
"content",
"=",
"$",
"data",
"->",
"encoding",
"===",
"'base64'",
"?",
"base64_decode",
"(",
"$",
"data",
"->",
"content",
")",
":",
"[",
"]",
";",
"return",
"json_decode",
"(",
"$",
"content",
",",
"true",
")",
";",
"// true to array",
"}"
] |
Get Extensions list from repo
@return array
|
[
"Get",
"Extensions",
"list",
"from",
"repo"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Remote.php#L76-L84
|
235,174
|
runcmf/runbb
|
src/RunBB/Core/Remote.php
|
Remote.getRemoteContents
|
public function getRemoteContents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null)
{
$method = (function_exists('curl_exec') &&
!ini_get('safe_mode') &&
!ini_get('open_basedir')) ?
'curlGetContents' : 'fsockGetContents';
return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
}
|
php
|
public function getRemoteContents(&$url, $timeout = 30, $redirect_max = 5, $ua = 'Mozilla/5.0', $fp = null)
{
$method = (function_exists('curl_exec') &&
!ini_get('safe_mode') &&
!ini_get('open_basedir')) ?
'curlGetContents' : 'fsockGetContents';
return $this->$method( $url, $timeout, $redirect_max, $ua, $fp );
}
|
[
"public",
"function",
"getRemoteContents",
"(",
"&",
"$",
"url",
",",
"$",
"timeout",
"=",
"30",
",",
"$",
"redirect_max",
"=",
"5",
",",
"$",
"ua",
"=",
"'Mozilla/5.0'",
",",
"$",
"fp",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"(",
"function_exists",
"(",
"'curl_exec'",
")",
"&&",
"!",
"ini_get",
"(",
"'safe_mode'",
")",
"&&",
"!",
"ini_get",
"(",
"'open_basedir'",
")",
")",
"?",
"'curlGetContents'",
":",
"'fsockGetContents'",
";",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"url",
",",
"$",
"timeout",
",",
"$",
"redirect_max",
",",
"$",
"ua",
",",
"$",
"fp",
")",
";",
"}"
] |
Get remote contents
from elFinder Core class. v 2.1
@param string $url target url
@param int $timeout timeout (sec)
@param int $redirect_max redirect max count
@param string $ua
@param resource $fp
@return string or bool(false)
@retval string contents
@rettval false error
@author Naoki Sawada
|
[
"Get",
"remote",
"contents"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Remote.php#L101-L108
|
235,175
|
runcmf/runbb
|
src/RunBB/Core/Remote.php
|
Remote.curlGetContents
|
protected function curlGetContents(&$url, $timeout, $redirect_max, $ua, $outfp)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
if ($outfp) {
curl_setopt($ch, CURLOPT_FILE, $outfp);
} else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
}
curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
$result = curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $outfp? $outfp : $result;
}
|
php
|
protected function curlGetContents(&$url, $timeout, $redirect_max, $ua, $outfp)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
if ($outfp) {
curl_setopt($ch, CURLOPT_FILE, $outfp);
} else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
}
curl_setopt($ch, CURLOPT_LOW_SPEED_LIMIT, 1);
curl_setopt($ch, CURLOPT_LOW_SPEED_TIME, $timeout);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $redirect_max);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
$result = curl_exec($ch);
$url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $outfp? $outfp : $result;
}
|
[
"protected",
"function",
"curlGetContents",
"(",
"&",
"$",
"url",
",",
"$",
"timeout",
",",
"$",
"redirect_max",
",",
"$",
"ua",
",",
"$",
"outfp",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"if",
"(",
"$",
"outfp",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FILE",
",",
"$",
"outfp",
")",
";",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_BINARYTRANSFER",
",",
"true",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_LOW_SPEED_LIMIT",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_LOW_SPEED_TIME",
",",
"$",
"timeout",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_MAXREDIRS",
",",
"$",
"redirect_max",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_USERAGENT",
",",
"$",
"ua",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"url",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_EFFECTIVE_URL",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"return",
"$",
"outfp",
"?",
"$",
"outfp",
":",
"$",
"result",
";",
"}"
] |
Get remote contents with cURL
from elFinder Core class. v 2.1
@param string $url target url
@param int $timeout timeout (sec)
@param int $redirect_max redirect max count
@param string $ua
@param resource $outfp
@return string or bool(false)
@retval string contents
@retval false error
@author Naoki Sawada
|
[
"Get",
"remote",
"contents",
"with",
"cURL"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Remote.php#L125-L146
|
235,176
|
accompli/accompli
|
src/Console/Helper/TitleBlock.php
|
TitleBlock.render
|
public function render()
{
$this->output->writeln('');
$lineLength = $this->getTerminalWidth();
$lines = explode(PHP_EOL, wordwrap($this->message, $lineLength - (strlen($this->blockStyles[$this->style]['prefix']) + 3), PHP_EOL, true));
array_unshift($lines, ' ');
array_push($lines, ' ');
foreach ($lines as $i => $line) {
$prefix = str_repeat(' ', strlen($this->blockStyles[$this->style]['prefix']));
if ($i === 1) {
$prefix = $this->blockStyles[$this->style]['prefix'];
}
$line = sprintf(' %s %s', $prefix, $line);
$this->output->writeln(sprintf('<%s>%s%s</>', $this->blockStyles[$this->style]['style'], $line, str_repeat(' ', $lineLength - Helper::strlenWithoutDecoration($this->output->getFormatter(), $line))));
}
$this->output->writeln('');
}
|
php
|
public function render()
{
$this->output->writeln('');
$lineLength = $this->getTerminalWidth();
$lines = explode(PHP_EOL, wordwrap($this->message, $lineLength - (strlen($this->blockStyles[$this->style]['prefix']) + 3), PHP_EOL, true));
array_unshift($lines, ' ');
array_push($lines, ' ');
foreach ($lines as $i => $line) {
$prefix = str_repeat(' ', strlen($this->blockStyles[$this->style]['prefix']));
if ($i === 1) {
$prefix = $this->blockStyles[$this->style]['prefix'];
}
$line = sprintf(' %s %s', $prefix, $line);
$this->output->writeln(sprintf('<%s>%s%s</>', $this->blockStyles[$this->style]['style'], $line, str_repeat(' ', $lineLength - Helper::strlenWithoutDecoration($this->output->getFormatter(), $line))));
}
$this->output->writeln('');
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"$",
"lineLength",
"=",
"$",
"this",
"->",
"getTerminalWidth",
"(",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"PHP_EOL",
",",
"wordwrap",
"(",
"$",
"this",
"->",
"message",
",",
"$",
"lineLength",
"-",
"(",
"strlen",
"(",
"$",
"this",
"->",
"blockStyles",
"[",
"$",
"this",
"->",
"style",
"]",
"[",
"'prefix'",
"]",
")",
"+",
"3",
")",
",",
"PHP_EOL",
",",
"true",
")",
")",
";",
"array_unshift",
"(",
"$",
"lines",
",",
"' '",
")",
";",
"array_push",
"(",
"$",
"lines",
",",
"' '",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"i",
"=>",
"$",
"line",
")",
"{",
"$",
"prefix",
"=",
"str_repeat",
"(",
"' '",
",",
"strlen",
"(",
"$",
"this",
"->",
"blockStyles",
"[",
"$",
"this",
"->",
"style",
"]",
"[",
"'prefix'",
"]",
")",
")",
";",
"if",
"(",
"$",
"i",
"===",
"1",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"blockStyles",
"[",
"$",
"this",
"->",
"style",
"]",
"[",
"'prefix'",
"]",
";",
"}",
"$",
"line",
"=",
"sprintf",
"(",
"' %s %s'",
",",
"$",
"prefix",
",",
"$",
"line",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'<%s>%s%s</>'",
",",
"$",
"this",
"->",
"blockStyles",
"[",
"$",
"this",
"->",
"style",
"]",
"[",
"'style'",
"]",
",",
"$",
"line",
",",
"str_repeat",
"(",
"' '",
",",
"$",
"lineLength",
"-",
"Helper",
"::",
"strlenWithoutDecoration",
"(",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
",",
"$",
"line",
")",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"}"
] |
Renders the title block to output.
|
[
"Renders",
"the",
"title",
"block",
"to",
"output",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Helper/TitleBlock.php#L75-L96
|
235,177
|
runcmf/runbb
|
src/RunBB/Core/Url.php
|
Url.base
|
public static function base()
{
return Request::getUri()->getScheme().'://'.Request::getUri()->getHost().
Request::getUri()->getBasePath();
}
|
php
|
public static function base()
{
return Request::getUri()->getScheme().'://'.Request::getUri()->getHost().
Request::getUri()->getBasePath();
}
|
[
"public",
"static",
"function",
"base",
"(",
")",
"{",
"return",
"Request",
"::",
"getUri",
"(",
")",
"->",
"getScheme",
"(",
")",
".",
"'://'",
".",
"Request",
"::",
"getUri",
"(",
")",
"->",
"getHost",
"(",
")",
".",
"Request",
"::",
"getUri",
"(",
")",
"->",
"getBasePath",
"(",
")",
";",
"}"
] |
Fetch the base_url, optionally support HTTPS and HTTP
@return string
|
[
"Fetch",
"the",
"base_url",
"optionally",
"support",
"HTTPS",
"and",
"HTTP"
] |
d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463
|
https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Url.php#L819-L823
|
235,178
|
someline/starter-framework
|
src/Someline/Base/Repositories/Eloquent/Repository.php
|
Repository.modelWhere
|
protected function modelWhere($column, $value = null)
{
$this->model = $this->model->where($column, $value);
return $this;
}
|
php
|
protected function modelWhere($column, $value = null)
{
$this->model = $this->model->where($column, $value);
return $this;
}
|
[
"protected",
"function",
"modelWhere",
"(",
"$",
"column",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"this",
"->",
"model",
"->",
"where",
"(",
"$",
"column",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a basic where clause to the model.
@param string|array|\Closure $column
@param mixed $value
@return $this
|
[
"Add",
"a",
"basic",
"where",
"clause",
"to",
"the",
"model",
"."
] |
38d3e97ca75dadb05bdc9020f73c78653dbecf15
|
https://github.com/someline/starter-framework/blob/38d3e97ca75dadb05bdc9020f73c78653dbecf15/src/Someline/Base/Repositories/Eloquent/Repository.php#L175-L179
|
235,179
|
someline/starter-framework
|
src/Someline/Base/Repositories/Eloquent/Repository.php
|
Repository.where
|
public function where(array $where)
{
$this->applyCriteria();
$this->applyScope();
$this->applyConditions($where);
return $this;
}
|
php
|
public function where(array $where)
{
$this->applyCriteria();
$this->applyScope();
$this->applyConditions($where);
return $this;
}
|
[
"public",
"function",
"where",
"(",
"array",
"$",
"where",
")",
"{",
"$",
"this",
"->",
"applyCriteria",
"(",
")",
";",
"$",
"this",
"->",
"applyScope",
"(",
")",
";",
"$",
"this",
"->",
"applyConditions",
"(",
"$",
"where",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Find data by where conditions
@param array $where
@return $this
|
[
"Find",
"data",
"by",
"where",
"conditions"
] |
38d3e97ca75dadb05bdc9020f73c78653dbecf15
|
https://github.com/someline/starter-framework/blob/38d3e97ca75dadb05bdc9020f73c78653dbecf15/src/Someline/Base/Repositories/Eloquent/Repository.php#L214-L222
|
235,180
|
makinacorpus/drupal-ucms
|
ucms_tree/src/EventDispatcher/ContextPaneEventSubscriber.php
|
ContextPaneEventSubscriber.onContextPaneInit
|
public function onContextPaneInit(ContextPaneEvent $event)
{
$site = null;
$contextPane = $event->getContextPane();
if ($this->siteManager->hasContext()) {
$site = $this->siteManager->getContext();
}
// Add admin actions on the tree listing page
if ('admin/dashboard/tree' === current_path()) {
$canCreate = false;
if ($site) {
$canCreate = $this->menuAccess->canCreateMenu($this->currentUser, $site);
} else {
$canCreate = $this->menuAccess->canCreateMenu($this->currentUser);
}
if ($canCreate) {
$contextPane->addActions([
new Action($this->t("Create menu"), 'admin/dashboard/tree/add', [], 'plus', 0, true, true),
]);
}
}
if ($site) {
// Add the tree structure as a new tab
$contextPane
->addTab('tree', $this->t("Menu tree"), 'bars')
->add($this->renderCurrentTree(), 'tree')
;
if (preg_match('@^admin/dashboard/tree/(\d+)$@', current_path())) {
// Default tab on tree edit is the cart
$contextPane->setDefaultTab('cart');
} elseif (!$contextPane->getRealDefaultTab()) {
// Else it's the tree
$contextPane->setDefaultTab('tree');
}
}
}
|
php
|
public function onContextPaneInit(ContextPaneEvent $event)
{
$site = null;
$contextPane = $event->getContextPane();
if ($this->siteManager->hasContext()) {
$site = $this->siteManager->getContext();
}
// Add admin actions on the tree listing page
if ('admin/dashboard/tree' === current_path()) {
$canCreate = false;
if ($site) {
$canCreate = $this->menuAccess->canCreateMenu($this->currentUser, $site);
} else {
$canCreate = $this->menuAccess->canCreateMenu($this->currentUser);
}
if ($canCreate) {
$contextPane->addActions([
new Action($this->t("Create menu"), 'admin/dashboard/tree/add', [], 'plus', 0, true, true),
]);
}
}
if ($site) {
// Add the tree structure as a new tab
$contextPane
->addTab('tree', $this->t("Menu tree"), 'bars')
->add($this->renderCurrentTree(), 'tree')
;
if (preg_match('@^admin/dashboard/tree/(\d+)$@', current_path())) {
// Default tab on tree edit is the cart
$contextPane->setDefaultTab('cart');
} elseif (!$contextPane->getRealDefaultTab()) {
// Else it's the tree
$contextPane->setDefaultTab('tree');
}
}
}
|
[
"public",
"function",
"onContextPaneInit",
"(",
"ContextPaneEvent",
"$",
"event",
")",
"{",
"$",
"site",
"=",
"null",
";",
"$",
"contextPane",
"=",
"$",
"event",
"->",
"getContextPane",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"siteManager",
"->",
"hasContext",
"(",
")",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"siteManager",
"->",
"getContext",
"(",
")",
";",
"}",
"// Add admin actions on the tree listing page",
"if",
"(",
"'admin/dashboard/tree'",
"===",
"current_path",
"(",
")",
")",
"{",
"$",
"canCreate",
"=",
"false",
";",
"if",
"(",
"$",
"site",
")",
"{",
"$",
"canCreate",
"=",
"$",
"this",
"->",
"menuAccess",
"->",
"canCreateMenu",
"(",
"$",
"this",
"->",
"currentUser",
",",
"$",
"site",
")",
";",
"}",
"else",
"{",
"$",
"canCreate",
"=",
"$",
"this",
"->",
"menuAccess",
"->",
"canCreateMenu",
"(",
"$",
"this",
"->",
"currentUser",
")",
";",
"}",
"if",
"(",
"$",
"canCreate",
")",
"{",
"$",
"contextPane",
"->",
"addActions",
"(",
"[",
"new",
"Action",
"(",
"$",
"this",
"->",
"t",
"(",
"\"Create menu\"",
")",
",",
"'admin/dashboard/tree/add'",
",",
"[",
"]",
",",
"'plus'",
",",
"0",
",",
"true",
",",
"true",
")",
",",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"site",
")",
"{",
"// Add the tree structure as a new tab",
"$",
"contextPane",
"->",
"addTab",
"(",
"'tree'",
",",
"$",
"this",
"->",
"t",
"(",
"\"Menu tree\"",
")",
",",
"'bars'",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"renderCurrentTree",
"(",
")",
",",
"'tree'",
")",
";",
"if",
"(",
"preg_match",
"(",
"'@^admin/dashboard/tree/(\\d+)$@'",
",",
"current_path",
"(",
")",
")",
")",
"{",
"// Default tab on tree edit is the cart",
"$",
"contextPane",
"->",
"setDefaultTab",
"(",
"'cart'",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"contextPane",
"->",
"getRealDefaultTab",
"(",
")",
")",
"{",
"// Else it's the tree",
"$",
"contextPane",
"->",
"setDefaultTab",
"(",
"'tree'",
")",
";",
"}",
"}",
"}"
] |
On context pane init.
@param ContextPaneEvent $event
|
[
"On",
"context",
"pane",
"init",
"."
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/EventDispatcher/ContextPaneEventSubscriber.php#L54-L93
|
235,181
|
makinacorpus/drupal-ucms
|
ucms_tree/src/EventDispatcher/ContextPaneEventSubscriber.php
|
ContextPaneEventSubscriber.renderCurrentTree
|
private function renderCurrentTree()
{
$site = $this->siteManager->getContext();
// Get all trees for this site
$menus = $this
->treeManager
->getMenuStorage()
->loadWithConditions(['site_id' => $site->getId()])
;
$build = [
'#prefix' => '<div class="col-xs-12">',
'#suffix' => '</div>',
'#attached' => [
'css' => [
drupal_get_path('module', 'ucms_tree').'/ucms_tree.css',
],
],
];
foreach ($menus as $menu) {
$build[$menu->getName()] = [
'#theme' => 'umenu__context_pane',
'#tree' => $this->treeManager->buildTree($menu->getId(), false),
'#prefix' => "<h3>" . $menu->getTitle() . "</h3>",
];
}
return $build;
}
|
php
|
private function renderCurrentTree()
{
$site = $this->siteManager->getContext();
// Get all trees for this site
$menus = $this
->treeManager
->getMenuStorage()
->loadWithConditions(['site_id' => $site->getId()])
;
$build = [
'#prefix' => '<div class="col-xs-12">',
'#suffix' => '</div>',
'#attached' => [
'css' => [
drupal_get_path('module', 'ucms_tree').'/ucms_tree.css',
],
],
];
foreach ($menus as $menu) {
$build[$menu->getName()] = [
'#theme' => 'umenu__context_pane',
'#tree' => $this->treeManager->buildTree($menu->getId(), false),
'#prefix' => "<h3>" . $menu->getTitle() . "</h3>",
];
}
return $build;
}
|
[
"private",
"function",
"renderCurrentTree",
"(",
")",
"{",
"$",
"site",
"=",
"$",
"this",
"->",
"siteManager",
"->",
"getContext",
"(",
")",
";",
"// Get all trees for this site",
"$",
"menus",
"=",
"$",
"this",
"->",
"treeManager",
"->",
"getMenuStorage",
"(",
")",
"->",
"loadWithConditions",
"(",
"[",
"'site_id'",
"=>",
"$",
"site",
"->",
"getId",
"(",
")",
"]",
")",
";",
"$",
"build",
"=",
"[",
"'#prefix'",
"=>",
"'<div class=\"col-xs-12\">'",
",",
"'#suffix'",
"=>",
"'</div>'",
",",
"'#attached'",
"=>",
"[",
"'css'",
"=>",
"[",
"drupal_get_path",
"(",
"'module'",
",",
"'ucms_tree'",
")",
".",
"'/ucms_tree.css'",
",",
"]",
",",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"menus",
"as",
"$",
"menu",
")",
"{",
"$",
"build",
"[",
"$",
"menu",
"->",
"getName",
"(",
")",
"]",
"=",
"[",
"'#theme'",
"=>",
"'umenu__context_pane'",
",",
"'#tree'",
"=>",
"$",
"this",
"->",
"treeManager",
"->",
"buildTree",
"(",
"$",
"menu",
"->",
"getId",
"(",
")",
",",
"false",
")",
",",
"'#prefix'",
"=>",
"\"<h3>\"",
".",
"$",
"menu",
"->",
"getTitle",
"(",
")",
".",
"\"</h3>\"",
",",
"]",
";",
"}",
"return",
"$",
"build",
";",
"}"
] |
Render current tree
|
[
"Render",
"current",
"tree"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/EventDispatcher/ContextPaneEventSubscriber.php#L98-L128
|
235,182
|
makinacorpus/drupal-ucms
|
ucms_group/src/Controller/AutocompleteController.php
|
AutocompleteController.siteAddAutocompleteAction
|
public function siteAddAutocompleteAction(Request $request, Group $group, $string)
{
if (!$this->isGranted(Access::ACL_PERM_MANAGE_SITES, $group)) {
throw $this->createAccessDeniedException();
}
$database = $this->getDatabaseConnection();
$q = $database
->select('ucms_site', 's')
->fields('s', ['id', 'title_admin'])
->isNull('s.group_id')
->condition(
(new \DatabaseCondition('OR'))
->condition('s.title', '%' . $database->escapeLike($string) . '%', 'LIKE')
->condition('s.title_admin', '%' . $database->escapeLike($string) . '%', 'LIKE')
->condition('s.http_host', '%' . $database->escapeLike($string) . '%', 'LIKE')
)
->orderBy('s.title_admin', 'asc')
->groupBy('s.id')
->range(0, 16)
->addTag('ucms_site_access')
;
$suggest = [];
foreach ($q->execute()->fetchAll() as $record) {
$key = $record->title_admin . ' [' . $record->id . ']';
$suggest[$key] = check_plain($record->title_admin);
}
return new JsonResponse($suggest);
}
|
php
|
public function siteAddAutocompleteAction(Request $request, Group $group, $string)
{
if (!$this->isGranted(Access::ACL_PERM_MANAGE_SITES, $group)) {
throw $this->createAccessDeniedException();
}
$database = $this->getDatabaseConnection();
$q = $database
->select('ucms_site', 's')
->fields('s', ['id', 'title_admin'])
->isNull('s.group_id')
->condition(
(new \DatabaseCondition('OR'))
->condition('s.title', '%' . $database->escapeLike($string) . '%', 'LIKE')
->condition('s.title_admin', '%' . $database->escapeLike($string) . '%', 'LIKE')
->condition('s.http_host', '%' . $database->escapeLike($string) . '%', 'LIKE')
)
->orderBy('s.title_admin', 'asc')
->groupBy('s.id')
->range(0, 16)
->addTag('ucms_site_access')
;
$suggest = [];
foreach ($q->execute()->fetchAll() as $record) {
$key = $record->title_admin . ' [' . $record->id . ']';
$suggest[$key] = check_plain($record->title_admin);
}
return new JsonResponse($suggest);
}
|
[
"public",
"function",
"siteAddAutocompleteAction",
"(",
"Request",
"$",
"request",
",",
"Group",
"$",
"group",
",",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isGranted",
"(",
"Access",
"::",
"ACL_PERM_MANAGE_SITES",
",",
"$",
"group",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"database",
"=",
"$",
"this",
"->",
"getDatabaseConnection",
"(",
")",
";",
"$",
"q",
"=",
"$",
"database",
"->",
"select",
"(",
"'ucms_site'",
",",
"'s'",
")",
"->",
"fields",
"(",
"'s'",
",",
"[",
"'id'",
",",
"'title_admin'",
"]",
")",
"->",
"isNull",
"(",
"'s.group_id'",
")",
"->",
"condition",
"(",
"(",
"new",
"\\",
"DatabaseCondition",
"(",
"'OR'",
")",
")",
"->",
"condition",
"(",
"'s.title'",
",",
"'%'",
".",
"$",
"database",
"->",
"escapeLike",
"(",
"$",
"string",
")",
".",
"'%'",
",",
"'LIKE'",
")",
"->",
"condition",
"(",
"'s.title_admin'",
",",
"'%'",
".",
"$",
"database",
"->",
"escapeLike",
"(",
"$",
"string",
")",
".",
"'%'",
",",
"'LIKE'",
")",
"->",
"condition",
"(",
"'s.http_host'",
",",
"'%'",
".",
"$",
"database",
"->",
"escapeLike",
"(",
"$",
"string",
")",
".",
"'%'",
",",
"'LIKE'",
")",
")",
"->",
"orderBy",
"(",
"'s.title_admin'",
",",
"'asc'",
")",
"->",
"groupBy",
"(",
"'s.id'",
")",
"->",
"range",
"(",
"0",
",",
"16",
")",
"->",
"addTag",
"(",
"'ucms_site_access'",
")",
";",
"$",
"suggest",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"q",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"record",
")",
"{",
"$",
"key",
"=",
"$",
"record",
"->",
"title_admin",
".",
"' ['",
".",
"$",
"record",
"->",
"id",
".",
"']'",
";",
"$",
"suggest",
"[",
"$",
"key",
"]",
"=",
"check_plain",
"(",
"$",
"record",
"->",
"title_admin",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"suggest",
")",
";",
"}"
] |
Autocomplete action for adding sites into group
|
[
"Autocomplete",
"action",
"for",
"adding",
"sites",
"into",
"group"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Controller/AutocompleteController.php#L27-L58
|
235,183
|
makinacorpus/drupal-ucms
|
ucms_group/src/Controller/AutocompleteController.php
|
AutocompleteController.siteAttachAutocompleteAction
|
public function siteAttachAutocompleteAction(Request $request, Site $site, $string)
{
if (!$this->isGranted(Access::PERM_GROUP_MANAGE_ALL)) {
throw $this->createAccessDeniedException();
}
$database = $this->getDatabaseConnection();
$q = $database
->select('ucms_group', 'g')
->fields('g', ['id', 'title'])
->condition(
(new \DatabaseCondition('OR'))
->condition('g.title', '%' . $database->escapeLike($string) . '%', 'LIKE')
)
->orderBy('g.title', 'asc')
->groupBy('g.id')
->range(0, 16)
->addTag('ucms_group_access')
;
$suggest = [];
foreach ($q->execute()->fetchAll() as $record) {
$key = $record->title . ' [' . $record->id . ']';
$suggest[$key] = check_plain($record->title);
}
return new JsonResponse($suggest);
}
|
php
|
public function siteAttachAutocompleteAction(Request $request, Site $site, $string)
{
if (!$this->isGranted(Access::PERM_GROUP_MANAGE_ALL)) {
throw $this->createAccessDeniedException();
}
$database = $this->getDatabaseConnection();
$q = $database
->select('ucms_group', 'g')
->fields('g', ['id', 'title'])
->condition(
(new \DatabaseCondition('OR'))
->condition('g.title', '%' . $database->escapeLike($string) . '%', 'LIKE')
)
->orderBy('g.title', 'asc')
->groupBy('g.id')
->range(0, 16)
->addTag('ucms_group_access')
;
$suggest = [];
foreach ($q->execute()->fetchAll() as $record) {
$key = $record->title . ' [' . $record->id . ']';
$suggest[$key] = check_plain($record->title);
}
return new JsonResponse($suggest);
}
|
[
"public",
"function",
"siteAttachAutocompleteAction",
"(",
"Request",
"$",
"request",
",",
"Site",
"$",
"site",
",",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isGranted",
"(",
"Access",
"::",
"PERM_GROUP_MANAGE_ALL",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"$",
"database",
"=",
"$",
"this",
"->",
"getDatabaseConnection",
"(",
")",
";",
"$",
"q",
"=",
"$",
"database",
"->",
"select",
"(",
"'ucms_group'",
",",
"'g'",
")",
"->",
"fields",
"(",
"'g'",
",",
"[",
"'id'",
",",
"'title'",
"]",
")",
"->",
"condition",
"(",
"(",
"new",
"\\",
"DatabaseCondition",
"(",
"'OR'",
")",
")",
"->",
"condition",
"(",
"'g.title'",
",",
"'%'",
".",
"$",
"database",
"->",
"escapeLike",
"(",
"$",
"string",
")",
".",
"'%'",
",",
"'LIKE'",
")",
")",
"->",
"orderBy",
"(",
"'g.title'",
",",
"'asc'",
")",
"->",
"groupBy",
"(",
"'g.id'",
")",
"->",
"range",
"(",
"0",
",",
"16",
")",
"->",
"addTag",
"(",
"'ucms_group_access'",
")",
";",
"$",
"suggest",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"q",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
")",
"as",
"$",
"record",
")",
"{",
"$",
"key",
"=",
"$",
"record",
"->",
"title",
".",
"' ['",
".",
"$",
"record",
"->",
"id",
".",
"']'",
";",
"$",
"suggest",
"[",
"$",
"key",
"]",
"=",
"check_plain",
"(",
"$",
"record",
"->",
"title",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"suggest",
")",
";",
"}"
] |
Autocomplete action for attaching group to site
|
[
"Autocomplete",
"action",
"for",
"attaching",
"group",
"to",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Controller/AutocompleteController.php#L63-L91
|
235,184
|
fintech-fab/bank-emulator
|
src/FintechFab/BankEmulator/Components/Processor/Payment.php
|
Payment.saveAsInit
|
public function saveAsInit()
{
$this->initDoubleBeforeSave();
if (empty($this->payment->rrn)) {
$this->payment->rrn = mt_rand(111111111111, 999999999999);
}
if (empty($this->payment->irn)) {
$this->payment->irn = substr(strtoupper(md5($this->payment->rrn . time())), 10, 10);
}
$this->payment->status = Status::PROCESSED;
$this->payment->save();
}
|
php
|
public function saveAsInit()
{
$this->initDoubleBeforeSave();
if (empty($this->payment->rrn)) {
$this->payment->rrn = mt_rand(111111111111, 999999999999);
}
if (empty($this->payment->irn)) {
$this->payment->irn = substr(strtoupper(md5($this->payment->rrn . time())), 10, 10);
}
$this->payment->status = Status::PROCESSED;
$this->payment->save();
}
|
[
"public",
"function",
"saveAsInit",
"(",
")",
"{",
"$",
"this",
"->",
"initDoubleBeforeSave",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"payment",
"->",
"rrn",
")",
")",
"{",
"$",
"this",
"->",
"payment",
"->",
"rrn",
"=",
"mt_rand",
"(",
"111111111111",
",",
"999999999999",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"payment",
"->",
"irn",
")",
")",
"{",
"$",
"this",
"->",
"payment",
"->",
"irn",
"=",
"substr",
"(",
"strtoupper",
"(",
"md5",
"(",
"$",
"this",
"->",
"payment",
"->",
"rrn",
".",
"time",
"(",
")",
")",
")",
",",
"10",
",",
"10",
")",
";",
"}",
"$",
"this",
"->",
"payment",
"->",
"status",
"=",
"Status",
"::",
"PROCESSED",
";",
"$",
"this",
"->",
"payment",
"->",
"save",
"(",
")",
";",
"}"
] |
first, save payment
|
[
"first",
"save",
"payment"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/FintechFab/BankEmulator/Components/Processor/Payment.php#L75-L88
|
235,185
|
fintech-fab/bank-emulator
|
src/FintechFab/BankEmulator/Components/Processor/Payment.php
|
Payment.doProcessCards
|
public function doProcessCards()
{
$pan = $this->payment->pan;
$this->payment->mask('pan');
$type = new Type($this->payment->type, $this->payment->toArray());
$fields = $type->fields();
if (!in_array('pan', $fields)) {
return '00';
}
$cvc = $this->payment->cvc;
$rc = BankCard::doCheckCard($pan, $cvc);
if ($rc !== '00') {
return $rc;
}
if ($type->sid() == Type::SALE) {
$to = $this->payment->to;
if ($to) {
$rc = BankCard::doCheckCard($to);
}
}
return $rc;
}
|
php
|
public function doProcessCards()
{
$pan = $this->payment->pan;
$this->payment->mask('pan');
$type = new Type($this->payment->type, $this->payment->toArray());
$fields = $type->fields();
if (!in_array('pan', $fields)) {
return '00';
}
$cvc = $this->payment->cvc;
$rc = BankCard::doCheckCard($pan, $cvc);
if ($rc !== '00') {
return $rc;
}
if ($type->sid() == Type::SALE) {
$to = $this->payment->to;
if ($to) {
$rc = BankCard::doCheckCard($to);
}
}
return $rc;
}
|
[
"public",
"function",
"doProcessCards",
"(",
")",
"{",
"$",
"pan",
"=",
"$",
"this",
"->",
"payment",
"->",
"pan",
";",
"$",
"this",
"->",
"payment",
"->",
"mask",
"(",
"'pan'",
")",
";",
"$",
"type",
"=",
"new",
"Type",
"(",
"$",
"this",
"->",
"payment",
"->",
"type",
",",
"$",
"this",
"->",
"payment",
"->",
"toArray",
"(",
")",
")",
";",
"$",
"fields",
"=",
"$",
"type",
"->",
"fields",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"'pan'",
",",
"$",
"fields",
")",
")",
"{",
"return",
"'00'",
";",
"}",
"$",
"cvc",
"=",
"$",
"this",
"->",
"payment",
"->",
"cvc",
";",
"$",
"rc",
"=",
"BankCard",
"::",
"doCheckCard",
"(",
"$",
"pan",
",",
"$",
"cvc",
")",
";",
"if",
"(",
"$",
"rc",
"!==",
"'00'",
")",
"{",
"return",
"$",
"rc",
";",
"}",
"if",
"(",
"$",
"type",
"->",
"sid",
"(",
")",
"==",
"Type",
"::",
"SALE",
")",
"{",
"$",
"to",
"=",
"$",
"this",
"->",
"payment",
"->",
"to",
";",
"if",
"(",
"$",
"to",
")",
"{",
"$",
"rc",
"=",
"BankCard",
"::",
"doCheckCard",
"(",
"$",
"to",
")",
";",
"}",
"}",
"return",
"$",
"rc",
";",
"}"
] |
RC process code by card numbers
@return string $rc
|
[
"RC",
"process",
"code",
"by",
"card",
"numbers"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/FintechFab/BankEmulator/Components/Processor/Payment.php#L176-L203
|
235,186
|
fintech-fab/bank-emulator
|
src/FintechFab/BankEmulator/Components/Processor/Payment.php
|
Payment.findDouble
|
public static function findDouble($id, $term, $order, $amount, $type = null, $status = null)
{
$payment = PaymentModel::whereTerm($term)
->whereOrder($order)
->whereAmount($amount)
->where('id', '!=', $id);
if (!is_array($type)) {
$type = (array)$type;
}
if (!is_array($status)) {
$status = (array)$status;
}
if ($status) {
$payment->whereIn('status', $status);
}
if ($type) {
$payment->whereIn('type', $type);
}
// last hour
$payment->whereRaw('created_at >= DATE_SUB(NOW(), INTERVAL 1 HOUR)');
$payment = $payment->first();
return $payment;
}
|
php
|
public static function findDouble($id, $term, $order, $amount, $type = null, $status = null)
{
$payment = PaymentModel::whereTerm($term)
->whereOrder($order)
->whereAmount($amount)
->where('id', '!=', $id);
if (!is_array($type)) {
$type = (array)$type;
}
if (!is_array($status)) {
$status = (array)$status;
}
if ($status) {
$payment->whereIn('status', $status);
}
if ($type) {
$payment->whereIn('type', $type);
}
// last hour
$payment->whereRaw('created_at >= DATE_SUB(NOW(), INTERVAL 1 HOUR)');
$payment = $payment->first();
return $payment;
}
|
[
"public",
"static",
"function",
"findDouble",
"(",
"$",
"id",
",",
"$",
"term",
",",
"$",
"order",
",",
"$",
"amount",
",",
"$",
"type",
"=",
"null",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"payment",
"=",
"PaymentModel",
"::",
"whereTerm",
"(",
"$",
"term",
")",
"->",
"whereOrder",
"(",
"$",
"order",
")",
"->",
"whereAmount",
"(",
"$",
"amount",
")",
"->",
"where",
"(",
"'id'",
",",
"'!='",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"(",
"array",
")",
"$",
"type",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"status",
")",
")",
"{",
"$",
"status",
"=",
"(",
"array",
")",
"$",
"status",
";",
"}",
"if",
"(",
"$",
"status",
")",
"{",
"$",
"payment",
"->",
"whereIn",
"(",
"'status'",
",",
"$",
"status",
")",
";",
"}",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"payment",
"->",
"whereIn",
"(",
"'type'",
",",
"$",
"type",
")",
";",
"}",
"// last hour",
"$",
"payment",
"->",
"whereRaw",
"(",
"'created_at >= DATE_SUB(NOW(), INTERVAL 1 HOUR)'",
")",
";",
"$",
"payment",
"=",
"$",
"payment",
"->",
"first",
"(",
")",
";",
"return",
"$",
"payment",
";",
"}"
] |
search double payment
@param int $id current payment id
@param string $term
@param string $order
@param string $amount
@param string|array $type
@param string|array $status
@return PaymentModel|null
|
[
"search",
"double",
"payment"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/FintechFab/BankEmulator/Components/Processor/Payment.php#L350-L378
|
235,187
|
fintech-fab/bank-emulator
|
src/FintechFab/BankEmulator/Components/Processor/Payment.php
|
Payment.doDetectAuth
|
private function doDetectAuth()
{
if ($this->payment->cvc == '333') {
$this->auth = Url::route('ff-bank-em-pay-auth', array(
'payment' => Crypt::encrypt($this->payment->id),
'back' => urlencode(Url::route('ff-bank-em-endpoint-auth-result')),
));
$this->payment->status = Status::AUTHORIZATION;
}
}
|
php
|
private function doDetectAuth()
{
if ($this->payment->cvc == '333') {
$this->auth = Url::route('ff-bank-em-pay-auth', array(
'payment' => Crypt::encrypt($this->payment->id),
'back' => urlencode(Url::route('ff-bank-em-endpoint-auth-result')),
));
$this->payment->status = Status::AUTHORIZATION;
}
}
|
[
"private",
"function",
"doDetectAuth",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"payment",
"->",
"cvc",
"==",
"'333'",
")",
"{",
"$",
"this",
"->",
"auth",
"=",
"Url",
"::",
"route",
"(",
"'ff-bank-em-pay-auth'",
",",
"array",
"(",
"'payment'",
"=>",
"Crypt",
"::",
"encrypt",
"(",
"$",
"this",
"->",
"payment",
"->",
"id",
")",
",",
"'back'",
"=>",
"urlencode",
"(",
"Url",
"::",
"route",
"(",
"'ff-bank-em-endpoint-auth-result'",
")",
")",
",",
")",
")",
";",
"$",
"this",
"->",
"payment",
"->",
"status",
"=",
"Status",
"::",
"AUTHORIZATION",
";",
"}",
"}"
] |
Init url payment authorization
|
[
"Init",
"url",
"payment",
"authorization"
] |
6256be98509de0ff8e96b5683a0b0197acd67b9e
|
https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/FintechFab/BankEmulator/Components/Processor/Payment.php#L383-L392
|
235,188
|
accompli/accompli
|
src/Task/MaintenanceModeTask.php
|
MaintenanceModeTask.onPrepareDeployReleaseLinkMaintenancePageToStage
|
public function onPrepareDeployReleaseLinkMaintenancePageToStage(PrepareDeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
if (VersionCategoryComparator::matchesStrategy($this->strategy, $event->getRelease(), $event->getCurrentRelease()) === false) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Skipped linking maintenance page according to strategy.', $eventName, $this));
return;
}
$host = $event->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$linkSource = $host->getPath().'/maintenance/';
$linkTarget = $host->getPath().'/'.$host->getStage();
$context = array('linkTarget' => $linkTarget);
if ($connection->isLink($linkTarget) && $connection->delete($linkTarget, false) === false) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed to remove existing "{linkTarget}" link.', $eventName, $this, $context));
}
$context['event.task.action'] = TaskInterface::ACTION_IN_PROGRESS;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Linking "{linkTarget}" to maintenance page.', $eventName, $this, $context));
if ($connection->link($linkSource, $linkTarget)) {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Linked "{linkTarget}" to maintenance page.', $eventName, $this, $context));
} else {
$context['event.task.action'] = TaskInterface::ACTION_FAILED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Linking "{linkTarget}" to maintenance page failed.', $eventName, $this, $context));
throw new TaskRuntimeException(sprintf('Linking "%s" to maintenance page failed.', $context['linkTarget']), $this);
}
}
|
php
|
public function onPrepareDeployReleaseLinkMaintenancePageToStage(PrepareDeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
if (VersionCategoryComparator::matchesStrategy($this->strategy, $event->getRelease(), $event->getCurrentRelease()) === false) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Skipped linking maintenance page according to strategy.', $eventName, $this));
return;
}
$host = $event->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$linkSource = $host->getPath().'/maintenance/';
$linkTarget = $host->getPath().'/'.$host->getStage();
$context = array('linkTarget' => $linkTarget);
if ($connection->isLink($linkTarget) && $connection->delete($linkTarget, false) === false) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed to remove existing "{linkTarget}" link.', $eventName, $this, $context));
}
$context['event.task.action'] = TaskInterface::ACTION_IN_PROGRESS;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Linking "{linkTarget}" to maintenance page.', $eventName, $this, $context));
if ($connection->link($linkSource, $linkTarget)) {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Linked "{linkTarget}" to maintenance page.', $eventName, $this, $context));
} else {
$context['event.task.action'] = TaskInterface::ACTION_FAILED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Linking "{linkTarget}" to maintenance page failed.', $eventName, $this, $context));
throw new TaskRuntimeException(sprintf('Linking "%s" to maintenance page failed.', $context['linkTarget']), $this);
}
}
|
[
"public",
"function",
"onPrepareDeployReleaseLinkMaintenancePageToStage",
"(",
"PrepareDeployReleaseEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"if",
"(",
"VersionCategoryComparator",
"::",
"matchesStrategy",
"(",
"$",
"this",
"->",
"strategy",
",",
"$",
"event",
"->",
"getRelease",
"(",
")",
",",
"$",
"event",
"->",
"getCurrentRelease",
"(",
")",
")",
"===",
"false",
")",
"{",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"INFO",
",",
"'Skipped linking maintenance page according to strategy.'",
",",
"$",
"eventName",
",",
"$",
"this",
")",
")",
";",
"return",
";",
"}",
"$",
"host",
"=",
"$",
"event",
"->",
"getWorkspace",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"ensureConnection",
"(",
"$",
"host",
")",
";",
"$",
"linkSource",
"=",
"$",
"host",
"->",
"getPath",
"(",
")",
".",
"'/maintenance/'",
";",
"$",
"linkTarget",
"=",
"$",
"host",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"host",
"->",
"getStage",
"(",
")",
";",
"$",
"context",
"=",
"array",
"(",
"'linkTarget'",
"=>",
"$",
"linkTarget",
")",
";",
"if",
"(",
"$",
"connection",
"->",
"isLink",
"(",
"$",
"linkTarget",
")",
"&&",
"$",
"connection",
"->",
"delete",
"(",
"$",
"linkTarget",
",",
"false",
")",
"===",
"false",
")",
"{",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"WARNING",
",",
"'Failed to remove existing \"{linkTarget}\" link.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"}",
"$",
"context",
"[",
"'event.task.action'",
"]",
"=",
"TaskInterface",
"::",
"ACTION_IN_PROGRESS",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"INFO",
",",
"'Linking \"{linkTarget}\" to maintenance page.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"if",
"(",
"$",
"connection",
"->",
"link",
"(",
"$",
"linkSource",
",",
"$",
"linkTarget",
")",
")",
"{",
"$",
"context",
"[",
"'event.task.action'",
"]",
"=",
"TaskInterface",
"::",
"ACTION_COMPLETED",
";",
"$",
"context",
"[",
"'output.resetLine'",
"]",
"=",
"true",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"INFO",
",",
"'Linked \"{linkTarget}\" to maintenance page.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"}",
"else",
"{",
"$",
"context",
"[",
"'event.task.action'",
"]",
"=",
"TaskInterface",
"::",
"ACTION_FAILED",
";",
"$",
"context",
"[",
"'output.resetLine'",
"]",
"=",
"true",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"AccompliEvents",
"::",
"LOG",
",",
"new",
"LogEvent",
"(",
"LogLevel",
"::",
"INFO",
",",
"'Linking \"{linkTarget}\" to maintenance page failed.'",
",",
"$",
"eventName",
",",
"$",
"this",
",",
"$",
"context",
")",
")",
";",
"throw",
"new",
"TaskRuntimeException",
"(",
"sprintf",
"(",
"'Linking \"%s\" to maintenance page failed.'",
",",
"$",
"context",
"[",
"'linkTarget'",
"]",
")",
",",
"$",
"this",
")",
";",
"}",
"}"
] |
Links the maintenance page to the stage being deployed.
@param PrepareDeployReleaseEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher
@throws TaskRuntimeException when not able to link the maintenance page
|
[
"Links",
"the",
"maintenance",
"page",
"to",
"the",
"stage",
"being",
"deployed",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/MaintenanceModeTask.php#L137-L173
|
235,189
|
heidilabs/markov-php
|
src/MarkovPHP/WordChain.php
|
WordChain.getThemedLink
|
public function getThemedLink($string)
{
$search = preg_grep('/\b' . preg_quote($string, '/') . '\b/', $this->words);
return $search[array_rand($search)];
}
|
php
|
public function getThemedLink($string)
{
$search = preg_grep('/\b' . preg_quote($string, '/') . '\b/', $this->words);
return $search[array_rand($search)];
}
|
[
"public",
"function",
"getThemedLink",
"(",
"$",
"string",
")",
"{",
"$",
"search",
"=",
"preg_grep",
"(",
"'/\\b'",
".",
"preg_quote",
"(",
"$",
"string",
",",
"'/'",
")",
".",
"'\\b/'",
",",
"$",
"this",
"->",
"words",
")",
";",
"return",
"$",
"search",
"[",
"array_rand",
"(",
"$",
"search",
")",
"]",
";",
"}"
] |
Gets a chain link based on a string search
@param $string
|
[
"Gets",
"a",
"chain",
"link",
"based",
"on",
"a",
"string",
"search"
] |
d29546f0a8f2ec831e12001d43eef1e79b950c24
|
https://github.com/heidilabs/markov-php/blob/d29546f0a8f2ec831e12001d43eef1e79b950c24/src/MarkovPHP/WordChain.php#L60-L64
|
235,190
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeAccessService.php
|
NodeAccessService.findMostRelevantEnabledSiteFor
|
public function findMostRelevantEnabledSiteFor(NodeInterface $node)
{
if (empty($node->ucms_enabled_sites)) {
return; // Node cannot be viewed
}
if (in_array($node->site_id, $node->ucms_enabled_sites)) {
// Per default, the primary site seems the best to work with
return $node->site_id;
}
return reset($node->ucms_enabled_sites); // Fallback on first
}
|
php
|
public function findMostRelevantEnabledSiteFor(NodeInterface $node)
{
if (empty($node->ucms_enabled_sites)) {
return; // Node cannot be viewed
}
if (in_array($node->site_id, $node->ucms_enabled_sites)) {
// Per default, the primary site seems the best to work with
return $node->site_id;
}
return reset($node->ucms_enabled_sites); // Fallback on first
}
|
[
"public",
"function",
"findMostRelevantEnabledSiteFor",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"node",
"->",
"ucms_enabled_sites",
")",
")",
"{",
"return",
";",
"// Node cannot be viewed",
"}",
"if",
"(",
"in_array",
"(",
"$",
"node",
"->",
"site_id",
",",
"$",
"node",
"->",
"ucms_enabled_sites",
")",
")",
"{",
"// Per default, the primary site seems the best to work with",
"return",
"$",
"node",
"->",
"site_id",
";",
"}",
"return",
"reset",
"(",
"$",
"node",
"->",
"ucms_enabled_sites",
")",
";",
"// Fallback on first",
"}"
] |
Find the most revelant ENABLED site to view the node in
@param NodeInterface $node
@see \MakinaCorpus\Ucms\Site\EventDispatcher\NodeEventSubscriber::onLoad()
@return int
The site identifier is returned, we don't need to load it to build
a node route
|
[
"Find",
"the",
"most",
"revelant",
"ENABLED",
"site",
"to",
"view",
"the",
"node",
"in"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeAccessService.php#L38-L50
|
235,191
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeAccessService.php
|
NodeAccessService.findMostRelevantSiteFor
|
public function findMostRelevantSiteFor(NodeInterface $node)
{
if ($siteId = $this->findMostRelevantEnabledSiteFor($node)) {
return $siteId;
}
if (empty($node->ucms_allowed_sites)) {
return; // Node cannot be viewed
}
if (in_array($node->site_id, $node->ucms_allowed_sites)) {
// Per default, the primary site seems the best to work with
return $node->site_id;
}
return reset($node->ucms_allowed_sites); // Fallback on first
}
|
php
|
public function findMostRelevantSiteFor(NodeInterface $node)
{
if ($siteId = $this->findMostRelevantEnabledSiteFor($node)) {
return $siteId;
}
if (empty($node->ucms_allowed_sites)) {
return; // Node cannot be viewed
}
if (in_array($node->site_id, $node->ucms_allowed_sites)) {
// Per default, the primary site seems the best to work with
return $node->site_id;
}
return reset($node->ucms_allowed_sites); // Fallback on first
}
|
[
"public",
"function",
"findMostRelevantSiteFor",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"siteId",
"=",
"$",
"this",
"->",
"findMostRelevantEnabledSiteFor",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"siteId",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"node",
"->",
"ucms_allowed_sites",
")",
")",
"{",
"return",
";",
"// Node cannot be viewed",
"}",
"if",
"(",
"in_array",
"(",
"$",
"node",
"->",
"site_id",
",",
"$",
"node",
"->",
"ucms_allowed_sites",
")",
")",
"{",
"// Per default, the primary site seems the best to work with",
"return",
"$",
"node",
"->",
"site_id",
";",
"}",
"return",
"reset",
"(",
"$",
"node",
"->",
"ucms_allowed_sites",
")",
";",
"// Fallback on first",
"}"
] |
Find the most revelant site to view the node in
@param NodeInterface $node
@param bool $onlyEnabled
Search only in enabled sites
@see \MakinaCorpus\Ucms\Site\EventDispatcher\NodeEventSubscriber::onLoad()
@return int
The site identifier is returned, we don't need to load it to build
a node route
|
[
"Find",
"the",
"most",
"revelant",
"site",
"to",
"view",
"the",
"node",
"in"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeAccessService.php#L65-L80
|
235,192
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeAccessService.php
|
NodeAccessService.userCanReference
|
public function userCanReference(AccountInterface $account, NodeInterface $node)
{
return $node->access(Permission::VIEW, $account) && $this->manager->getAccess()->userIsWebmaster($account);
}
|
php
|
public function userCanReference(AccountInterface $account, NodeInterface $node)
{
return $node->access(Permission::VIEW, $account) && $this->manager->getAccess()->userIsWebmaster($account);
}
|
[
"public",
"function",
"userCanReference",
"(",
"AccountInterface",
"$",
"account",
",",
"NodeInterface",
"$",
"node",
")",
"{",
"return",
"$",
"node",
"->",
"access",
"(",
"Permission",
"::",
"VIEW",
",",
"$",
"account",
")",
"&&",
"$",
"this",
"->",
"manager",
"->",
"getAccess",
"(",
")",
"->",
"userIsWebmaster",
"(",
"$",
"account",
")",
";",
"}"
] |
Can the user reference this node on one of his sites
@param AccountInterface $account
@param NodeInterface $node
@return boolean
|
[
"Can",
"the",
"user",
"reference",
"this",
"node",
"on",
"one",
"of",
"his",
"sites"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeAccessService.php#L90-L93
|
235,193
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeAccessService.php
|
NodeAccessService.userCanDereference
|
public function userCanDereference(AccountInterface $account, NodeInterface $node, Site $site)
{
return $node->access(Permission::VIEW, $account) && in_array($site->getId(), $node->ucms_sites) && $this->manager->getAccess()->userIsWebmaster($account, $site);
}
|
php
|
public function userCanDereference(AccountInterface $account, NodeInterface $node, Site $site)
{
return $node->access(Permission::VIEW, $account) && in_array($site->getId(), $node->ucms_sites) && $this->manager->getAccess()->userIsWebmaster($account, $site);
}
|
[
"public",
"function",
"userCanDereference",
"(",
"AccountInterface",
"$",
"account",
",",
"NodeInterface",
"$",
"node",
",",
"Site",
"$",
"site",
")",
"{",
"return",
"$",
"node",
"->",
"access",
"(",
"Permission",
"::",
"VIEW",
",",
"$",
"account",
")",
"&&",
"in_array",
"(",
"$",
"site",
"->",
"getId",
"(",
")",
",",
"$",
"node",
"->",
"ucms_sites",
")",
"&&",
"$",
"this",
"->",
"manager",
"->",
"getAccess",
"(",
")",
"->",
"userIsWebmaster",
"(",
"$",
"account",
",",
"$",
"site",
")",
";",
"}"
] |
Can the user dereference the current content from the given site
@param AccountInterface $account
@param NodeInterface $node
@param Site $site
@return boolean
|
[
"Can",
"the",
"user",
"dereference",
"the",
"current",
"content",
"from",
"the",
"given",
"site"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeAccessService.php#L104-L107
|
235,194
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeAccessService.php
|
NodeAccessService.userCanCreateInSite
|
public function userCanCreateInSite(AccountInterface $account, $type, Site $site)
{
// Damn this is ugly
if ($this->manager->hasContext()) {
$previous = $this->manager->getContext();
$this->manager->setContext($site, new Request());
$result = $this->userCanCreate($account, $type);
$this->manager->setContext($previous, new Request());
} else {
$this->manager->setContext($site, new Request());
$result = $this->userCanCreate($account, $type);
$this->manager->dropContext();
}
return $result;
}
|
php
|
public function userCanCreateInSite(AccountInterface $account, $type, Site $site)
{
// Damn this is ugly
if ($this->manager->hasContext()) {
$previous = $this->manager->getContext();
$this->manager->setContext($site, new Request());
$result = $this->userCanCreate($account, $type);
$this->manager->setContext($previous, new Request());
} else {
$this->manager->setContext($site, new Request());
$result = $this->userCanCreate($account, $type);
$this->manager->dropContext();
}
return $result;
}
|
[
"public",
"function",
"userCanCreateInSite",
"(",
"AccountInterface",
"$",
"account",
",",
"$",
"type",
",",
"Site",
"$",
"site",
")",
"{",
"// Damn this is ugly",
"if",
"(",
"$",
"this",
"->",
"manager",
"->",
"hasContext",
"(",
")",
")",
"{",
"$",
"previous",
"=",
"$",
"this",
"->",
"manager",
"->",
"getContext",
"(",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"setContext",
"(",
"$",
"site",
",",
"new",
"Request",
"(",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"userCanCreate",
"(",
"$",
"account",
",",
"$",
"type",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"setContext",
"(",
"$",
"previous",
",",
"new",
"Request",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"manager",
"->",
"setContext",
"(",
"$",
"site",
",",
"new",
"Request",
"(",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"userCanCreate",
"(",
"$",
"account",
",",
"$",
"type",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"dropContext",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Can user create nodes with the given type in the given site context
@param AccountInterface $account
@param string $type
@param Site $site
@return bool
@deprecated
|
[
"Can",
"user",
"create",
"nodes",
"with",
"the",
"given",
"type",
"in",
"the",
"given",
"site",
"context"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeAccessService.php#L133-L147
|
235,195
|
makinacorpus/drupal-ucms
|
ucms_site/src/NodeAccessService.php
|
NodeAccessService.userCanCreateInAnySite
|
public function userCanCreateInAnySite(AccountInterface $account, $type)
{
// Check for global contribs
if ($this->userCanCreate($account, $type)) {
return true;
}
// Iterate over all sites, check if type creation is possible in context
$sites = $this->manager->loadOwnSites($account);
foreach ($sites as $site) {
if ($this->userCanCreateInSite($account, $type, $site)) {
return true;
}
}
return false;
}
|
php
|
public function userCanCreateInAnySite(AccountInterface $account, $type)
{
// Check for global contribs
if ($this->userCanCreate($account, $type)) {
return true;
}
// Iterate over all sites, check if type creation is possible in context
$sites = $this->manager->loadOwnSites($account);
foreach ($sites as $site) {
if ($this->userCanCreateInSite($account, $type, $site)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"userCanCreateInAnySite",
"(",
"AccountInterface",
"$",
"account",
",",
"$",
"type",
")",
"{",
"// Check for global contribs",
"if",
"(",
"$",
"this",
"->",
"userCanCreate",
"(",
"$",
"account",
",",
"$",
"type",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Iterate over all sites, check if type creation is possible in context",
"$",
"sites",
"=",
"$",
"this",
"->",
"manager",
"->",
"loadOwnSites",
"(",
"$",
"account",
")",
";",
"foreach",
"(",
"$",
"sites",
"as",
"$",
"site",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userCanCreateInSite",
"(",
"$",
"account",
",",
"$",
"type",
",",
"$",
"site",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Can user create type in our platform
@param \Drupal\Core\Session\AccountInterface $account
@param string $type
@return bool
|
[
"Can",
"user",
"create",
"type",
"in",
"our",
"platform"
] |
6b8a84305472d2cad816102672f10274b3bbb535
|
https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/NodeAccessService.php#L156-L172
|
235,196
|
aimeos/ai-admin-extadm
|
controller/extjs/src/Controller/ExtJS/Common/Load/Text/Base.php
|
Base.storeFile
|
protected function storeFile( \Psr\Http\Message\ServerRequestInterface $request, &$clientFilename = '' )
{
$context = $this->getContext();
$files = (array) $request->getUploadedFiles();
if( ( $file = reset( $files ) ) === false || $file->getError() !== UPLOAD_ERR_OK ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded or an error occured' );
}
$clientFilename = $file->getClientFilename();
$fileext = pathinfo( $clientFilename, PATHINFO_EXTENSION );
$dest = md5( $clientFilename . time() . getmypid() ) . '.' . $fileext;
$fs = $context->getFilesystemManager()->get( 'fs-admin' );
$fs->writes( $dest, $file->getStream()->detach() );
return $dest;
}
|
php
|
protected function storeFile( \Psr\Http\Message\ServerRequestInterface $request, &$clientFilename = '' )
{
$context = $this->getContext();
$files = (array) $request->getUploadedFiles();
if( ( $file = reset( $files ) ) === false || $file->getError() !== UPLOAD_ERR_OK ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'No file was uploaded or an error occured' );
}
$clientFilename = $file->getClientFilename();
$fileext = pathinfo( $clientFilename, PATHINFO_EXTENSION );
$dest = md5( $clientFilename . time() . getmypid() ) . '.' . $fileext;
$fs = $context->getFilesystemManager()->get( 'fs-admin' );
$fs->writes( $dest, $file->getStream()->detach() );
return $dest;
}
|
[
"protected",
"function",
"storeFile",
"(",
"\\",
"Psr",
"\\",
"Http",
"\\",
"Message",
"\\",
"ServerRequestInterface",
"$",
"request",
",",
"&",
"$",
"clientFilename",
"=",
"''",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getContext",
"(",
")",
";",
"$",
"files",
"=",
"(",
"array",
")",
"$",
"request",
"->",
"getUploadedFiles",
"(",
")",
";",
"if",
"(",
"(",
"$",
"file",
"=",
"reset",
"(",
"$",
"files",
")",
")",
"===",
"false",
"||",
"$",
"file",
"->",
"getError",
"(",
")",
"!==",
"UPLOAD_ERR_OK",
")",
"{",
"throw",
"new",
"\\",
"Aimeos",
"\\",
"Controller",
"\\",
"ExtJS",
"\\",
"Exception",
"(",
"'No file was uploaded or an error occured'",
")",
";",
"}",
"$",
"clientFilename",
"=",
"$",
"file",
"->",
"getClientFilename",
"(",
")",
";",
"$",
"fileext",
"=",
"pathinfo",
"(",
"$",
"clientFilename",
",",
"PATHINFO_EXTENSION",
")",
";",
"$",
"dest",
"=",
"md5",
"(",
"$",
"clientFilename",
".",
"time",
"(",
")",
".",
"getmypid",
"(",
")",
")",
".",
"'.'",
".",
"$",
"fileext",
";",
"$",
"fs",
"=",
"$",
"context",
"->",
"getFilesystemManager",
"(",
")",
"->",
"get",
"(",
"'fs-admin'",
")",
";",
"$",
"fs",
"->",
"writes",
"(",
"$",
"dest",
",",
"$",
"file",
"->",
"getStream",
"(",
")",
"->",
"detach",
"(",
")",
")",
";",
"return",
"$",
"dest",
";",
"}"
] |
Stores the uploaded file and returns the path to this file
@param \Psr\Http\Message\ServerRequestInterface $request PSR-7 request object
@param string $clientFilename Result parameter for the file name sent by the client
@throws \Aimeos\Controller\ExtJS\Exception If no file was uploaded or an error occured
@return string Path to the stored file
|
[
"Stores",
"the",
"uploaded",
"file",
"and",
"returns",
"the",
"path",
"to",
"this",
"file"
] |
594ee7cec90fd63a4773c05c93f353e66d9b3408
|
https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Common/Load/Text/Base.php#L312-L329
|
235,197
|
accompli/accompli
|
src/Deployment/Connection/SSHConnectionAdapter.php
|
SSHConnectionAdapter.getUserDirectory
|
private function getUserDirectory()
{
$userDirectory = null;
if (isset($_SERVER['HOME'])) {
$userDirectory = $_SERVER['HOME'];
} elseif (isset($_SERVER['USERPROFILE'])) {
$userDirectory = $_SERVER['USERPROFILE'];
}
$userDirectory = realpath($userDirectory.'/../');
$userDirectory .= '/'.$this->authenticationUsername;
return $userDirectory;
}
|
php
|
private function getUserDirectory()
{
$userDirectory = null;
if (isset($_SERVER['HOME'])) {
$userDirectory = $_SERVER['HOME'];
} elseif (isset($_SERVER['USERPROFILE'])) {
$userDirectory = $_SERVER['USERPROFILE'];
}
$userDirectory = realpath($userDirectory.'/../');
$userDirectory .= '/'.$this->authenticationUsername;
return $userDirectory;
}
|
[
"private",
"function",
"getUserDirectory",
"(",
")",
"{",
"$",
"userDirectory",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HOME'",
"]",
")",
")",
"{",
"$",
"userDirectory",
"=",
"$",
"_SERVER",
"[",
"'HOME'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'USERPROFILE'",
"]",
")",
")",
"{",
"$",
"userDirectory",
"=",
"$",
"_SERVER",
"[",
"'USERPROFILE'",
"]",
";",
"}",
"$",
"userDirectory",
"=",
"realpath",
"(",
"$",
"userDirectory",
".",
"'/../'",
")",
";",
"$",
"userDirectory",
".=",
"'/'",
".",
"$",
"this",
"->",
"authenticationUsername",
";",
"return",
"$",
"userDirectory",
";",
"}"
] |
Returns the 'home' directory for the user.
@return string|null
|
[
"Returns",
"the",
"home",
"directory",
"for",
"the",
"user",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Connection/SSHConnectionAdapter.php#L417-L429
|
235,198
|
accompli/accompli
|
src/Deployment/Connection/SSHConnectionAdapter.php
|
SSHConnectionAdapter.getFilteredOutput
|
private function getFilteredOutput($output, $command)
{
$output = str_replace(array("\r\n", "\r"), array("\n", ''), $output);
$matches = array();
if (preg_match($this->getOutputFilterRegex($command), $output, $matches) === 1) {
$output = ltrim($matches[1]);
}
return $output;
}
|
php
|
private function getFilteredOutput($output, $command)
{
$output = str_replace(array("\r\n", "\r"), array("\n", ''), $output);
$matches = array();
if (preg_match($this->getOutputFilterRegex($command), $output, $matches) === 1) {
$output = ltrim($matches[1]);
}
return $output;
}
|
[
"private",
"function",
"getFilteredOutput",
"(",
"$",
"output",
",",
"$",
"command",
")",
"{",
"$",
"output",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\r\"",
")",
",",
"array",
"(",
"\"\\n\"",
",",
"''",
")",
",",
"$",
"output",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"getOutputFilterRegex",
"(",
"$",
"command",
")",
",",
"$",
"output",
",",
"$",
"matches",
")",
"===",
"1",
")",
"{",
"$",
"output",
"=",
"ltrim",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Returns the filtered output of the command.
Removes the command echo and shell prompt from the output.
@param string $output
@param string $command
@return string
|
[
"Returns",
"the",
"filtered",
"output",
"of",
"the",
"command",
".",
"Removes",
"the",
"command",
"echo",
"and",
"shell",
"prompt",
"from",
"the",
"output",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Connection/SSHConnectionAdapter.php#L440-L450
|
235,199
|
accompli/accompli
|
src/Deployment/Connection/SSHConnectionAdapter.php
|
SSHConnectionAdapter.getOutputFilterRegex
|
private function getOutputFilterRegex($command)
{
$commandCharacters = str_split(preg_quote($command, '/'));
$commandCharacterRegexWhitespaceFunction = function ($value) {
if ($value !== '\\') {
$value .= '\s?';
}
return $value;
};
$commandCharacters = array_map($commandCharacterRegexWhitespaceFunction, $commandCharacters);
return sprintf('/%s(.*)%s/s', implode('', $commandCharacters), substr($this->getShellPromptRegex(), 1, -1));
}
|
php
|
private function getOutputFilterRegex($command)
{
$commandCharacters = str_split(preg_quote($command, '/'));
$commandCharacterRegexWhitespaceFunction = function ($value) {
if ($value !== '\\') {
$value .= '\s?';
}
return $value;
};
$commandCharacters = array_map($commandCharacterRegexWhitespaceFunction, $commandCharacters);
return sprintf('/%s(.*)%s/s', implode('', $commandCharacters), substr($this->getShellPromptRegex(), 1, -1));
}
|
[
"private",
"function",
"getOutputFilterRegex",
"(",
"$",
"command",
")",
"{",
"$",
"commandCharacters",
"=",
"str_split",
"(",
"preg_quote",
"(",
"$",
"command",
",",
"'/'",
")",
")",
";",
"$",
"commandCharacterRegexWhitespaceFunction",
"=",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"'\\\\'",
")",
"{",
"$",
"value",
".=",
"'\\s?'",
";",
"}",
"return",
"$",
"value",
";",
"}",
";",
"$",
"commandCharacters",
"=",
"array_map",
"(",
"$",
"commandCharacterRegexWhitespaceFunction",
",",
"$",
"commandCharacters",
")",
";",
"return",
"sprintf",
"(",
"'/%s(.*)%s/s'",
",",
"implode",
"(",
"''",
",",
"$",
"commandCharacters",
")",
",",
"substr",
"(",
"$",
"this",
"->",
"getShellPromptRegex",
"(",
")",
",",
"1",
",",
"-",
"1",
")",
")",
";",
"}"
] |
Returns the output filter regex to filter the output.
@param string $command
@return string
|
[
"Returns",
"the",
"output",
"filter",
"regex",
"to",
"filter",
"the",
"output",
"."
] |
618f28377448d8caa90d63bfa5865a3ee15e49e7
|
https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Deployment/Connection/SSHConnectionAdapter.php#L459-L473
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.