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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
221,800
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Manager.php
|
Manager.render
|
public function render()
{
if ($breadcrumbs = $this->generator->generate()) {
return $this->renderer->render(config('breadcrumbs.view'), $breadcrumbs);
}
}
|
php
|
public function render()
{
if ($breadcrumbs = $this->generator->generate()) {
return $this->renderer->render(config('breadcrumbs.view'), $breadcrumbs);
}
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"breadcrumbs",
"=",
"$",
"this",
"->",
"generator",
"->",
"generate",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"renderer",
"->",
"render",
"(",
"config",
"(",
"'breadcrumbs.view'",
")",
",",
"$",
"breadcrumbs",
")",
";",
"}",
"}"
] |
Render the breadcrumbs as an HTML string.
@return \Illuminate\Support\HtmlString
|
[
"Render",
"the",
"breadcrumbs",
"as",
"an",
"HTML",
"string",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Manager.php#L40-L45
|
221,801
|
Pageworks/craft-manytomany
|
src/services/ManyToManyService.php
|
ManyToManyService.getRelatedEntries
|
public function getRelatedEntries(ElementInterface $element, Section $section, string $field): array
{
$query = Entry::find();
$query->section = $section;
$query->limit = null;
$query->status = null;
$query->enabledForSite = null;
$query->relatedTo = [
'targetElement' => $element,
'field' => $field,
];
return $query->all();
}
|
php
|
public function getRelatedEntries(ElementInterface $element, Section $section, string $field): array
{
$query = Entry::find();
$query->section = $section;
$query->limit = null;
$query->status = null;
$query->enabledForSite = null;
$query->relatedTo = [
'targetElement' => $element,
'field' => $field,
];
return $query->all();
}
|
[
"public",
"function",
"getRelatedEntries",
"(",
"ElementInterface",
"$",
"element",
",",
"Section",
"$",
"section",
",",
"string",
"$",
"field",
")",
":",
"array",
"{",
"$",
"query",
"=",
"Entry",
"::",
"find",
"(",
")",
";",
"$",
"query",
"->",
"section",
"=",
"$",
"section",
";",
"$",
"query",
"->",
"limit",
"=",
"null",
";",
"$",
"query",
"->",
"status",
"=",
"null",
";",
"$",
"query",
"->",
"enabledForSite",
"=",
"null",
";",
"$",
"query",
"->",
"relatedTo",
"=",
"[",
"'targetElement'",
"=>",
"$",
"element",
",",
"'field'",
"=>",
"$",
"field",
",",
"]",
";",
"return",
"$",
"query",
"->",
"all",
"(",
")",
";",
"}"
] |
Returns related entries from an element limited to a section.
@param ElementInterface $element
@param Section $section
@param string $field
@return Entry[]
|
[
"Returns",
"related",
"entries",
"from",
"an",
"element",
"limited",
"to",
"a",
"section",
"."
] |
bd4d2e81e43428962e910cfd5a6b4a6aefc195f6
|
https://github.com/Pageworks/craft-manytomany/blob/bd4d2e81e43428962e910cfd5a6b4a6aefc195f6/src/services/ManyToManyService.php#L24-L38
|
221,802
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Generator.php
|
Generator.register
|
public function register(string $name, Closure $definition)
{
$this->registrar->set($name, $definition);
}
|
php
|
public function register(string $name, Closure $definition)
{
$this->registrar->set($name, $definition);
}
|
[
"public",
"function",
"register",
"(",
"string",
"$",
"name",
",",
"Closure",
"$",
"definition",
")",
"{",
"$",
"this",
"->",
"registrar",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"definition",
")",
";",
"}"
] |
Register a definition with the registrar.
@param string $name
@param \Closure $definition
@return void
@throws \Watson\Breadcrumbs\Exceptions\DefinitionAlreadyExists
|
[
"Register",
"a",
"definition",
"with",
"the",
"registrar",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Generator.php#L53-L56
|
221,803
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Generator.php
|
Generator.generate
|
public function generate(): Collection
{
if ($this->route->present() && $this->registrar->has($this->route->name())) {
$this->call(
$this->route->name(),
$this->route->parameters()
);
}
return $this->breadcrumbs;
}
|
php
|
public function generate(): Collection
{
if ($this->route->present() && $this->registrar->has($this->route->name())) {
$this->call(
$this->route->name(),
$this->route->parameters()
);
}
return $this->breadcrumbs;
}
|
[
"public",
"function",
"generate",
"(",
")",
":",
"Collection",
"{",
"if",
"(",
"$",
"this",
"->",
"route",
"->",
"present",
"(",
")",
"&&",
"$",
"this",
"->",
"registrar",
"->",
"has",
"(",
"$",
"this",
"->",
"route",
"->",
"name",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"$",
"this",
"->",
"route",
"->",
"name",
"(",
")",
",",
"$",
"this",
"->",
"route",
"->",
"parameters",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"breadcrumbs",
";",
"}"
] |
Generate the collection of breadcrumbs from the given route.
@return \Illuminate\Support\Collection
|
[
"Generate",
"the",
"collection",
"of",
"breadcrumbs",
"from",
"the",
"given",
"route",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Generator.php#L63-L73
|
221,804
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Generator.php
|
Generator.add
|
public function add(string $title, string $url)
{
$this->breadcrumbs->push(new Breadcrumb($title, $url));
}
|
php
|
public function add(string $title, string $url)
{
$this->breadcrumbs->push(new Breadcrumb($title, $url));
}
|
[
"public",
"function",
"add",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"breadcrumbs",
"->",
"push",
"(",
"new",
"Breadcrumb",
"(",
"$",
"title",
",",
"$",
"url",
")",
")",
";",
"}"
] |
Add a breadcrumb to the collection.
@param string $title
@param string $url
@return void
|
[
"Add",
"a",
"breadcrumb",
"to",
"the",
"collection",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Generator.php#L94-L97
|
221,805
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Generator.php
|
Generator.call
|
protected function call(string $name, array $parameters)
{
$definition = $this->registrar->get($name);
$parameters = array_prepend(array_values($parameters), $this);
call_user_func_array($definition, $parameters);
}
|
php
|
protected function call(string $name, array $parameters)
{
$definition = $this->registrar->get($name);
$parameters = array_prepend(array_values($parameters), $this);
call_user_func_array($definition, $parameters);
}
|
[
"protected",
"function",
"call",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"parameters",
")",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"registrar",
"->",
"get",
"(",
"$",
"name",
")",
";",
"$",
"parameters",
"=",
"array_prepend",
"(",
"array_values",
"(",
"$",
"parameters",
")",
",",
"$",
"this",
")",
";",
"call_user_func_array",
"(",
"$",
"definition",
",",
"$",
"parameters",
")",
";",
"}"
] |
Call the breadcrumb definition with the given parameters.
@param string $name
@param array $parameters
@return void
@throws \Watson\Breadcrumbs\DefinitionNotFoundException
|
[
"Call",
"the",
"breadcrumb",
"definition",
"with",
"the",
"given",
"parameters",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Generator.php#L107-L114
|
221,806
|
Pageworks/craft-manytomany
|
src/fields/ManyToManyField.php
|
ManyToManyField.getSettingsHtml
|
public function getSettingsHtml(): string
{
$allSections = Craft::$app->sections->getAllSections();
$allFields = Craft::$app->fields->getAllFields() ?? [];
// Group the Sections into an array
$elements = [];
foreach ($allSections as $element) {
$elements[$element->id] = $element->name;
}
// Group Field Types into an array
$fields = [];
foreach ($allFields as $field) {
$fields[$field->id] = $field->name;
}
// Get the Section Source
if (empty($this->source)) {
$this->source = ['type' => '', 'value' => ''];
}
return Craft::$app->view->renderTemplate(
'manytomany/_settings', [
'source' => $this->source,
'singleField' => $this->singleField,
'elements' => $elements,
'fields' => $fields,
]
);
}
|
php
|
public function getSettingsHtml(): string
{
$allSections = Craft::$app->sections->getAllSections();
$allFields = Craft::$app->fields->getAllFields() ?? [];
// Group the Sections into an array
$elements = [];
foreach ($allSections as $element) {
$elements[$element->id] = $element->name;
}
// Group Field Types into an array
$fields = [];
foreach ($allFields as $field) {
$fields[$field->id] = $field->name;
}
// Get the Section Source
if (empty($this->source)) {
$this->source = ['type' => '', 'value' => ''];
}
return Craft::$app->view->renderTemplate(
'manytomany/_settings', [
'source' => $this->source,
'singleField' => $this->singleField,
'elements' => $elements,
'fields' => $fields,
]
);
}
|
[
"public",
"function",
"getSettingsHtml",
"(",
")",
":",
"string",
"{",
"$",
"allSections",
"=",
"Craft",
"::",
"$",
"app",
"->",
"sections",
"->",
"getAllSections",
"(",
")",
";",
"$",
"allFields",
"=",
"Craft",
"::",
"$",
"app",
"->",
"fields",
"->",
"getAllFields",
"(",
")",
"??",
"[",
"]",
";",
"// Group the Sections into an array",
"$",
"elements",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"allSections",
"as",
"$",
"element",
")",
"{",
"$",
"elements",
"[",
"$",
"element",
"->",
"id",
"]",
"=",
"$",
"element",
"->",
"name",
";",
"}",
"// Group Field Types into an array",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"allFields",
"as",
"$",
"field",
")",
"{",
"$",
"fields",
"[",
"$",
"field",
"->",
"id",
"]",
"=",
"$",
"field",
"->",
"name",
";",
"}",
"// Get the Section Source",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"source",
")",
")",
"{",
"$",
"this",
"->",
"source",
"=",
"[",
"'type'",
"=>",
"''",
",",
"'value'",
"=>",
"''",
"]",
";",
"}",
"return",
"Craft",
"::",
"$",
"app",
"->",
"view",
"->",
"renderTemplate",
"(",
"'manytomany/_settings'",
",",
"[",
"'source'",
"=>",
"$",
"this",
"->",
"source",
",",
"'singleField'",
"=>",
"$",
"this",
"->",
"singleField",
",",
"'elements'",
"=>",
"$",
"elements",
",",
"'fields'",
"=>",
"$",
"fields",
",",
"]",
")",
";",
"}"
] |
Get template for field type settings.
@return string
|
[
"Get",
"template",
"for",
"field",
"type",
"settings",
"."
] |
bd4d2e81e43428962e910cfd5a6b4a6aefc195f6
|
https://github.com/Pageworks/craft-manytomany/blob/bd4d2e81e43428962e910cfd5a6b4a6aefc195f6/src/fields/ManyToManyField.php#L67-L97
|
221,807
|
Pageworks/craft-manytomany
|
src/fields/ManyToManyField.php
|
ManyToManyField.getInputHtml
|
public function getInputHtml($value, ElementInterface $element = null): string
{
$plugin = Plugin::getInstance();
$service = $plugin->service;
// Validate settings
if (empty($this->source)) {
return Craft::t('manytomany', 'To use the {pluginName} plugin you need to set a source.',
['pluginName' => $plugin->name]);
}
if (empty($this->singleField)) {
return Craft::t('manytomany',
'To use the {pluginName} plugin you need associate it with a related field.',
['pluginName' => $plugin->name]);
}
$singleFieldModel = Craft::$app->fields->getFieldById($this->singleField);
if ($singleFieldModel->getIsTranslatable()) {
return Craft::t('manytomany',
'The {pluginName} plugin does not currently work with localized content.',
['pluginName' => $plugin->name]);
}
// For this iteration of the plugin, everything is a SECTION, but it's setup so it can be
// refactored in the future to allow for multiple types
if (!is_object($element) || $element->refHandle() != 'entry') {
return Craft::t('manytomany',
'For this version of the {pluginName} plugin, you can only use this field with Entries.',
['pluginName' => $plugin->name]);
}
/** @var Entry $element */
$relatedSection = Craft::$app->sections->getSectionById($this->source['value']);
// Get all the entries that this has already been attached to
$relatedEntries = $service->getRelatedEntries($element, $relatedSection, $this->singleField);
// Put related Entries into an array that can be consumed by the JavaScript popup window
$nonSelectable = [];
if (!empty($relatedEntries)) {
foreach ($relatedEntries as $relatedEntry) {
$nonSelectable[] = $relatedEntry->id;
}
}
$nonSelectable = implode(',', $nonSelectable);
$id = Craft::$app->view->formatInputId($this->handle);
$namespacedId = Craft::$app->view->namespaceInputId($id);
return Craft::$app->view->renderTemplate('manytomany/_input', [
'name' => $this->handle,
'value' => $value,
'id' => $namespacedId,
'current' => $relatedEntries,
'section' => $relatedSection->id,
'nonSelectable' => $nonSelectable,
'singleField' => $this->singleField,
'nameSpace' => Craft::$app->view->getNamespace(),
]);
}
|
php
|
public function getInputHtml($value, ElementInterface $element = null): string
{
$plugin = Plugin::getInstance();
$service = $plugin->service;
// Validate settings
if (empty($this->source)) {
return Craft::t('manytomany', 'To use the {pluginName} plugin you need to set a source.',
['pluginName' => $plugin->name]);
}
if (empty($this->singleField)) {
return Craft::t('manytomany',
'To use the {pluginName} plugin you need associate it with a related field.',
['pluginName' => $plugin->name]);
}
$singleFieldModel = Craft::$app->fields->getFieldById($this->singleField);
if ($singleFieldModel->getIsTranslatable()) {
return Craft::t('manytomany',
'The {pluginName} plugin does not currently work with localized content.',
['pluginName' => $plugin->name]);
}
// For this iteration of the plugin, everything is a SECTION, but it's setup so it can be
// refactored in the future to allow for multiple types
if (!is_object($element) || $element->refHandle() != 'entry') {
return Craft::t('manytomany',
'For this version of the {pluginName} plugin, you can only use this field with Entries.',
['pluginName' => $plugin->name]);
}
/** @var Entry $element */
$relatedSection = Craft::$app->sections->getSectionById($this->source['value']);
// Get all the entries that this has already been attached to
$relatedEntries = $service->getRelatedEntries($element, $relatedSection, $this->singleField);
// Put related Entries into an array that can be consumed by the JavaScript popup window
$nonSelectable = [];
if (!empty($relatedEntries)) {
foreach ($relatedEntries as $relatedEntry) {
$nonSelectable[] = $relatedEntry->id;
}
}
$nonSelectable = implode(',', $nonSelectable);
$id = Craft::$app->view->formatInputId($this->handle);
$namespacedId = Craft::$app->view->namespaceInputId($id);
return Craft::$app->view->renderTemplate('manytomany/_input', [
'name' => $this->handle,
'value' => $value,
'id' => $namespacedId,
'current' => $relatedEntries,
'section' => $relatedSection->id,
'nonSelectable' => $nonSelectable,
'singleField' => $this->singleField,
'nameSpace' => Craft::$app->view->getNamespace(),
]);
}
|
[
"public",
"function",
"getInputHtml",
"(",
"$",
"value",
",",
"ElementInterface",
"$",
"element",
"=",
"null",
")",
":",
"string",
"{",
"$",
"plugin",
"=",
"Plugin",
"::",
"getInstance",
"(",
")",
";",
"$",
"service",
"=",
"$",
"plugin",
"->",
"service",
";",
"// Validate settings",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"source",
")",
")",
"{",
"return",
"Craft",
"::",
"t",
"(",
"'manytomany'",
",",
"'To use the {pluginName} plugin you need to set a source.'",
",",
"[",
"'pluginName'",
"=>",
"$",
"plugin",
"->",
"name",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"singleField",
")",
")",
"{",
"return",
"Craft",
"::",
"t",
"(",
"'manytomany'",
",",
"'To use the {pluginName} plugin you need associate it with a related field.'",
",",
"[",
"'pluginName'",
"=>",
"$",
"plugin",
"->",
"name",
"]",
")",
";",
"}",
"$",
"singleFieldModel",
"=",
"Craft",
"::",
"$",
"app",
"->",
"fields",
"->",
"getFieldById",
"(",
"$",
"this",
"->",
"singleField",
")",
";",
"if",
"(",
"$",
"singleFieldModel",
"->",
"getIsTranslatable",
"(",
")",
")",
"{",
"return",
"Craft",
"::",
"t",
"(",
"'manytomany'",
",",
"'The {pluginName} plugin does not currently work with localized content.'",
",",
"[",
"'pluginName'",
"=>",
"$",
"plugin",
"->",
"name",
"]",
")",
";",
"}",
"// For this iteration of the plugin, everything is a SECTION, but it's setup so it can be",
"// refactored in the future to allow for multiple types",
"if",
"(",
"!",
"is_object",
"(",
"$",
"element",
")",
"||",
"$",
"element",
"->",
"refHandle",
"(",
")",
"!=",
"'entry'",
")",
"{",
"return",
"Craft",
"::",
"t",
"(",
"'manytomany'",
",",
"'For this version of the {pluginName} plugin, you can only use this field with Entries.'",
",",
"[",
"'pluginName'",
"=>",
"$",
"plugin",
"->",
"name",
"]",
")",
";",
"}",
"/** @var Entry $element */",
"$",
"relatedSection",
"=",
"Craft",
"::",
"$",
"app",
"->",
"sections",
"->",
"getSectionById",
"(",
"$",
"this",
"->",
"source",
"[",
"'value'",
"]",
")",
";",
"// Get all the entries that this has already been attached to",
"$",
"relatedEntries",
"=",
"$",
"service",
"->",
"getRelatedEntries",
"(",
"$",
"element",
",",
"$",
"relatedSection",
",",
"$",
"this",
"->",
"singleField",
")",
";",
"// Put related Entries into an array that can be consumed by the JavaScript popup window",
"$",
"nonSelectable",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"relatedEntries",
")",
")",
"{",
"foreach",
"(",
"$",
"relatedEntries",
"as",
"$",
"relatedEntry",
")",
"{",
"$",
"nonSelectable",
"[",
"]",
"=",
"$",
"relatedEntry",
"->",
"id",
";",
"}",
"}",
"$",
"nonSelectable",
"=",
"implode",
"(",
"','",
",",
"$",
"nonSelectable",
")",
";",
"$",
"id",
"=",
"Craft",
"::",
"$",
"app",
"->",
"view",
"->",
"formatInputId",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"namespacedId",
"=",
"Craft",
"::",
"$",
"app",
"->",
"view",
"->",
"namespaceInputId",
"(",
"$",
"id",
")",
";",
"return",
"Craft",
"::",
"$",
"app",
"->",
"view",
"->",
"renderTemplate",
"(",
"'manytomany/_input'",
",",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"handle",
",",
"'value'",
"=>",
"$",
"value",
",",
"'id'",
"=>",
"$",
"namespacedId",
",",
"'current'",
"=>",
"$",
"relatedEntries",
",",
"'section'",
"=>",
"$",
"relatedSection",
"->",
"id",
",",
"'nonSelectable'",
"=>",
"$",
"nonSelectable",
",",
"'singleField'",
"=>",
"$",
"this",
"->",
"singleField",
",",
"'nameSpace'",
"=>",
"Craft",
"::",
"$",
"app",
"->",
"view",
"->",
"getNamespace",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Product input HTML for edit pages.
@param mixed $value
@param ElementInterface|null $element
@return string
|
[
"Product",
"input",
"HTML",
"for",
"edit",
"pages",
"."
] |
bd4d2e81e43428962e910cfd5a6b4a6aefc195f6
|
https://github.com/Pageworks/craft-manytomany/blob/bd4d2e81e43428962e910cfd5a6b4a6aefc195f6/src/fields/ManyToManyField.php#L106-L167
|
221,808
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Renderer.php
|
Renderer.render
|
public function render(string $view, Collection $breadcrumbs): HtmlString
{
return new HtmlString(
$this->makeView($view, $breadcrumbs)->render()
);
}
|
php
|
public function render(string $view, Collection $breadcrumbs): HtmlString
{
return new HtmlString(
$this->makeView($view, $breadcrumbs)->render()
);
}
|
[
"public",
"function",
"render",
"(",
"string",
"$",
"view",
",",
"Collection",
"$",
"breadcrumbs",
")",
":",
"HtmlString",
"{",
"return",
"new",
"HtmlString",
"(",
"$",
"this",
"->",
"makeView",
"(",
"$",
"view",
",",
"$",
"breadcrumbs",
")",
"->",
"render",
"(",
")",
")",
";",
"}"
] |
Render the given breadcrumbs into the given view.
@param string $view
@param \Illuminate\Support\Collection $breadcrumbs
@return \Illuminate\Support\HtmlString
|
[
"Render",
"the",
"given",
"breadcrumbs",
"into",
"the",
"given",
"view",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Renderer.php#L37-L42
|
221,809
|
dwightwatson/breadcrumbs
|
src/Breadcrumbs/Renderer.php
|
Renderer.makeView
|
protected function makeView(string $view, Collection $breadcrumbs): View
{
return $this->factory->make($view, compact('breadcrumbs'));
}
|
php
|
protected function makeView(string $view, Collection $breadcrumbs): View
{
return $this->factory->make($view, compact('breadcrumbs'));
}
|
[
"protected",
"function",
"makeView",
"(",
"string",
"$",
"view",
",",
"Collection",
"$",
"breadcrumbs",
")",
":",
"View",
"{",
"return",
"$",
"this",
"->",
"factory",
"->",
"make",
"(",
"$",
"view",
",",
"compact",
"(",
"'breadcrumbs'",
")",
")",
";",
"}"
] |
Get a view instance of the given view file with breadcrumbs.
@param string $view
@param \Illuminate\Support\Collection $breadcrumbs
@return \Illuminate\View\View
|
[
"Get",
"a",
"view",
"instance",
"of",
"the",
"given",
"view",
"file",
"with",
"breadcrumbs",
"."
] |
b54dc7e1fc131749ff60c88115ca70bf7c6443ca
|
https://github.com/dwightwatson/breadcrumbs/blob/b54dc7e1fc131749ff60c88115ca70bf7c6443ca/src/Breadcrumbs/Renderer.php#L51-L54
|
221,810
|
xperseguers/doodle_client
|
src/Domain/Model/Poll.php
|
Poll.getPublicUrl
|
public function getPublicUrl(): string
{
if (!empty($this->_info['prettyUrl'])) {
$publicUrl = $this->_info['prettyUrl'];
} else {
$publicUrl = 'https://doodle.com/poll/' . $this->getId();
}
return $publicUrl;
}
|
php
|
public function getPublicUrl(): string
{
if (!empty($this->_info['prettyUrl'])) {
$publicUrl = $this->_info['prettyUrl'];
} else {
$publicUrl = 'https://doodle.com/poll/' . $this->getId();
}
return $publicUrl;
}
|
[
"public",
"function",
"getPublicUrl",
"(",
")",
":",
"string",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_info",
"[",
"'prettyUrl'",
"]",
")",
")",
"{",
"$",
"publicUrl",
"=",
"$",
"this",
"->",
"_info",
"[",
"'prettyUrl'",
"]",
";",
"}",
"else",
"{",
"$",
"publicUrl",
"=",
"'https://doodle.com/poll/'",
".",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"}",
"return",
"$",
"publicUrl",
";",
"}"
] |
Returns the public URL.
@return string
|
[
"Returns",
"the",
"public",
"URL",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Model/Poll.php#L523-L532
|
221,811
|
xperseguers/doodle_client
|
src/Domain/Model/Poll.php
|
Poll.getDescription
|
public function getDescription(): string
{
if ($this->description === null && $this->_repository !== null) {
$this->_repository->injectDescription($this);
}
return $this->description ?: '';
}
|
php
|
public function getDescription(): string
{
if ($this->description === null && $this->_repository !== null) {
$this->_repository->injectDescription($this);
}
return $this->description ?: '';
}
|
[
"public",
"function",
"getDescription",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"description",
"===",
"null",
"&&",
"$",
"this",
"->",
"_repository",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_repository",
"->",
"injectDescription",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"description",
"?",
":",
"''",
";",
"}"
] |
Returns the description.
@return string
|
[
"Returns",
"the",
"description",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Model/Poll.php#L539-L546
|
221,812
|
xperseguers/doodle_client
|
src/Domain/Model/Poll.php
|
Poll.setDescription
|
public function setDescription(string $description): Poll
{
$description = trim($description);
$this->description = substr($description, 0, min(static::MAX_LENGTH_DESCRIPTION, strlen($description)));
return $this;
}
|
php
|
public function setDescription(string $description): Poll
{
$description = trim($description);
$this->description = substr($description, 0, min(static::MAX_LENGTH_DESCRIPTION, strlen($description)));
return $this;
}
|
[
"public",
"function",
"setDescription",
"(",
"string",
"$",
"description",
")",
":",
"Poll",
"{",
"$",
"description",
"=",
"trim",
"(",
"$",
"description",
")",
";",
"$",
"this",
"->",
"description",
"=",
"substr",
"(",
"$",
"description",
",",
"0",
",",
"min",
"(",
"static",
"::",
"MAX_LENGTH_DESCRIPTION",
",",
"strlen",
"(",
"$",
"description",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the description.
@param string $description
@return $this
|
[
"Sets",
"the",
"description",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Model/Poll.php#L554-L560
|
221,813
|
xperseguers/doodle_client
|
src/Domain/Model/Poll.php
|
Poll.getOptions
|
public function getOptions(): array
{
if ($this->options === null && $this->_repository !== null) {
$this->_repository->injectOptions($this);
}
return $this->options ?: [];
}
|
php
|
public function getOptions(): array
{
if ($this->options === null && $this->_repository !== null) {
$this->_repository->injectOptions($this);
}
return $this->options ?: [];
}
|
[
"public",
"function",
"getOptions",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"===",
"null",
"&&",
"$",
"this",
"->",
"_repository",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_repository",
"->",
"injectOptions",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"options",
"?",
":",
"[",
"]",
";",
"}"
] |
Returns the options.
@return Option[]
|
[
"Returns",
"the",
"options",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Model/Poll.php#L567-L574
|
221,814
|
xperseguers/doodle_client
|
src/Domain/Model/Poll.php
|
Poll.getParticipants
|
public function getParticipants(): array
{
if ($this->participants === null && $this->_repository !== null) {
$this->_repository->injectParticipants($this);
}
return $this->participants ?: [];
}
|
php
|
public function getParticipants(): array
{
if ($this->participants === null && $this->_repository !== null) {
$this->_repository->injectParticipants($this);
}
return $this->participants ?: [];
}
|
[
"public",
"function",
"getParticipants",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"participants",
"===",
"null",
"&&",
"$",
"this",
"->",
"_repository",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_repository",
"->",
"injectParticipants",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"participants",
"?",
":",
"[",
"]",
";",
"}"
] |
Returns the participants.
@return Participant[]
|
[
"Returns",
"the",
"participants",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Model/Poll.php#L594-L601
|
221,815
|
xperseguers/doodle_client
|
src/Domain/Model/Poll.php
|
Poll.getLocation
|
public function getLocation(): Location
{
if ($this->location === false && $this->_repository !== null) {
$this->_repository->injectLocation($this);
}
return $this->location ?: null;
}
|
php
|
public function getLocation(): Location
{
if ($this->location === false && $this->_repository !== null) {
$this->_repository->injectLocation($this);
}
return $this->location ?: null;
}
|
[
"public",
"function",
"getLocation",
"(",
")",
":",
"Location",
"{",
"if",
"(",
"$",
"this",
"->",
"location",
"===",
"false",
"&&",
"$",
"this",
"->",
"_repository",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_repository",
"->",
"injectLocation",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"location",
"?",
":",
"null",
";",
"}"
] |
Returns the location.
@return Location|null
|
[
"Returns",
"the",
"location",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Model/Poll.php#L620-L627
|
221,816
|
Ocramius/OcraServiceManager
|
src/OcraServiceManager/ServiceFactory/ServiceManagerFactory.php
|
ServiceManagerFactory.createService
|
public function createService(ServiceLocatorInterface $serviceLocator, $name = null)
{
$config = $serviceLocator->get('Config');
if (! $config['ocra_service_manager']['logged_service_manager']) {
return $serviceLocator;
}
/* @var $proxyFactory \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory */
$proxyFactory = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
/* @var $locatorInterceptors \Closure[] */
$locatorInterceptors = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');
// @todo maybe this should be a callback, and `locatorInterceptors` should not be used explicitly
$proxyLocator = $proxyFactory->createProxy($serviceLocator, array(), $locatorInterceptors);
if (! ($name && $serviceLocator instanceof ServiceManager)) {
return $proxyLocator;
}
// @todo this service hardcoding should be removed
$allowOverrides = $serviceLocator->getAllowOverride();
$serviceLocator->setAllowOverride(true);
$serviceLocator->setService('ServiceManager', $proxyLocator);
$serviceLocator->setAllowOverride($allowOverrides);
return $proxyLocator;
}
|
php
|
public function createService(ServiceLocatorInterface $serviceLocator, $name = null)
{
$config = $serviceLocator->get('Config');
if (! $config['ocra_service_manager']['logged_service_manager']) {
return $serviceLocator;
}
/* @var $proxyFactory \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory */
$proxyFactory = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
/* @var $locatorInterceptors \Closure[] */
$locatorInterceptors = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');
// @todo maybe this should be a callback, and `locatorInterceptors` should not be used explicitly
$proxyLocator = $proxyFactory->createProxy($serviceLocator, array(), $locatorInterceptors);
if (! ($name && $serviceLocator instanceof ServiceManager)) {
return $proxyLocator;
}
// @todo this service hardcoding should be removed
$allowOverrides = $serviceLocator->getAllowOverride();
$serviceLocator->setAllowOverride(true);
$serviceLocator->setService('ServiceManager', $proxyLocator);
$serviceLocator->setAllowOverride($allowOverrides);
return $proxyLocator;
}
|
[
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"if",
"(",
"!",
"$",
"config",
"[",
"'ocra_service_manager'",
"]",
"[",
"'logged_service_manager'",
"]",
")",
"{",
"return",
"$",
"serviceLocator",
";",
"}",
"/* @var $proxyFactory \\ProxyManager\\Factory\\AccessInterceptorScopeLocalizerFactory */",
"$",
"proxyFactory",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'OcraServiceManager\\\\ServiceManager\\\\AccessInterceptorProxyFactory'",
")",
";",
"/* @var $locatorInterceptors \\Closure[] */",
"$",
"locatorInterceptors",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'OcraServiceManager\\\\ServiceManager\\\\AccessInterceptors'",
")",
";",
"// @todo maybe this should be a callback, and `locatorInterceptors` should not be used explicitly",
"$",
"proxyLocator",
"=",
"$",
"proxyFactory",
"->",
"createProxy",
"(",
"$",
"serviceLocator",
",",
"array",
"(",
")",
",",
"$",
"locatorInterceptors",
")",
";",
"if",
"(",
"!",
"(",
"$",
"name",
"&&",
"$",
"serviceLocator",
"instanceof",
"ServiceManager",
")",
")",
"{",
"return",
"$",
"proxyLocator",
";",
"}",
"// @todo this service hardcoding should be removed",
"$",
"allowOverrides",
"=",
"$",
"serviceLocator",
"->",
"getAllowOverride",
"(",
")",
";",
"$",
"serviceLocator",
"->",
"setAllowOverride",
"(",
"true",
")",
";",
"$",
"serviceLocator",
"->",
"setService",
"(",
"'ServiceManager'",
",",
"$",
"proxyLocator",
")",
";",
"$",
"serviceLocator",
"->",
"setAllowOverride",
"(",
"$",
"allowOverrides",
")",
";",
"return",
"$",
"proxyLocator",
";",
"}"
] |
Create an overloaded service manager
@param ServiceLocatorInterface $serviceLocator
@param string|null $name
@return ServiceLocatorInterface
|
[
"Create",
"an",
"overloaded",
"service",
"manager"
] |
8ca97c970ff32e138e89e93338ab3647a5d9370c
|
https://github.com/Ocramius/OcraServiceManager/blob/8ca97c970ff32e138e89e93338ab3647a5d9370c/src/OcraServiceManager/ServiceFactory/ServiceManagerFactory.php#L40-L68
|
221,817
|
silverstripe/silverstripe-mssql
|
code/MSSQLQueryBuilder.php
|
MSSQLQueryBuilder.parseLimit
|
protected function parseLimit(SQLSelect $query)
{
$limit = '';
$offset = '0';
if (is_array($query->getLimit())) {
$limitArr = $query->getLimit();
if (isset($limitArr['limit'])) {
$limit = $limitArr['limit'];
}
if (isset($limitArr['start'])) {
$offset = $limitArr['start'];
}
} elseif (preg_match('/^([0-9]+) offset ([0-9]+)$/i', trim($query->getLimit()), $matches)) {
$limit = $matches[1];
$offset = $matches[2];
} else {
//could be a comma delimited string
$bits = explode(',', $query->getLimit());
if (sizeof($bits) > 1) {
list($offset, $limit) = $bits;
} else {
$limit = $bits[0];
}
}
return array($limit, $offset);
}
|
php
|
protected function parseLimit(SQLSelect $query)
{
$limit = '';
$offset = '0';
if (is_array($query->getLimit())) {
$limitArr = $query->getLimit();
if (isset($limitArr['limit'])) {
$limit = $limitArr['limit'];
}
if (isset($limitArr['start'])) {
$offset = $limitArr['start'];
}
} elseif (preg_match('/^([0-9]+) offset ([0-9]+)$/i', trim($query->getLimit()), $matches)) {
$limit = $matches[1];
$offset = $matches[2];
} else {
//could be a comma delimited string
$bits = explode(',', $query->getLimit());
if (sizeof($bits) > 1) {
list($offset, $limit) = $bits;
} else {
$limit = $bits[0];
}
}
return array($limit, $offset);
}
|
[
"protected",
"function",
"parseLimit",
"(",
"SQLSelect",
"$",
"query",
")",
"{",
"$",
"limit",
"=",
"''",
";",
"$",
"offset",
"=",
"'0'",
";",
"if",
"(",
"is_array",
"(",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
")",
"{",
"$",
"limitArr",
"=",
"$",
"query",
"->",
"getLimit",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"limitArr",
"[",
"'limit'",
"]",
")",
")",
"{",
"$",
"limit",
"=",
"$",
"limitArr",
"[",
"'limit'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"limitArr",
"[",
"'start'",
"]",
")",
")",
"{",
"$",
"offset",
"=",
"$",
"limitArr",
"[",
"'start'",
"]",
";",
"}",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^([0-9]+) offset ([0-9]+)$/i'",
",",
"trim",
"(",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
",",
"$",
"matches",
")",
")",
"{",
"$",
"limit",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"offset",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"//could be a comma delimited string",
"$",
"bits",
"=",
"explode",
"(",
"','",
",",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"bits",
")",
">",
"1",
")",
"{",
"list",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
"=",
"$",
"bits",
";",
"}",
"else",
"{",
"$",
"limit",
"=",
"$",
"bits",
"[",
"0",
"]",
";",
"}",
"}",
"return",
"array",
"(",
"$",
"limit",
",",
"$",
"offset",
")",
";",
"}"
] |
Extracts the limit and offset from the limit clause
@param SQLSelect $query
@return array Two item array with $limit and $offset as values
@throws InvalidArgumentException
|
[
"Extracts",
"the",
"limit",
"and",
"offset",
"from",
"the",
"limit",
"clause"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLQueryBuilder.php#L98-L123
|
221,818
|
stackify/stackify-api-php
|
src/Stackify/Log/Transport/ExecTransport.php
|
ExecTransport.finish
|
public function finish()
{
if (!empty($this->queue)) {
// empty queue to avoid duplicates
$queue = $this->queue;
$this->queue = array();
$this->sendChunk($queue);
}
}
|
php
|
public function finish()
{
if (!empty($this->queue)) {
// empty queue to avoid duplicates
$queue = $this->queue;
$this->queue = array();
$this->sendChunk($queue);
}
}
|
[
"public",
"function",
"finish",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"queue",
")",
")",
"{",
"// empty queue to avoid duplicates",
"$",
"queue",
"=",
"$",
"this",
"->",
"queue",
";",
"$",
"this",
"->",
"queue",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"sendChunk",
"(",
"$",
"queue",
")",
";",
"}",
"}"
] |
Overrides parent's method
|
[
"Overrides",
"parent",
"s",
"method"
] |
73b4e67432dc532d1dd46b90d385feb321f24e0a
|
https://github.com/stackify/stackify-api-php/blob/73b4e67432dc532d1dd46b90d385feb321f24e0a/src/Stackify/Log/Transport/ExecTransport.php#L36-L44
|
221,819
|
Ocramius/OcraServiceManager
|
src/OcraServiceManager/View/Helper/YumlUrl.php
|
YumlUrl.getUrl
|
public function getUrl(array $services)
{
$chunks = array();
foreach ($services as $serviceName => $details) {
foreach ($details['dependencies'] as $dependency) {
$chunks[] = '[' . $serviceName . ']->[' . $dependency . ']';
}
}
return implode(',', $chunks);
}
|
php
|
public function getUrl(array $services)
{
$chunks = array();
foreach ($services as $serviceName => $details) {
foreach ($details['dependencies'] as $dependency) {
$chunks[] = '[' . $serviceName . ']->[' . $dependency . ']';
}
}
return implode(',', $chunks);
}
|
[
"public",
"function",
"getUrl",
"(",
"array",
"$",
"services",
")",
"{",
"$",
"chunks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"services",
"as",
"$",
"serviceName",
"=>",
"$",
"details",
")",
"{",
"foreach",
"(",
"$",
"details",
"[",
"'dependencies'",
"]",
"as",
"$",
"dependency",
")",
"{",
"$",
"chunks",
"[",
"]",
"=",
"'['",
".",
"$",
"serviceName",
".",
"']->['",
".",
"$",
"dependency",
".",
"']'",
";",
"}",
"}",
"return",
"implode",
"(",
"','",
",",
"$",
"chunks",
")",
";",
"}"
] |
Retrieves a YUML diagram link
@param array $services services as produced
by {@see \OcraServiceManager\ServiceManager\LoggedServiceManager::getLoggedServices}
@return string
|
[
"Retrieves",
"a",
"YUML",
"diagram",
"link"
] |
8ca97c970ff32e138e89e93338ab3647a5d9370c
|
https://github.com/Ocramius/OcraServiceManager/blob/8ca97c970ff32e138e89e93338ab3647a5d9370c/src/OcraServiceManager/View/Helper/YumlUrl.php#L40-L51
|
221,820
|
tabuna/VestaAPI
|
src/Services/DNS.php
|
DNS.listOnlyDNS
|
public function listOnlyDNS($dns)
{
$this->returnCode = 'no';
$listDNS = $this->send('v-list-dns-domain', $this->userName, $dns, 'json');
$data = json_decode($listDNS, true);
return $data;
}
|
php
|
public function listOnlyDNS($dns)
{
$this->returnCode = 'no';
$listDNS = $this->send('v-list-dns-domain', $this->userName, $dns, 'json');
$data = json_decode($listDNS, true);
return $data;
}
|
[
"public",
"function",
"listOnlyDNS",
"(",
"$",
"dns",
")",
"{",
"$",
"this",
"->",
"returnCode",
"=",
"'no'",
";",
"$",
"listDNS",
"=",
"$",
"this",
"->",
"send",
"(",
"'v-list-dns-domain'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"dns",
",",
"'json'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"listDNS",
",",
"true",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
List Only DNS.
@param $dns
@return mixed
|
[
"List",
"Only",
"DNS",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/DNS.php#L28-L35
|
221,821
|
tabuna/VestaAPI
|
src/Services/DNS.php
|
DNS.addDNSDomain
|
public function addDNSDomain($domain, $ip, $ns1, $ns2, $ns3 = null, $ns4 = null)
{
return $this->send('v-add-dns-domain', $this->userName, $domain, $ip, $ns1, $ns2, $ns3,
$ns4, 'no');
}
|
php
|
public function addDNSDomain($domain, $ip, $ns1, $ns2, $ns3 = null, $ns4 = null)
{
return $this->send('v-add-dns-domain', $this->userName, $domain, $ip, $ns1, $ns2, $ns3,
$ns4, 'no');
}
|
[
"public",
"function",
"addDNSDomain",
"(",
"$",
"domain",
",",
"$",
"ip",
",",
"$",
"ns1",
",",
"$",
"ns2",
",",
"$",
"ns3",
"=",
"null",
",",
"$",
"ns4",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-add-dns-domain'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"$",
"ip",
",",
"$",
"ns1",
",",
"$",
"ns2",
",",
"$",
"ns3",
",",
"$",
"ns4",
",",
"'no'",
")",
";",
"}"
] |
Add DNS domain.
@param $domain
@param $ip
@param $ns1
@param $ns2
@param null $ns3
@param null $ns4
@return mixed
|
[
"Add",
"DNS",
"domain",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/DNS.php#L74-L78
|
221,822
|
tabuna/VestaAPI
|
src/Services/DNS.php
|
DNS.listDNSRecords
|
public function listDNSRecords($domain)
{
$this->returnCode = 'no';
$data = $this->send('v-list-dns-records', $this->userName, $domain, 'json');
$data = json_decode($data, true);
return $data;
}
|
php
|
public function listDNSRecords($domain)
{
$this->returnCode = 'no';
$data = $this->send('v-list-dns-records', $this->userName, $domain, 'json');
$data = json_decode($data, true);
return $data;
}
|
[
"public",
"function",
"listDNSRecords",
"(",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"returnCode",
"=",
"'no'",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"send",
"(",
"'v-list-dns-records'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"'json'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
List DNS record domain.
@param $domain
@return mixed
|
[
"List",
"DNS",
"record",
"domain",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/DNS.php#L113-L120
|
221,823
|
tabuna/VestaAPI
|
src/Services/DNS.php
|
DNS.changeDNSDomainRecord
|
public function changeDNSDomainRecord($domain, $recordId, $val, $priority)
{
return $this->send('v-change-dns-record', $this->userName, $domain, $recordId, $val,
$priority);
}
|
php
|
public function changeDNSDomainRecord($domain, $recordId, $val, $priority)
{
return $this->send('v-change-dns-record', $this->userName, $domain, $recordId, $val,
$priority);
}
|
[
"public",
"function",
"changeDNSDomainRecord",
"(",
"$",
"domain",
",",
"$",
"recordId",
",",
"$",
"val",
",",
"$",
"priority",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-change-dns-record'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"$",
"recordId",
",",
"$",
"val",
",",
"$",
"priority",
")",
";",
"}"
] |
Change DNS domain record.
@param $domain
@param $recordId
@param $val
@param $priority
@return mixed
|
[
"Change",
"DNS",
"domain",
"record",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/DNS.php#L132-L136
|
221,824
|
tabuna/VestaAPI
|
src/Services/DNS.php
|
DNS.addDNSRecord
|
public function addDNSRecord($domain, $rec, $type, $val, $priority)
{
$this->send('v-add-dns-record', $this->userName, $domain, $rec, $type, $val, $priority);
}
|
php
|
public function addDNSRecord($domain, $rec, $type, $val, $priority)
{
$this->send('v-add-dns-record', $this->userName, $domain, $rec, $type, $val, $priority);
}
|
[
"public",
"function",
"addDNSRecord",
"(",
"$",
"domain",
",",
"$",
"rec",
",",
"$",
"type",
",",
"$",
"val",
",",
"$",
"priority",
")",
"{",
"$",
"this",
"->",
"send",
"(",
"'v-add-dns-record'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"$",
"rec",
",",
"$",
"type",
",",
"$",
"val",
",",
"$",
"priority",
")",
";",
"}"
] |
Add DNS record.
@param $domain
@param $rec
@param $type
@param $val
@param $priority
|
[
"Add",
"DNS",
"record",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/DNS.php#L158-L161
|
221,825
|
Ocramius/OcraServiceManager
|
src/OcraServiceManager/ServiceFactory/ServiceManagerAccessInterceptorsFactory.php
|
ServiceManagerAccessInterceptorsFactory.createInstantiationListener
|
private function createInstantiationListener(EventManagerInterface $eventManager)
{
return function ($proxy, $instance, $method, $params, $returnValue) use ($eventManager) {
$eventName = ('create' === $method)
? ServiceManagerEvent::EVENT_SERVICEMANAGER_CREATE
: ServiceManagerEvent::EVENT_SERVICEMANAGER_GET;
$serviceName = $params['name'];
if (is_array($serviceName)) {
list($canonicalName, $serviceName) = $serviceName;
} else {
$canonicalName = strtolower(
strtr($serviceName, array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''))
);
}
$eventManager->trigger(new ServiceManagerEvent(
$eventName,
$proxy,
$returnValue,
$serviceName,
$canonicalName
));
};
}
|
php
|
private function createInstantiationListener(EventManagerInterface $eventManager)
{
return function ($proxy, $instance, $method, $params, $returnValue) use ($eventManager) {
$eventName = ('create' === $method)
? ServiceManagerEvent::EVENT_SERVICEMANAGER_CREATE
: ServiceManagerEvent::EVENT_SERVICEMANAGER_GET;
$serviceName = $params['name'];
if (is_array($serviceName)) {
list($canonicalName, $serviceName) = $serviceName;
} else {
$canonicalName = strtolower(
strtr($serviceName, array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''))
);
}
$eventManager->trigger(new ServiceManagerEvent(
$eventName,
$proxy,
$returnValue,
$serviceName,
$canonicalName
));
};
}
|
[
"private",
"function",
"createInstantiationListener",
"(",
"EventManagerInterface",
"$",
"eventManager",
")",
"{",
"return",
"function",
"(",
"$",
"proxy",
",",
"$",
"instance",
",",
"$",
"method",
",",
"$",
"params",
",",
"$",
"returnValue",
")",
"use",
"(",
"$",
"eventManager",
")",
"{",
"$",
"eventName",
"=",
"(",
"'create'",
"===",
"$",
"method",
")",
"?",
"ServiceManagerEvent",
"::",
"EVENT_SERVICEMANAGER_CREATE",
":",
"ServiceManagerEvent",
"::",
"EVENT_SERVICEMANAGER_GET",
";",
"$",
"serviceName",
"=",
"$",
"params",
"[",
"'name'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"serviceName",
")",
")",
"{",
"list",
"(",
"$",
"canonicalName",
",",
"$",
"serviceName",
")",
"=",
"$",
"serviceName",
";",
"}",
"else",
"{",
"$",
"canonicalName",
"=",
"strtolower",
"(",
"strtr",
"(",
"$",
"serviceName",
",",
"array",
"(",
"'-'",
"=>",
"''",
",",
"'_'",
"=>",
"''",
",",
"' '",
"=>",
"''",
",",
"'\\\\'",
"=>",
"''",
",",
"'/'",
"=>",
"''",
")",
")",
")",
";",
"}",
"$",
"eventManager",
"->",
"trigger",
"(",
"new",
"ServiceManagerEvent",
"(",
"$",
"eventName",
",",
"$",
"proxy",
",",
"$",
"returnValue",
",",
"$",
"serviceName",
",",
"$",
"canonicalName",
")",
")",
";",
"}",
";",
"}"
] |
Bulds a listener closure responsible for triggering events on service instantiation
@param EventManagerInterface $eventManager
@return \Closure
|
[
"Bulds",
"a",
"listener",
"closure",
"responsible",
"for",
"triggering",
"events",
"on",
"service",
"instantiation"
] |
8ca97c970ff32e138e89e93338ab3647a5d9370c
|
https://github.com/Ocramius/OcraServiceManager/blob/8ca97c970ff32e138e89e93338ab3647a5d9370c/src/OcraServiceManager/ServiceFactory/ServiceManagerAccessInterceptorsFactory.php#L62-L87
|
221,826
|
gboyegadada/lumen-jwt
|
src/JWTGuard.php
|
JWTGuard.logout
|
public function logout()
{
$this->user = null;
return $this->jwt->isHealthy()
? $this->jwt->invalidateToken()
: null;
}
|
php
|
public function logout()
{
$this->user = null;
return $this->jwt->isHealthy()
? $this->jwt->invalidateToken()
: null;
}
|
[
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"null",
";",
"return",
"$",
"this",
"->",
"jwt",
"->",
"isHealthy",
"(",
")",
"?",
"$",
"this",
"->",
"jwt",
"->",
"invalidateToken",
"(",
")",
":",
"null",
";",
"}"
] |
Invalidate token for a user.
@return string
|
[
"Invalidate",
"token",
"for",
"a",
"user",
"."
] |
3701e6615e43ec9ba33f69a92eb8dc8afe8a8c62
|
https://github.com/gboyegadada/lumen-jwt/blob/3701e6615e43ec9ba33f69a92eb8dc8afe8a8c62/src/JWTGuard.php#L209-L215
|
221,827
|
Ocramius/OcraServiceManager
|
src/OcraServiceManager/Controller/YumlController.php
|
YumlController.indexAction
|
public function indexAction()
{
$config = $this->getServiceLocator()->get('Config');
if (! $config['ocra_service_manager']['logged_service_manager']
|| ! isset($config['zenddevelopertools']['toolbar']['enabled'])
|| ! $config['zenddevelopertools']['toolbar']['enabled']
) {
throw new BadMethodCallException('Toolbar not enabled, aborting');
}
/* @var $request \Zend\Http\Request */
$request = $this->getRequest();
$client = $this->getHttpClient();
$client->setMethod(Request::METHOD_POST);
$client->setParameterPost(array(
'dsl_text' => $request->getPost('dsl_text'),
));
$response = $client->send();
if (!$response->isSuccess()) {
throw new \UnexpectedValueException('HTTP Request failed');
}
/* @var $redirect \Zend\Mvc\Controller\Plugin\Redirect */
$redirect = $this->plugin('redirect');
return $redirect->toUrl('http://yuml.me/' . $response->getBody());
}
|
php
|
public function indexAction()
{
$config = $this->getServiceLocator()->get('Config');
if (! $config['ocra_service_manager']['logged_service_manager']
|| ! isset($config['zenddevelopertools']['toolbar']['enabled'])
|| ! $config['zenddevelopertools']['toolbar']['enabled']
) {
throw new BadMethodCallException('Toolbar not enabled, aborting');
}
/* @var $request \Zend\Http\Request */
$request = $this->getRequest();
$client = $this->getHttpClient();
$client->setMethod(Request::METHOD_POST);
$client->setParameterPost(array(
'dsl_text' => $request->getPost('dsl_text'),
));
$response = $client->send();
if (!$response->isSuccess()) {
throw new \UnexpectedValueException('HTTP Request failed');
}
/* @var $redirect \Zend\Mvc\Controller\Plugin\Redirect */
$redirect = $this->plugin('redirect');
return $redirect->toUrl('http://yuml.me/' . $response->getBody());
}
|
[
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'Config'",
")",
";",
"if",
"(",
"!",
"$",
"config",
"[",
"'ocra_service_manager'",
"]",
"[",
"'logged_service_manager'",
"]",
"||",
"!",
"isset",
"(",
"$",
"config",
"[",
"'zenddevelopertools'",
"]",
"[",
"'toolbar'",
"]",
"[",
"'enabled'",
"]",
")",
"||",
"!",
"$",
"config",
"[",
"'zenddevelopertools'",
"]",
"[",
"'toolbar'",
"]",
"[",
"'enabled'",
"]",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'Toolbar not enabled, aborting'",
")",
";",
"}",
"/* @var $request \\Zend\\Http\\Request */",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"client",
"=",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
";",
"$",
"client",
"->",
"setMethod",
"(",
"Request",
"::",
"METHOD_POST",
")",
";",
"$",
"client",
"->",
"setParameterPost",
"(",
"array",
"(",
"'dsl_text'",
"=>",
"$",
"request",
"->",
"getPost",
"(",
"'dsl_text'",
")",
",",
")",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"send",
"(",
")",
";",
"if",
"(",
"!",
"$",
"response",
"->",
"isSuccess",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'HTTP Request failed'",
")",
";",
"}",
"/* @var $redirect \\Zend\\Mvc\\Controller\\Plugin\\Redirect */",
"$",
"redirect",
"=",
"$",
"this",
"->",
"plugin",
"(",
"'redirect'",
")",
";",
"return",
"$",
"redirect",
"->",
"toUrl",
"(",
"'http://yuml.me/'",
".",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"}"
] |
Redirects the user to a YUML graph drawn with the provided `dsl_text`
@return \Zend\Http\Response
@throws \UnexpectedValueException if the YUML service answered incorrectly
@throws BadMethodCallException if the request has been aborted for security reasons
|
[
"Redirects",
"the",
"user",
"to",
"a",
"YUML",
"graph",
"drawn",
"with",
"the",
"provided",
"dsl_text"
] |
8ca97c970ff32e138e89e93338ab3647a5d9370c
|
https://github.com/Ocramius/OcraServiceManager/blob/8ca97c970ff32e138e89e93338ab3647a5d9370c/src/OcraServiceManager/Controller/YumlController.php#L46-L75
|
221,828
|
gboyegadada/lumen-jwt
|
src/JWTHelper.php
|
JWTHelper.getDecoded
|
public function getDecoded()
{
if (is_null($this->token)) return null;
if (is_null($this->decoded)) {
try {
$this->decoded = JWT::decode($this->token, $this->key, ['HS512']);
}
catch (\Exception $e) {}
catch (\DomainException $e) {}
}
return $this->decoded;
}
|
php
|
public function getDecoded()
{
if (is_null($this->token)) return null;
if (is_null($this->decoded)) {
try {
$this->decoded = JWT::decode($this->token, $this->key, ['HS512']);
}
catch (\Exception $e) {}
catch (\DomainException $e) {}
}
return $this->decoded;
}
|
[
"public",
"function",
"getDecoded",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"token",
")",
")",
"return",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"decoded",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"decoded",
"=",
"JWT",
"::",
"decode",
"(",
"$",
"this",
"->",
"token",
",",
"$",
"this",
"->",
"key",
",",
"[",
"'HS512'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"catch",
"(",
"\\",
"DomainException",
"$",
"e",
")",
"{",
"}",
"}",
"return",
"$",
"this",
"->",
"decoded",
";",
"}"
] |
Get decoded token.
@return StdObject JSON Object
|
[
"Get",
"decoded",
"token",
"."
] |
3701e6615e43ec9ba33f69a92eb8dc8afe8a8c62
|
https://github.com/gboyegadada/lumen-jwt/blob/3701e6615e43ec9ba33f69a92eb8dc8afe8a8c62/src/JWTHelper.php#L124-L135
|
221,829
|
gboyegadada/lumen-jwt
|
src/JWTHelper.php
|
JWTHelper.getId
|
public function getId()
{
$decoded = $this->getDecoded();
return !is_null($decoded)
? $decoded->data->{$this->id_field}
: null;
}
|
php
|
public function getId()
{
$decoded = $this->getDecoded();
return !is_null($decoded)
? $decoded->data->{$this->id_field}
: null;
}
|
[
"public",
"function",
"getId",
"(",
")",
"{",
"$",
"decoded",
"=",
"$",
"this",
"->",
"getDecoded",
"(",
")",
";",
"return",
"!",
"is_null",
"(",
"$",
"decoded",
")",
"?",
"$",
"decoded",
"->",
"data",
"->",
"{",
"$",
"this",
"->",
"id_field",
"}",
":",
"null",
";",
"}"
] |
Get value stored in token id field
@return string
|
[
"Get",
"value",
"stored",
"in",
"token",
"id",
"field"
] |
3701e6615e43ec9ba33f69a92eb8dc8afe8a8c62
|
https://github.com/gboyegadada/lumen-jwt/blob/3701e6615e43ec9ba33f69a92eb8dc8afe8a8c62/src/JWTHelper.php#L174-L180
|
221,830
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.buildMSSQLIndexName
|
public function buildMSSQLIndexName($tableName, $indexName, $prefix = 'ix')
{
// Cleanup names of namespaced tables
$tableName = str_replace('\\', '_', $tableName);
$indexName = str_replace('\\', '_', $indexName);
return "{$prefix}_{$tableName}_{$indexName}";
}
|
php
|
public function buildMSSQLIndexName($tableName, $indexName, $prefix = 'ix')
{
// Cleanup names of namespaced tables
$tableName = str_replace('\\', '_', $tableName);
$indexName = str_replace('\\', '_', $indexName);
return "{$prefix}_{$tableName}_{$indexName}";
}
|
[
"public",
"function",
"buildMSSQLIndexName",
"(",
"$",
"tableName",
",",
"$",
"indexName",
",",
"$",
"prefix",
"=",
"'ix'",
")",
"{",
"// Cleanup names of namespaced tables",
"$",
"tableName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"tableName",
")",
";",
"$",
"indexName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"indexName",
")",
";",
"return",
"\"{$prefix}_{$tableName}_{$indexName}\"",
";",
"}"
] |
Builds the internal MS SQL Server index name given the silverstripe table and index name
@param string $tableName
@param string $indexName
@param string $prefix The optional prefix for the index. Defaults to "ix" for indexes.
@return string The name of the index
|
[
"Builds",
"the",
"internal",
"MS",
"SQL",
"Server",
"index",
"name",
"given",
"the",
"silverstripe",
"table",
"and",
"index",
"name"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L28-L36
|
221,831
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.waitUntilIndexingFinished
|
public function waitUntilIndexingFinished($maxWaitingTime = 15)
{
if (!$this->database->fullTextEnabled()) {
return;
}
$this->query("EXEC sp_fulltext_catalog 'ftCatalog', 'Rebuild';");
// Busy wait until it's done updating, but no longer than 15 seconds.
$start = time();
while (time() - $start < $maxWaitingTime) {
$status = $this->query("EXEC sp_help_fulltext_catalogs 'ftCatalog';")->first();
if (isset($status['STATUS']) && $status['STATUS'] == 0) {
// Idle!
break;
}
sleep(1);
}
}
|
php
|
public function waitUntilIndexingFinished($maxWaitingTime = 15)
{
if (!$this->database->fullTextEnabled()) {
return;
}
$this->query("EXEC sp_fulltext_catalog 'ftCatalog', 'Rebuild';");
// Busy wait until it's done updating, but no longer than 15 seconds.
$start = time();
while (time() - $start < $maxWaitingTime) {
$status = $this->query("EXEC sp_help_fulltext_catalogs 'ftCatalog';")->first();
if (isset($status['STATUS']) && $status['STATUS'] == 0) {
// Idle!
break;
}
sleep(1);
}
}
|
[
"public",
"function",
"waitUntilIndexingFinished",
"(",
"$",
"maxWaitingTime",
"=",
"15",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"database",
"->",
"fullTextEnabled",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"query",
"(",
"\"EXEC sp_fulltext_catalog 'ftCatalog', 'Rebuild';\"",
")",
";",
"// Busy wait until it's done updating, but no longer than 15 seconds.",
"$",
"start",
"=",
"time",
"(",
")",
";",
"while",
"(",
"time",
"(",
")",
"-",
"$",
"start",
"<",
"$",
"maxWaitingTime",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"query",
"(",
"\"EXEC sp_help_fulltext_catalogs 'ftCatalog';\"",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"status",
"[",
"'STATUS'",
"]",
")",
"&&",
"$",
"status",
"[",
"'STATUS'",
"]",
"==",
"0",
")",
"{",
"// Idle!",
"break",
";",
"}",
"sleep",
"(",
"1",
")",
";",
"}",
"}"
] |
Sleep until the catalog has been fully rebuilt. This is a busy wait designed for situations
when you need to be sure the index is up to date - for example in unit tests.
TODO: move this to Database class? Can we assume this will be useful for all databases?
Also see the wrapper functions "waitUntilIndexingFinished" in SearchFormTest and TranslatableSearchFormTest
@param int $maxWaitingTime Time in seconds to wait for the database.
|
[
"Sleep",
"until",
"the",
"catalog",
"has",
"been",
"fully",
"rebuilt",
".",
"This",
"is",
"a",
"busy",
"wait",
"designed",
"for",
"situations",
"when",
"you",
"need",
"to",
"be",
"sure",
"the",
"index",
"is",
"up",
"to",
"date",
"-",
"for",
"example",
"in",
"unit",
"tests",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L75-L94
|
221,832
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.fulltextIndexExists
|
public function fulltextIndexExists($tableName)
{
// Special case for no full text index support
if (!$this->database->fullTextEnabled()) {
return null;
}
return (bool) $this->preparedQuery("
SELECT 1 FROM sys.fulltext_indexes i
JOIN sys.objects o ON i.object_id = o.object_id
WHERE o.name = ?",
array($tableName)
)->value();
}
|
php
|
public function fulltextIndexExists($tableName)
{
// Special case for no full text index support
if (!$this->database->fullTextEnabled()) {
return null;
}
return (bool) $this->preparedQuery("
SELECT 1 FROM sys.fulltext_indexes i
JOIN sys.objects o ON i.object_id = o.object_id
WHERE o.name = ?",
array($tableName)
)->value();
}
|
[
"public",
"function",
"fulltextIndexExists",
"(",
"$",
"tableName",
")",
"{",
"// Special case for no full text index support",
"if",
"(",
"!",
"$",
"this",
"->",
"database",
"->",
"fullTextEnabled",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"preparedQuery",
"(",
"\"\n\t\t\tSELECT 1 FROM sys.fulltext_indexes i\n\t\t\tJOIN sys.objects o ON i.object_id = o.object_id\n\t\t\tWHERE o.name = ?\"",
",",
"array",
"(",
"$",
"tableName",
")",
")",
"->",
"value",
"(",
")",
";",
"}"
] |
Check if a fulltext index exists on a particular table name.
@param string $tableName
@return boolean TRUE index exists | FALSE index does not exist | NULL no support
|
[
"Check",
"if",
"a",
"fulltext",
"index",
"exists",
"on",
"a",
"particular",
"table",
"name",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L102-L115
|
221,833
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.getPrimaryKey
|
public function getPrimaryKey($tableName)
{
$indexes = $this->query("EXEC sp_helpindex '$tableName';");
$indexName = '';
foreach ($indexes as $index) {
if ($index['index_keys'] == 'ID') {
$indexName = $index['index_name'];
break;
}
}
return $indexName;
}
|
php
|
public function getPrimaryKey($tableName)
{
$indexes = $this->query("EXEC sp_helpindex '$tableName';");
$indexName = '';
foreach ($indexes as $index) {
if ($index['index_keys'] == 'ID') {
$indexName = $index['index_name'];
break;
}
}
return $indexName;
}
|
[
"public",
"function",
"getPrimaryKey",
"(",
"$",
"tableName",
")",
"{",
"$",
"indexes",
"=",
"$",
"this",
"->",
"query",
"(",
"\"EXEC sp_helpindex '$tableName';\"",
")",
";",
"$",
"indexName",
"=",
"''",
";",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
"[",
"'index_keys'",
"]",
"==",
"'ID'",
")",
"{",
"$",
"indexName",
"=",
"$",
"index",
"[",
"'index_name'",
"]",
";",
"break",
";",
"}",
"}",
"return",
"$",
"indexName",
";",
"}"
] |
MSSQL stores the primary key column with an internal identifier,
so a lookup needs to be done to determine it.
@param string $tableName Name of table with primary key column "ID"
@return string Internal identifier for primary key
|
[
"MSSQL",
"stores",
"the",
"primary",
"key",
"column",
"with",
"an",
"internal",
"identifier",
"so",
"a",
"lookup",
"needs",
"to",
"be",
"done",
"to",
"determine",
"it",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L124-L136
|
221,834
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.alterTable
|
public function alterTable($tableName, $newFields = null, $newIndexes = null, $alteredFields = null, $alteredIndexes = null, $alteredOptions=null, $advancedOptions=null)
{
$alterList = array();
// drop any fulltext indexes that exist on the table before altering the structure
if ($this->fulltextIndexExists($tableName)) {
$alterList[] = "\nDROP FULLTEXT INDEX ON \"$tableName\";";
}
if ($newFields) {
foreach ($newFields as $k => $v) {
$alterList[] = "ALTER TABLE \"$tableName\" ADD \"$k\" $v";
}
}
if ($alteredFields) {
foreach ($alteredFields as $k => $v) {
$alterList[] = $this->alterTableAlterColumn($tableName, $k, $v);
}
}
if ($alteredIndexes) {
foreach ($alteredIndexes as $k => $v) {
$alterList[] = $this->getIndexSqlDefinition($tableName, $k, $v);
}
}
if ($newIndexes) {
foreach ($newIndexes as $k => $v) {
$alterList[] = $this->getIndexSqlDefinition($tableName, $k, $v);
}
}
if ($alterList) {
foreach ($alterList as $alteration) {
if ($alteration != '') {
$this->query($alteration);
}
}
}
}
|
php
|
public function alterTable($tableName, $newFields = null, $newIndexes = null, $alteredFields = null, $alteredIndexes = null, $alteredOptions=null, $advancedOptions=null)
{
$alterList = array();
// drop any fulltext indexes that exist on the table before altering the structure
if ($this->fulltextIndexExists($tableName)) {
$alterList[] = "\nDROP FULLTEXT INDEX ON \"$tableName\";";
}
if ($newFields) {
foreach ($newFields as $k => $v) {
$alterList[] = "ALTER TABLE \"$tableName\" ADD \"$k\" $v";
}
}
if ($alteredFields) {
foreach ($alteredFields as $k => $v) {
$alterList[] = $this->alterTableAlterColumn($tableName, $k, $v);
}
}
if ($alteredIndexes) {
foreach ($alteredIndexes as $k => $v) {
$alterList[] = $this->getIndexSqlDefinition($tableName, $k, $v);
}
}
if ($newIndexes) {
foreach ($newIndexes as $k => $v) {
$alterList[] = $this->getIndexSqlDefinition($tableName, $k, $v);
}
}
if ($alterList) {
foreach ($alterList as $alteration) {
if ($alteration != '') {
$this->query($alteration);
}
}
}
}
|
[
"public",
"function",
"alterTable",
"(",
"$",
"tableName",
",",
"$",
"newFields",
"=",
"null",
",",
"$",
"newIndexes",
"=",
"null",
",",
"$",
"alteredFields",
"=",
"null",
",",
"$",
"alteredIndexes",
"=",
"null",
",",
"$",
"alteredOptions",
"=",
"null",
",",
"$",
"advancedOptions",
"=",
"null",
")",
"{",
"$",
"alterList",
"=",
"array",
"(",
")",
";",
"// drop any fulltext indexes that exist on the table before altering the structure",
"if",
"(",
"$",
"this",
"->",
"fulltextIndexExists",
"(",
"$",
"tableName",
")",
")",
"{",
"$",
"alterList",
"[",
"]",
"=",
"\"\\nDROP FULLTEXT INDEX ON \\\"$tableName\\\";\"",
";",
"}",
"if",
"(",
"$",
"newFields",
")",
"{",
"foreach",
"(",
"$",
"newFields",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"alterList",
"[",
"]",
"=",
"\"ALTER TABLE \\\"$tableName\\\" ADD \\\"$k\\\" $v\"",
";",
"}",
"}",
"if",
"(",
"$",
"alteredFields",
")",
"{",
"foreach",
"(",
"$",
"alteredFields",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"alterList",
"[",
"]",
"=",
"$",
"this",
"->",
"alterTableAlterColumn",
"(",
"$",
"tableName",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"if",
"(",
"$",
"alteredIndexes",
")",
"{",
"foreach",
"(",
"$",
"alteredIndexes",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"alterList",
"[",
"]",
"=",
"$",
"this",
"->",
"getIndexSqlDefinition",
"(",
"$",
"tableName",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"if",
"(",
"$",
"newIndexes",
")",
"{",
"foreach",
"(",
"$",
"newIndexes",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"alterList",
"[",
"]",
"=",
"$",
"this",
"->",
"getIndexSqlDefinition",
"(",
"$",
"tableName",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"if",
"(",
"$",
"alterList",
")",
"{",
"foreach",
"(",
"$",
"alterList",
"as",
"$",
"alteration",
")",
"{",
"if",
"(",
"$",
"alteration",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"query",
"(",
"$",
"alteration",
")",
";",
"}",
"}",
"}",
"}"
] |
Alter a table's schema.
@param string $tableName The name of the table to alter
@param array $newFields New fields, a map of field name => field schema
@param array $newIndexes New indexes, a map of index name => index type
@param array $alteredFields Updated fields, a map of field name => field schema
@param array $alteredIndexes Updated indexes, a map of index name => index type
@param array $alteredOptions
@param array $advancedOptions
|
[
"Alter",
"a",
"table",
"s",
"schema",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L241-L279
|
221,835
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.getConstraintCheckClause
|
public function getConstraintCheckClause($tableName, $columnName)
{
// Check already processed table columns
if (isset(self::$cached_checks[$tableName])) {
if (!isset(self::$cached_checks[$tableName][$columnName])) {
return null;
}
return self::$cached_checks[$tableName][$columnName];
}
// Regenerate cehcks for this table
$checks = array();
foreach ($this->preparedQuery("
SELECT CAST(CHECK_CLAUSE AS TEXT) AS CHECK_CLAUSE, COLUMN_NAME
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS AS CC
INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS CCU ON CCU.CONSTRAINT_NAME = CC.CONSTRAINT_NAME
WHERE TABLE_NAME = ?",
array($tableName)
) as $record) {
$checks[$record['COLUMN_NAME']] = $record['CHECK_CLAUSE'];
}
self::$cached_checks[$tableName] = $checks;
// Return via cached records
return $this->getConstraintCheckClause($tableName, $columnName);
}
|
php
|
public function getConstraintCheckClause($tableName, $columnName)
{
// Check already processed table columns
if (isset(self::$cached_checks[$tableName])) {
if (!isset(self::$cached_checks[$tableName][$columnName])) {
return null;
}
return self::$cached_checks[$tableName][$columnName];
}
// Regenerate cehcks for this table
$checks = array();
foreach ($this->preparedQuery("
SELECT CAST(CHECK_CLAUSE AS TEXT) AS CHECK_CLAUSE, COLUMN_NAME
FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS AS CC
INNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS CCU ON CCU.CONSTRAINT_NAME = CC.CONSTRAINT_NAME
WHERE TABLE_NAME = ?",
array($tableName)
) as $record) {
$checks[$record['COLUMN_NAME']] = $record['CHECK_CLAUSE'];
}
self::$cached_checks[$tableName] = $checks;
// Return via cached records
return $this->getConstraintCheckClause($tableName, $columnName);
}
|
[
"public",
"function",
"getConstraintCheckClause",
"(",
"$",
"tableName",
",",
"$",
"columnName",
")",
"{",
"// Check already processed table columns",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cached_checks",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"cached_checks",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"self",
"::",
"$",
"cached_checks",
"[",
"$",
"tableName",
"]",
"[",
"$",
"columnName",
"]",
";",
"}",
"// Regenerate cehcks for this table",
"$",
"checks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"preparedQuery",
"(",
"\"\n\t\t\tSELECT CAST(CHECK_CLAUSE AS TEXT) AS CHECK_CLAUSE, COLUMN_NAME\n\t\t\tFROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS AS CC\n\t\t\tINNER JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE AS CCU ON CCU.CONSTRAINT_NAME = CC.CONSTRAINT_NAME\n\t\t\tWHERE TABLE_NAME = ?\"",
",",
"array",
"(",
"$",
"tableName",
")",
")",
"as",
"$",
"record",
")",
"{",
"$",
"checks",
"[",
"$",
"record",
"[",
"'COLUMN_NAME'",
"]",
"]",
"=",
"$",
"record",
"[",
"'CHECK_CLAUSE'",
"]",
";",
"}",
"self",
"::",
"$",
"cached_checks",
"[",
"$",
"tableName",
"]",
"=",
"$",
"checks",
";",
"// Return via cached records",
"return",
"$",
"this",
"->",
"getConstraintCheckClause",
"(",
"$",
"tableName",
",",
"$",
"columnName",
")",
";",
"}"
] |
Given a table and column name, return a check constraint clause for that column in
the table.
This is an expensive query, so it is cached per-request and stored by table. The initial
call for a table that has not been cached will query all columns and store that
so subsequent calls are fast.
@param string $tableName Table name column resides in
@param string $columnName Column name the constraint is for
@return string The check string
|
[
"Given",
"a",
"table",
"and",
"column",
"name",
"return",
"a",
"check",
"constraint",
"clause",
"for",
"that",
"column",
"in",
"the",
"table",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L311-L336
|
221,836
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.enumValuesFromCheckClause
|
protected function enumValuesFromCheckClause($clause)
{
$segments = preg_split('/ +OR *\[/i', $clause);
$constraints = array();
foreach ($segments as $segment) {
$bits = preg_split('/ *= */', $segment);
for ($i = 1; $i < sizeof($bits); $i += 2) {
array_unshift($constraints, substr(rtrim($bits[$i], ')'), 1, -1));
}
}
return $constraints;
}
|
php
|
protected function enumValuesFromCheckClause($clause)
{
$segments = preg_split('/ +OR *\[/i', $clause);
$constraints = array();
foreach ($segments as $segment) {
$bits = preg_split('/ *= */', $segment);
for ($i = 1; $i < sizeof($bits); $i += 2) {
array_unshift($constraints, substr(rtrim($bits[$i], ')'), 1, -1));
}
}
return $constraints;
}
|
[
"protected",
"function",
"enumValuesFromCheckClause",
"(",
"$",
"clause",
")",
"{",
"$",
"segments",
"=",
"preg_split",
"(",
"'/ +OR *\\[/i'",
",",
"$",
"clause",
")",
";",
"$",
"constraints",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"segment",
")",
"{",
"$",
"bits",
"=",
"preg_split",
"(",
"'/ *= */'",
",",
"$",
"segment",
")",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"bits",
")",
";",
"$",
"i",
"+=",
"2",
")",
"{",
"array_unshift",
"(",
"$",
"constraints",
",",
"substr",
"(",
"rtrim",
"(",
"$",
"bits",
"[",
"$",
"i",
"]",
",",
"')'",
")",
",",
"1",
",",
"-",
"1",
")",
")",
";",
"}",
"}",
"return",
"$",
"constraints",
";",
"}"
] |
Get enum values from a constraint check clause.
@param string $clause Check clause to parse values from
@return array Enum values
|
[
"Get",
"enum",
"values",
"from",
"a",
"constraint",
"check",
"clause",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L366-L377
|
221,837
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.getIndexSqlDefinition
|
protected function getIndexSqlDefinition($tableName, $indexName, $indexSpec)
{
// Determine index name
$index = $this->buildMSSQLIndexName($tableName, $indexName);
// Consolidate/Cleanup spec into array format
$indexSpec = $this->parseIndexSpec($indexName, $indexSpec);
$drop = "IF EXISTS (SELECT name FROM sys.indexes WHERE name = '$index' AND object_id = object_id(SCHEMA_NAME() + '.$tableName')) DROP INDEX $index ON \"$tableName\";";
// create a type-specific index
if ($indexSpec['type'] == 'fulltext') {
if(!$this->database->fullTextEnabled()) {
return '';
}
// enable fulltext on this table
$this->createFullTextCatalog();
$primary_key = $this->getPrimaryKey($tableName);
if ($primary_key) {
return "$drop CREATE FULLTEXT INDEX ON \"$tableName\" ({$indexSpec['value']})"
. "KEY INDEX $primary_key WITH CHANGE_TRACKING AUTO;";
}
}
if ($indexSpec['type'] == 'unique') {
return "$drop CREATE UNIQUE INDEX $index ON \"$tableName\" ({$indexSpec['value']});";
}
return "$drop CREATE INDEX $index ON \"$tableName\" ({$indexSpec['value']});";
}
|
php
|
protected function getIndexSqlDefinition($tableName, $indexName, $indexSpec)
{
// Determine index name
$index = $this->buildMSSQLIndexName($tableName, $indexName);
// Consolidate/Cleanup spec into array format
$indexSpec = $this->parseIndexSpec($indexName, $indexSpec);
$drop = "IF EXISTS (SELECT name FROM sys.indexes WHERE name = '$index' AND object_id = object_id(SCHEMA_NAME() + '.$tableName')) DROP INDEX $index ON \"$tableName\";";
// create a type-specific index
if ($indexSpec['type'] == 'fulltext') {
if(!$this->database->fullTextEnabled()) {
return '';
}
// enable fulltext on this table
$this->createFullTextCatalog();
$primary_key = $this->getPrimaryKey($tableName);
if ($primary_key) {
return "$drop CREATE FULLTEXT INDEX ON \"$tableName\" ({$indexSpec['value']})"
. "KEY INDEX $primary_key WITH CHANGE_TRACKING AUTO;";
}
}
if ($indexSpec['type'] == 'unique') {
return "$drop CREATE UNIQUE INDEX $index ON \"$tableName\" ({$indexSpec['value']});";
}
return "$drop CREATE INDEX $index ON \"$tableName\" ({$indexSpec['value']});";
}
|
[
"protected",
"function",
"getIndexSqlDefinition",
"(",
"$",
"tableName",
",",
"$",
"indexName",
",",
"$",
"indexSpec",
")",
"{",
"// Determine index name",
"$",
"index",
"=",
"$",
"this",
"->",
"buildMSSQLIndexName",
"(",
"$",
"tableName",
",",
"$",
"indexName",
")",
";",
"// Consolidate/Cleanup spec into array format",
"$",
"indexSpec",
"=",
"$",
"this",
"->",
"parseIndexSpec",
"(",
"$",
"indexName",
",",
"$",
"indexSpec",
")",
";",
"$",
"drop",
"=",
"\"IF EXISTS (SELECT name FROM sys.indexes WHERE name = '$index' AND object_id = object_id(SCHEMA_NAME() + '.$tableName')) DROP INDEX $index ON \\\"$tableName\\\";\"",
";",
"// create a type-specific index",
"if",
"(",
"$",
"indexSpec",
"[",
"'type'",
"]",
"==",
"'fulltext'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"database",
"->",
"fullTextEnabled",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"// enable fulltext on this table",
"$",
"this",
"->",
"createFullTextCatalog",
"(",
")",
";",
"$",
"primary_key",
"=",
"$",
"this",
"->",
"getPrimaryKey",
"(",
"$",
"tableName",
")",
";",
"if",
"(",
"$",
"primary_key",
")",
"{",
"return",
"\"$drop CREATE FULLTEXT INDEX ON \\\"$tableName\\\" ({$indexSpec['value']})\"",
".",
"\"KEY INDEX $primary_key WITH CHANGE_TRACKING AUTO;\"",
";",
"}",
"}",
"if",
"(",
"$",
"indexSpec",
"[",
"'type'",
"]",
"==",
"'unique'",
")",
"{",
"return",
"\"$drop CREATE UNIQUE INDEX $index ON \\\"$tableName\\\" ({$indexSpec['value']});\"",
";",
"}",
"return",
"\"$drop CREATE INDEX $index ON \\\"$tableName\\\" ({$indexSpec['value']});\"",
";",
"}"
] |
Return SQL for dropping and recreating an index
@param string $tableName Name of table to create this index against
@param string $indexName Name of this index
@param array|string $indexSpec Index specification, either as a raw string
or parsed array form
@return string The SQL required to generate this index
|
[
"Return",
"SQL",
"for",
"dropping",
"and",
"recreating",
"an",
"index"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L603-L634
|
221,838
|
silverstripe/silverstripe-mssql
|
code/MSSQLSchemaManager.php
|
MSSQLSchemaManager.indexList
|
public function indexList($table)
{
$indexes = $this->query("EXEC sp_helpindex '$table';");
$indexList = array();
// Enumerate all basic indexes
foreach ($indexes as $index) {
if (strpos($index['index_description'], 'unique') !== false) {
$indexType = 'unique ';
} else {
$indexType = 'index ';
}
// Extract name from index
$baseIndexName = $this->buildMSSQLIndexName($table, '');
$indexName = substr($index['index_name'], strlen($baseIndexName));
// Extract columns
$columns = $this->quoteColumnSpecString($index['index_keys']);
$indexList[$indexName] = $this->parseIndexSpec($indexName, array(
'name' => $indexName,
'value' => $columns,
'type' => $indexType
));
}
// Now we need to check to see if we have any fulltext indexes attached to this table:
if ($this->database->fullTextEnabled()) {
$result = $this->query('EXEC sp_help_fulltext_columns;');
// Extract columns from this fulltext definition
$columns = array();
foreach ($result as $row) {
if ($row['TABLE_NAME'] == $table) {
$columns[] = $row['FULLTEXT_COLUMN_NAME'];
}
}
if (!empty($columns)) {
$indexList['SearchFields'] = $this->parseIndexSpec('SearchFields', array(
'name' => 'SearchFields',
'value' => $this->implodeColumnList($columns),
'type' => 'fulltext'
));
}
}
return $indexList;
}
|
php
|
public function indexList($table)
{
$indexes = $this->query("EXEC sp_helpindex '$table';");
$indexList = array();
// Enumerate all basic indexes
foreach ($indexes as $index) {
if (strpos($index['index_description'], 'unique') !== false) {
$indexType = 'unique ';
} else {
$indexType = 'index ';
}
// Extract name from index
$baseIndexName = $this->buildMSSQLIndexName($table, '');
$indexName = substr($index['index_name'], strlen($baseIndexName));
// Extract columns
$columns = $this->quoteColumnSpecString($index['index_keys']);
$indexList[$indexName] = $this->parseIndexSpec($indexName, array(
'name' => $indexName,
'value' => $columns,
'type' => $indexType
));
}
// Now we need to check to see if we have any fulltext indexes attached to this table:
if ($this->database->fullTextEnabled()) {
$result = $this->query('EXEC sp_help_fulltext_columns;');
// Extract columns from this fulltext definition
$columns = array();
foreach ($result as $row) {
if ($row['TABLE_NAME'] == $table) {
$columns[] = $row['FULLTEXT_COLUMN_NAME'];
}
}
if (!empty($columns)) {
$indexList['SearchFields'] = $this->parseIndexSpec('SearchFields', array(
'name' => 'SearchFields',
'value' => $this->implodeColumnList($columns),
'type' => 'fulltext'
));
}
}
return $indexList;
}
|
[
"public",
"function",
"indexList",
"(",
"$",
"table",
")",
"{",
"$",
"indexes",
"=",
"$",
"this",
"->",
"query",
"(",
"\"EXEC sp_helpindex '$table';\"",
")",
";",
"$",
"indexList",
"=",
"array",
"(",
")",
";",
"// Enumerate all basic indexes",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"index",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"index",
"[",
"'index_description'",
"]",
",",
"'unique'",
")",
"!==",
"false",
")",
"{",
"$",
"indexType",
"=",
"'unique '",
";",
"}",
"else",
"{",
"$",
"indexType",
"=",
"'index '",
";",
"}",
"// Extract name from index",
"$",
"baseIndexName",
"=",
"$",
"this",
"->",
"buildMSSQLIndexName",
"(",
"$",
"table",
",",
"''",
")",
";",
"$",
"indexName",
"=",
"substr",
"(",
"$",
"index",
"[",
"'index_name'",
"]",
",",
"strlen",
"(",
"$",
"baseIndexName",
")",
")",
";",
"// Extract columns",
"$",
"columns",
"=",
"$",
"this",
"->",
"quoteColumnSpecString",
"(",
"$",
"index",
"[",
"'index_keys'",
"]",
")",
";",
"$",
"indexList",
"[",
"$",
"indexName",
"]",
"=",
"$",
"this",
"->",
"parseIndexSpec",
"(",
"$",
"indexName",
",",
"array",
"(",
"'name'",
"=>",
"$",
"indexName",
",",
"'value'",
"=>",
"$",
"columns",
",",
"'type'",
"=>",
"$",
"indexType",
")",
")",
";",
"}",
"// Now we need to check to see if we have any fulltext indexes attached to this table:",
"if",
"(",
"$",
"this",
"->",
"database",
"->",
"fullTextEnabled",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"query",
"(",
"'EXEC sp_help_fulltext_columns;'",
")",
";",
"// Extract columns from this fulltext definition",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"[",
"'TABLE_NAME'",
"]",
"==",
"$",
"table",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"$",
"row",
"[",
"'FULLTEXT_COLUMN_NAME'",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"indexList",
"[",
"'SearchFields'",
"]",
"=",
"$",
"this",
"->",
"parseIndexSpec",
"(",
"'SearchFields'",
",",
"array",
"(",
"'name'",
"=>",
"'SearchFields'",
",",
"'value'",
"=>",
"$",
"this",
"->",
"implodeColumnList",
"(",
"$",
"columns",
")",
",",
"'type'",
"=>",
"'fulltext'",
")",
")",
";",
"}",
"}",
"return",
"$",
"indexList",
";",
"}"
] |
Return the list of indexes in a table.
@param string $table The table name.
@return array
|
[
"Return",
"the",
"list",
"of",
"indexes",
"in",
"a",
"table",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLSchemaManager.php#L646-L694
|
221,839
|
silverstripe/silverstripe-mssql
|
code/MSSQLAzureDatabase.php
|
MSSQLAzureDatabase.connectDatabase
|
protected function connectDatabase($database)
{
$parameters = $this->parameters;
$parameters['database'] = $database;
$parameters['multipleactiveresultsets'] = 0;
// Ensure that driver is available (required by PDO)
if (empty($parameters['driver'])) {
$parameters['driver'] = $this->getDatabaseServer();
}
// Notify connector of parameters, instructing the connector
// to connect immediately to the Azure database
$this->connector->connect($parameters, true);
// Configure the connection
$this->query('SET QUOTED_IDENTIFIER ON');
$this->query('SET TEXTSIZE 2147483647');
}
|
php
|
protected function connectDatabase($database)
{
$parameters = $this->parameters;
$parameters['database'] = $database;
$parameters['multipleactiveresultsets'] = 0;
// Ensure that driver is available (required by PDO)
if (empty($parameters['driver'])) {
$parameters['driver'] = $this->getDatabaseServer();
}
// Notify connector of parameters, instructing the connector
// to connect immediately to the Azure database
$this->connector->connect($parameters, true);
// Configure the connection
$this->query('SET QUOTED_IDENTIFIER ON');
$this->query('SET TEXTSIZE 2147483647');
}
|
[
"protected",
"function",
"connectDatabase",
"(",
"$",
"database",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"parameters",
";",
"$",
"parameters",
"[",
"'database'",
"]",
"=",
"$",
"database",
";",
"$",
"parameters",
"[",
"'multipleactiveresultsets'",
"]",
"=",
"0",
";",
"// Ensure that driver is available (required by PDO)",
"if",
"(",
"empty",
"(",
"$",
"parameters",
"[",
"'driver'",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"'driver'",
"]",
"=",
"$",
"this",
"->",
"getDatabaseServer",
"(",
")",
";",
"}",
"// Notify connector of parameters, instructing the connector",
"// to connect immediately to the Azure database",
"$",
"this",
"->",
"connector",
"->",
"connect",
"(",
"$",
"parameters",
",",
"true",
")",
";",
"// Configure the connection",
"$",
"this",
"->",
"query",
"(",
"'SET QUOTED_IDENTIFIER ON'",
")",
";",
"$",
"this",
"->",
"query",
"(",
"'SET TEXTSIZE 2147483647'",
")",
";",
"}"
] |
Connect to a database using the provided parameters
@param string $database
|
[
"Connect",
"to",
"a",
"database",
"using",
"the",
"provided",
"parameters"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLAzureDatabase.php#L62-L80
|
221,840
|
silverstripe/silverstripe-mssql
|
code/MSSQLAzureDatabase.php
|
MSSQLAzureDatabase.selectDatabase
|
public function selectDatabase($name, $create = false, $errorLevel = E_USER_ERROR)
{
$this->fullTextEnabled = null;
if (!$this->schemaManager->databaseExists($name)) {
// Check DB creation permisson
if (!$create) {
if ($errorLevel !== false) {
user_error("Attempted to connect to non-existing database \"$name\"", $errorLevel);
}
// Unselect database
$this->connector->unloadDatabase();
return false;
}
$this->schemaManager->createDatabase($name);
}
$this->connectDatabase($name);
return true;
}
|
php
|
public function selectDatabase($name, $create = false, $errorLevel = E_USER_ERROR)
{
$this->fullTextEnabled = null;
if (!$this->schemaManager->databaseExists($name)) {
// Check DB creation permisson
if (!$create) {
if ($errorLevel !== false) {
user_error("Attempted to connect to non-existing database \"$name\"", $errorLevel);
}
// Unselect database
$this->connector->unloadDatabase();
return false;
}
$this->schemaManager->createDatabase($name);
}
$this->connectDatabase($name);
return true;
}
|
[
"public",
"function",
"selectDatabase",
"(",
"$",
"name",
",",
"$",
"create",
"=",
"false",
",",
"$",
"errorLevel",
"=",
"E_USER_ERROR",
")",
"{",
"$",
"this",
"->",
"fullTextEnabled",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"schemaManager",
"->",
"databaseExists",
"(",
"$",
"name",
")",
")",
"{",
"// Check DB creation permisson",
"if",
"(",
"!",
"$",
"create",
")",
"{",
"if",
"(",
"$",
"errorLevel",
"!==",
"false",
")",
"{",
"user_error",
"(",
"\"Attempted to connect to non-existing database \\\"$name\\\"\"",
",",
"$",
"errorLevel",
")",
";",
"}",
"// Unselect database",
"$",
"this",
"->",
"connector",
"->",
"unloadDatabase",
"(",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"schemaManager",
"->",
"createDatabase",
"(",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"connectDatabase",
"(",
"$",
"name",
")",
";",
"return",
"true",
";",
"}"
] |
Switches to the given database.
IMPORTANT: SQL Azure doesn't support "USE", so we need
to reinitialize the database connection with the requested
database name.
@see http://msdn.microsoft.com/en-us/library/windowsazure/ee336288.aspx
@param string $name The database name to switch to
@param bool $create
@param bool|int $errorLevel
@return bool
|
[
"Switches",
"to",
"the",
"given",
"database",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLAzureDatabase.php#L95-L112
|
221,841
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.fullTextSearchMSSQL
|
public function fullTextSearchMSSQL($tableName, $keywords, $fields = null)
{
// Make sure we are getting an array of fields
if (isset($fields) && !is_array($fields)) {
$fields = array($fields);
}
// Strip unfriendly characters, SQLServer "CONTAINS" predicate will crash on & and | and ignore others anyway.
if (function_exists('mb_ereg_replace')) {
$keywords = mb_ereg_replace('[^\w\s]', '', trim($keywords));
} else {
$keywords = $this->escapeString(str_replace(array('&', '|', '!', '"', '\''), '', trim($keywords)));
}
// Remove stopwords, concat with ANDs
$keywordList = explode(' ', $keywords);
$keywordList = $this->removeStopwords($keywordList);
// remove any empty values from the array
$keywordList = array_filter($keywordList);
if (empty($keywordList)) {
return null;
}
$keywords = implode(' AND ', $keywordList);
if ($fields) {
$fieldNames = '"' . implode('", "', $fields) . '"';
} else {
$fieldNames = "*";
}
return "CONTAINSTABLE(\"$tableName\", ($fieldNames), '$keywords')";
}
|
php
|
public function fullTextSearchMSSQL($tableName, $keywords, $fields = null)
{
// Make sure we are getting an array of fields
if (isset($fields) && !is_array($fields)) {
$fields = array($fields);
}
// Strip unfriendly characters, SQLServer "CONTAINS" predicate will crash on & and | and ignore others anyway.
if (function_exists('mb_ereg_replace')) {
$keywords = mb_ereg_replace('[^\w\s]', '', trim($keywords));
} else {
$keywords = $this->escapeString(str_replace(array('&', '|', '!', '"', '\''), '', trim($keywords)));
}
// Remove stopwords, concat with ANDs
$keywordList = explode(' ', $keywords);
$keywordList = $this->removeStopwords($keywordList);
// remove any empty values from the array
$keywordList = array_filter($keywordList);
if (empty($keywordList)) {
return null;
}
$keywords = implode(' AND ', $keywordList);
if ($fields) {
$fieldNames = '"' . implode('", "', $fields) . '"';
} else {
$fieldNames = "*";
}
return "CONTAINSTABLE(\"$tableName\", ($fieldNames), '$keywords')";
}
|
[
"public",
"function",
"fullTextSearchMSSQL",
"(",
"$",
"tableName",
",",
"$",
"keywords",
",",
"$",
"fields",
"=",
"null",
")",
"{",
"// Make sure we are getting an array of fields",
"if",
"(",
"isset",
"(",
"$",
"fields",
")",
"&&",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
"$",
"fields",
")",
";",
"}",
"// Strip unfriendly characters, SQLServer \"CONTAINS\" predicate will crash on & and | and ignore others anyway.",
"if",
"(",
"function_exists",
"(",
"'mb_ereg_replace'",
")",
")",
"{",
"$",
"keywords",
"=",
"mb_ereg_replace",
"(",
"'[^\\w\\s]'",
",",
"''",
",",
"trim",
"(",
"$",
"keywords",
")",
")",
";",
"}",
"else",
"{",
"$",
"keywords",
"=",
"$",
"this",
"->",
"escapeString",
"(",
"str_replace",
"(",
"array",
"(",
"'&'",
",",
"'|'",
",",
"'!'",
",",
"'\"'",
",",
"'\\''",
")",
",",
"''",
",",
"trim",
"(",
"$",
"keywords",
")",
")",
")",
";",
"}",
"// Remove stopwords, concat with ANDs",
"$",
"keywordList",
"=",
"explode",
"(",
"' '",
",",
"$",
"keywords",
")",
";",
"$",
"keywordList",
"=",
"$",
"this",
"->",
"removeStopwords",
"(",
"$",
"keywordList",
")",
";",
"// remove any empty values from the array",
"$",
"keywordList",
"=",
"array_filter",
"(",
"$",
"keywordList",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"keywordList",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"keywords",
"=",
"implode",
"(",
"' AND '",
",",
"$",
"keywordList",
")",
";",
"if",
"(",
"$",
"fields",
")",
"{",
"$",
"fieldNames",
"=",
"'\"'",
".",
"implode",
"(",
"'\", \"'",
",",
"$",
"fields",
")",
".",
"'\"'",
";",
"}",
"else",
"{",
"$",
"fieldNames",
"=",
"\"*\"",
";",
"}",
"return",
"\"CONTAINSTABLE(\\\"$tableName\\\", ($fieldNames), '$keywords')\"",
";",
"}"
] |
Returns a SQL fragment for querying a fulltext search index
@param string $tableName specific - table name
@param string $keywords The search query
@param array $fields The list of field names to search on, or null to include all
@return string Clause, or null if keyword set is empty or the string with JOIN clause to be added to SQL query
|
[
"Returns",
"a",
"SQL",
"fragment",
"for",
"querying",
"a",
"fulltext",
"search",
"index"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L370-L402
|
221,842
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.removeStopwords
|
public function removeStopwords($keywords)
{
$goodKeywords = array();
foreach ($keywords as $keyword) {
if (in_array($keyword, self::$noiseWords)) {
continue;
}
$goodKeywords[] = trim($keyword);
}
return $goodKeywords;
}
|
php
|
public function removeStopwords($keywords)
{
$goodKeywords = array();
foreach ($keywords as $keyword) {
if (in_array($keyword, self::$noiseWords)) {
continue;
}
$goodKeywords[] = trim($keyword);
}
return $goodKeywords;
}
|
[
"public",
"function",
"removeStopwords",
"(",
"$",
"keywords",
")",
"{",
"$",
"goodKeywords",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"keywords",
"as",
"$",
"keyword",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"keyword",
",",
"self",
"::",
"$",
"noiseWords",
")",
")",
"{",
"continue",
";",
"}",
"$",
"goodKeywords",
"[",
"]",
"=",
"trim",
"(",
"$",
"keyword",
")",
";",
"}",
"return",
"$",
"goodKeywords",
";",
"}"
] |
Remove stopwords that would kill a MSSQL full-text query
@param array $keywords
@return array $keywords with stopwords removed
|
[
"Remove",
"stopwords",
"that",
"would",
"kill",
"a",
"MSSQL",
"full",
"-",
"text",
"query"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L411-L421
|
221,843
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.supportsExtensions
|
public function supportsExtensions($extensions = array('partitions', 'tablespaces', 'clustering'))
{
if (isset($extensions['partitions'])) {
return false;
} elseif (isset($extensions['tablespaces'])) {
return false;
} elseif (isset($extensions['clustering'])) {
return false;
} else {
return false;
}
}
|
php
|
public function supportsExtensions($extensions = array('partitions', 'tablespaces', 'clustering'))
{
if (isset($extensions['partitions'])) {
return false;
} elseif (isset($extensions['tablespaces'])) {
return false;
} elseif (isset($extensions['clustering'])) {
return false;
} else {
return false;
}
}
|
[
"public",
"function",
"supportsExtensions",
"(",
"$",
"extensions",
"=",
"array",
"(",
"'partitions'",
",",
"'tablespaces'",
",",
"'clustering'",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"extensions",
"[",
"'partitions'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"extensions",
"[",
"'tablespaces'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"extensions",
"[",
"'clustering'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
This is a quick lookup to discover if the database supports particular extensions
Currently, MSSQL supports no extensions
@param array $extensions List of extensions to check for support of. The key of this array
will be an extension name, and the value the configuration for that extension. This
could be one of partitions, tablespaces, or clustering
@return boolean Flag indicating support for all of the above
|
[
"This",
"is",
"a",
"quick",
"lookup",
"to",
"discover",
"if",
"the",
"database",
"supports",
"particular",
"extensions",
"Currently",
"MSSQL",
"supports",
"no",
"extensions"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L440-L451
|
221,844
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.transactionStart
|
public function transactionStart($transactionMode = false, $sessionCharacteristics = false)
{
if ($this->transactionNesting > 0) {
$this->transactionSavepoint('NESTEDTRANSACTION' . $this->transactionNesting);
} elseif ($this->connector instanceof SQLServerConnector) {
$this->connector->transactionStart();
} else {
$this->query('BEGIN TRANSACTION');
}
++$this->transactionNesting;
}
|
php
|
public function transactionStart($transactionMode = false, $sessionCharacteristics = false)
{
if ($this->transactionNesting > 0) {
$this->transactionSavepoint('NESTEDTRANSACTION' . $this->transactionNesting);
} elseif ($this->connector instanceof SQLServerConnector) {
$this->connector->transactionStart();
} else {
$this->query('BEGIN TRANSACTION');
}
++$this->transactionNesting;
}
|
[
"public",
"function",
"transactionStart",
"(",
"$",
"transactionMode",
"=",
"false",
",",
"$",
"sessionCharacteristics",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionNesting",
">",
"0",
")",
"{",
"$",
"this",
"->",
"transactionSavepoint",
"(",
"'NESTEDTRANSACTION'",
".",
"$",
"this",
"->",
"transactionNesting",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"connector",
"instanceof",
"SQLServerConnector",
")",
"{",
"$",
"this",
"->",
"connector",
"->",
"transactionStart",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"(",
"'BEGIN TRANSACTION'",
")",
";",
"}",
"++",
"$",
"this",
"->",
"transactionNesting",
";",
"}"
] |
Start transaction. READ ONLY not supported.
@param bool $transactionMode
@param bool $sessionCharacteristics
|
[
"Start",
"transaction",
".",
"READ",
"ONLY",
"not",
"supported",
"."
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L459-L469
|
221,845
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.formattedDatetimeClause
|
public function formattedDatetimeClause($date, $format)
{
preg_match_all('/%(.)/', $format, $matches);
foreach ($matches[1] as $match) {
if (array_search($match, array('Y', 'm', 'd', 'H', 'i', 's', 'U')) === false) {
user_error('formattedDatetimeClause(): unsupported format character %' . $match, E_USER_WARNING);
}
}
if (preg_match('/^now$/i', $date)) {
$date = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date)) {
$date = "'$date.000'";
}
if ($format == '%U') {
return "DATEDIFF(s, '1970-01-01 00:00:00', DATEADD(hour, DATEDIFF(hour, GETDATE(), GETUTCDATE()), $date))";
}
$trans = array(
'Y' => 'yy',
'm' => 'mm',
'd' => 'dd',
'H' => 'hh',
'i' => 'mi',
's' => 'ss',
);
$strings = array();
$buffer = $format;
while (strlen($buffer)) {
if (substr($buffer, 0, 1) == '%') {
$f = substr($buffer, 1, 1);
$flen = $f == 'Y' ? 4 : 2;
$strings[] = "RIGHT('0' + CAST(DATEPART({$trans[$f]},$date) AS VARCHAR), $flen)";
$buffer = substr($buffer, 2);
} else {
$pos = strpos($buffer, '%');
if ($pos === false) {
$strings[] = $buffer;
$buffer = '';
} else {
$strings[] = "'".substr($buffer, 0, $pos)."'";
$buffer = substr($buffer, $pos);
}
}
}
return '(' . implode(' + ', $strings) . ')';
}
|
php
|
public function formattedDatetimeClause($date, $format)
{
preg_match_all('/%(.)/', $format, $matches);
foreach ($matches[1] as $match) {
if (array_search($match, array('Y', 'm', 'd', 'H', 'i', 's', 'U')) === false) {
user_error('formattedDatetimeClause(): unsupported format character %' . $match, E_USER_WARNING);
}
}
if (preg_match('/^now$/i', $date)) {
$date = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date)) {
$date = "'$date.000'";
}
if ($format == '%U') {
return "DATEDIFF(s, '1970-01-01 00:00:00', DATEADD(hour, DATEDIFF(hour, GETDATE(), GETUTCDATE()), $date))";
}
$trans = array(
'Y' => 'yy',
'm' => 'mm',
'd' => 'dd',
'H' => 'hh',
'i' => 'mi',
's' => 'ss',
);
$strings = array();
$buffer = $format;
while (strlen($buffer)) {
if (substr($buffer, 0, 1) == '%') {
$f = substr($buffer, 1, 1);
$flen = $f == 'Y' ? 4 : 2;
$strings[] = "RIGHT('0' + CAST(DATEPART({$trans[$f]},$date) AS VARCHAR), $flen)";
$buffer = substr($buffer, 2);
} else {
$pos = strpos($buffer, '%');
if ($pos === false) {
$strings[] = $buffer;
$buffer = '';
} else {
$strings[] = "'".substr($buffer, 0, $pos)."'";
$buffer = substr($buffer, $pos);
}
}
}
return '(' . implode(' + ', $strings) . ')';
}
|
[
"public",
"function",
"formattedDatetimeClause",
"(",
"$",
"date",
",",
"$",
"format",
")",
"{",
"preg_match_all",
"(",
"'/%(.)/'",
",",
"$",
"format",
",",
"$",
"matches",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"match",
")",
"{",
"if",
"(",
"array_search",
"(",
"$",
"match",
",",
"array",
"(",
"'Y'",
",",
"'m'",
",",
"'d'",
",",
"'H'",
",",
"'i'",
",",
"'s'",
",",
"'U'",
")",
")",
"===",
"false",
")",
"{",
"user_error",
"(",
"'formattedDatetimeClause(): unsupported format character %'",
".",
"$",
"match",
",",
"E_USER_WARNING",
")",
";",
"}",
"}",
"if",
"(",
"preg_match",
"(",
"'/^now$/i'",
",",
"$",
"date",
")",
")",
"{",
"$",
"date",
"=",
"\"CURRENT_TIMESTAMP\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/i'",
",",
"$",
"date",
")",
")",
"{",
"$",
"date",
"=",
"\"'$date.000'\"",
";",
"}",
"if",
"(",
"$",
"format",
"==",
"'%U'",
")",
"{",
"return",
"\"DATEDIFF(s, '1970-01-01 00:00:00', DATEADD(hour, DATEDIFF(hour, GETDATE(), GETUTCDATE()), $date))\"",
";",
"}",
"$",
"trans",
"=",
"array",
"(",
"'Y'",
"=>",
"'yy'",
",",
"'m'",
"=>",
"'mm'",
",",
"'d'",
"=>",
"'dd'",
",",
"'H'",
"=>",
"'hh'",
",",
"'i'",
"=>",
"'mi'",
",",
"'s'",
"=>",
"'ss'",
",",
")",
";",
"$",
"strings",
"=",
"array",
"(",
")",
";",
"$",
"buffer",
"=",
"$",
"format",
";",
"while",
"(",
"strlen",
"(",
"$",
"buffer",
")",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"buffer",
",",
"0",
",",
"1",
")",
"==",
"'%'",
")",
"{",
"$",
"f",
"=",
"substr",
"(",
"$",
"buffer",
",",
"1",
",",
"1",
")",
";",
"$",
"flen",
"=",
"$",
"f",
"==",
"'Y'",
"?",
"4",
":",
"2",
";",
"$",
"strings",
"[",
"]",
"=",
"\"RIGHT('0' + CAST(DATEPART({$trans[$f]},$date) AS VARCHAR), $flen)\"",
";",
"$",
"buffer",
"=",
"substr",
"(",
"$",
"buffer",
",",
"2",
")",
";",
"}",
"else",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"buffer",
",",
"'%'",
")",
";",
"if",
"(",
"$",
"pos",
"===",
"false",
")",
"{",
"$",
"strings",
"[",
"]",
"=",
"$",
"buffer",
";",
"$",
"buffer",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"strings",
"[",
"]",
"=",
"\"'\"",
".",
"substr",
"(",
"$",
"buffer",
",",
"0",
",",
"$",
"pos",
")",
".",
"\"'\"",
";",
"$",
"buffer",
"=",
"substr",
"(",
"$",
"buffer",
",",
"$",
"pos",
")",
";",
"}",
"}",
"}",
"return",
"'('",
".",
"implode",
"(",
"' + '",
",",
"$",
"strings",
")",
".",
"')'",
";",
"}"
] |
Function to return an SQL datetime expression for MSSQL
used for querying a datetime in a certain format
@param string $date to be formated, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
@param string $format to be used, supported specifiers:
%Y = Year (four digits)
%m = Month (01..12)
%d = Day (01..31)
%H = Hour (00..23)
%i = Minutes (00..59)
%s = Seconds (00..59)
%U = unix timestamp, can only be used on it's own
@return string SQL datetime expression to query for a formatted datetime
|
[
"Function",
"to",
"return",
"an",
"SQL",
"datetime",
"expression",
"for",
"MSSQL",
"used",
"for",
"querying",
"a",
"datetime",
"in",
"a",
"certain",
"format"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L599-L648
|
221,846
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.datetimeIntervalClause
|
public function datetimeIntervalClause($date, $interval)
{
$trans = array(
'year' => 'yy',
'month' => 'mm',
'day' => 'dd',
'hour' => 'hh',
'minute' => 'mi',
'second' => 'ss',
);
$singularinterval = preg_replace('/(year|month|day|hour|minute|second)s/i', '$1', $interval);
if (
!($params = preg_match('/([-+]\d+) (\w+)/i', $singularinterval, $matches)) ||
!isset($trans[strtolower($matches[2])])
) {
user_error('datetimeIntervalClause(): invalid interval ' . $interval, E_USER_WARNING);
}
if (preg_match('/^now$/i', $date)) {
$date = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date)) {
$date = "'$date'";
}
return "CONVERT(VARCHAR, DATEADD(" . $trans[strtolower($matches[2])] . ", " . (int)$matches[1] . ", $date), 120)";
}
|
php
|
public function datetimeIntervalClause($date, $interval)
{
$trans = array(
'year' => 'yy',
'month' => 'mm',
'day' => 'dd',
'hour' => 'hh',
'minute' => 'mi',
'second' => 'ss',
);
$singularinterval = preg_replace('/(year|month|day|hour|minute|second)s/i', '$1', $interval);
if (
!($params = preg_match('/([-+]\d+) (\w+)/i', $singularinterval, $matches)) ||
!isset($trans[strtolower($matches[2])])
) {
user_error('datetimeIntervalClause(): invalid interval ' . $interval, E_USER_WARNING);
}
if (preg_match('/^now$/i', $date)) {
$date = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date)) {
$date = "'$date'";
}
return "CONVERT(VARCHAR, DATEADD(" . $trans[strtolower($matches[2])] . ", " . (int)$matches[1] . ", $date), 120)";
}
|
[
"public",
"function",
"datetimeIntervalClause",
"(",
"$",
"date",
",",
"$",
"interval",
")",
"{",
"$",
"trans",
"=",
"array",
"(",
"'year'",
"=>",
"'yy'",
",",
"'month'",
"=>",
"'mm'",
",",
"'day'",
"=>",
"'dd'",
",",
"'hour'",
"=>",
"'hh'",
",",
"'minute'",
"=>",
"'mi'",
",",
"'second'",
"=>",
"'ss'",
",",
")",
";",
"$",
"singularinterval",
"=",
"preg_replace",
"(",
"'/(year|month|day|hour|minute|second)s/i'",
",",
"'$1'",
",",
"$",
"interval",
")",
";",
"if",
"(",
"!",
"(",
"$",
"params",
"=",
"preg_match",
"(",
"'/([-+]\\d+) (\\w+)/i'",
",",
"$",
"singularinterval",
",",
"$",
"matches",
")",
")",
"||",
"!",
"isset",
"(",
"$",
"trans",
"[",
"strtolower",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"]",
")",
")",
"{",
"user_error",
"(",
"'datetimeIntervalClause(): invalid interval '",
".",
"$",
"interval",
",",
"E_USER_WARNING",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^now$/i'",
",",
"$",
"date",
")",
")",
"{",
"$",
"date",
"=",
"\"CURRENT_TIMESTAMP\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/i'",
",",
"$",
"date",
")",
")",
"{",
"$",
"date",
"=",
"\"'$date'\"",
";",
"}",
"return",
"\"CONVERT(VARCHAR, DATEADD(\"",
".",
"$",
"trans",
"[",
"strtolower",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"]",
".",
"\", \"",
".",
"(",
"int",
")",
"$",
"matches",
"[",
"1",
"]",
".",
"\", $date), 120)\"",
";",
"}"
] |
Function to return an SQL datetime expression for MSSQL.
used for querying a datetime addition
@param string $date, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
@param string $interval to be added, use the format [sign][integer] [qualifier], e.g. -1 Day, +15 minutes, +1 YEAR
supported qualifiers:
- years
- months
- days
- hours
- minutes
- seconds
This includes the singular forms as well
@return string SQL datetime expression to query for a datetime (YYYY-MM-DD hh:mm:ss) which is the result of the addition
|
[
"Function",
"to",
"return",
"an",
"SQL",
"datetime",
"expression",
"for",
"MSSQL",
".",
"used",
"for",
"querying",
"a",
"datetime",
"addition"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L666-L693
|
221,847
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabase.php
|
MSSQLDatabase.datetimeDifferenceClause
|
public function datetimeDifferenceClause($date1, $date2)
{
if (preg_match('/^now$/i', $date1)) {
$date1 = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date1)) {
$date1 = "'$date1'";
}
if (preg_match('/^now$/i', $date2)) {
$date2 = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date2)) {
$date2 = "'$date2'";
}
return "DATEDIFF(s, $date2, $date1)";
}
|
php
|
public function datetimeDifferenceClause($date1, $date2)
{
if (preg_match('/^now$/i', $date1)) {
$date1 = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date1)) {
$date1 = "'$date1'";
}
if (preg_match('/^now$/i', $date2)) {
$date2 = "CURRENT_TIMESTAMP";
} elseif (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/i', $date2)) {
$date2 = "'$date2'";
}
return "DATEDIFF(s, $date2, $date1)";
}
|
[
"public",
"function",
"datetimeDifferenceClause",
"(",
"$",
"date1",
",",
"$",
"date2",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^now$/i'",
",",
"$",
"date1",
")",
")",
"{",
"$",
"date1",
"=",
"\"CURRENT_TIMESTAMP\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/i'",
",",
"$",
"date1",
")",
")",
"{",
"$",
"date1",
"=",
"\"'$date1'\"",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^now$/i'",
",",
"$",
"date2",
")",
")",
"{",
"$",
"date2",
"=",
"\"CURRENT_TIMESTAMP\"",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/i'",
",",
"$",
"date2",
")",
")",
"{",
"$",
"date2",
"=",
"\"'$date2'\"",
";",
"}",
"return",
"\"DATEDIFF(s, $date2, $date1)\"",
";",
"}"
] |
Function to return an SQL datetime expression for MSSQL.
used for querying a datetime substraction
@param string $date1, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
@param string $date2 to be substracted of $date1, can be either 'now', literal datetime like '1973-10-14 10:30:00' or field name, e.g. '"SiteTree"."Created"'
@return string SQL datetime expression to query for the interval between $date1 and $date2 in seconds which is the result of the substraction
|
[
"Function",
"to",
"return",
"an",
"SQL",
"datetime",
"expression",
"for",
"MSSQL",
".",
"used",
"for",
"querying",
"a",
"datetime",
"substraction"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabase.php#L703-L718
|
221,848
|
tabuna/VestaAPI
|
src/Services/User.php
|
User.regUser
|
public function regUser($username, $password, $email, $package, $fistName, $lastName)
{
return $this->send('v-add-user', $username, $password, $email, $package, $fistName, $lastName);
}
|
php
|
public function regUser($username, $password, $email, $package, $fistName, $lastName)
{
return $this->send('v-add-user', $username, $password, $email, $package, $fistName, $lastName);
}
|
[
"public",
"function",
"regUser",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"email",
",",
"$",
"package",
",",
"$",
"fistName",
",",
"$",
"lastName",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-add-user'",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"email",
",",
"$",
"package",
",",
"$",
"fistName",
",",
"$",
"lastName",
")",
";",
"}"
] |
Registration User.
@param $username
@param $password
@param $email
@param $package
@param $fistName
@param $lastName
@return mixed
|
[
"Registration",
"User",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/User.php#L19-L22
|
221,849
|
tabuna/VestaAPI
|
src/Services/User.php
|
User.showUserBackup
|
public function showUserBackup($backup)
{
$this->returnCode = 'no';
$answer = $this->send('v-list-user-backup', $this->userName, $backup, 'json');
$data = json_decode($answer, true);
return $data;
}
|
php
|
public function showUserBackup($backup)
{
$this->returnCode = 'no';
$answer = $this->send('v-list-user-backup', $this->userName, $backup, 'json');
$data = json_decode($answer, true);
return $data;
}
|
[
"public",
"function",
"showUserBackup",
"(",
"$",
"backup",
")",
"{",
"$",
"this",
"->",
"returnCode",
"=",
"'no'",
";",
"$",
"answer",
"=",
"$",
"this",
"->",
"send",
"(",
"'v-list-user-backup'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"backup",
",",
"'json'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"answer",
",",
"true",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Show Backup.
@param $backup
@return mixed
|
[
"Show",
"Backup",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/User.php#L103-L110
|
221,850
|
xperseguers/doodle_client
|
src/Client.php
|
Client.getTokenFromCookie
|
protected function getTokenFromCookie()
{
$cookies = $this->getCookies();
if (!empty($cookies['token']) && $cookies['token']['expiration'] > time()) {
return $cookies['token']['value'];
}
return null;
}
|
php
|
protected function getTokenFromCookie()
{
$cookies = $this->getCookies();
if (!empty($cookies['token']) && $cookies['token']['expiration'] > time()) {
return $cookies['token']['value'];
}
return null;
}
|
[
"protected",
"function",
"getTokenFromCookie",
"(",
")",
"{",
"$",
"cookies",
"=",
"$",
"this",
"->",
"getCookies",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cookies",
"[",
"'token'",
"]",
")",
"&&",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'expiration'",
"]",
">",
"time",
"(",
")",
")",
"{",
"return",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'value'",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the authentication token.
@return string|null
|
[
"Returns",
"the",
"authentication",
"token",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L108-L116
|
221,851
|
xperseguers/doodle_client
|
src/Client.php
|
Client.getCookies
|
public function getCookies(): array
{
$cookies = [];
$cookieFileName = $this->getCookieFileName();
if (!file_exists($cookieFileName)) {
return $cookies;
}
$contents = file_get_contents($cookieFileName);
$lines = explode(LF, $contents);
foreach ($lines as $line) {
if (empty($line) || $line{0} === '#') {
continue;
}
$data = explode(TAB, $line);
$cookie = array_combine(
/** @see http://www.cookiecentral.com/faq/#3.5 */
['domain', 'flag', 'path', 'secure', 'expiration', 'name', 'value'],
$data
);
$cookies[$cookie['name']] = $cookie;
}
return $cookies;
}
|
php
|
public function getCookies(): array
{
$cookies = [];
$cookieFileName = $this->getCookieFileName();
if (!file_exists($cookieFileName)) {
return $cookies;
}
$contents = file_get_contents($cookieFileName);
$lines = explode(LF, $contents);
foreach ($lines as $line) {
if (empty($line) || $line{0} === '#') {
continue;
}
$data = explode(TAB, $line);
$cookie = array_combine(
/** @see http://www.cookiecentral.com/faq/#3.5 */
['domain', 'flag', 'path', 'secure', 'expiration', 'name', 'value'],
$data
);
$cookies[$cookie['name']] = $cookie;
}
return $cookies;
}
|
[
"public",
"function",
"getCookies",
"(",
")",
":",
"array",
"{",
"$",
"cookies",
"=",
"[",
"]",
";",
"$",
"cookieFileName",
"=",
"$",
"this",
"->",
"getCookieFileName",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"cookieFileName",
")",
")",
"{",
"return",
"$",
"cookies",
";",
"}",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"cookieFileName",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"LF",
",",
"$",
"contents",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"line",
")",
"||",
"$",
"line",
"{",
"0",
"}",
"===",
"'#'",
")",
"{",
"continue",
";",
"}",
"$",
"data",
"=",
"explode",
"(",
"TAB",
",",
"$",
"line",
")",
";",
"$",
"cookie",
"=",
"array_combine",
"(",
"/** @see http://www.cookiecentral.com/faq/#3.5 */",
"[",
"'domain'",
",",
"'flag'",
",",
"'path'",
",",
"'secure'",
",",
"'expiration'",
",",
"'name'",
",",
"'value'",
"]",
",",
"$",
"data",
")",
";",
"$",
"cookies",
"[",
"$",
"cookie",
"[",
"'name'",
"]",
"]",
"=",
"$",
"cookie",
";",
"}",
"return",
"$",
"cookies",
";",
"}"
] |
Returns the available cookies.
@return array
|
[
"Returns",
"the",
"available",
"cookies",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L123-L148
|
221,852
|
xperseguers/doodle_client
|
src/Client.php
|
Client.getCookieFileName
|
protected function getCookieFileName(): string
{
return $this->cookiePath . sha1($this->username . chr(0) . $this->password . chr(0) . $this->userAgent);
}
|
php
|
protected function getCookieFileName(): string
{
return $this->cookiePath . sha1($this->username . chr(0) . $this->password . chr(0) . $this->userAgent);
}
|
[
"protected",
"function",
"getCookieFileName",
"(",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"cookiePath",
".",
"sha1",
"(",
"$",
"this",
"->",
"username",
".",
"chr",
"(",
"0",
")",
".",
"$",
"this",
"->",
"password",
".",
"chr",
"(",
"0",
")",
".",
"$",
"this",
"->",
"userAgent",
")",
";",
"}"
] |
Returns the cookie file name.
@return string
|
[
"Returns",
"the",
"cookie",
"file",
"name",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L155-L158
|
221,853
|
xperseguers/doodle_client
|
src/Client.php
|
Client.connect
|
public function connect(): bool
{
/** @var array $response */
$response = $this->doPost('/api/v2.0/users/oauth/token', [
'email' => $this->username,
'password' => $this->password
]);
// Define the token we want to use
$this->storeToken($response['accessToken']);
$response = $this->doGet('/api/v2.0/users/me/cookie-from-access-token');
return true;
}
|
php
|
public function connect(): bool
{
/** @var array $response */
$response = $this->doPost('/api/v2.0/users/oauth/token', [
'email' => $this->username,
'password' => $this->password
]);
// Define the token we want to use
$this->storeToken($response['accessToken']);
$response = $this->doGet('/api/v2.0/users/me/cookie-from-access-token');
return true;
}
|
[
"public",
"function",
"connect",
"(",
")",
":",
"bool",
"{",
"/** @var array $response */",
"$",
"response",
"=",
"$",
"this",
"->",
"doPost",
"(",
"'/api/v2.0/users/oauth/token'",
",",
"[",
"'email'",
"=>",
"$",
"this",
"->",
"username",
",",
"'password'",
"=>",
"$",
"this",
"->",
"password",
"]",
")",
";",
"// Define the token we want to use",
"$",
"this",
"->",
"storeToken",
"(",
"$",
"response",
"[",
"'accessToken'",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"doGet",
"(",
"'/api/v2.0/users/me/cookie-from-access-token'",
")",
";",
"return",
"true",
";",
"}"
] |
Connects to Doodle.
@return bool Returns true if connection succeeded, otherwise false
|
[
"Connects",
"to",
"Doodle",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L231-L245
|
221,854
|
xperseguers/doodle_client
|
src/Client.php
|
Client.doRequest
|
protected function doRequest(string $method, string $relativeUrl, array $data)
{
$url = 'https://doodle.com' . $relativeUrl;
$cookieFileName = $this->getCookieFileName();
$dataQuery = '';
if (strpos($relativeUrl, 'api') !== false) {
if (!empty($data)) {
$dataQuery = json_encode($data);
}
} else {
$dataQuery = http_build_query($data);
$dataQuery = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '%5B%5D=', $dataQuery);
}
$ch = curl_init();
switch ($method) {
case 'GET':
if (!empty($dataQuery)) {
$url .= '?' . $dataQuery;
}
if (strpos($relativeUrl, 'api') !== false) {
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Access-Token: ' . $this->token
]);
}
break;
case 'POST':
case 'DELETE':
if ($method === 'DELETE') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
} else {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataQuery);
}
if (strpos($relativeUrl, 'api') !== false) {
if ($method === 'POST') {
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($dataQuery)]
);
}
}
break;
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFileName);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFileName);
curl_setopt($ch, CURLOPT_VERBOSE, true);
//$verbose = fopen('php://temp', 'wb+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
if ($result === FALSE) {
printf("cUrl error (#%d): %s\n", curl_errno($ch), curl_error($ch));
//$verboseLog = stream_get_contents($verbose);
//echo "Verbose information:\n", $verboseLog, "\n";
}
//rewind($verbose);
curl_close($ch);
if (strpos($relativeUrl, 'api') !== false) {
if ($method === 'DELETE') {
return $info['http_code'] === 200;
}
if ($result) {
if ($result[0] === 'E') {
$result = substr($result, 1);
}
return json_decode($result, true);
}
}
return $result;
}
|
php
|
protected function doRequest(string $method, string $relativeUrl, array $data)
{
$url = 'https://doodle.com' . $relativeUrl;
$cookieFileName = $this->getCookieFileName();
$dataQuery = '';
if (strpos($relativeUrl, 'api') !== false) {
if (!empty($data)) {
$dataQuery = json_encode($data);
}
} else {
$dataQuery = http_build_query($data);
$dataQuery = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '%5B%5D=', $dataQuery);
}
$ch = curl_init();
switch ($method) {
case 'GET':
if (!empty($dataQuery)) {
$url .= '?' . $dataQuery;
}
if (strpos($relativeUrl, 'api') !== false) {
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Access-Token: ' . $this->token
]);
}
break;
case 'POST':
case 'DELETE':
if ($method === 'DELETE') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
} else {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataQuery);
}
if (strpos($relativeUrl, 'api') !== false) {
if ($method === 'POST') {
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($dataQuery)]
);
}
}
break;
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFileName);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFileName);
curl_setopt($ch, CURLOPT_VERBOSE, true);
//$verbose = fopen('php://temp', 'wb+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
if ($result === FALSE) {
printf("cUrl error (#%d): %s\n", curl_errno($ch), curl_error($ch));
//$verboseLog = stream_get_contents($verbose);
//echo "Verbose information:\n", $verboseLog, "\n";
}
//rewind($verbose);
curl_close($ch);
if (strpos($relativeUrl, 'api') !== false) {
if ($method === 'DELETE') {
return $info['http_code'] === 200;
}
if ($result) {
if ($result[0] === 'E') {
$result = substr($result, 1);
}
return json_decode($result, true);
}
}
return $result;
}
|
[
"protected",
"function",
"doRequest",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"relativeUrl",
",",
"array",
"$",
"data",
")",
"{",
"$",
"url",
"=",
"'https://doodle.com'",
".",
"$",
"relativeUrl",
";",
"$",
"cookieFileName",
"=",
"$",
"this",
"->",
"getCookieFileName",
"(",
")",
";",
"$",
"dataQuery",
"=",
"''",
";",
"if",
"(",
"strpos",
"(",
"$",
"relativeUrl",
",",
"'api'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"dataQuery",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"}",
"}",
"else",
"{",
"$",
"dataQuery",
"=",
"http_build_query",
"(",
"$",
"data",
")",
";",
"$",
"dataQuery",
"=",
"preg_replace",
"(",
"'/%5B(?:[0-9]|[1-9][0-9]+)%5D=/'",
",",
"'%5B%5D='",
",",
"$",
"dataQuery",
")",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"'GET'",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"dataQuery",
")",
")",
"{",
"$",
"url",
".=",
"'?'",
".",
"$",
"dataQuery",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"relativeUrl",
",",
"'api'",
")",
"!==",
"false",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"[",
"'Access-Token: '",
".",
"$",
"this",
"->",
"token",
"]",
")",
";",
"}",
"break",
";",
"case",
"'POST'",
":",
"case",
"'DELETE'",
":",
"if",
"(",
"$",
"method",
"===",
"'DELETE'",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'DELETE'",
")",
";",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"dataQuery",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"relativeUrl",
",",
"'api'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"'POST'",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"[",
"'Content-Type: application/json'",
",",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"dataQuery",
")",
"]",
")",
";",
"}",
"}",
"break",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_USERAGENT",
",",
"$",
"this",
"->",
"userAgent",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_COOKIEFILE",
",",
"$",
"cookieFileName",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_COOKIEJAR",
",",
"$",
"cookieFileName",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_VERBOSE",
",",
"true",
")",
";",
"//$verbose = fopen('php://temp', 'wb+');",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_STDERR",
",",
"$",
"verbose",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLINFO_HEADER_OUT",
",",
"true",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"info",
"=",
"curl_getinfo",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"$",
"result",
"===",
"FALSE",
")",
"{",
"printf",
"(",
"\"cUrl error (#%d): %s\\n\"",
",",
"curl_errno",
"(",
"$",
"ch",
")",
",",
"curl_error",
"(",
"$",
"ch",
")",
")",
";",
"//$verboseLog = stream_get_contents($verbose);",
"//echo \"Verbose information:\\n\", $verboseLog, \"\\n\";",
"}",
"//rewind($verbose);",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"relativeUrl",
",",
"'api'",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"method",
"===",
"'DELETE'",
")",
"{",
"return",
"$",
"info",
"[",
"'http_code'",
"]",
"===",
"200",
";",
"}",
"if",
"(",
"$",
"result",
")",
"{",
"if",
"(",
"$",
"result",
"[",
"0",
"]",
"===",
"'E'",
")",
"{",
"$",
"result",
"=",
"substr",
"(",
"$",
"result",
",",
"1",
")",
";",
"}",
"return",
"json_decode",
"(",
"$",
"result",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Sends a HTTP request to Doodle.
@param string $method
@param string $relativeUrl
@param array $data
@return string|array
|
[
"Sends",
"a",
"HTTP",
"request",
"to",
"Doodle",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L280-L366
|
221,855
|
xperseguers/doodle_client
|
src/Client.php
|
Client.storeToken
|
protected function storeToken(string $token)
{
$cookies = $this->getCookies();
$cookies['token']['domain'] = '.doodle.com';
$cookies['token']['truefalse'] = 'TRUE';
$cookies['token']['path'] = '/';
$cookies['token']['truefalse2'] = 'FALSE';
$cookies['token']['something'] = '0';
$cookies['token']['name'] = 'Token';
$cookies['token']['value'] = $token;
$cookies['d-betaCode'] = $cookies['DoodleAuthentication'];
$cookies['d-betaCode']['name'] = 'd-betaCode';
$cookies['d-betaCode']['value'] = true;
$cookies['d-forceBeta'] = $cookies['DoodleAuthentication'];
$cookies['d-forceBeta']['name'] = 'd-forceBeta';
$cookies['d-forceBeta']['value'] = false;
$this->persistCookies($cookies);
$this->token = $token;
}
|
php
|
protected function storeToken(string $token)
{
$cookies = $this->getCookies();
$cookies['token']['domain'] = '.doodle.com';
$cookies['token']['truefalse'] = 'TRUE';
$cookies['token']['path'] = '/';
$cookies['token']['truefalse2'] = 'FALSE';
$cookies['token']['something'] = '0';
$cookies['token']['name'] = 'Token';
$cookies['token']['value'] = $token;
$cookies['d-betaCode'] = $cookies['DoodleAuthentication'];
$cookies['d-betaCode']['name'] = 'd-betaCode';
$cookies['d-betaCode']['value'] = true;
$cookies['d-forceBeta'] = $cookies['DoodleAuthentication'];
$cookies['d-forceBeta']['name'] = 'd-forceBeta';
$cookies['d-forceBeta']['value'] = false;
$this->persistCookies($cookies);
$this->token = $token;
}
|
[
"protected",
"function",
"storeToken",
"(",
"string",
"$",
"token",
")",
"{",
"$",
"cookies",
"=",
"$",
"this",
"->",
"getCookies",
"(",
")",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'domain'",
"]",
"=",
"'.doodle.com'",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'truefalse'",
"]",
"=",
"'TRUE'",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'path'",
"]",
"=",
"'/'",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'truefalse2'",
"]",
"=",
"'FALSE'",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'something'",
"]",
"=",
"'0'",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'name'",
"]",
"=",
"'Token'",
";",
"$",
"cookies",
"[",
"'token'",
"]",
"[",
"'value'",
"]",
"=",
"$",
"token",
";",
"$",
"cookies",
"[",
"'d-betaCode'",
"]",
"=",
"$",
"cookies",
"[",
"'DoodleAuthentication'",
"]",
";",
"$",
"cookies",
"[",
"'d-betaCode'",
"]",
"[",
"'name'",
"]",
"=",
"'d-betaCode'",
";",
"$",
"cookies",
"[",
"'d-betaCode'",
"]",
"[",
"'value'",
"]",
"=",
"true",
";",
"$",
"cookies",
"[",
"'d-forceBeta'",
"]",
"=",
"$",
"cookies",
"[",
"'DoodleAuthentication'",
"]",
";",
"$",
"cookies",
"[",
"'d-forceBeta'",
"]",
"[",
"'name'",
"]",
"=",
"'d-forceBeta'",
";",
"$",
"cookies",
"[",
"'d-forceBeta'",
"]",
"[",
"'value'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"persistCookies",
"(",
"$",
"cookies",
")",
";",
"$",
"this",
"->",
"token",
"=",
"$",
"token",
";",
"}"
] |
Stores the authentication token.
Business logic is inspired from
http://doodle.com/builstatic/<timestamp>/doodle/js/common/loginUtils.js:updateToken()
@param string $token
@return void
|
[
"Stores",
"the",
"authentication",
"token",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L377-L395
|
221,856
|
xperseguers/doodle_client
|
src/Client.php
|
Client.persistCookies
|
protected function persistCookies(array $cookies)
{
$cookieFileName = $this->getCookieFileName();
$contents = <<<EOT
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
EOT;
foreach ($cookies as $cookie) {
$contents .= implode(TAB, $cookie) . LF;
}
file_put_contents($cookieFileName, $contents);
}
|
php
|
protected function persistCookies(array $cookies)
{
$cookieFileName = $this->getCookieFileName();
$contents = <<<EOT
# Netscape HTTP Cookie File
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
EOT;
foreach ($cookies as $cookie) {
$contents .= implode(TAB, $cookie) . LF;
}
file_put_contents($cookieFileName, $contents);
}
|
[
"protected",
"function",
"persistCookies",
"(",
"array",
"$",
"cookies",
")",
"{",
"$",
"cookieFileName",
"=",
"$",
"this",
"->",
"getCookieFileName",
"(",
")",
";",
"$",
"contents",
"=",
" <<<EOT\n# Netscape HTTP Cookie File\n# http://curl.haxx.se/docs/http-cookies.html\n# This file was generated by libcurl! Edit at your own risk.\n\nEOT",
";",
"foreach",
"(",
"$",
"cookies",
"as",
"$",
"cookie",
")",
"{",
"$",
"contents",
".=",
"implode",
"(",
"TAB",
",",
"$",
"cookie",
")",
".",
"LF",
";",
"}",
"file_put_contents",
"(",
"$",
"cookieFileName",
",",
"$",
"contents",
")",
";",
"}"
] |
Persists cookies.
@param array $cookies
@return void
|
[
"Persists",
"cookies",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L403-L418
|
221,857
|
xperseguers/doodle_client
|
src/Client.php
|
Client.disconnect
|
public function disconnect(): bool
{
$cookieFileName = $this->getCookieFileName();
if (file_exists($cookieFileName)) {
return unlink($cookieFileName);
}
return false;
}
|
php
|
public function disconnect(): bool
{
$cookieFileName = $this->getCookieFileName();
if (file_exists($cookieFileName)) {
return unlink($cookieFileName);
}
return false;
}
|
[
"public",
"function",
"disconnect",
"(",
")",
":",
"bool",
"{",
"$",
"cookieFileName",
"=",
"$",
"this",
"->",
"getCookieFileName",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"cookieFileName",
")",
")",
"{",
"return",
"unlink",
"(",
"$",
"cookieFileName",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Disconnects from Doodle.
@return bool Returns true if disconnect succeeded, otherwise false
|
[
"Disconnects",
"from",
"Doodle",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L437-L445
|
221,858
|
xperseguers/doodle_client
|
src/Client.php
|
Client.getUserInfo
|
public function getUserInfo(): array
{
$data = [
'isMobile' => 'false',
'includeKalsysInfos' => 'false',
'token' => $this->token,
];
$response = $this->doGet('/np/users/me', $data);
$userInfo = json_decode($response, true);
return $userInfo;
}
|
php
|
public function getUserInfo(): array
{
$data = [
'isMobile' => 'false',
'includeKalsysInfos' => 'false',
'token' => $this->token,
];
$response = $this->doGet('/np/users/me', $data);
$userInfo = json_decode($response, true);
return $userInfo;
}
|
[
"public",
"function",
"getUserInfo",
"(",
")",
":",
"array",
"{",
"$",
"data",
"=",
"[",
"'isMobile'",
"=>",
"'false'",
",",
"'includeKalsysInfos'",
"=>",
"'false'",
",",
"'token'",
"=>",
"$",
"this",
"->",
"token",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"doGet",
"(",
"'/np/users/me'",
",",
"$",
"data",
")",
";",
"$",
"userInfo",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"return",
"$",
"userInfo",
";",
"}"
] |
Returns user information.
@return array
|
[
"Returns",
"user",
"information",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L452-L463
|
221,859
|
xperseguers/doodle_client
|
src/Client.php
|
Client.getPersonalPolls
|
public function getPersonalPolls()
{
$data = [
'fullList' => 'true',
'locale' => $this->locale,
'token' => $this->token,
];
$response = $this->doGet('/np/users/me/dashboard/myPolls', $data);
if (strpos($response, '<title>Doodle: Not found') !== false) {
throw new \Causal\DoodleClient\Exception\UnauthenticatedException('Doodle returned an error while fetching polls. Either you are not authenticated or your token is considered to be outdated.', 1454323881);
}
$polls = json_decode($response, true);
$objects = [];
if (!empty($polls['myPolls']['myPolls'])) {
foreach ($polls['myPolls']['myPolls'] as $poll) {
$objects[] = $this->pollRepository->create($poll);
}
}
return $objects;
}
|
php
|
public function getPersonalPolls()
{
$data = [
'fullList' => 'true',
'locale' => $this->locale,
'token' => $this->token,
];
$response = $this->doGet('/np/users/me/dashboard/myPolls', $data);
if (strpos($response, '<title>Doodle: Not found') !== false) {
throw new \Causal\DoodleClient\Exception\UnauthenticatedException('Doodle returned an error while fetching polls. Either you are not authenticated or your token is considered to be outdated.', 1454323881);
}
$polls = json_decode($response, true);
$objects = [];
if (!empty($polls['myPolls']['myPolls'])) {
foreach ($polls['myPolls']['myPolls'] as $poll) {
$objects[] = $this->pollRepository->create($poll);
}
}
return $objects;
}
|
[
"public",
"function",
"getPersonalPolls",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'fullList'",
"=>",
"'true'",
",",
"'locale'",
"=>",
"$",
"this",
"->",
"locale",
",",
"'token'",
"=>",
"$",
"this",
"->",
"token",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"doGet",
"(",
"'/np/users/me/dashboard/myPolls'",
",",
"$",
"data",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"response",
",",
"'<title>Doodle: Not found'",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"\\",
"Causal",
"\\",
"DoodleClient",
"\\",
"Exception",
"\\",
"UnauthenticatedException",
"(",
"'Doodle returned an error while fetching polls. Either you are not authenticated or your token is considered to be outdated.'",
",",
"1454323881",
")",
";",
"}",
"$",
"polls",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"$",
"objects",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"polls",
"[",
"'myPolls'",
"]",
"[",
"'myPolls'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"polls",
"[",
"'myPolls'",
"]",
"[",
"'myPolls'",
"]",
"as",
"$",
"poll",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"$",
"this",
"->",
"pollRepository",
"->",
"create",
"(",
"$",
"poll",
")",
";",
"}",
"}",
"return",
"$",
"objects",
";",
"}"
] |
Returns personal polls.
@return Poll[]
@throws \Causal\DoodleClient\Exception\UnauthenticatedException
|
[
"Returns",
"personal",
"polls",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L471-L493
|
221,860
|
xperseguers/doodle_client
|
src/Client.php
|
Client.getOtherPolls
|
public function getOtherPolls()
{
$data = [
'fullList' => 'true',
'locale' => $this->locale,
'token' => $this->token,
];
$response = $this->doGet('/np/users/me/dashboard/otherPolls', $data);
$polls = json_decode($response, true);
$objects = [];
if (!empty($polls['otherPolls']['otherPolls'])) {
foreach ($polls['otherPolls']['otherPolls'] as $poll) {
$objects[] = $this->pollRepository->create($poll);
}
}
return $objects;
}
|
php
|
public function getOtherPolls()
{
$data = [
'fullList' => 'true',
'locale' => $this->locale,
'token' => $this->token,
];
$response = $this->doGet('/np/users/me/dashboard/otherPolls', $data);
$polls = json_decode($response, true);
$objects = [];
if (!empty($polls['otherPolls']['otherPolls'])) {
foreach ($polls['otherPolls']['otherPolls'] as $poll) {
$objects[] = $this->pollRepository->create($poll);
}
}
return $objects;
}
|
[
"public",
"function",
"getOtherPolls",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'fullList'",
"=>",
"'true'",
",",
"'locale'",
"=>",
"$",
"this",
"->",
"locale",
",",
"'token'",
"=>",
"$",
"this",
"->",
"token",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"doGet",
"(",
"'/np/users/me/dashboard/otherPolls'",
",",
"$",
"data",
")",
";",
"$",
"polls",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"$",
"objects",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"polls",
"[",
"'otherPolls'",
"]",
"[",
"'otherPolls'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"polls",
"[",
"'otherPolls'",
"]",
"[",
"'otherPolls'",
"]",
"as",
"$",
"poll",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"$",
"this",
"->",
"pollRepository",
"->",
"create",
"(",
"$",
"poll",
")",
";",
"}",
"}",
"return",
"$",
"objects",
";",
"}"
] |
Returns other polls.
@return Poll[]
|
[
"Returns",
"other",
"polls",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L500-L518
|
221,861
|
xperseguers/doodle_client
|
src/Client.php
|
Client.deletePoll
|
public function deletePoll(Poll $poll): bool
{
if (empty($poll->getAdminKey())) {
throw new \Exception(sprintf('Admin key not available. Poll %s cannot be deleted.', $poll->getId()), 1443782170);
}
return $this->doDelete('/api/v2.0/polls/' . $poll->getId() . '?adminKey=' . $poll->getAdminKey());
}
|
php
|
public function deletePoll(Poll $poll): bool
{
if (empty($poll->getAdminKey())) {
throw new \Exception(sprintf('Admin key not available. Poll %s cannot be deleted.', $poll->getId()), 1443782170);
}
return $this->doDelete('/api/v2.0/polls/' . $poll->getId() . '?adminKey=' . $poll->getAdminKey());
}
|
[
"public",
"function",
"deletePoll",
"(",
"Poll",
"$",
"poll",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"poll",
"->",
"getAdminKey",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Admin key not available. Poll %s cannot be deleted.'",
",",
"$",
"poll",
"->",
"getId",
"(",
")",
")",
",",
"1443782170",
")",
";",
"}",
"return",
"$",
"this",
"->",
"doDelete",
"(",
"'/api/v2.0/polls/'",
".",
"$",
"poll",
"->",
"getId",
"(",
")",
".",
"'?adminKey='",
".",
"$",
"poll",
"->",
"getAdminKey",
"(",
")",
")",
";",
"}"
] |
Deletes a poll.
@param Poll $poll
@return bool
@throws \Exception
|
[
"Deletes",
"a",
"poll",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L646-L652
|
221,862
|
xperseguers/doodle_client
|
src/Client.php
|
Client.deleteParticipant
|
public function deleteParticipant(Poll $poll, int $participantid)
{
if (empty($poll->getAdminKey())) {
throw new \Exception(sprintf('Admin key not available. Poll %s cannot be deleted.', $poll->getId()), 1443782170);
}
return $this->doDelete('/api/v2.0/polls/' . $poll->getId() . '/participants/' . $participantid . '?adminKey=' . $poll->getAdminKey());
}
|
php
|
public function deleteParticipant(Poll $poll, int $participantid)
{
if (empty($poll->getAdminKey())) {
throw new \Exception(sprintf('Admin key not available. Poll %s cannot be deleted.', $poll->getId()), 1443782170);
}
return $this->doDelete('/api/v2.0/polls/' . $poll->getId() . '/participants/' . $participantid . '?adminKey=' . $poll->getAdminKey());
}
|
[
"public",
"function",
"deleteParticipant",
"(",
"Poll",
"$",
"poll",
",",
"int",
"$",
"participantid",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"poll",
"->",
"getAdminKey",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Admin key not available. Poll %s cannot be deleted.'",
",",
"$",
"poll",
"->",
"getId",
"(",
")",
")",
",",
"1443782170",
")",
";",
"}",
"return",
"$",
"this",
"->",
"doDelete",
"(",
"'/api/v2.0/polls/'",
".",
"$",
"poll",
"->",
"getId",
"(",
")",
".",
"'/participants/'",
".",
"$",
"participantid",
".",
"'?adminKey='",
".",
"$",
"poll",
"->",
"getAdminKey",
"(",
")",
")",
";",
"}"
] |
Deletes a participant.
@param Poll $poll
@param int $participantid
@return string
@throws \Exception
|
[
"Deletes",
"a",
"participant",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Client.php#L662-L668
|
221,863
|
tabuna/VestaAPI
|
src/Services/BD.php
|
BD.listOnlyBD
|
public function listOnlyBD($database)
{
$this->returnCode = 'no';
$listBd = $this->send('v-list-database', $this->userName, $database, 'json');
$data = json_decode($listBd, true);
return $data;
}
|
php
|
public function listOnlyBD($database)
{
$this->returnCode = 'no';
$listBd = $this->send('v-list-database', $this->userName, $database, 'json');
$data = json_decode($listBd, true);
return $data;
}
|
[
"public",
"function",
"listOnlyBD",
"(",
"$",
"database",
")",
"{",
"$",
"this",
"->",
"returnCode",
"=",
"'no'",
";",
"$",
"listBd",
"=",
"$",
"this",
"->",
"send",
"(",
"'v-list-database'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"database",
",",
"'json'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"listBd",
",",
"true",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
List Only BD.
@param $database
@return mixed
|
[
"List",
"Only",
"BD",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/BD.php#L52-L59
|
221,864
|
tabuna/VestaAPI
|
src/Services/BD.php
|
BD.addDateBase
|
public function addDateBase($database, $dbuser, $password, $type, $charset)
{
return $this->send('v-add-database', $this->userName, $database, $dbuser, $password, $type,
'localhost', $charset);
}
|
php
|
public function addDateBase($database, $dbuser, $password, $type, $charset)
{
return $this->send('v-add-database', $this->userName, $database, $dbuser, $password, $type,
'localhost', $charset);
}
|
[
"public",
"function",
"addDateBase",
"(",
"$",
"database",
",",
"$",
"dbuser",
",",
"$",
"password",
",",
"$",
"type",
",",
"$",
"charset",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-add-database'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"database",
",",
"$",
"dbuser",
",",
"$",
"password",
",",
"$",
"type",
",",
"'localhost'",
",",
"$",
"charset",
")",
";",
"}"
] |
Add date base.
@param $database
@param $dbuser
@param $password
@param string $type
@param $charset
@return mixed
|
[
"Add",
"date",
"base",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/BD.php#L72-L76
|
221,865
|
stackify/stackify-api-php
|
src/Stackify/Utils/TypeConverter.php
|
TypeConverter.stringify
|
public static function stringify($value)
{
$string = '';
if (is_scalar($value)) {
// integer, float, string, boolean
$string = (string)$value;
} elseif (is_resource($value)) {
// resource
$string = '[resource]';
} else {
// array, object, null, callable
$string = json_encode($value);
}
return $string;
}
|
php
|
public static function stringify($value)
{
$string = '';
if (is_scalar($value)) {
// integer, float, string, boolean
$string = (string)$value;
} elseif (is_resource($value)) {
// resource
$string = '[resource]';
} else {
// array, object, null, callable
$string = json_encode($value);
}
return $string;
}
|
[
"public",
"static",
"function",
"stringify",
"(",
"$",
"value",
")",
"{",
"$",
"string",
"=",
"''",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"// integer, float, string, boolean",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"// resource",
"$",
"string",
"=",
"'[resource]'",
";",
"}",
"else",
"{",
"// array, object, null, callable",
"$",
"string",
"=",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Converts any PHP type to string
@param mixed $value
@return string
|
[
"Converts",
"any",
"PHP",
"type",
"to",
"string"
] |
73b4e67432dc532d1dd46b90d385feb321f24e0a
|
https://github.com/stackify/stackify-api-php/blob/73b4e67432dc532d1dd46b90d385feb321f24e0a/src/Stackify/Utils/TypeConverter.php#L13-L27
|
221,866
|
tabuna/VestaAPI
|
src/Services/Cron.php
|
Cron.listCron
|
public function listCron()
{
$this->returnCode = 'no';
$listDns = $this->send('v-list-cron-jobs', $this->userName, 'json');
$data = json_decode($listDns, true);
return $data;
}
|
php
|
public function listCron()
{
$this->returnCode = 'no';
$listDns = $this->send('v-list-cron-jobs', $this->userName, 'json');
$data = json_decode($listDns, true);
return $data;
}
|
[
"public",
"function",
"listCron",
"(",
")",
"{",
"$",
"this",
"->",
"returnCode",
"=",
"'no'",
";",
"$",
"listDns",
"=",
"$",
"this",
"->",
"send",
"(",
"'v-list-cron-jobs'",
",",
"$",
"this",
"->",
"userName",
",",
"'json'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"listDns",
",",
"true",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Cron list.
@return mixed
|
[
"Cron",
"list",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Cron.php#L12-L19
|
221,867
|
tabuna/VestaAPI
|
src/Services/Cron.php
|
Cron.addCron
|
public function addCron($min, $hour, $day, $month, $wday, $cmd)
{
return $this->send('v-add-cron-job', $this->userName, $min, $hour, $day, $month, $wday,
$cmd);
}
|
php
|
public function addCron($min, $hour, $day, $month, $wday, $cmd)
{
return $this->send('v-add-cron-job', $this->userName, $min, $hour, $day, $month, $wday,
$cmd);
}
|
[
"public",
"function",
"addCron",
"(",
"$",
"min",
",",
"$",
"hour",
",",
"$",
"day",
",",
"$",
"month",
",",
"$",
"wday",
",",
"$",
"cmd",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-add-cron-job'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"min",
",",
"$",
"hour",
",",
"$",
"day",
",",
"$",
"month",
",",
"$",
"wday",
",",
"$",
"cmd",
")",
";",
"}"
] |
Add Cron.
@param $min
@param $hour
@param $day
@param $month
@param $wday
@param $cmd
@return mixed
|
[
"Add",
"Cron",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Cron.php#L33-L37
|
221,868
|
tabuna/VestaAPI
|
src/Services/Cron.php
|
Cron.showCron
|
public function showCron($job)
{
$this->returnCode = 'no';
$request = $this->send('v-list-cron-job', $this->userName, $job, 'json');
$data = json_decode($request, true);
return $data;
}
|
php
|
public function showCron($job)
{
$this->returnCode = 'no';
$request = $this->send('v-list-cron-job', $this->userName, $job, 'json');
$data = json_decode($request, true);
return $data;
}
|
[
"public",
"function",
"showCron",
"(",
"$",
"job",
")",
"{",
"$",
"this",
"->",
"returnCode",
"=",
"'no'",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"send",
"(",
"'v-list-cron-job'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"job",
",",
"'json'",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"request",
",",
"true",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Show Cron.
@param $job
@return mixed
|
[
"Show",
"Cron",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Cron.php#L46-L53
|
221,869
|
tabuna/VestaAPI
|
src/Services/Cron.php
|
Cron.editCron
|
public function editCron($job, $min, $hour, $day, $month, $wday, $cmd)
{
return $this->send('v-change-cron-job', $this->userName, $job, $min, $hour, $day, $month,
$wday, $cmd);
}
|
php
|
public function editCron($job, $min, $hour, $day, $month, $wday, $cmd)
{
return $this->send('v-change-cron-job', $this->userName, $job, $min, $hour, $day, $month,
$wday, $cmd);
}
|
[
"public",
"function",
"editCron",
"(",
"$",
"job",
",",
"$",
"min",
",",
"$",
"hour",
",",
"$",
"day",
",",
"$",
"month",
",",
"$",
"wday",
",",
"$",
"cmd",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-change-cron-job'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"job",
",",
"$",
"min",
",",
"$",
"hour",
",",
"$",
"day",
",",
"$",
"month",
",",
"$",
"wday",
",",
"$",
"cmd",
")",
";",
"}"
] |
Edit cron.
@param $job
@param $min
@param $hour
@param $day
@param $month
@param $wday
@param $cmd
@return mixed
|
[
"Edit",
"cron",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Cron.php#L80-L84
|
221,870
|
tabuna/VestaAPI
|
src/Services/Web.php
|
Web.addFtpDomain
|
public function addFtpDomain($domain, $ftpUserName, $ftpPassword, $ftpPath)
{
return $this->send('v-add-web-domain-ftp', $this->userName, $domain, $ftpUserName, $ftpPassword,
$ftpPath);
}
|
php
|
public function addFtpDomain($domain, $ftpUserName, $ftpPassword, $ftpPath)
{
return $this->send('v-add-web-domain-ftp', $this->userName, $domain, $ftpUserName, $ftpPassword,
$ftpPath);
}
|
[
"public",
"function",
"addFtpDomain",
"(",
"$",
"domain",
",",
"$",
"ftpUserName",
",",
"$",
"ftpPassword",
",",
"$",
"ftpPath",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-add-web-domain-ftp'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"$",
"ftpUserName",
",",
"$",
"ftpPassword",
",",
"$",
"ftpPath",
")",
";",
"}"
] |
Add FTP domain.
@param $domain
@param $ftpUserName
@param $ftpPassword
@param $ftpPath
@return mixed
|
[
"Add",
"FTP",
"domain",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Web.php#L135-L139
|
221,871
|
tabuna/VestaAPI
|
src/Services/Web.php
|
Web.changeWebDomain
|
public function changeWebDomain($domain, $ftpUserName, $ftpPath)
{
return $this->send('v-change-web-domain-ftp-path', $this->userName, $domain, $ftpUserName,
$ftpPath);
}
|
php
|
public function changeWebDomain($domain, $ftpUserName, $ftpPath)
{
return $this->send('v-change-web-domain-ftp-path', $this->userName, $domain, $ftpUserName,
$ftpPath);
}
|
[
"public",
"function",
"changeWebDomain",
"(",
"$",
"domain",
",",
"$",
"ftpUserName",
",",
"$",
"ftpPath",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-change-web-domain-ftp-path'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"$",
"ftpUserName",
",",
"$",
"ftpPath",
")",
";",
"}"
] |
Change web domain.
@param $domain
@param $ftpUserName
@param $ftpPath
@return mixed
|
[
"Change",
"web",
"domain",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Web.php#L201-L205
|
221,872
|
tabuna/VestaAPI
|
src/Services/Web.php
|
Web.changeFtpPassword
|
public function changeFtpPassword($domain, $ftpUserName, $password)
{
return $this->send('v-change-web-domain-ftp-password', $this->userName, $domain, $ftpUserName,
$password);
}
|
php
|
public function changeFtpPassword($domain, $ftpUserName, $password)
{
return $this->send('v-change-web-domain-ftp-password', $this->userName, $domain, $ftpUserName,
$password);
}
|
[
"public",
"function",
"changeFtpPassword",
"(",
"$",
"domain",
",",
"$",
"ftpUserName",
",",
"$",
"password",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"'v-change-web-domain-ftp-password'",
",",
"$",
"this",
"->",
"userName",
",",
"$",
"domain",
",",
"$",
"ftpUserName",
",",
"$",
"password",
")",
";",
"}"
] |
Change ftp password.
@param $domain
@param $ftpUserName
@param $password
@return mixed
|
[
"Change",
"ftp",
"password",
"."
] |
3f6e9c411b70d01d4cc38cb4e007803ff0abd457
|
https://github.com/tabuna/VestaAPI/blob/3f6e9c411b70d01d4cc38cb4e007803ff0abd457/src/Services/Web.php#L216-L220
|
221,873
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.create
|
public function create(array $data): Poll
{
$poll = new Poll($data['id'], $this);
$poll
->setType($data['type'])
->setTitle($data['title'])
->setState($data['state'])
->setMultiDay((bool)$data['multiDay'])
->setByInvitation((bool)$data['byInvitation'])
->setInviteesCount((int)$data['inviteesCount'])
->setParticipantsCount((int)$data['participantsCount'])
->setAskAddress((bool)$data['askAddress'])
->setAskEmail((bool)$data['askEmail'])
->setAskPhone((bool)$data['askPhone'])
->setAmINotified((bool)$data['amINotified'])
->setLastWriteAccess(new \DateTime($data['lastWriteAccess']));
// Possible exception
try {
$lastActivity = new \DateTime($data['lastActivity']);
} catch (\Exception $e) {
$lastActivity = new \DateTime();
}
$poll->setLastActivity($lastActivity);
// Optional, possibly missing, attributes
if (!empty($data['adminKey'])) {
$poll->setAdminKey($data['adminKey']);
}
if (!empty($data['rowConstraint'])) {
$poll->setRowConstraint((bool)$data['rowConstraint']);
}
return $poll;
}
|
php
|
public function create(array $data): Poll
{
$poll = new Poll($data['id'], $this);
$poll
->setType($data['type'])
->setTitle($data['title'])
->setState($data['state'])
->setMultiDay((bool)$data['multiDay'])
->setByInvitation((bool)$data['byInvitation'])
->setInviteesCount((int)$data['inviteesCount'])
->setParticipantsCount((int)$data['participantsCount'])
->setAskAddress((bool)$data['askAddress'])
->setAskEmail((bool)$data['askEmail'])
->setAskPhone((bool)$data['askPhone'])
->setAmINotified((bool)$data['amINotified'])
->setLastWriteAccess(new \DateTime($data['lastWriteAccess']));
// Possible exception
try {
$lastActivity = new \DateTime($data['lastActivity']);
} catch (\Exception $e) {
$lastActivity = new \DateTime();
}
$poll->setLastActivity($lastActivity);
// Optional, possibly missing, attributes
if (!empty($data['adminKey'])) {
$poll->setAdminKey($data['adminKey']);
}
if (!empty($data['rowConstraint'])) {
$poll->setRowConstraint((bool)$data['rowConstraint']);
}
return $poll;
}
|
[
"public",
"function",
"create",
"(",
"array",
"$",
"data",
")",
":",
"Poll",
"{",
"$",
"poll",
"=",
"new",
"Poll",
"(",
"$",
"data",
"[",
"'id'",
"]",
",",
"$",
"this",
")",
";",
"$",
"poll",
"->",
"setType",
"(",
"$",
"data",
"[",
"'type'",
"]",
")",
"->",
"setTitle",
"(",
"$",
"data",
"[",
"'title'",
"]",
")",
"->",
"setState",
"(",
"$",
"data",
"[",
"'state'",
"]",
")",
"->",
"setMultiDay",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'multiDay'",
"]",
")",
"->",
"setByInvitation",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'byInvitation'",
"]",
")",
"->",
"setInviteesCount",
"(",
"(",
"int",
")",
"$",
"data",
"[",
"'inviteesCount'",
"]",
")",
"->",
"setParticipantsCount",
"(",
"(",
"int",
")",
"$",
"data",
"[",
"'participantsCount'",
"]",
")",
"->",
"setAskAddress",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'askAddress'",
"]",
")",
"->",
"setAskEmail",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'askEmail'",
"]",
")",
"->",
"setAskPhone",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'askPhone'",
"]",
")",
"->",
"setAmINotified",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'amINotified'",
"]",
")",
"->",
"setLastWriteAccess",
"(",
"new",
"\\",
"DateTime",
"(",
"$",
"data",
"[",
"'lastWriteAccess'",
"]",
")",
")",
";",
"// Possible exception",
"try",
"{",
"$",
"lastActivity",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"data",
"[",
"'lastActivity'",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"lastActivity",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"}",
"$",
"poll",
"->",
"setLastActivity",
"(",
"$",
"lastActivity",
")",
";",
"// Optional, possibly missing, attributes",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'adminKey'",
"]",
")",
")",
"{",
"$",
"poll",
"->",
"setAdminKey",
"(",
"$",
"data",
"[",
"'adminKey'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'rowConstraint'",
"]",
")",
")",
"{",
"$",
"poll",
"->",
"setRowConstraint",
"(",
"(",
"bool",
")",
"$",
"data",
"[",
"'rowConstraint'",
"]",
")",
";",
"}",
"return",
"$",
"poll",
";",
"}"
] |
Creates a new Poll object.
@param array $data
@return Poll
|
[
"Creates",
"a",
"new",
"Poll",
"object",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L55-L89
|
221,874
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.injectInfo
|
public function injectInfo(Poll $poll): array
{
$info = $poll->_getInfo();
if ($info === null) {
$info = $this->client->_getInfo($poll);
$poll->_setInfo($info);
}
return $info;
}
|
php
|
public function injectInfo(Poll $poll): array
{
$info = $poll->_getInfo();
if ($info === null) {
$info = $this->client->_getInfo($poll);
$poll->_setInfo($info);
}
return $info;
}
|
[
"public",
"function",
"injectInfo",
"(",
"Poll",
"$",
"poll",
")",
":",
"array",
"{",
"$",
"info",
"=",
"$",
"poll",
"->",
"_getInfo",
"(",
")",
";",
"if",
"(",
"$",
"info",
"===",
"null",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"client",
"->",
"_getInfo",
"(",
"$",
"poll",
")",
";",
"$",
"poll",
"->",
"_setInfo",
"(",
"$",
"info",
")",
";",
"}",
"return",
"$",
"info",
";",
"}"
] |
Injects the information of a given poll.
@param Poll $poll
@return array
|
[
"Injects",
"the",
"information",
"of",
"a",
"given",
"poll",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L97-L106
|
221,875
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.injectDescription
|
public function injectDescription(Poll $poll)
{
$info = $this->injectInfo($poll);
$description = $this->decodeHtml($info['descriptionHTML']);
$poll->setDescription($description);
}
|
php
|
public function injectDescription(Poll $poll)
{
$info = $this->injectInfo($poll);
$description = $this->decodeHtml($info['descriptionHTML']);
$poll->setDescription($description);
}
|
[
"public",
"function",
"injectDescription",
"(",
"Poll",
"$",
"poll",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"injectInfo",
"(",
"$",
"poll",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"decodeHtml",
"(",
"$",
"info",
"[",
"'descriptionHTML'",
"]",
")",
";",
"$",
"poll",
"->",
"setDescription",
"(",
"$",
"description",
")",
";",
"}"
] |
Injects the description of a given poll.
@param Poll $poll
@return void
|
[
"Injects",
"the",
"description",
"of",
"a",
"given",
"poll",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L114-L119
|
221,876
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.injectOptions
|
public function injectOptions(Poll $poll)
{
$info = $this->injectInfo($poll);
$type = $poll->getType();
$options = array();
foreach ($info['options'] as $i => $optionText) {
if (!empty($optionText['text'])) {
$options[] = new Option($i, null, null, $optionText['text']);
} else {
$start = date("Y-m-d\TH:i:s", substr($optionText['start'], 0, -3));
$end = date("Y-m-d\TH:i:s", substr($optionText['end'], 0, -3));
$options[] = new Option($i, new \DateTime($start), new \DateTime($end));
}
}
$poll->setOptions($options);
}
|
php
|
public function injectOptions(Poll $poll)
{
$info = $this->injectInfo($poll);
$type = $poll->getType();
$options = array();
foreach ($info['options'] as $i => $optionText) {
if (!empty($optionText['text'])) {
$options[] = new Option($i, null, null, $optionText['text']);
} else {
$start = date("Y-m-d\TH:i:s", substr($optionText['start'], 0, -3));
$end = date("Y-m-d\TH:i:s", substr($optionText['end'], 0, -3));
$options[] = new Option($i, new \DateTime($start), new \DateTime($end));
}
}
$poll->setOptions($options);
}
|
[
"public",
"function",
"injectOptions",
"(",
"Poll",
"$",
"poll",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"injectInfo",
"(",
"$",
"poll",
")",
";",
"$",
"type",
"=",
"$",
"poll",
"->",
"getType",
"(",
")",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"info",
"[",
"'options'",
"]",
"as",
"$",
"i",
"=>",
"$",
"optionText",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"optionText",
"[",
"'text'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"new",
"Option",
"(",
"$",
"i",
",",
"null",
",",
"null",
",",
"$",
"optionText",
"[",
"'text'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"start",
"=",
"date",
"(",
"\"Y-m-d\\TH:i:s\"",
",",
"substr",
"(",
"$",
"optionText",
"[",
"'start'",
"]",
",",
"0",
",",
"-",
"3",
")",
")",
";",
"$",
"end",
"=",
"date",
"(",
"\"Y-m-d\\TH:i:s\"",
",",
"substr",
"(",
"$",
"optionText",
"[",
"'end'",
"]",
",",
"0",
",",
"-",
"3",
")",
")",
";",
"$",
"options",
"[",
"]",
"=",
"new",
"Option",
"(",
"$",
"i",
",",
"new",
"\\",
"DateTime",
"(",
"$",
"start",
")",
",",
"new",
"\\",
"DateTime",
"(",
"$",
"end",
")",
")",
";",
"}",
"}",
"$",
"poll",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"}"
] |
Injects the option of a given poll.
@param Poll $poll
@return void
|
[
"Injects",
"the",
"option",
"of",
"a",
"given",
"poll",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L127-L142
|
221,877
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.injectParticipants
|
public function injectParticipants(Poll $poll)
{
$info = $this->injectInfo($poll);
$options = $poll->getOptions();
$countOptions = count($options);
$participants = [];
foreach ($info['participants'] as $p) {
$preferences = [];
for ($i = 0; $i < $countOptions; $i++) {
$preferences[] = new Preference($options[$i], $p['preferences'][$i]);
}
$participant = new Participant($p['id']);
$participant
->setName($p['name'])
->setAvatar(isset($p['largeAvatarUrl']) ? $p['largeAvatarUrl'] : '')
->setPreferences($preferences)
->setUserBehindParticipant(isset($p['userId']) ? $p['userId'] : '');
$participants[] = $participant;
}
$poll->setParticipants($participants);
}
|
php
|
public function injectParticipants(Poll $poll)
{
$info = $this->injectInfo($poll);
$options = $poll->getOptions();
$countOptions = count($options);
$participants = [];
foreach ($info['participants'] as $p) {
$preferences = [];
for ($i = 0; $i < $countOptions; $i++) {
$preferences[] = new Preference($options[$i], $p['preferences'][$i]);
}
$participant = new Participant($p['id']);
$participant
->setName($p['name'])
->setAvatar(isset($p['largeAvatarUrl']) ? $p['largeAvatarUrl'] : '')
->setPreferences($preferences)
->setUserBehindParticipant(isset($p['userId']) ? $p['userId'] : '');
$participants[] = $participant;
}
$poll->setParticipants($participants);
}
|
[
"public",
"function",
"injectParticipants",
"(",
"Poll",
"$",
"poll",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"injectInfo",
"(",
"$",
"poll",
")",
";",
"$",
"options",
"=",
"$",
"poll",
"->",
"getOptions",
"(",
")",
";",
"$",
"countOptions",
"=",
"count",
"(",
"$",
"options",
")",
";",
"$",
"participants",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"info",
"[",
"'participants'",
"]",
"as",
"$",
"p",
")",
"{",
"$",
"preferences",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"countOptions",
";",
"$",
"i",
"++",
")",
"{",
"$",
"preferences",
"[",
"]",
"=",
"new",
"Preference",
"(",
"$",
"options",
"[",
"$",
"i",
"]",
",",
"$",
"p",
"[",
"'preferences'",
"]",
"[",
"$",
"i",
"]",
")",
";",
"}",
"$",
"participant",
"=",
"new",
"Participant",
"(",
"$",
"p",
"[",
"'id'",
"]",
")",
";",
"$",
"participant",
"->",
"setName",
"(",
"$",
"p",
"[",
"'name'",
"]",
")",
"->",
"setAvatar",
"(",
"isset",
"(",
"$",
"p",
"[",
"'largeAvatarUrl'",
"]",
")",
"?",
"$",
"p",
"[",
"'largeAvatarUrl'",
"]",
":",
"''",
")",
"->",
"setPreferences",
"(",
"$",
"preferences",
")",
"->",
"setUserBehindParticipant",
"(",
"isset",
"(",
"$",
"p",
"[",
"'userId'",
"]",
")",
"?",
"$",
"p",
"[",
"'userId'",
"]",
":",
"''",
")",
";",
"$",
"participants",
"[",
"]",
"=",
"$",
"participant",
";",
"}",
"$",
"poll",
"->",
"setParticipants",
"(",
"$",
"participants",
")",
";",
"}"
] |
Injects the participants.
@param Poll $poll
@return void
|
[
"Injects",
"the",
"participants",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L150-L172
|
221,878
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.injectLocation
|
public function injectLocation(Poll $poll)
{
$location = null;
$info = $this->injectInfo($poll);
if (!empty($info['location'])) {
$location = new Location($info['location']['name']);
if (!empty($info['location']['address'])) {
$location->setAddress($info['location']['address']);
}
if (!empty($info['location']['country'])) {
$location->setCountry($info['location']['country']);
}
}
$poll->setLocation($location);
}
|
php
|
public function injectLocation(Poll $poll)
{
$location = null;
$info = $this->injectInfo($poll);
if (!empty($info['location'])) {
$location = new Location($info['location']['name']);
if (!empty($info['location']['address'])) {
$location->setAddress($info['location']['address']);
}
if (!empty($info['location']['country'])) {
$location->setCountry($info['location']['country']);
}
}
$poll->setLocation($location);
}
|
[
"public",
"function",
"injectLocation",
"(",
"Poll",
"$",
"poll",
")",
"{",
"$",
"location",
"=",
"null",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"injectInfo",
"(",
"$",
"poll",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"info",
"[",
"'location'",
"]",
")",
")",
"{",
"$",
"location",
"=",
"new",
"Location",
"(",
"$",
"info",
"[",
"'location'",
"]",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"info",
"[",
"'location'",
"]",
"[",
"'address'",
"]",
")",
")",
"{",
"$",
"location",
"->",
"setAddress",
"(",
"$",
"info",
"[",
"'location'",
"]",
"[",
"'address'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"info",
"[",
"'location'",
"]",
"[",
"'country'",
"]",
")",
")",
"{",
"$",
"location",
"->",
"setCountry",
"(",
"$",
"info",
"[",
"'location'",
"]",
"[",
"'country'",
"]",
")",
";",
"}",
"}",
"$",
"poll",
"->",
"setLocation",
"(",
"$",
"location",
")",
";",
"}"
] |
Injects the location.
@param Poll $poll
@return void
|
[
"Injects",
"the",
"location",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L180-L194
|
221,879
|
xperseguers/doodle_client
|
src/Domain/Repository/PollRepository.php
|
PollRepository.decodeHtml
|
protected function decodeHtml($html): string
{
$text = html_entity_decode($html);
$text = preg_replace('#<br\s*/?>#', LF, $text);
return $text;
}
|
php
|
protected function decodeHtml($html): string
{
$text = html_entity_decode($html);
$text = preg_replace('#<br\s*/?>#', LF, $text);
return $text;
}
|
[
"protected",
"function",
"decodeHtml",
"(",
"$",
"html",
")",
":",
"string",
"{",
"$",
"text",
"=",
"html_entity_decode",
"(",
"$",
"html",
")",
";",
"$",
"text",
"=",
"preg_replace",
"(",
"'#<br\\s*/?>#'",
",",
"LF",
",",
"$",
"text",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Decodes HTML entities.
@param string $html
@return string
|
[
"Decodes",
"HTML",
"entities",
"."
] |
5ad422023d3d599631e908c852ef04fb7afa7087
|
https://github.com/xperseguers/doodle_client/blob/5ad422023d3d599631e908c852ef04fb7afa7087/src/Domain/Repository/PollRepository.php#L202-L208
|
221,880
|
jbboehr/PolynomialRegression.php
|
src/PolynomialRegression.php
|
PolynomialRegression.reset
|
public function reset()
{
$this->forcedValue = array();
$this->xPowers = array();
$this->xyPowers = array();
$this->index = 0;
$this->weightingInterface = NULL;
$squares = ( $this->numberOfCoefficient - 1 ) * 2;
// Initialize power arrays.
for ( $index = 0; $index <= $squares; ++$index )
{
$this->xPowers[ $index ] = 0;
$this->xyPowers[ $index ] = 0;
}
}
|
php
|
public function reset()
{
$this->forcedValue = array();
$this->xPowers = array();
$this->xyPowers = array();
$this->index = 0;
$this->weightingInterface = NULL;
$squares = ( $this->numberOfCoefficient - 1 ) * 2;
// Initialize power arrays.
for ( $index = 0; $index <= $squares; ++$index )
{
$this->xPowers[ $index ] = 0;
$this->xyPowers[ $index ] = 0;
}
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"forcedValue",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"xPowers",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"xyPowers",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"index",
"=",
"0",
";",
"$",
"this",
"->",
"weightingInterface",
"=",
"NULL",
";",
"$",
"squares",
"=",
"(",
"$",
"this",
"->",
"numberOfCoefficient",
"-",
"1",
")",
"*",
"2",
";",
"// Initialize power arrays.",
"for",
"(",
"$",
"index",
"=",
"0",
";",
"$",
"index",
"<=",
"$",
"squares",
";",
"++",
"$",
"index",
")",
"{",
"$",
"this",
"->",
"xPowers",
"[",
"$",
"index",
"]",
"=",
"0",
";",
"$",
"this",
"->",
"xyPowers",
"[",
"$",
"index",
"]",
"=",
"0",
";",
"}",
"}"
] |
Reset data.
Clear all internal data and prepare for new calculation.
Must be called *after* setNumberOfCoefficient if number of coefficients has
changed.
|
[
"Reset",
"data",
"."
] |
e71d684ee05d5694a29b28f8ca61807f7770d0cd
|
https://github.com/jbboehr/PolynomialRegression.php/blob/e71d684ee05d5694a29b28f8ca61807f7770d0cd/src/PolynomialRegression.php#L157-L174
|
221,881
|
jbboehr/PolynomialRegression.php
|
src/PolynomialRegression.php
|
PolynomialRegression.getForcedCoefficient
|
public function getForcedCoefficient( $coefficient )
{
$result = null;
if ( isset( $this->forcedValue[ $coefficient ] ) )
$result = $this->forcedValue[ $coefficient ];
return $result;
}
|
php
|
public function getForcedCoefficient( $coefficient )
{
$result = null;
if ( isset( $this->forcedValue[ $coefficient ] ) )
$result = $this->forcedValue[ $coefficient ];
return $result;
}
|
[
"public",
"function",
"getForcedCoefficient",
"(",
"$",
"coefficient",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"forcedValue",
"[",
"$",
"coefficient",
"]",
")",
")",
"$",
"result",
"=",
"$",
"this",
"->",
"forcedValue",
"[",
"$",
"coefficient",
"]",
";",
"return",
"$",
"result",
";",
"}"
] |
Get a forced coefficient.
Get a previously set forced coefficient.
@param int $coefficient Which coefficient.
@return float Value of this force this coefficient. Null if the
coefficient isn't being forced.
@since Version 1.1
|
[
"Get",
"a",
"forced",
"coefficient",
"."
] |
e71d684ee05d5694a29b28f8ca61807f7770d0cd
|
https://github.com/jbboehr/PolynomialRegression.php/blob/e71d684ee05d5694a29b28f8ca61807f7770d0cd/src/PolynomialRegression.php#L248-L256
|
221,882
|
jbboehr/PolynomialRegression.php
|
src/PolynomialRegression.php
|
PolynomialRegression.RAdjusted
|
public function RAdjusted($r2, $predictors, $sample_size)
{
if( ($sample_size - $predictors - 1) != 0 ) {
$radjusted = 1 - ((1 - $r2) * ($sample_size - 1)) / ($sample_size - $predictors - 1);
} else {
$radjusted = 1.0;
}
return $radjusted;
}
|
php
|
public function RAdjusted($r2, $predictors, $sample_size)
{
if( ($sample_size - $predictors - 1) != 0 ) {
$radjusted = 1 - ((1 - $r2) * ($sample_size - 1)) / ($sample_size - $predictors - 1);
} else {
$radjusted = 1.0;
}
return $radjusted;
}
|
[
"public",
"function",
"RAdjusted",
"(",
"$",
"r2",
",",
"$",
"predictors",
",",
"$",
"sample_size",
")",
"{",
"if",
"(",
"(",
"$",
"sample_size",
"-",
"$",
"predictors",
"-",
"1",
")",
"!=",
"0",
")",
"{",
"$",
"radjusted",
"=",
"1",
"-",
"(",
"(",
"1",
"-",
"$",
"r2",
")",
"*",
"(",
"$",
"sample_size",
"-",
"1",
")",
")",
"/",
"(",
"$",
"sample_size",
"-",
"$",
"predictors",
"-",
"1",
")",
";",
"}",
"else",
"{",
"$",
"radjusted",
"=",
"1.0",
";",
"}",
"return",
"$",
"radjusted",
";",
"}"
] |
08 August, 2016
Calculate the 'Adjusted R Squared'.
Adjusted R2 also indicates how well terms fit a curve or line,
but adjusts for the number of terms in a model.
If you add more and more useless variables to a model, adjusted r-squared will decrease.
If you add more useful variables, adjusted r-squared will increase.
http://www.statisticshowto.com/adjusted-r2/
http://blog.minitab.com/blog/adventures-in-statistics/multiple-regession-analysis-use-adjusted-r-squared-and-predicted-r-squared-to-include-the-correct-number-of-variables
@param number $r2
@param number $predictors
@param number $sample_size
@return float
@author Konstantinos Magarisiotis
|
[
"08",
"August",
"2016",
"Calculate",
"the",
"Adjusted",
"R",
"Squared",
"."
] |
e71d684ee05d5694a29b28f8ca61807f7770d0cd
|
https://github.com/jbboehr/PolynomialRegression.php/blob/e71d684ee05d5694a29b28f8ca61807f7770d0cd/src/PolynomialRegression.php#L594-L603
|
221,883
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabaseConfigurationHelper.php
|
MSSQLDatabaseConfigurationHelper.getPDODriver
|
public static function getPDODriver() {
if (!class_exists('PDO')) {
return null;
}
foreach(PDO::getAvailableDrivers() as $driver) {
if(in_array($driver, array('sqlsrv', 'dblib'))) {
return $driver;
}
}
return null;
}
|
php
|
public static function getPDODriver() {
if (!class_exists('PDO')) {
return null;
}
foreach(PDO::getAvailableDrivers() as $driver) {
if(in_array($driver, array('sqlsrv', 'dblib'))) {
return $driver;
}
}
return null;
}
|
[
"public",
"static",
"function",
"getPDODriver",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'PDO'",
")",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"PDO",
"::",
"getAvailableDrivers",
"(",
")",
"as",
"$",
"driver",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"driver",
",",
"array",
"(",
"'sqlsrv'",
",",
"'dblib'",
")",
")",
")",
"{",
"return",
"$",
"driver",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get supported PDO driver
@return null
|
[
"Get",
"supported",
"PDO",
"driver"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabaseConfigurationHelper.php#L95-L105
|
221,884
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabaseConfigurationHelper.php
|
MSSQLDatabaseConfigurationHelper.quote
|
protected function quote($conn, $value)
{
if ($conn instanceof PDO) {
return $conn->quote($value);
} elseif (is_resource($conn)) {
$value = str_replace("'", "''", $value);
$value = str_replace("\0", "[NULL]", $value);
return "N'$value'";
} else {
user_error('Invalid database connection', E_USER_ERROR);
}
return null;
}
|
php
|
protected function quote($conn, $value)
{
if ($conn instanceof PDO) {
return $conn->quote($value);
} elseif (is_resource($conn)) {
$value = str_replace("'", "''", $value);
$value = str_replace("\0", "[NULL]", $value);
return "N'$value'";
} else {
user_error('Invalid database connection', E_USER_ERROR);
}
return null;
}
|
[
"protected",
"function",
"quote",
"(",
"$",
"conn",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"conn",
"instanceof",
"PDO",
")",
"{",
"return",
"$",
"conn",
"->",
"quote",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"conn",
")",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"\"'\"",
",",
"\"''\"",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"str_replace",
"(",
"\"\\0\"",
",",
"\"[NULL]\"",
",",
"$",
"value",
")",
";",
"return",
"\"N'$value'\"",
";",
"}",
"else",
"{",
"user_error",
"(",
"'Invalid database connection'",
",",
"E_USER_ERROR",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Helper function to quote a string value
@param mixed $conn Connection object/resource
@param string $value Value to quote
@return string Quoted string
|
[
"Helper",
"function",
"to",
"quote",
"a",
"string",
"value"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabaseConfigurationHelper.php#L114-L126
|
221,885
|
silverstripe/silverstripe-mssql
|
code/MSSQLDatabaseConfigurationHelper.php
|
MSSQLDatabaseConfigurationHelper.query
|
protected function query($conn, $sql)
{
$items = array();
if ($conn instanceof PDO) {
$result = $conn->query($sql);
if ($result) {
foreach ($result as $row) {
$items[] = $row[0];
}
}
} elseif (is_resource($conn)) {
$result = sqlsrv_query($conn, $sql);
if ($result) {
while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_NUMERIC)) {
$items[] = $row[0];
}
}
}
return $items;
}
|
php
|
protected function query($conn, $sql)
{
$items = array();
if ($conn instanceof PDO) {
$result = $conn->query($sql);
if ($result) {
foreach ($result as $row) {
$items[] = $row[0];
}
}
} elseif (is_resource($conn)) {
$result = sqlsrv_query($conn, $sql);
if ($result) {
while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_NUMERIC)) {
$items[] = $row[0];
}
}
}
return $items;
}
|
[
"protected",
"function",
"query",
"(",
"$",
"conn",
",",
"$",
"sql",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"conn",
"instanceof",
"PDO",
")",
"{",
"$",
"result",
"=",
"$",
"conn",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"conn",
")",
")",
"{",
"$",
"result",
"=",
"sqlsrv_query",
"(",
"$",
"conn",
",",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"while",
"(",
"$",
"row",
"=",
"sqlsrv_fetch_array",
"(",
"$",
"result",
",",
"SQLSRV_FETCH_NUMERIC",
")",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"items",
";",
"}"
] |
Helper function to execute a query
@param mixed $conn Connection object/resource
@param string $sql SQL string to execute
@return array List of first value from each resulting row
|
[
"Helper",
"function",
"to",
"execute",
"a",
"query"
] |
34fb10580af3f403d69ba84984e78bcfc3f48bf3
|
https://github.com/silverstripe/silverstripe-mssql/blob/34fb10580af3f403d69ba84984e78bcfc3f48bf3/code/MSSQLDatabaseConfigurationHelper.php#L135-L154
|
221,886
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Tracking/Social.php
|
Social.createPackage
|
public function createPackage()
{
if (!$this->getSocialAction()) {
throw new MissingTrackingParameterException('social action must be set');
}
if (!$this->getSocialNetwork()) {
throw new MissingTrackingParameterException('social network must be set');
}
if (!$this->getSocialTarget()) {
throw new MissingTrackingParameterException('social target must be set');
}
return array(
't' => 'social',
'sa' => $this->getSocialAction(),
'sn' => $this->getSocialNetwork(),
'st' => $this->getSocialTarget()
);
}
|
php
|
public function createPackage()
{
if (!$this->getSocialAction()) {
throw new MissingTrackingParameterException('social action must be set');
}
if (!$this->getSocialNetwork()) {
throw new MissingTrackingParameterException('social network must be set');
}
if (!$this->getSocialTarget()) {
throw new MissingTrackingParameterException('social target must be set');
}
return array(
't' => 'social',
'sa' => $this->getSocialAction(),
'sn' => $this->getSocialNetwork(),
'st' => $this->getSocialTarget()
);
}
|
[
"public",
"function",
"createPackage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getSocialAction",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'social action must be set'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getSocialNetwork",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'social network must be set'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getSocialTarget",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'social target must be set'",
")",
";",
"}",
"return",
"array",
"(",
"'t'",
"=>",
"'social'",
",",
"'sa'",
"=>",
"$",
"this",
"->",
"getSocialAction",
"(",
")",
",",
"'sn'",
"=>",
"$",
"this",
"->",
"getSocialNetwork",
"(",
")",
",",
"'st'",
"=>",
"$",
"this",
"->",
"getSocialTarget",
"(",
")",
")",
";",
"}"
] |
Returns the Google Paket for Social Tracking
@return array
@throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
[
"Returns",
"the",
"Google",
"Paket",
"for",
"Social",
"Tracking"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Tracking/Social.php#L106-L126
|
221,887
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Tracking/AbstractTracking.php
|
AbstractTracking.addCustomPayloadData
|
public function addCustomPayloadData($key, $value)
{
if (!is_string($value)) {
throw new Exception\InvalidArgumentException('Custom payload data value must be a string');
}
$this->customPayload[$key] = $value;
}
|
php
|
public function addCustomPayloadData($key, $value)
{
if (!is_string($value)) {
throw new Exception\InvalidArgumentException('Custom payload data value must be a string');
}
$this->customPayload[$key] = $value;
}
|
[
"public",
"function",
"addCustomPayloadData",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Custom payload data value must be a string'",
")",
";",
"}",
"$",
"this",
"->",
"customPayload",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Add Custom Tracking Payload Data send to Google
@param $key
@param $value
@throws Exception\InvalidArgumentException
|
[
"Add",
"Custom",
"Tracking",
"Payload",
"Data",
"send",
"to",
"Google"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Tracking/AbstractTracking.php#L140-L147
|
221,888
|
kkiernan/caesar-cipher-php
|
src/KKiernan/CaesarCipher.php
|
CaesarCipher.crack
|
public function crack($ciphertext)
{
$plaintexts = [];
foreach (range(0, 25) as $key) {
$plaintexts[$key] = substr_count(strtolower($this->decrypt($ciphertext, $key)), 'e');
}
return array_search(max($plaintexts), $plaintexts);
}
|
php
|
public function crack($ciphertext)
{
$plaintexts = [];
foreach (range(0, 25) as $key) {
$plaintexts[$key] = substr_count(strtolower($this->decrypt($ciphertext, $key)), 'e');
}
return array_search(max($plaintexts), $plaintexts);
}
|
[
"public",
"function",
"crack",
"(",
"$",
"ciphertext",
")",
"{",
"$",
"plaintexts",
"=",
"[",
"]",
";",
"foreach",
"(",
"range",
"(",
"0",
",",
"25",
")",
"as",
"$",
"key",
")",
"{",
"$",
"plaintexts",
"[",
"$",
"key",
"]",
"=",
"substr_count",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"decrypt",
"(",
"$",
"ciphertext",
",",
"$",
"key",
")",
")",
",",
"'e'",
")",
";",
"}",
"return",
"array_search",
"(",
"max",
"(",
"$",
"plaintexts",
")",
",",
"$",
"plaintexts",
")",
";",
"}"
] |
Attempts to brute force the key. This is using an extremely simplified
version of frequency analysis. We are just looking for the most
frequently used character and assuming it is the letter e.
@param string $ciphertext
@return int
|
[
"Attempts",
"to",
"brute",
"force",
"the",
"key",
".",
"This",
"is",
"using",
"an",
"extremely",
"simplified",
"version",
"of",
"frequency",
"analysis",
".",
"We",
"are",
"just",
"looking",
"for",
"the",
"most",
"frequently",
"used",
"character",
"and",
"assuming",
"it",
"is",
"the",
"letter",
"e",
"."
] |
30ef5e634ac1405be9c7c475d8401e298724cbe1
|
https://github.com/kkiernan/caesar-cipher-php/blob/30ef5e634ac1405be9c7c475d8401e298724cbe1/src/KKiernan/CaesarCipher.php#L42-L51
|
221,889
|
kkiernan/caesar-cipher-php
|
src/KKiernan/CaesarCipher.php
|
CaesarCipher.run
|
protected function run($string, $key)
{
return implode('', array_map(function ($char) use ($key) {
return $this->shift($char, $key);
}, str_split($string)));
}
|
php
|
protected function run($string, $key)
{
return implode('', array_map(function ($char) use ($key) {
return $this->shift($char, $key);
}, str_split($string)));
}
|
[
"protected",
"function",
"run",
"(",
"$",
"string",
",",
"$",
"key",
")",
"{",
"return",
"implode",
"(",
"''",
",",
"array_map",
"(",
"function",
"(",
"$",
"char",
")",
"use",
"(",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"shift",
"(",
"$",
"char",
",",
"$",
"key",
")",
";",
"}",
",",
"str_split",
"(",
"$",
"string",
")",
")",
")",
";",
"}"
] |
Runs the algorithm to encrypt or decrypt the given string.
@return string
|
[
"Runs",
"the",
"algorithm",
"to",
"encrypt",
"or",
"decrypt",
"the",
"given",
"string",
"."
] |
30ef5e634ac1405be9c7c475d8401e298724cbe1
|
https://github.com/kkiernan/caesar-cipher-php/blob/30ef5e634ac1405be9c7c475d8401e298724cbe1/src/KKiernan/CaesarCipher.php#L58-L63
|
221,890
|
kkiernan/caesar-cipher-php
|
src/KKiernan/CaesarCipher.php
|
CaesarCipher.shift
|
protected function shift($char, $shift)
{
$shift = $shift % 25;
$ascii = ord($char);
$shifted = $ascii + $shift;
if ($ascii >= 65 && $ascii <= 90) {
return chr($this->wrapUppercase($shifted));
}
if ($ascii >= 97 && $ascii <= 122) {
return chr($this->wrapLowercase($shifted));
}
return chr($ascii);
}
|
php
|
protected function shift($char, $shift)
{
$shift = $shift % 25;
$ascii = ord($char);
$shifted = $ascii + $shift;
if ($ascii >= 65 && $ascii <= 90) {
return chr($this->wrapUppercase($shifted));
}
if ($ascii >= 97 && $ascii <= 122) {
return chr($this->wrapLowercase($shifted));
}
return chr($ascii);
}
|
[
"protected",
"function",
"shift",
"(",
"$",
"char",
",",
"$",
"shift",
")",
"{",
"$",
"shift",
"=",
"$",
"shift",
"%",
"25",
";",
"$",
"ascii",
"=",
"ord",
"(",
"$",
"char",
")",
";",
"$",
"shifted",
"=",
"$",
"ascii",
"+",
"$",
"shift",
";",
"if",
"(",
"$",
"ascii",
">=",
"65",
"&&",
"$",
"ascii",
"<=",
"90",
")",
"{",
"return",
"chr",
"(",
"$",
"this",
"->",
"wrapUppercase",
"(",
"$",
"shifted",
")",
")",
";",
"}",
"if",
"(",
"$",
"ascii",
">=",
"97",
"&&",
"$",
"ascii",
"<=",
"122",
")",
"{",
"return",
"chr",
"(",
"$",
"this",
"->",
"wrapLowercase",
"(",
"$",
"shifted",
")",
")",
";",
"}",
"return",
"chr",
"(",
"$",
"ascii",
")",
";",
"}"
] |
Handles requests to shift a character by the given number of places.
@param string $char
@param int $shift
@return string
|
[
"Handles",
"requests",
"to",
"shift",
"a",
"character",
"by",
"the",
"given",
"number",
"of",
"places",
"."
] |
30ef5e634ac1405be9c7c475d8401e298724cbe1
|
https://github.com/kkiernan/caesar-cipher-php/blob/30ef5e634ac1405be9c7c475d8401e298724cbe1/src/KKiernan/CaesarCipher.php#L73-L88
|
221,891
|
subugoe/typo3-find
|
Classes/Controller/SearchController.php
|
SearchController.initializeAction
|
public function initializeAction()
{
ksort($this->settings['queryFields']);
$this->initializeConnection($this->settings['activeConnection']);
$this->requestArguments = $this->request->getArguments();
$this->requestArguments = ArrayUtility::cleanArgumentsArray($this->requestArguments);
$this->searchProvider->setRequestArguments($this->requestArguments);
$this->searchProvider->setAction($this->request->getControllerActionName());
$this->searchProvider->setControllerExtensionKey($this->request->getControllerExtensionKey());
}
|
php
|
public function initializeAction()
{
ksort($this->settings['queryFields']);
$this->initializeConnection($this->settings['activeConnection']);
$this->requestArguments = $this->request->getArguments();
$this->requestArguments = ArrayUtility::cleanArgumentsArray($this->requestArguments);
$this->searchProvider->setRequestArguments($this->requestArguments);
$this->searchProvider->setAction($this->request->getControllerActionName());
$this->searchProvider->setControllerExtensionKey($this->request->getControllerExtensionKey());
}
|
[
"public",
"function",
"initializeAction",
"(",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"settings",
"[",
"'queryFields'",
"]",
")",
";",
"$",
"this",
"->",
"initializeConnection",
"(",
"$",
"this",
"->",
"settings",
"[",
"'activeConnection'",
"]",
")",
";",
"$",
"this",
"->",
"requestArguments",
"=",
"$",
"this",
"->",
"request",
"->",
"getArguments",
"(",
")",
";",
"$",
"this",
"->",
"requestArguments",
"=",
"ArrayUtility",
"::",
"cleanArgumentsArray",
"(",
"$",
"this",
"->",
"requestArguments",
")",
";",
"$",
"this",
"->",
"searchProvider",
"->",
"setRequestArguments",
"(",
"$",
"this",
"->",
"requestArguments",
")",
";",
"$",
"this",
"->",
"searchProvider",
"->",
"setAction",
"(",
"$",
"this",
"->",
"request",
"->",
"getControllerActionName",
"(",
")",
")",
";",
"$",
"this",
"->",
"searchProvider",
"->",
"setControllerExtensionKey",
"(",
"$",
"this",
"->",
"request",
"->",
"getControllerExtensionKey",
"(",
")",
")",
";",
"}"
] |
Initialisation and setup.
|
[
"Initialisation",
"and",
"setup",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Controller/SearchController.php#L66-L77
|
221,892
|
subugoe/typo3-find
|
Classes/Controller/SearchController.php
|
SearchController.indexAction
|
public function indexAction()
{
if (array_key_exists('id', $this->requestArguments)) {
$this->forward('detail');
} else {
$this->searchProvider->setCounter();
$this->response->addAdditionalHeaderData(
FrontendUtility::addQueryInformationAsJavaScript(
$this->searchProvider->getRequestArguments()['q'],
$this->settings,
null,
$this->searchProvider->getRequestArguments()
),
false,
true
);
$this->addStandardAssignments();
$defaultQuery = $this->searchProvider->getDefaultQuery();
$viewValues = [
'arguments' => $this->searchProvider->getRequestArguments(),
'config' => $this->searchProvider->getConfiguration(),
];
CoreArrayUtility::mergeRecursiveWithOverrule($viewValues, $defaultQuery);
$this->view->assignMultiple($viewValues);
}
}
|
php
|
public function indexAction()
{
if (array_key_exists('id', $this->requestArguments)) {
$this->forward('detail');
} else {
$this->searchProvider->setCounter();
$this->response->addAdditionalHeaderData(
FrontendUtility::addQueryInformationAsJavaScript(
$this->searchProvider->getRequestArguments()['q'],
$this->settings,
null,
$this->searchProvider->getRequestArguments()
),
false,
true
);
$this->addStandardAssignments();
$defaultQuery = $this->searchProvider->getDefaultQuery();
$viewValues = [
'arguments' => $this->searchProvider->getRequestArguments(),
'config' => $this->searchProvider->getConfiguration(),
];
CoreArrayUtility::mergeRecursiveWithOverrule($viewValues, $defaultQuery);
$this->view->assignMultiple($viewValues);
}
}
|
[
"public",
"function",
"indexAction",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'id'",
",",
"$",
"this",
"->",
"requestArguments",
")",
")",
"{",
"$",
"this",
"->",
"forward",
"(",
"'detail'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"searchProvider",
"->",
"setCounter",
"(",
")",
";",
"$",
"this",
"->",
"response",
"->",
"addAdditionalHeaderData",
"(",
"FrontendUtility",
"::",
"addQueryInformationAsJavaScript",
"(",
"$",
"this",
"->",
"searchProvider",
"->",
"getRequestArguments",
"(",
")",
"[",
"'q'",
"]",
",",
"$",
"this",
"->",
"settings",
",",
"null",
",",
"$",
"this",
"->",
"searchProvider",
"->",
"getRequestArguments",
"(",
")",
")",
",",
"false",
",",
"true",
")",
";",
"$",
"this",
"->",
"addStandardAssignments",
"(",
")",
";",
"$",
"defaultQuery",
"=",
"$",
"this",
"->",
"searchProvider",
"->",
"getDefaultQuery",
"(",
")",
";",
"$",
"viewValues",
"=",
"[",
"'arguments'",
"=>",
"$",
"this",
"->",
"searchProvider",
"->",
"getRequestArguments",
"(",
")",
",",
"'config'",
"=>",
"$",
"this",
"->",
"searchProvider",
"->",
"getConfiguration",
"(",
")",
",",
"]",
";",
"CoreArrayUtility",
"::",
"mergeRecursiveWithOverrule",
"(",
"$",
"viewValues",
",",
"$",
"defaultQuery",
")",
";",
"$",
"this",
"->",
"view",
"->",
"assignMultiple",
"(",
"$",
"viewValues",
")",
";",
"}",
"}"
] |
Index Action.
|
[
"Index",
"Action",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Controller/SearchController.php#L95-L123
|
221,893
|
subugoe/typo3-find
|
Classes/Controller/SearchController.php
|
SearchController.addStandardAssignments
|
protected function addStandardAssignments()
{
$this->searchProvider->setConfigurationValue('extendedSearch', $this->searchProvider->isExtendedSearch());
$this->searchProvider->setConfigurationValue(
'uid',
$this->configurationManager->getContentObject()->data['uid']
);
$this->searchProvider->setConfigurationValue('prefixID', 'tx_find_find');
$this->searchProvider->setConfigurationValue('pageTitle', $GLOBALS['TSFE']->page['title']);
}
|
php
|
protected function addStandardAssignments()
{
$this->searchProvider->setConfigurationValue('extendedSearch', $this->searchProvider->isExtendedSearch());
$this->searchProvider->setConfigurationValue(
'uid',
$this->configurationManager->getContentObject()->data['uid']
);
$this->searchProvider->setConfigurationValue('prefixID', 'tx_find_find');
$this->searchProvider->setConfigurationValue('pageTitle', $GLOBALS['TSFE']->page['title']);
}
|
[
"protected",
"function",
"addStandardAssignments",
"(",
")",
"{",
"$",
"this",
"->",
"searchProvider",
"->",
"setConfigurationValue",
"(",
"'extendedSearch'",
",",
"$",
"this",
"->",
"searchProvider",
"->",
"isExtendedSearch",
"(",
")",
")",
";",
"$",
"this",
"->",
"searchProvider",
"->",
"setConfigurationValue",
"(",
"'uid'",
",",
"$",
"this",
"->",
"configurationManager",
"->",
"getContentObject",
"(",
")",
"->",
"data",
"[",
"'uid'",
"]",
")",
";",
"$",
"this",
"->",
"searchProvider",
"->",
"setConfigurationValue",
"(",
"'prefixID'",
",",
"'tx_find_find'",
")",
";",
"$",
"this",
"->",
"searchProvider",
"->",
"setConfigurationValue",
"(",
"'pageTitle'",
",",
"$",
"GLOBALS",
"[",
"'TSFE'",
"]",
"->",
"page",
"[",
"'title'",
"]",
")",
";",
"}"
] |
Assigns standard variables to the view.
|
[
"Assigns",
"standard",
"variables",
"to",
"the",
"view",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/Controller/SearchController.php#L168-L177
|
221,894
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Tracking/User/Timing.php
|
Timing.createPackage
|
public function createPackage()
{
return array(
't' => 'timing',
'utc' => $this->getTimingCategory(),
'utv' => $this->getTimingVariable(),
'utt' => $this->getTimingTime(),
'utl' => $this->getTimingLabel(),
'dns' => $this->getBrowserDnsLoadTime(),
'pdt' => $this->getBrowserPageDownloadTime(),
'rrt' => $this->getBrowserRedirectTime(),
'tcp' => $this->getBrowserTcpConnectTime(),
'srt' => $this->getBrowserServerResponseTime()
);
}
|
php
|
public function createPackage()
{
return array(
't' => 'timing',
'utc' => $this->getTimingCategory(),
'utv' => $this->getTimingVariable(),
'utt' => $this->getTimingTime(),
'utl' => $this->getTimingLabel(),
'dns' => $this->getBrowserDnsLoadTime(),
'pdt' => $this->getBrowserPageDownloadTime(),
'rrt' => $this->getBrowserRedirectTime(),
'tcp' => $this->getBrowserTcpConnectTime(),
'srt' => $this->getBrowserServerResponseTime()
);
}
|
[
"public",
"function",
"createPackage",
"(",
")",
"{",
"return",
"array",
"(",
"'t'",
"=>",
"'timing'",
",",
"'utc'",
"=>",
"$",
"this",
"->",
"getTimingCategory",
"(",
")",
",",
"'utv'",
"=>",
"$",
"this",
"->",
"getTimingVariable",
"(",
")",
",",
"'utt'",
"=>",
"$",
"this",
"->",
"getTimingTime",
"(",
")",
",",
"'utl'",
"=>",
"$",
"this",
"->",
"getTimingLabel",
"(",
")",
",",
"'dns'",
"=>",
"$",
"this",
"->",
"getBrowserDnsLoadTime",
"(",
")",
",",
"'pdt'",
"=>",
"$",
"this",
"->",
"getBrowserPageDownloadTime",
"(",
")",
",",
"'rrt'",
"=>",
"$",
"this",
"->",
"getBrowserRedirectTime",
"(",
")",
",",
"'tcp'",
"=>",
"$",
"this",
"->",
"getBrowserTcpConnectTime",
"(",
")",
",",
"'srt'",
"=>",
"$",
"this",
"->",
"getBrowserServerResponseTime",
"(",
")",
")",
";",
"}"
] |
Returns the Paket for User Timing Tracking
@return array
|
[
"Returns",
"the",
"Paket",
"for",
"User",
"Timing",
"Tracking"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Tracking/User/Timing.php#L236-L250
|
221,895
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Tracking/Ecommerce/Item.php
|
Item.createPackage
|
public function createPackage()
{
if (!$this->getTransactionID()) {
throw new MissingTrackingParameterException('transaction id is missing');
}
if (!$this->getName()) {
throw new MissingTrackingParameterException('item name is missing');
}
return array(
't' => 'item',
'ti' => $this->getTransactionID(),
'in' => $this->getName(),
'ip' => $this->getPrice(),
'iq' => $this->getQuantity(),
'ic' => $this->getSku(),
'iv' => $this->getCategory(),
'cu' => $this->getCurrency()
);
}
|
php
|
public function createPackage()
{
if (!$this->getTransactionID()) {
throw new MissingTrackingParameterException('transaction id is missing');
}
if (!$this->getName()) {
throw new MissingTrackingParameterException('item name is missing');
}
return array(
't' => 'item',
'ti' => $this->getTransactionID(),
'in' => $this->getName(),
'ip' => $this->getPrice(),
'iq' => $this->getQuantity(),
'ic' => $this->getSku(),
'iv' => $this->getCategory(),
'cu' => $this->getCurrency()
);
}
|
[
"public",
"function",
"createPackage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getTransactionID",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'transaction id is missing'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"{",
"throw",
"new",
"MissingTrackingParameterException",
"(",
"'item name is missing'",
")",
";",
"}",
"return",
"array",
"(",
"'t'",
"=>",
"'item'",
",",
"'ti'",
"=>",
"$",
"this",
"->",
"getTransactionID",
"(",
")",
",",
"'in'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'ip'",
"=>",
"$",
"this",
"->",
"getPrice",
"(",
")",
",",
"'iq'",
"=>",
"$",
"this",
"->",
"getQuantity",
"(",
")",
",",
"'ic'",
"=>",
"$",
"this",
"->",
"getSku",
"(",
")",
",",
"'iv'",
"=>",
"$",
"this",
"->",
"getCategory",
"(",
")",
",",
"'cu'",
"=>",
"$",
"this",
"->",
"getCurrency",
"(",
")",
")",
";",
"}"
] |
Create the Package
@return array
@throws \Racecore\GATracking\Exception\MissingTrackingParameterException
|
[
"Create",
"the",
"Package"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Tracking/Ecommerce/Item.php#L193-L213
|
221,896
|
wallee-payment/php-sdk
|
lib/Http/CurlHttpClient.php
|
CurlHttpClient.handleResponse
|
private function handleResponse(ApiClient $apiClient, HttpRequest $request, $curl, $response, $url) {
$httpHeaderSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$httpHeader = substr($response, 0, $httpHeaderSize);
$httpBody = substr($response, $httpHeaderSize);
$responseInfo = curl_getinfo($curl);
// debug HTTP response body
if ($apiClient->isDebuggingEnabled()) {
error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($httpBody, true).PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
}
if ($responseInfo['http_code'] === 0) {
$curlErrorMessage = curl_error($curl);
// curl_exec can sometimes fail but still return a blank message from curl_error().
if (!empty($curlErrorMessage)) {
throw new ConnectionException($url, $request->getLogToken(), $curlErrorMessage);
} else {
throw new ConnectionException($url, $request->getLogToken(), 'API call failed for an unknown reason. This could happen if you are disconnected from the network.');
}
} else {
return new HttpResponse($responseInfo['http_code'], $httpHeader, $httpBody);
}
}
|
php
|
private function handleResponse(ApiClient $apiClient, HttpRequest $request, $curl, $response, $url) {
$httpHeaderSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$httpHeader = substr($response, 0, $httpHeaderSize);
$httpBody = substr($response, $httpHeaderSize);
$responseInfo = curl_getinfo($curl);
// debug HTTP response body
if ($apiClient->isDebuggingEnabled()) {
error_log("[DEBUG] HTTP Response body ~BEGIN~".PHP_EOL.print_r($httpBody, true).PHP_EOL."~END~".PHP_EOL, 3, $apiClient->getDebugFile());
}
if ($responseInfo['http_code'] === 0) {
$curlErrorMessage = curl_error($curl);
// curl_exec can sometimes fail but still return a blank message from curl_error().
if (!empty($curlErrorMessage)) {
throw new ConnectionException($url, $request->getLogToken(), $curlErrorMessage);
} else {
throw new ConnectionException($url, $request->getLogToken(), 'API call failed for an unknown reason. This could happen if you are disconnected from the network.');
}
} else {
return new HttpResponse($responseInfo['http_code'], $httpHeader, $httpBody);
}
}
|
[
"private",
"function",
"handleResponse",
"(",
"ApiClient",
"$",
"apiClient",
",",
"HttpRequest",
"$",
"request",
",",
"$",
"curl",
",",
"$",
"response",
",",
"$",
"url",
")",
"{",
"$",
"httpHeaderSize",
"=",
"curl_getinfo",
"(",
"$",
"curl",
",",
"CURLINFO_HEADER_SIZE",
")",
";",
"$",
"httpHeader",
"=",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"$",
"httpHeaderSize",
")",
";",
"$",
"httpBody",
"=",
"substr",
"(",
"$",
"response",
",",
"$",
"httpHeaderSize",
")",
";",
"$",
"responseInfo",
"=",
"curl_getinfo",
"(",
"$",
"curl",
")",
";",
"// debug HTTP response body",
"if",
"(",
"$",
"apiClient",
"->",
"isDebuggingEnabled",
"(",
")",
")",
"{",
"error_log",
"(",
"\"[DEBUG] HTTP Response body ~BEGIN~\"",
".",
"PHP_EOL",
".",
"print_r",
"(",
"$",
"httpBody",
",",
"true",
")",
".",
"PHP_EOL",
".",
"\"~END~\"",
".",
"PHP_EOL",
",",
"3",
",",
"$",
"apiClient",
"->",
"getDebugFile",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"responseInfo",
"[",
"'http_code'",
"]",
"===",
"0",
")",
"{",
"$",
"curlErrorMessage",
"=",
"curl_error",
"(",
"$",
"curl",
")",
";",
"// curl_exec can sometimes fail but still return a blank message from curl_error().",
"if",
"(",
"!",
"empty",
"(",
"$",
"curlErrorMessage",
")",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"$",
"url",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"$",
"curlErrorMessage",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ConnectionException",
"(",
"$",
"url",
",",
"$",
"request",
"->",
"getLogToken",
"(",
")",
",",
"'API call failed for an unknown reason. This could happen if you are disconnected from the network.'",
")",
";",
"}",
"}",
"else",
"{",
"return",
"new",
"HttpResponse",
"(",
"$",
"responseInfo",
"[",
"'http_code'",
"]",
",",
"$",
"httpHeader",
",",
"$",
"httpBody",
")",
";",
"}",
"}"
] |
Puts together the HTTP response.
@param ApiClient $apiClient the API client instance
@param HttpRequest $request the HTTP request
@param resource $curl the cURL handler
@param mixed $response the response the of HTTP request
@param string $url the url of the HTTP request
@return HttpResponse
|
[
"Puts",
"together",
"the",
"HTTP",
"response",
"."
] |
e1d18453855382af3144e845f2d9704efb93e9cb
|
https://github.com/wallee-payment/php-sdk/blob/e1d18453855382af3144e845f2d9704efb93e9cb/lib/Http/CurlHttpClient.php#L120-L143
|
221,897
|
subugoe/typo3-find
|
Classes/ViewHelpers/Find/HighlightFieldViewHelper.php
|
HighlightFieldViewHelper.highlightField
|
protected static function highlightField($fieldContent, $arguments)
{
$highlightInfo = self::getHighlightInfo($arguments);
if (is_array($fieldContent)) {
$result = [];
foreach ($fieldContent as $singleField) {
$result[] = self::highlightSingleField($singleField, $highlightInfo, $arguments);
}
} else {
$result = self::highlightSingleField($fieldContent, $highlightInfo, $arguments);
}
return $result;
}
|
php
|
protected static function highlightField($fieldContent, $arguments)
{
$highlightInfo = self::getHighlightInfo($arguments);
if (is_array($fieldContent)) {
$result = [];
foreach ($fieldContent as $singleField) {
$result[] = self::highlightSingleField($singleField, $highlightInfo, $arguments);
}
} else {
$result = self::highlightSingleField($fieldContent, $highlightInfo, $arguments);
}
return $result;
}
|
[
"protected",
"static",
"function",
"highlightField",
"(",
"$",
"fieldContent",
",",
"$",
"arguments",
")",
"{",
"$",
"highlightInfo",
"=",
"self",
"::",
"getHighlightInfo",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"fieldContent",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fieldContent",
"as",
"$",
"singleField",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"self",
"::",
"highlightSingleField",
"(",
"$",
"singleField",
",",
"$",
"highlightInfo",
",",
"$",
"arguments",
")",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"self",
"::",
"highlightSingleField",
"(",
"$",
"fieldContent",
",",
"$",
"highlightInfo",
",",
"$",
"arguments",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns string or array of strings with highlighted areas enclosed
by \ueeee and \ueeef.
@param array|string $fieldContent content of the field to highlight
@param array $arguments
@return array|string
|
[
"Returns",
"string",
"or",
"array",
"of",
"strings",
"with",
"highlighted",
"areas",
"enclosed",
"by",
"\\",
"ueeee",
"and",
"\\",
"ueeef",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/ViewHelpers/Find/HighlightFieldViewHelper.php#L104-L118
|
221,898
|
subugoe/typo3-find
|
Classes/ViewHelpers/Find/HighlightFieldViewHelper.php
|
HighlightFieldViewHelper.getHighlightInfo
|
protected static function getHighlightInfo($arguments)
{
$highlightInfo = [];
$documentID = $arguments['document'][$arguments['idKey']];
if ($documentID) {
$highlighting = $arguments['results']->getHighlighting();
if ($highlighting) {
if ($arguments['alternateField']) {
$highlightInfo += $highlighting->getResult($documentID)->getField($arguments['alternateField']);
} else {
$highlightInfo += $highlighting->getResult($documentID)->getField($arguments['field']);
}
}
}
return $highlightInfo;
}
|
php
|
protected static function getHighlightInfo($arguments)
{
$highlightInfo = [];
$documentID = $arguments['document'][$arguments['idKey']];
if ($documentID) {
$highlighting = $arguments['results']->getHighlighting();
if ($highlighting) {
if ($arguments['alternateField']) {
$highlightInfo += $highlighting->getResult($documentID)->getField($arguments['alternateField']);
} else {
$highlightInfo += $highlighting->getResult($documentID)->getField($arguments['field']);
}
}
}
return $highlightInfo;
}
|
[
"protected",
"static",
"function",
"getHighlightInfo",
"(",
"$",
"arguments",
")",
"{",
"$",
"highlightInfo",
"=",
"[",
"]",
";",
"$",
"documentID",
"=",
"$",
"arguments",
"[",
"'document'",
"]",
"[",
"$",
"arguments",
"[",
"'idKey'",
"]",
"]",
";",
"if",
"(",
"$",
"documentID",
")",
"{",
"$",
"highlighting",
"=",
"$",
"arguments",
"[",
"'results'",
"]",
"->",
"getHighlighting",
"(",
")",
";",
"if",
"(",
"$",
"highlighting",
")",
"{",
"if",
"(",
"$",
"arguments",
"[",
"'alternateField'",
"]",
")",
"{",
"$",
"highlightInfo",
"+=",
"$",
"highlighting",
"->",
"getResult",
"(",
"$",
"documentID",
")",
"->",
"getField",
"(",
"$",
"arguments",
"[",
"'alternateField'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"highlightInfo",
"+=",
"$",
"highlighting",
"->",
"getResult",
"(",
"$",
"documentID",
")",
"->",
"getField",
"(",
"$",
"arguments",
"[",
"'field'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"highlightInfo",
";",
"}"
] |
Returns highlight information for the document and field configured in
our arguments.
@return array
|
[
"Returns",
"highlight",
"information",
"for",
"the",
"document",
"and",
"field",
"configured",
"in",
"our",
"arguments",
"."
] |
d628a0b6a131d05f4842b08a556fe17cba9d7da0
|
https://github.com/subugoe/typo3-find/blob/d628a0b6a131d05f4842b08a556fe17cba9d7da0/Classes/ViewHelpers/Find/HighlightFieldViewHelper.php#L126-L143
|
221,899
|
ins0/google-measurement-php-client
|
src/Racecore/GATracking/Client/Adapter/Socket.php
|
Socket.createConnection
|
private function createConnection($endpoint)
{
// port
$port = $this->getOption('ssl') == true ? 443 : 80;
if (!($connection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
throw new Exception\EndpointServerException('Analytics Socket failure! Error: ' . $errormsg);
}
if (!socket_connect($connection, $endpoint['host'], $port)) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
throw new Exception\EndpointServerException('Analytics Host not reachable! Error: ' . $errormsg);
}
socket_set_option($connection, SOL_SOCKET, SO_RCVTIMEO, array('sec' => self::READ_TIMEOUT, 'usec' => 0));
if ($this->getOption('async')) {
socket_set_nonblock($connection);
}
$this->connection = $connection;
}
|
php
|
private function createConnection($endpoint)
{
// port
$port = $this->getOption('ssl') == true ? 443 : 80;
if (!($connection = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
throw new Exception\EndpointServerException('Analytics Socket failure! Error: ' . $errormsg);
}
if (!socket_connect($connection, $endpoint['host'], $port)) {
$errorcode = socket_last_error();
$errormsg = socket_strerror($errorcode);
throw new Exception\EndpointServerException('Analytics Host not reachable! Error: ' . $errormsg);
}
socket_set_option($connection, SOL_SOCKET, SO_RCVTIMEO, array('sec' => self::READ_TIMEOUT, 'usec' => 0));
if ($this->getOption('async')) {
socket_set_nonblock($connection);
}
$this->connection = $connection;
}
|
[
"private",
"function",
"createConnection",
"(",
"$",
"endpoint",
")",
"{",
"// port",
"$",
"port",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'ssl'",
")",
"==",
"true",
"?",
"443",
":",
"80",
";",
"if",
"(",
"!",
"(",
"$",
"connection",
"=",
"socket_create",
"(",
"AF_INET",
",",
"SOCK_STREAM",
",",
"SOL_TCP",
")",
")",
")",
"{",
"$",
"errorcode",
"=",
"socket_last_error",
"(",
")",
";",
"$",
"errormsg",
"=",
"socket_strerror",
"(",
"$",
"errorcode",
")",
";",
"throw",
"new",
"Exception",
"\\",
"EndpointServerException",
"(",
"'Analytics Socket failure! Error: '",
".",
"$",
"errormsg",
")",
";",
"}",
"if",
"(",
"!",
"socket_connect",
"(",
"$",
"connection",
",",
"$",
"endpoint",
"[",
"'host'",
"]",
",",
"$",
"port",
")",
")",
"{",
"$",
"errorcode",
"=",
"socket_last_error",
"(",
")",
";",
"$",
"errormsg",
"=",
"socket_strerror",
"(",
"$",
"errorcode",
")",
";",
"throw",
"new",
"Exception",
"\\",
"EndpointServerException",
"(",
"'Analytics Host not reachable! Error: '",
".",
"$",
"errormsg",
")",
";",
"}",
"socket_set_option",
"(",
"$",
"connection",
",",
"SOL_SOCKET",
",",
"SO_RCVTIMEO",
",",
"array",
"(",
"'sec'",
"=>",
"self",
"::",
"READ_TIMEOUT",
",",
"'usec'",
"=>",
"0",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'async'",
")",
")",
"{",
"socket_set_nonblock",
"(",
"$",
"connection",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"=",
"$",
"connection",
";",
"}"
] |
Create Connection to the Google Server
@param $endpoint
@throws Exception\EndpointServerException
|
[
"Create",
"Connection",
"to",
"the",
"Google",
"Server"
] |
415cabca0c6d83cd0bd6a8ed6fb695b35f892018
|
https://github.com/ins0/google-measurement-php-client/blob/415cabca0c6d83cd0bd6a8ed6fb695b35f892018/src/Racecore/GATracking/Client/Adapter/Socket.php#L21-L45
|
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.