repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
silverorange/swat | Swat/SwatToolLink.php | SwatToolLink.getInsensitiveTag | protected function getInsensitiveTag()
{
$tag = new SwatHtmlTag('span');
$tag->id = $this->id;
$tag->class = $this->getCSSClassString();
if ($this->tooltip !== null) {
$tag->title = $this->tooltip;
}
return $tag;
} | php | protected function getInsensitiveTag()
{
$tag = new SwatHtmlTag('span');
$tag->id = $this->id;
$tag->class = $this->getCSSClassString();
if ($this->tooltip !== null) {
$tag->title = $this->tooltip;
}
return $tag;
} | [
"protected",
"function",
"getInsensitiveTag",
"(",
")",
"{",
"$",
"tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'span'",
")",
";",
"$",
"tag",
"->",
"id",
"=",
"$",
"this",
"->",
"id",
";",
"$",
"tag",
"->",
"class",
"=",
"$",
"this",
"->",
"getCSSClassStr... | Gets the tag used to display this tool link when it is not sensitive
@return SwatHtmlTag the tag used to display this tool link when it is
not sensitive. | [
"Gets",
"the",
"tag",
"used",
"to",
"display",
"this",
"tool",
"link",
"when",
"it",
"is",
"not",
"sensitive"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatToolLink.php#L353-L365 | train |
silverorange/swat | Swat/SwatNullTextCellRenderer.php | SwatNullTextCellRenderer.render | public function render()
{
if (!$this->visible) {
return;
}
$is_null = $this->strict ? $this->text === null : $this->text == null;
if ($is_null) {
$this->text = $this->null_text;
echo '<span class="swat-null-text-cell-renderer">';
parent::render();
echo '</span>';
// Reset the text so that subsequent $is_null checks pass.
$this->text = null;
} else {
parent::render();
}
} | php | public function render()
{
if (!$this->visible) {
return;
}
$is_null = $this->strict ? $this->text === null : $this->text == null;
if ($is_null) {
$this->text = $this->null_text;
echo '<span class="swat-null-text-cell-renderer">';
parent::render();
echo '</span>';
// Reset the text so that subsequent $is_null checks pass.
$this->text = null;
} else {
parent::render();
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"$",
"is_null",
"=",
"$",
"this",
"->",
"strict",
"?",
"$",
"this",
"->",
"text",
"===",
"null",
":",
"$",
"this",
"->",
... | Renders this cell renderer | [
"Renders",
"this",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNullTextCellRenderer.php#L53-L73 | train |
silverorange/swat | Swat/SwatActionItem.php | SwatActionItem.setWidget | public function setWidget(SwatWidget $widget)
{
if ($this->widget !== null) {
throw new SwatException(
'SwatUI: Only one widget can be nested ' .
'within a SwatActionItem'
);
}
$this->widget = $widget;
$widget->parent = $this;
} | php | public function setWidget(SwatWidget $widget)
{
if ($this->widget !== null) {
throw new SwatException(
'SwatUI: Only one widget can be nested ' .
'within a SwatActionItem'
);
}
$this->widget = $widget;
$widget->parent = $this;
} | [
"public",
"function",
"setWidget",
"(",
"SwatWidget",
"$",
"widget",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"widget",
"!==",
"null",
")",
"{",
"throw",
"new",
"SwatException",
"(",
"'SwatUI: Only one widget can be nested '",
".",
"'within a SwatActionItem'",
")",... | Sets the widget to use for this item
Each SwatActionItem can have one associated SwatWidget. This method
sets the widget for this item.
@param SwatWidget $widget the widget associated with this action.
@throws SwatException | [
"Sets",
"the",
"widget",
"to",
"use",
"for",
"this",
"item"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatActionItem.php#L87-L98 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.getPage | public function getPage($id)
{
$found_page = null;
foreach ($this->pages as $page) {
if ($page->id == $id) {
$found_page = $page;
break;
}
}
return $found_page;
} | php | public function getPage($id)
{
$found_page = null;
foreach ($this->pages as $page) {
if ($page->id == $id) {
$found_page = $page;
break;
}
}
return $found_page;
} | [
"public",
"function",
"getPage",
"(",
"$",
"id",
")",
"{",
"$",
"found_page",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"pages",
"as",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"->",
"id",
"==",
"$",
"id",
")",
"{",
"$",
"found_... | Gets a page in this notebook
Retrieves a page from the list of pages in this notebook based on
the unique identifier of the page.
@param string $id the unique id of the page to look for.
@return SwatNoteBookPage the found page or null if not found. | [
"Gets",
"a",
"page",
"in",
"this",
"notebook"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L132-L144 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.init | public function init()
{
parent::init();
foreach ($this->children as $child) {
$child->init();
foreach ($child->getPages() as $page) {
$this->addPage($page);
}
}
foreach ($this->pages as $page) {
$page->init();
}
} | php | public function init()
{
parent::init();
foreach ($this->children as $child) {
$child->init();
foreach ($child->getPages() as $page) {
$this->addPage($page);
}
}
foreach ($this->pages as $page) {
$page->init();
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"child",
"->",
"init",
"(",
")",
";",
"foreach",
"(",
"$",
"child",
"->",
"getPa... | Initializes this notebook | [
"Initializes",
"this",
"notebook"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L152-L166 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.process | public function process()
{
parent::process();
if (!$this->processValue()) {
return;
}
if (
$this->required &&
$this->isSensitive() &&
$this->selected_page == ''
) {
$this->addMessage($this->getValidationMessage('required'));
}
foreach ($this->pages as $page) {
if ($page->id == $this->selected_page) {
$page->process();
}
}
} | php | public function process()
{
parent::process();
if (!$this->processValue()) {
return;
}
if (
$this->required &&
$this->isSensitive() &&
$this->selected_page == ''
) {
$this->addMessage($this->getValidationMessage('required'));
}
foreach ($this->pages as $page) {
if ($page->id == $this->selected_page) {
$page->process();
}
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"processValue",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"required",
"&&",
"$",
"this",
"->"... | Processes this notebook | [
"Processes",
"this",
"notebook"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L174-L195 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.getMessages | public function getMessages()
{
$messages = parent::getMessages();
foreach ($this->pages as $page) {
$messages = array_merge($messages, $page->getMessages());
}
return $messages;
} | php | public function getMessages()
{
$messages = parent::getMessages();
foreach ($this->pages as $page) {
$messages = array_merge($messages, $page->getMessages());
}
return $messages;
} | [
"public",
"function",
"getMessages",
"(",
")",
"{",
"$",
"messages",
"=",
"parent",
"::",
"getMessages",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"pages",
"as",
"$",
"page",
")",
"{",
"$",
"messages",
"=",
"array_merge",
"(",
"$",
"messages",
... | Gets all messaages
Gathers all messages from pages of this notebook and from this notebook
itself.
@return array an array of {@link SwatMessage} objects.
@see SwatMessage | [
"Gets",
"all",
"messaages"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L276-L285 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.processValue | public function processValue()
{
$form = $this->getForm();
if ($form->getHiddenField($this->id . '_submitted') === null) {
return false;
}
$data = &$form->getFormData();
if (isset($data[$this->id])) {
// get selected page id, strip off this id prefix
$this->selected_page = mb_substr(
$data[$this->id],
mb_strlen($this->id) + 1
);
} else {
$this->selected_page = null;
}
return true;
} | php | public function processValue()
{
$form = $this->getForm();
if ($form->getHiddenField($this->id . '_submitted') === null) {
return false;
}
$data = &$form->getFormData();
if (isset($data[$this->id])) {
// get selected page id, strip off this id prefix
$this->selected_page = mb_substr(
$data[$this->id],
mb_strlen($this->id) + 1
);
} else {
$this->selected_page = null;
}
return true;
} | [
"public",
"function",
"processValue",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"$",
"form",
"->",
"getHiddenField",
"(",
"$",
"this",
"->",
"id",
".",
"'_submitted'",
")",
"===",
"null",
")",
"{",
"re... | Processes the value of this radio list from user-submitted form data
This method can be used to process the list value without processing
the selected page widget sub-tree.
@return boolean true if the value was processed from form data | [
"Processes",
"the",
"value",
"of",
"this",
"radio",
"list",
"from",
"user",
"-",
"submitted",
"form",
"data"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L524-L545 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.displayPage | protected function displayPage(SwatNoteBookPage $page, $count = 0)
{
echo '<tr class="swat-radio-note-book-option-row">';
echo '<td>';
$radio = new SwatHtmlTag('input');
$radio->type = 'radio';
$radio->name = $this->id;
$radio->id = $this->id . '_' . $page->id;
$radio->value = $this->id . '_' . $page->id;
if ($page->id == $this->selected_page) {
$radio->checked = 'checked';
}
echo '<span class="swat-radio-wrapper">';
$radio->display();
echo '<span class="swat-radio-shim"></span>';
echo '</span>';
echo '</td>';
echo '<td>';
$label = new SwatHtmlTag('label');
$label->for = $this->id . '_' . $page->id;
$label->setContent($page->title, $page->title_content_type);
$label->display();
echo '</td>';
echo '</tr>';
echo '<tr class="swat-radio-note-book-page-row">';
echo '<td></td>';
$td = new SwatHtmlTag('td');
$td->class = 'swat-radio-note-book-page';
if ($page->id == $this->selected_page) {
$td->class .= ' selected';
}
$td->open();
echo '<div class="swat-radio-note-book-page-container">';
$page->display();
echo '</div>';
$td->close();
echo '</tr>';
} | php | protected function displayPage(SwatNoteBookPage $page, $count = 0)
{
echo '<tr class="swat-radio-note-book-option-row">';
echo '<td>';
$radio = new SwatHtmlTag('input');
$radio->type = 'radio';
$radio->name = $this->id;
$radio->id = $this->id . '_' . $page->id;
$radio->value = $this->id . '_' . $page->id;
if ($page->id == $this->selected_page) {
$radio->checked = 'checked';
}
echo '<span class="swat-radio-wrapper">';
$radio->display();
echo '<span class="swat-radio-shim"></span>';
echo '</span>';
echo '</td>';
echo '<td>';
$label = new SwatHtmlTag('label');
$label->for = $this->id . '_' . $page->id;
$label->setContent($page->title, $page->title_content_type);
$label->display();
echo '</td>';
echo '</tr>';
echo '<tr class="swat-radio-note-book-page-row">';
echo '<td></td>';
$td = new SwatHtmlTag('td');
$td->class = 'swat-radio-note-book-page';
if ($page->id == $this->selected_page) {
$td->class .= ' selected';
}
$td->open();
echo '<div class="swat-radio-note-book-page-container">';
$page->display();
echo '</div>';
$td->close();
echo '</tr>';
} | [
"protected",
"function",
"displayPage",
"(",
"SwatNoteBookPage",
"$",
"page",
",",
"$",
"count",
"=",
"0",
")",
"{",
"echo",
"'<tr class=\"swat-radio-note-book-option-row\">'",
";",
"echo",
"'<td>'",
";",
"$",
"radio",
"=",
"new",
"SwatHtmlTag",
"(",
"'input'",
... | Displays an individual page in this radio notebook
@param SwatNoteBookPage $page the page to display
@param integer $count the ordinal idnex of the page being displayed
starting at 1. | [
"Displays",
"an",
"individual",
"page",
"in",
"this",
"radio",
"notebook"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L557-L605 | train |
silverorange/swat | Swat/SwatRadioNoteBook.php | SwatRadioNoteBook.displaySinglePage | protected function displaySinglePage(SwatNoteBookPage $page)
{
$container = new SwatHtmlTag('div');
$container->id = $this->id;
$container->class = 'swat-radio-note-book';
$container->open();
$div = new SwatHtmlTag('div');
$div->class = 'swat-radio-note-book-page';
$div->open();
$page->display();
$div->close();
$input = new SwatHtmlTag('input');
$input->type = 'hidden';
$input->name = $this->id;
$input->id = $this->id . '_' . $page->id;
$input->value = $this->id . '_' . $page->id;
$input->display();
$container->close();
} | php | protected function displaySinglePage(SwatNoteBookPage $page)
{
$container = new SwatHtmlTag('div');
$container->id = $this->id;
$container->class = 'swat-radio-note-book';
$container->open();
$div = new SwatHtmlTag('div');
$div->class = 'swat-radio-note-book-page';
$div->open();
$page->display();
$div->close();
$input = new SwatHtmlTag('input');
$input->type = 'hidden';
$input->name = $this->id;
$input->id = $this->id . '_' . $page->id;
$input->value = $this->id . '_' . $page->id;
$input->display();
$container->close();
} | [
"protected",
"function",
"displaySinglePage",
"(",
"SwatNoteBookPage",
"$",
"page",
")",
"{",
"$",
"container",
"=",
"new",
"SwatHtmlTag",
"(",
"'div'",
")",
";",
"$",
"container",
"->",
"id",
"=",
"$",
"this",
"->",
"id",
";",
"$",
"container",
"->",
"c... | Displays the only page of this notebook if this notebook contains only
one page
@param SwatNoteBookPage $page the page to display. | [
"Displays",
"the",
"only",
"page",
"of",
"this",
"notebook",
"if",
"this",
"notebook",
"contains",
"only",
"one",
"page"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRadioNoteBook.php#L616-L637 | train |
honey-comb/core | src/Models/HCUser.php | HCUser.updateLastLogin | public function updateLastLogin(string $time = null): void
{
$this->timestamps = false;
$this->last_login = is_null($time) ? $this->freshTimestamp() : $time;
$this->save();
$this->updateLastActivity();
} | php | public function updateLastLogin(string $time = null): void
{
$this->timestamps = false;
$this->last_login = is_null($time) ? $this->freshTimestamp() : $time;
$this->save();
$this->updateLastActivity();
} | [
"public",
"function",
"updateLastLogin",
"(",
"string",
"$",
"time",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"timestamps",
"=",
"false",
";",
"$",
"this",
"->",
"last_login",
"=",
"is_null",
"(",
"$",
"time",
")",
"?",
"$",
"this",
"->... | Update last login timestamp
@param null|string $time
@throws \Exception | [
"Update",
"last",
"login",
"timestamp"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Models/HCUser.php#L154-L161 | train |
honey-comb/core | src/Models/HCUser.php | HCUser.updateLastActivity | public function updateLastActivity(string $time = null): void
{
$this->timestamps = false;
$this->last_activity = is_null($time) ? $this->freshTimestamp() : $time;
$this->save();
} | php | public function updateLastActivity(string $time = null): void
{
$this->timestamps = false;
$this->last_activity = is_null($time) ? $this->freshTimestamp() : $time;
$this->save();
} | [
"public",
"function",
"updateLastActivity",
"(",
"string",
"$",
"time",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"timestamps",
"=",
"false",
";",
"$",
"this",
"->",
"last_activity",
"=",
"is_null",
"(",
"$",
"time",
")",
"?",
"$",
"this",... | Update last activity timestamp
@param null|string $time
@throws \Exception | [
"Update",
"last",
"activity",
"timestamp"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Models/HCUser.php#L169-L174 | train |
silverorange/swat | Swat/SwatMoneyEntry.php | SwatMoneyEntry.display | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
if ($this->display_currency) {
$locale = SwatI18NLocale::get($this->locale);
echo SwatString::minimizeEntities(
' ' . $locale->getInternationalCurrencySymbol()
);
}
} | php | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
if ($this->display_currency) {
$locale = SwatI18NLocale::get($this->locale);
echo SwatString::minimizeEntities(
' ' . $locale->getInternationalCurrencySymbol()
);
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"display",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"display_currency",
")",
"{",
"$",
"locale",
"=",
... | Displays this money entry widget
The widget is displayed as an input box and an optional currency symbol. | [
"Displays",
"this",
"money",
"entry",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMoneyEntry.php#L53-L67 | train |
silverorange/swat | Swat/SwatMoneyEntry.php | SwatMoneyEntry.process | public function process()
{
parent::process();
if ($this->value === null) {
return;
}
$locale = SwatI18NLocale::get($this->locale);
$format = $locale->getNationalCurrencyFormat();
$max_decimal_places =
$this->decimal_places === null
? $format->fractional_digits
: $this->decimal_places;
$value = $this->getRawValue();
// Get the number of entered fractional digits places from the raw
// value. This checks the raw value instead of the processed value
// because the processed value could have been parsed into a float by
// this point.
$decimal_position = mb_strpos(
(string) $value,
$format->decimal_separator
);
if ($decimal_position === false) {
$decimal_places = 0;
} else {
$fractional_digits = mb_substr(
rtrim((string) $value, '0'),
$decimal_position + mb_strlen($format->decimal_separator)
);
$decimal_places = preg_match_all('/[0-9]/', $fractional_digits);
}
// check if length of the given fractional part is more than the
// allowed length
if ($decimal_places > $max_decimal_places) {
// validation failed so reset value to the raw value
$this->value = $value;
if ($this->decimal_places === null) {
$message = $this->getValidationMessage(
'currency-decimal-places'
);
$max_decimal_places_formatted = str_replace(
'%',
'%%',
$locale->formatNumber($max_decimal_places)
);
// C99 specification includes spacing character, remove it
$currency_formatted = str_replace(
'%',
'%%',
$locale->getInternationalCurrencySymbol()
);
$message->primary_content = sprintf(
$message->primary_content,
$currency_formatted,
$max_decimal_places_formatted
);
} else {
if ($max_decimal_places === 0) {
$message = $this->getValidationMessage('no-decimal-places');
} else {
$max_decimal_places_formatted = str_replace(
'%',
'%%',
$locale->formatNumber($max_decimal_places)
);
// note: not using getValidationMessage() because of
// ngettext. We may want to add this ability to that method
$message = new SwatMessage(
sprintf(
Swat::ngettext(
'The %%s field has too many decimal places. There ' .
'can be at most one decimal place.',
'The %%s field has too many decimal places. There ' .
'can be at most %s decimal places.',
$max_decimal_places
),
$max_decimal_places_formatted
),
'error'
);
}
}
$this->addMessage($message);
}
} | php | public function process()
{
parent::process();
if ($this->value === null) {
return;
}
$locale = SwatI18NLocale::get($this->locale);
$format = $locale->getNationalCurrencyFormat();
$max_decimal_places =
$this->decimal_places === null
? $format->fractional_digits
: $this->decimal_places;
$value = $this->getRawValue();
// Get the number of entered fractional digits places from the raw
// value. This checks the raw value instead of the processed value
// because the processed value could have been parsed into a float by
// this point.
$decimal_position = mb_strpos(
(string) $value,
$format->decimal_separator
);
if ($decimal_position === false) {
$decimal_places = 0;
} else {
$fractional_digits = mb_substr(
rtrim((string) $value, '0'),
$decimal_position + mb_strlen($format->decimal_separator)
);
$decimal_places = preg_match_all('/[0-9]/', $fractional_digits);
}
// check if length of the given fractional part is more than the
// allowed length
if ($decimal_places > $max_decimal_places) {
// validation failed so reset value to the raw value
$this->value = $value;
if ($this->decimal_places === null) {
$message = $this->getValidationMessage(
'currency-decimal-places'
);
$max_decimal_places_formatted = str_replace(
'%',
'%%',
$locale->formatNumber($max_decimal_places)
);
// C99 specification includes spacing character, remove it
$currency_formatted = str_replace(
'%',
'%%',
$locale->getInternationalCurrencySymbol()
);
$message->primary_content = sprintf(
$message->primary_content,
$currency_formatted,
$max_decimal_places_formatted
);
} else {
if ($max_decimal_places === 0) {
$message = $this->getValidationMessage('no-decimal-places');
} else {
$max_decimal_places_formatted = str_replace(
'%',
'%%',
$locale->formatNumber($max_decimal_places)
);
// note: not using getValidationMessage() because of
// ngettext. We may want to add this ability to that method
$message = new SwatMessage(
sprintf(
Swat::ngettext(
'The %%s field has too many decimal places. There ' .
'can be at most one decimal place.',
'The %%s field has too many decimal places. There ' .
'can be at most %s decimal places.',
$max_decimal_places
),
$max_decimal_places_formatted
),
'error'
);
}
}
$this->addMessage($message);
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"locale",
"=",
"SwatI18NLocale",
"::",
"get",
"(",
"$",
"this",
"->",... | Processes this money entry widget
If the value of this widget is not a monetary value or the number of
fractional decimal places is not within the allowed range, an error
message is attached to this money entry widget. | [
"Processes",
"this",
"money",
"entry",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMoneyEntry.php#L79-L174 | train |
silverorange/swat | Swat/SwatMoneyEntry.php | SwatMoneyEntry.getDisplayValue | protected function getDisplayValue($value)
{
// if the value is valid, format accordingly
if (!$this->hasMessage() && is_numeric($value)) {
$value = SwatI18NLocale::get($this->locale)->formatCurrency(
$value,
false,
array('fractional_digits' => $this->decimal_places)
);
}
return $value;
} | php | protected function getDisplayValue($value)
{
// if the value is valid, format accordingly
if (!$this->hasMessage() && is_numeric($value)) {
$value = SwatI18NLocale::get($this->locale)->formatCurrency(
$value,
false,
array('fractional_digits' => $this->decimal_places)
);
}
return $value;
} | [
"protected",
"function",
"getDisplayValue",
"(",
"$",
"value",
")",
"{",
"// if the value is valid, format accordingly",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMessage",
"(",
")",
"&&",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"Swat... | Formats a monetary value to display
@param string $value the value to format for display.
@return string the formatted value. | [
"Formats",
"a",
"monetary",
"value",
"to",
"display"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMoneyEntry.php#L186-L198 | train |
silverorange/swat | Swat/SwatMoneyEntry.php | SwatMoneyEntry.getValidationMessage | protected function getValidationMessage($id)
{
switch ($id) {
case 'float':
$locale = SwatI18NLocale::get($this->locale);
$currency = $locale->getInternationalCurrencySymbol();
$example = $locale->formatCurrency(1036.95, false, array(
'fractional_digits' => $this->decimal_places
));
$text = sprintf(
$this->show_field_title_in_messages
? Swat::_(
'The %%s field must be a monetary value ' .
'formatted for %s (i.e. %s).'
)
: Swat::_(
'This field must be a monetary value ' .
'formatted for %s (i.e. %s).'
),
str_replace('%', '%%', $currency),
str_replace('%', '%%', $example)
);
$message = new SwatMessage($text, 'error');
break;
case 'currency-decimal-places':
$text = $this->show_field_title_in_messages
? Swat::_(
'The %%s field has too many decimal places. The ' .
'currency %s only allows %s.'
)
: Swat::_(
'This field has too many decimal places. The ' .
'currency %s only allows %s.'
);
$message = new SwatMessage($text, 'error');
break;
case 'no-decimal-places':
$text = $this->show_field_title_in_messages
? Swat::_('The %s field must not have any decimal places.')
: Swat::_('This field must not have any decimal places.');
$message = new SwatMessage($text, 'error');
break;
default:
$message = parent::getValidationMessage($id);
break;
}
return $message;
} | php | protected function getValidationMessage($id)
{
switch ($id) {
case 'float':
$locale = SwatI18NLocale::get($this->locale);
$currency = $locale->getInternationalCurrencySymbol();
$example = $locale->formatCurrency(1036.95, false, array(
'fractional_digits' => $this->decimal_places
));
$text = sprintf(
$this->show_field_title_in_messages
? Swat::_(
'The %%s field must be a monetary value ' .
'formatted for %s (i.e. %s).'
)
: Swat::_(
'This field must be a monetary value ' .
'formatted for %s (i.e. %s).'
),
str_replace('%', '%%', $currency),
str_replace('%', '%%', $example)
);
$message = new SwatMessage($text, 'error');
break;
case 'currency-decimal-places':
$text = $this->show_field_title_in_messages
? Swat::_(
'The %%s field has too many decimal places. The ' .
'currency %s only allows %s.'
)
: Swat::_(
'This field has too many decimal places. The ' .
'currency %s only allows %s.'
);
$message = new SwatMessage($text, 'error');
break;
case 'no-decimal-places':
$text = $this->show_field_title_in_messages
? Swat::_('The %s field must not have any decimal places.')
: Swat::_('This field must not have any decimal places.');
$message = new SwatMessage($text, 'error');
break;
default:
$message = parent::getValidationMessage($id);
break;
}
return $message;
} | [
"protected",
"function",
"getValidationMessage",
"(",
"$",
"id",
")",
"{",
"switch",
"(",
"$",
"id",
")",
"{",
"case",
"'float'",
":",
"$",
"locale",
"=",
"SwatI18NLocale",
"::",
"get",
"(",
"$",
"this",
"->",
"locale",
")",
";",
"$",
"currency",
"=",
... | Gets a validation message for this money entry widget
@see SwatEntry::getValidationMessage()
@param string $id the string identifier of the validation message.
@return SwatMessage the validation message. | [
"Gets",
"a",
"validation",
"message",
"for",
"this",
"money",
"entry",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatMoneyEntry.php#L227-L279 | train |
spiral/dumper | src/System.php | System.isColorsSupported | public static function isColorsSupported($stream = STDOUT): bool
{
if ('Hyper' === getenv('TERM_PROGRAM')) {
return true;
}
try {
if (\DIRECTORY_SEPARATOR === '\\') {
return (
function_exists('sapi_windows_vt100_support')
&& @sapi_windows_vt100_support($stream)
) || getenv('ANSICON') !== false
|| getenv('ConEmuANSI') == 'ON'
|| getenv('TERM') == 'xterm';
}
if (\function_exists('stream_isatty')) {
return @stream_isatty($stream);
}
if (\function_exists('posix_isatty')) {
return @posix_isatty($stream);
}
$stat = @fstat($stream);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
} catch (\Throwable $e) {
return false;
}
} | php | public static function isColorsSupported($stream = STDOUT): bool
{
if ('Hyper' === getenv('TERM_PROGRAM')) {
return true;
}
try {
if (\DIRECTORY_SEPARATOR === '\\') {
return (
function_exists('sapi_windows_vt100_support')
&& @sapi_windows_vt100_support($stream)
) || getenv('ANSICON') !== false
|| getenv('ConEmuANSI') == 'ON'
|| getenv('TERM') == 'xterm';
}
if (\function_exists('stream_isatty')) {
return @stream_isatty($stream);
}
if (\function_exists('posix_isatty')) {
return @posix_isatty($stream);
}
$stat = @fstat($stream);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
} catch (\Throwable $e) {
return false;
}
} | [
"public",
"static",
"function",
"isColorsSupported",
"(",
"$",
"stream",
"=",
"STDOUT",
")",
":",
"bool",
"{",
"if",
"(",
"'Hyper'",
"===",
"getenv",
"(",
"'TERM_PROGRAM'",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"if",
"(",
"\\",
"DIRECT... | Returns true if the STDOUT supports colorization.
@codeCoverageIgnore
@link https://github.com/symfony/Console/blob/master/Output/StreamOutput.php#L94
@param mixed $stream
@return bool | [
"Returns",
"true",
"if",
"the",
"STDOUT",
"supports",
"colorization",
"."
] | 87bc579b0ecd69754197804b1fc5e0d5b3293bd3 | https://github.com/spiral/dumper/blob/87bc579b0ecd69754197804b1fc5e0d5b3293bd3/src/System.php#L45-L76 | train |
brainworxx/kreXX | src/Service/Reflection/ReflectionClass.php | ReflectionClass.retrieveValue | public function retrieveValue(\ReflectionProperty $refProperty)
{
$propName = $refProperty->getName();
if (array_key_exists("\0*\0" . $propName, $this->objectArray)) {
// Protected or a private
return $this->objectArray["\0*\0" . $propName];
}
if (array_key_exists($propName, $this->objectArray)) {
// Must be a public. Those are rare.
return $this->objectArray[$propName];
}
if ($refProperty->isStatic() === true) {
// Static values are not inside the value array.
$refProperty->setAccessible(true);
return $refProperty->getValue($this->data);
}
// If we are facing multiple declarations, the declaring class name
// is set in front of the key.
$propName = "\0" . $refProperty->getDeclaringClass()->getName() . "\0" . $propName;
if (array_key_exists($propName, $this->objectArray)) {
// Found it!
return $this->objectArray[$propName];
}
// We are still here, which means that we are not able to get the value
// out of it. The only remaining possibility is, that this value was
// unset during runtime.
$refProperty->isUnset = true;
return null;
} | php | public function retrieveValue(\ReflectionProperty $refProperty)
{
$propName = $refProperty->getName();
if (array_key_exists("\0*\0" . $propName, $this->objectArray)) {
// Protected or a private
return $this->objectArray["\0*\0" . $propName];
}
if (array_key_exists($propName, $this->objectArray)) {
// Must be a public. Those are rare.
return $this->objectArray[$propName];
}
if ($refProperty->isStatic() === true) {
// Static values are not inside the value array.
$refProperty->setAccessible(true);
return $refProperty->getValue($this->data);
}
// If we are facing multiple declarations, the declaring class name
// is set in front of the key.
$propName = "\0" . $refProperty->getDeclaringClass()->getName() . "\0" . $propName;
if (array_key_exists($propName, $this->objectArray)) {
// Found it!
return $this->objectArray[$propName];
}
// We are still here, which means that we are not able to get the value
// out of it. The only remaining possibility is, that this value was
// unset during runtime.
$refProperty->isUnset = true;
return null;
} | [
"public",
"function",
"retrieveValue",
"(",
"\\",
"ReflectionProperty",
"$",
"refProperty",
")",
"{",
"$",
"propName",
"=",
"$",
"refProperty",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"\"\\0*\\0\"",
".",
"$",
"propName",
",",
"$",... | Retrieve the value from the object, if possible.
@param \ReflectionProperty $refProperty
The reflection of the property we are analysing.
@return mixed;
The retrieved value. | [
"Retrieve",
"the",
"value",
"from",
"the",
"object",
"if",
"possible",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Reflection/ReflectionClass.php#L84-L117 | train |
silverorange/swat | Swat/SwatError.php | SwatError.process | public function process()
{
if (ini_get('display_errors')) {
$this->display();
}
if (ini_get('log_errors')) {
$this->log();
}
if ($this->severity & self::$fatal_severity) {
exit(1);
}
} | php | public function process()
{
if (ini_get('display_errors')) {
$this->display();
}
if (ini_get('log_errors')) {
$this->log();
}
if ($this->severity & self::$fatal_severity) {
exit(1);
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"ini_get",
"(",
"'display_errors'",
")",
")",
"{",
"$",
"this",
"->",
"display",
"(",
")",
";",
"}",
"if",
"(",
"ini_get",
"(",
"'log_errors'",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",... | Processes this error
Processing involves displaying errors, logging errors and sending
error message emails.
If a fatal error has occured, this calls exit to ensure no further
processing is done. | [
"Processes",
"this",
"error"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L202-L215 | train |
silverorange/swat | Swat/SwatError.php | SwatError.log | public function log()
{
if (count(self::$loggers) === 0) {
error_log($this->getSummary(), 0);
} else {
foreach (self::$loggers as $logger) {
$logger->log($this);
}
}
} | php | public function log()
{
if (count(self::$loggers) === 0) {
error_log($this->getSummary(), 0);
} else {
foreach (self::$loggers as $logger) {
$logger->log($this);
}
}
} | [
"public",
"function",
"log",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"loggers",
")",
"===",
"0",
")",
"{",
"error_log",
"(",
"$",
"this",
"->",
"getSummary",
"(",
")",
",",
"0",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"se... | Logs this error
The error is logged to the webserver error log. | [
"Logs",
"this",
"error"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L277-L286 | train |
silverorange/swat | Swat/SwatError.php | SwatError.getSummary | public function getSummary()
{
ob_start();
printf(
"%s error in file '%s' line %s",
$this->getSeverityString(),
$this->file,
$this->line
);
return ob_get_clean();
} | php | public function getSummary()
{
ob_start();
printf(
"%s error in file '%s' line %s",
$this->getSeverityString(),
$this->file,
$this->line
);
return ob_get_clean();
} | [
"public",
"function",
"getSummary",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"printf",
"(",
"\"%s error in file '%s' line %s\"",
",",
"$",
"this",
"->",
"getSeverityString",
"(",
")",
",",
"$",
"this",
"->",
"file",
",",
"$",
"this",
"->",
"line",
")",
... | Gets a one-line short text summary of this error
This summary is useful for log entries and error email titles.
@return string a one-line summary of this error. | [
"Gets",
"a",
"one",
"-",
"line",
"short",
"text",
"summary",
"of",
"this",
"error"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L315-L327 | train |
silverorange/swat | Swat/SwatError.php | SwatError.toString | public function toString()
{
ob_start();
printf(
"%s:\n\nMessage:\n\t%s\n\n" . "In file '%s' on line %s.\n\n",
$this->getSeverityString(),
$this->message,
$this->file,
$this->line
);
echo "Stack Trace:\n";
$count = count($this->backtrace);
foreach ($this->backtrace as $entry) {
$class = array_key_exists('class', $entry) ? $entry['class'] : null;
$function = array_key_exists('function', $entry)
? $entry['function']
: null;
if (array_key_exists('args', $entry)) {
$arguments = $this->getArguments(
$entry['args'],
$function,
$class
);
} else {
$arguments = '';
}
printf(
"%s. In file '%s' on line %s.\n%sMethod: %s%s%s(%s)\n",
str_pad(--$count, 6, ' ', STR_PAD_LEFT),
array_key_exists('file', $entry) ? $entry['file'] : 'unknown',
array_key_exists('line', $entry) ? $entry['line'] : 'unknown',
str_repeat(' ', 8),
$class === null ? '' : $class,
array_key_exists('type', $entry) ? $entry['type'] : '',
$function === null ? '' : $function,
$arguments
);
}
echo "\n";
return ob_get_clean();
} | php | public function toString()
{
ob_start();
printf(
"%s:\n\nMessage:\n\t%s\n\n" . "In file '%s' on line %s.\n\n",
$this->getSeverityString(),
$this->message,
$this->file,
$this->line
);
echo "Stack Trace:\n";
$count = count($this->backtrace);
foreach ($this->backtrace as $entry) {
$class = array_key_exists('class', $entry) ? $entry['class'] : null;
$function = array_key_exists('function', $entry)
? $entry['function']
: null;
if (array_key_exists('args', $entry)) {
$arguments = $this->getArguments(
$entry['args'],
$function,
$class
);
} else {
$arguments = '';
}
printf(
"%s. In file '%s' on line %s.\n%sMethod: %s%s%s(%s)\n",
str_pad(--$count, 6, ' ', STR_PAD_LEFT),
array_key_exists('file', $entry) ? $entry['file'] : 'unknown',
array_key_exists('line', $entry) ? $entry['line'] : 'unknown',
str_repeat(' ', 8),
$class === null ? '' : $class,
array_key_exists('type', $entry) ? $entry['type'] : '',
$function === null ? '' : $function,
$arguments
);
}
echo "\n";
return ob_get_clean();
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"printf",
"(",
"\"%s:\\n\\nMessage:\\n\\t%s\\n\\n\"",
".",
"\"In file '%s' on line %s.\\n\\n\"",
",",
"$",
"this",
"->",
"getSeverityString",
"(",
")",
",",
"$",
"this",
"->",
"message",
... | Gets this error as a nicely formatted text block
This is useful for text-based logs and emails.
@return string this error formatted as text. | [
"Gets",
"this",
"error",
"as",
"a",
"nicely",
"formatted",
"text",
"block"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L339-L387 | train |
silverorange/swat | Swat/SwatError.php | SwatError.toXHTML | public function toXHTML()
{
ob_start();
$this->displayStyleSheet();
echo '<div class="swat-exception">';
printf(
'<h3>%s</h3>' .
'<div class="swat-exception-body">' .
'Message:<div class="swat-exception-message">%s</div>' .
'Occurred in file <strong>%s</strong> ' .
'on line <strong>%s</strong>.<br /><br />',
$this->getSeverityString(),
nl2br(htmlspecialchars($this->message)),
$this->file,
$this->line
);
echo 'Stack Trace:<br /><dl>';
$count = count($this->backtrace);
foreach ($this->backtrace as $entry) {
$class = array_key_exists('class', $entry) ? $entry['class'] : null;
$function = array_key_exists('function', $entry)
? $entry['function']
: null;
if (array_key_exists('args', $entry)) {
$arguments = htmlspecialchars(
$this->getArguments($entry['args'], $function, $class),
null,
'UTF-8'
);
} else {
$arguments = '';
}
printf(
'<dt>%s.</dt><dd>In file <strong>%s</strong> ' .
'line <strong>%s</strong>.<br />Method: ' .
'<strong>%s%s%s(</strong>%s<strong>)</strong></dd>',
--$count,
array_key_exists('file', $entry) ? $entry['file'] : 'unknown',
array_key_exists('line', $entry) ? $entry['line'] : 'unknown',
$class === null ? '' : $class,
array_key_exists('type', $entry) ? $entry['type'] : '',
$function === null ? '' : $function,
$arguments
);
}
echo '</dl></div></div>';
return ob_get_clean();
} | php | public function toXHTML()
{
ob_start();
$this->displayStyleSheet();
echo '<div class="swat-exception">';
printf(
'<h3>%s</h3>' .
'<div class="swat-exception-body">' .
'Message:<div class="swat-exception-message">%s</div>' .
'Occurred in file <strong>%s</strong> ' .
'on line <strong>%s</strong>.<br /><br />',
$this->getSeverityString(),
nl2br(htmlspecialchars($this->message)),
$this->file,
$this->line
);
echo 'Stack Trace:<br /><dl>';
$count = count($this->backtrace);
foreach ($this->backtrace as $entry) {
$class = array_key_exists('class', $entry) ? $entry['class'] : null;
$function = array_key_exists('function', $entry)
? $entry['function']
: null;
if (array_key_exists('args', $entry)) {
$arguments = htmlspecialchars(
$this->getArguments($entry['args'], $function, $class),
null,
'UTF-8'
);
} else {
$arguments = '';
}
printf(
'<dt>%s.</dt><dd>In file <strong>%s</strong> ' .
'line <strong>%s</strong>.<br />Method: ' .
'<strong>%s%s%s(</strong>%s<strong>)</strong></dd>',
--$count,
array_key_exists('file', $entry) ? $entry['file'] : 'unknown',
array_key_exists('line', $entry) ? $entry['line'] : 'unknown',
$class === null ? '' : $class,
array_key_exists('type', $entry) ? $entry['type'] : '',
$function === null ? '' : $function,
$arguments
);
}
echo '</dl></div></div>';
return ob_get_clean();
} | [
"public",
"function",
"toXHTML",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"displayStyleSheet",
"(",
")",
";",
"echo",
"'<div class=\"swat-exception\">'",
";",
"printf",
"(",
"'<h3>%s</h3>'",
".",
"'<div class=\"swat-exception-body\">'",
".",
"'... | Gets this error as a nicely formatted XHTML fragment
This is nice for debugging errors on a staging server.
@return string this error formatted as XHTML. | [
"Gets",
"this",
"error",
"as",
"a",
"nicely",
"formatted",
"XHTML",
"fragment"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L399-L456 | train |
silverorange/swat | Swat/SwatError.php | SwatError.handle | public static function handle($errno, $errstr, $errfile, $errline)
{
// only handle error if error reporting is not suppressed
if (error_reporting() != 0) {
$error = new SwatError($errno, $errstr, $errfile, $errline);
$error->process();
}
} | php | public static function handle($errno, $errstr, $errfile, $errline)
{
// only handle error if error reporting is not suppressed
if (error_reporting() != 0) {
$error = new SwatError($errno, $errstr, $errfile, $errline);
$error->process();
}
} | [
"public",
"static",
"function",
"handle",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"// only handle error if error reporting is not suppressed",
"if",
"(",
"error_reporting",
"(",
")",
"!=",
"0",
")",
"{",
"$",
... | Handles an error
When an error occurs, a SwatError object is created and processed.
@param integer $errno the severity code of the handled error.
@param string $errstr the message of the handled error.
@param string $errfile the file ther handled error occurred in.
@param integer $errline the line the handled error occurred at. | [
"Handles",
"an",
"error"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L471-L478 | train |
silverorange/swat | Swat/SwatError.php | SwatError.getArguments | protected function getArguments($args, $function = null, $class = null)
{
$params = array();
$method = null;
// try to get function or method parameter list using reflection
if ($class !== null && $function !== null && class_exists($class)) {
$class_reflector = new ReflectionClass($class);
if ($class_reflector->hasMethod($function)) {
$method = $class_reflector->getMethod($function);
$params = $method->getParameters();
}
} elseif ($function !== null && function_exists($function)) {
$method = new ReflectionFunction($function);
$params = $method->getParameters();
}
// display each parameter
$formatted_values = array();
for ($i = 0; $i < count($args); $i++) {
$value = $args[$i];
if ($method !== null && array_key_exists($i, $params)) {
$name = $params[$i]->getName();
$sensitive = $this->isSensitiveParameter($method, $name);
} else {
$name = null;
$sensitive = false;
}
if ($name !== null && $sensitive) {
$formatted_values[] = $this->formatSensitiveParam(
$name,
$value
);
} else {
$formatted_values[] = $this->formatValue($value);
}
}
return implode(', ', $formatted_values);
} | php | protected function getArguments($args, $function = null, $class = null)
{
$params = array();
$method = null;
// try to get function or method parameter list using reflection
if ($class !== null && $function !== null && class_exists($class)) {
$class_reflector = new ReflectionClass($class);
if ($class_reflector->hasMethod($function)) {
$method = $class_reflector->getMethod($function);
$params = $method->getParameters();
}
} elseif ($function !== null && function_exists($function)) {
$method = new ReflectionFunction($function);
$params = $method->getParameters();
}
// display each parameter
$formatted_values = array();
for ($i = 0; $i < count($args); $i++) {
$value = $args[$i];
if ($method !== null && array_key_exists($i, $params)) {
$name = $params[$i]->getName();
$sensitive = $this->isSensitiveParameter($method, $name);
} else {
$name = null;
$sensitive = false;
}
if ($name !== null && $sensitive) {
$formatted_values[] = $this->formatSensitiveParam(
$name,
$value
);
} else {
$formatted_values[] = $this->formatValue($value);
}
}
return implode(', ', $formatted_values);
} | [
"protected",
"function",
"getArguments",
"(",
"$",
"args",
",",
"$",
"function",
"=",
"null",
",",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"method",
"=",
"null",
";",
"// try to get function or method parameter... | Formats a method call's arguments
This method is also responsible for filtering sensitive parameters
out of the final stack trace.
@param array $args an array of arguments.
@param string $method optional. The current method or function.
@param string $class optional. The current class name.
@return string the arguments formatted into a comma delimited string. | [
"Formats",
"a",
"method",
"call",
"s",
"arguments"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L495-L536 | train |
silverorange/swat | Swat/SwatError.php | SwatError.getSeverityString | protected function getSeverityString()
{
static $error_types = array(
E_WARNING => 'Warning',
E_NOTICE => 'Notice',
E_USER_ERROR => 'User Fatal Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Forward Compatibility Notice'
);
$out = null;
if (isset($error_types[$this->severity])) {
$out = $error_types[$this->severity];
}
return $out;
} | php | protected function getSeverityString()
{
static $error_types = array(
E_WARNING => 'Warning',
E_NOTICE => 'Notice',
E_USER_ERROR => 'User Fatal Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Forward Compatibility Notice'
);
$out = null;
if (isset($error_types[$this->severity])) {
$out = $error_types[$this->severity];
}
return $out;
} | [
"protected",
"function",
"getSeverityString",
"(",
")",
"{",
"static",
"$",
"error_types",
"=",
"array",
"(",
"E_WARNING",
"=>",
"'Warning'",
",",
"E_NOTICE",
"=>",
"'Notice'",
",",
"E_USER_ERROR",
"=>",
"'User Fatal Error'",
",",
"E_USER_WARNING",
"=>",
"'User Wa... | Gets a string representation of this error's severity
@return string a string representation of this error's severity. | [
"Gets",
"a",
"string",
"representation",
"of",
"this",
"error",
"s",
"severity"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L663-L680 | train |
silverorange/swat | Swat/SwatError.php | SwatError.isSensitiveParameter | protected function isSensitiveParameter(
ReflectionFunctionAbstract $method,
$name
) {
$sensitive = false;
$exp =
'/^.*@sensitive\s+\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*).*$/';
$documentation = $method->getDocComment();
$documentation = str_replace("\r", "\n", $documentation);
$documentation_exp = explode("\n", $documentation);
foreach ($documentation_exp as $documentation_line) {
$matches = array();
if (
preg_match($exp, $documentation_line, $matches) === 1 &&
$matches[1] == $name
) {
$sensitive = true;
break;
}
}
return $sensitive;
} | php | protected function isSensitiveParameter(
ReflectionFunctionAbstract $method,
$name
) {
$sensitive = false;
$exp =
'/^.*@sensitive\s+\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*).*$/';
$documentation = $method->getDocComment();
$documentation = str_replace("\r", "\n", $documentation);
$documentation_exp = explode("\n", $documentation);
foreach ($documentation_exp as $documentation_line) {
$matches = array();
if (
preg_match($exp, $documentation_line, $matches) === 1 &&
$matches[1] == $name
) {
$sensitive = true;
break;
}
}
return $sensitive;
} | [
"protected",
"function",
"isSensitiveParameter",
"(",
"ReflectionFunctionAbstract",
"$",
"method",
",",
"$",
"name",
")",
"{",
"$",
"sensitive",
"=",
"false",
";",
"$",
"exp",
"=",
"'/^.*@sensitive\\s+\\$([a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*).*$/'",
";",
"$",
"d... | Detects whether or not a parameter is sensitive from the method-level
documentation of the parameter's method
Parameters with the following docblock tag are considered sensitive:
<code>
<?php
/**
* @sensitive $parameter_name
*\/
?>
</code>
@param ReflectionFunctionAbstract $method the method the parameter to
which the parameter belongs.
@param string $name the name of the parameter.
@return boolean true if the parameter is sensitive and false if the
method is not sensitive. | [
"Detects",
"whether",
"or",
"not",
"a",
"parameter",
"is",
"sensitive",
"from",
"the",
"method",
"-",
"level",
"documentation",
"of",
"the",
"parameter",
"s",
"method"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatError.php#L705-L729 | train |
brainworxx/kreXX | src/Analyse/Callback/AbstractCallback.php | AbstractCallback.dispatchEventWithModel | protected function dispatchEventWithModel($name, Model $model)
{
$this->pool->eventService->dispatch(
static::$eventPrefix . '::' . $name,
$this,
$model
);
return $model;
} | php | protected function dispatchEventWithModel($name, Model $model)
{
$this->pool->eventService->dispatch(
static::$eventPrefix . '::' . $name,
$this,
$model
);
return $model;
} | [
"protected",
"function",
"dispatchEventWithModel",
"(",
"$",
"name",
",",
"Model",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"pool",
"->",
"eventService",
"->",
"dispatch",
"(",
"static",
"::",
"$",
"eventPrefix",
".",
"'::'",
".",
"$",
"name",
",",
"$"... | Dispatches an event where the modes is available.
@param string $name
The name of the event.
@param Model $model
The model so far.
@return Model
Return the model for chaining. | [
"Dispatches",
"an",
"event",
"where",
"the",
"modes",
"is",
"available",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/AbstractCallback.php#L147-L156 | train |
brainworxx/kreXX | src/Analyse/Callback/AbstractCallback.php | AbstractCallback.isPropertyNameNormal | protected function isPropertyNameNormal($propName)
{
static $cache = array();
if (isset($cache[$propName])) {
return $cache[$propName];
}
// The first regex detects all allowed characters.
// For some reason, they also allow BOM characters.
return $cache[$propName] = (bool) preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $propName) &&
!(bool) preg_match("/[\xEF\xBB\xBF]$/", $propName);
} | php | protected function isPropertyNameNormal($propName)
{
static $cache = array();
if (isset($cache[$propName])) {
return $cache[$propName];
}
// The first regex detects all allowed characters.
// For some reason, they also allow BOM characters.
return $cache[$propName] = (bool) preg_match("/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/", $propName) &&
!(bool) preg_match("/[\xEF\xBB\xBF]$/", $propName);
} | [
"protected",
"function",
"isPropertyNameNormal",
"(",
"$",
"propName",
")",
"{",
"static",
"$",
"cache",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"$",
"propName",
"]",
")",
")",
"{",
"return",
"$",
"cache",
"[",
"$",
... | Check for special chars in properties.
AFAIK this is only possible for dynamically declared properties
or some magical stuff from __get()
@see https://stackoverflow.com/questions/29019484/validate-a-php-variable
@author AbraCadaver
@param $propName
The property name we want to check.
@return bool
Whether we have a special char in there, or not. | [
"Check",
"for",
"special",
"chars",
"in",
"properties",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/AbstractCallback.php#L172-L184 | train |
brainworxx/kreXX | src/Analyse/Comment/AbstractComment.php | AbstractComment.prettifyComment | protected function prettifyComment($comment)
{
if (empty($comment) === true) {
return '';
}
// We split our comment into single lines and remove the unwanted
// comment chars with the array_map callback.
// We skip lines with /** and */
$result = array();
foreach (array_slice(explode("\n", $comment), 1, -1) as $commentLine) {
// Remove comment-chars and trim the whitespace.
$result[] = trim($commentLine, "* \t\n\r\0\x0B");
}
// Sadly, we must not escape this here, or glue it with <br /> for a
// direct display. The thing is, we may resolve several @inheritdoc
// marks. The escaping and nlbr() will be done when everything is
// stitched together.
return implode(PHP_EOL, $result);
} | php | protected function prettifyComment($comment)
{
if (empty($comment) === true) {
return '';
}
// We split our comment into single lines and remove the unwanted
// comment chars with the array_map callback.
// We skip lines with /** and */
$result = array();
foreach (array_slice(explode("\n", $comment), 1, -1) as $commentLine) {
// Remove comment-chars and trim the whitespace.
$result[] = trim($commentLine, "* \t\n\r\0\x0B");
}
// Sadly, we must not escape this here, or glue it with <br /> for a
// direct display. The thing is, we may resolve several @inheritdoc
// marks. The escaping and nlbr() will be done when everything is
// stitched together.
return implode(PHP_EOL, $result);
} | [
"protected",
"function",
"prettifyComment",
"(",
"$",
"comment",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"comment",
")",
"===",
"true",
")",
"{",
"return",
"''",
";",
"}",
"// We split our comment into single lines and remove the unwanted",
"// comment chars with the ... | Removes the comment-chars from the comment string.
@param string $comment
The original comment from code.
@return string
The better readable comment | [
"Removes",
"the",
"comment",
"-",
"chars",
"from",
"the",
"comment",
"string",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Comment/AbstractComment.php#L99-L119 | train |
silverorange/swat | Swat/SwatTimeZoneEntry.php | SwatTimeZoneEntry.display | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$areas_flydown = $this->getCompositeWidget('areas_flydown');
$regions_flydown = $this->getCompositeWidget('regions_flydown');
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
$areas_flydown->value = $this->getArea($this->value);
$areas_flydown->display();
$regions_flydown->options = $this->regions;
$regions_flydown->value = $this->getRegion($this->value);
$regions_flydown->display();
$div_tag->close();
} | php | public function display()
{
if (!$this->visible) {
return;
}
parent::display();
$areas_flydown = $this->getCompositeWidget('areas_flydown');
$regions_flydown = $this->getCompositeWidget('regions_flydown');
$div_tag = new SwatHtmlTag('div');
$div_tag->id = $this->id;
$div_tag->class = $this->getCSSClassString();
$div_tag->open();
$areas_flydown->value = $this->getArea($this->value);
$areas_flydown->display();
$regions_flydown->options = $this->regions;
$regions_flydown->value = $this->getRegion($this->value);
$regions_flydown->display();
$div_tag->close();
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"visible",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"display",
"(",
")",
";",
"$",
"areas_flydown",
"=",
"$",
"this",
"->",
"getCompositeWidget",
"(",
"'areas_flydo... | Displays this time zone entry widget
Outputs a cascading list of time zones. | [
"Displays",
"this",
"time",
"zone",
"entry",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTimeZoneEntry.php#L84-L108 | train |
silverorange/swat | Swat/SwatTimeZoneEntry.php | SwatTimeZoneEntry.process | public function process()
{
parent::process();
$areas_flydown = $this->getCompositeWidget('areas_flydown');
$regions_flydown = $this->getCompositeWidget('regions_flydown');
if ($areas_flydown->value === 'UTC') {
$this->value = 'UTC';
} elseif (
$areas_flydown->value === null ||
$regions_flydown->value === null
) {
$this->value = null;
} else {
$this->value =
$areas_flydown->value . '/' . $regions_flydown->value;
}
if (!$this->required && $this->value === null && $this->isSensitive()) {
return;
} elseif ($this->value === null) {
$message = Swat::_('The %s field is required.');
$this->addMessage(new SwatMessage($message, 'error'));
} else {
try {
$time_zone = new DateTimeZone($this->value);
} catch (Exception $e) {
$message = Swat::_('The %s field is an invalid time zone.');
$this->addMessage(new SwatMessage($message, 'error'));
}
}
} | php | public function process()
{
parent::process();
$areas_flydown = $this->getCompositeWidget('areas_flydown');
$regions_flydown = $this->getCompositeWidget('regions_flydown');
if ($areas_flydown->value === 'UTC') {
$this->value = 'UTC';
} elseif (
$areas_flydown->value === null ||
$regions_flydown->value === null
) {
$this->value = null;
} else {
$this->value =
$areas_flydown->value . '/' . $regions_flydown->value;
}
if (!$this->required && $this->value === null && $this->isSensitive()) {
return;
} elseif ($this->value === null) {
$message = Swat::_('The %s field is required.');
$this->addMessage(new SwatMessage($message, 'error'));
} else {
try {
$time_zone = new DateTimeZone($this->value);
} catch (Exception $e) {
$message = Swat::_('The %s field is an invalid time zone.');
$this->addMessage(new SwatMessage($message, 'error'));
}
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"parent",
"::",
"process",
"(",
")",
";",
"$",
"areas_flydown",
"=",
"$",
"this",
"->",
"getCompositeWidget",
"(",
"'areas_flydown'",
")",
";",
"$",
"regions_flydown",
"=",
"$",
"this",
"->",
"getCompositeWidge... | Processes this time zone entry widget
If any validation type errors occur, an error message is attached to
this entry widget. | [
"Processes",
"this",
"time",
"zone",
"entry",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTimeZoneEntry.php#L119-L151 | train |
silverorange/swat | Swat/SwatTimeZoneEntry.php | SwatTimeZoneEntry.parseAreaWhitelist | private function parseAreaWhitelist($area_whitelist)
{
$areas = array();
$whitelist = 0;
foreach ($area_whitelist as $area) {
$whitelist = $whitelist | $area;
}
$tz_data = DateTimeZone::listIdentifiers($whitelist);
foreach ($tz_data as $id) {
$area = $this->getArea($id);
$region = $this->getRegion($id);
if (!array_key_exists($area, $areas)) {
$areas[$area] = array();
}
$areas[$area][] = $region;
}
return $areas;
} | php | private function parseAreaWhitelist($area_whitelist)
{
$areas = array();
$whitelist = 0;
foreach ($area_whitelist as $area) {
$whitelist = $whitelist | $area;
}
$tz_data = DateTimeZone::listIdentifiers($whitelist);
foreach ($tz_data as $id) {
$area = $this->getArea($id);
$region = $this->getRegion($id);
if (!array_key_exists($area, $areas)) {
$areas[$area] = array();
}
$areas[$area][] = $region;
}
return $areas;
} | [
"private",
"function",
"parseAreaWhitelist",
"(",
"$",
"area_whitelist",
")",
"{",
"$",
"areas",
"=",
"array",
"(",
")",
";",
"$",
"whitelist",
"=",
"0",
";",
"foreach",
"(",
"$",
"area_whitelist",
"as",
"$",
"area",
")",
"{",
"$",
"whitelist",
"=",
"$... | Parses a whitelist of valid areas
Filters the full list of areas down to a select list and returns a
tree-structured array of areas, regions, and subregions.
@param array area_whitelist an array of valid area names.
@return array a tree-structured array of areas regions and subregions
inside the specified whitelist of areas. | [
"Parses",
"a",
"whitelist",
"of",
"valid",
"areas"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTimeZoneEntry.php#L236-L258 | train |
silverorange/swat | Swat/SwatTimeZoneEntry.php | SwatTimeZoneEntry.getArea | private function getArea($time_zone)
{
$area = null;
if ($time_zone === 'UTC') {
$area = 'UTC';
} elseif ($time_zone !== null) {
$parts = explode('/', $time_zone, 2);
$area = reset($parts);
}
return $area;
} | php | private function getArea($time_zone)
{
$area = null;
if ($time_zone === 'UTC') {
$area = 'UTC';
} elseif ($time_zone !== null) {
$parts = explode('/', $time_zone, 2);
$area = reset($parts);
}
return $area;
} | [
"private",
"function",
"getArea",
"(",
"$",
"time_zone",
")",
"{",
"$",
"area",
"=",
"null",
";",
"if",
"(",
"$",
"time_zone",
"===",
"'UTC'",
")",
"{",
"$",
"area",
"=",
"'UTC'",
";",
"}",
"elseif",
"(",
"$",
"time_zone",
"!==",
"null",
")",
"{",
... | Gets an area from a time zone identifier
Returns the area part of a full time zone.
@param string $time_zone the time zone identifier to get the area from.
@return string an area name. | [
"Gets",
"an",
"area",
"from",
"a",
"time",
"zone",
"identifier"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTimeZoneEntry.php#L333-L345 | train |
silverorange/swat | Swat/SwatTimeZoneEntry.php | SwatTimeZoneEntry.getRegion | private function getRegion($time_zone)
{
$region = null;
if ($time_zone === 'UTC') {
$region = 'Coordinated_Universal_Time'; // fake region for UTC
} elseif ($time_zone !== null) {
$parts = explode('/', $time_zone, 2);
$region = end($parts);
}
return $region;
} | php | private function getRegion($time_zone)
{
$region = null;
if ($time_zone === 'UTC') {
$region = 'Coordinated_Universal_Time'; // fake region for UTC
} elseif ($time_zone !== null) {
$parts = explode('/', $time_zone, 2);
$region = end($parts);
}
return $region;
} | [
"private",
"function",
"getRegion",
"(",
"$",
"time_zone",
")",
"{",
"$",
"region",
"=",
"null",
";",
"if",
"(",
"$",
"time_zone",
"===",
"'UTC'",
")",
"{",
"$",
"region",
"=",
"'Coordinated_Universal_Time'",
";",
"// fake region for UTC",
"}",
"elseif",
"("... | Gets a region from a time zone identifier
@param string $time_zone the time zone identifier from which to get the
region.
@return string the region part of a full time zone indentifier. | [
"Gets",
"a",
"region",
"from",
"a",
"time",
"zone",
"identifier"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTimeZoneEntry.php#L358-L370 | train |
silverorange/swat | Swat/SwatTimeZoneEntry.php | SwatTimeZoneEntry.getRegionTitle | private function getRegionTitle($region)
{
$region = str_replace('_', ' ', $region);
$region = explode('/', $region);
$title = array_shift($region);
foreach ($region as $part) {
$title .= ' (' . $part . ')';
}
return $title;
} | php | private function getRegionTitle($region)
{
$region = str_replace('_', ' ', $region);
$region = explode('/', $region);
$title = array_shift($region);
foreach ($region as $part) {
$title .= ' (' . $part . ')';
}
return $title;
} | [
"private",
"function",
"getRegionTitle",
"(",
"$",
"region",
")",
"{",
"$",
"region",
"=",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"region",
")",
";",
"$",
"region",
"=",
"explode",
"(",
"'/'",
",",
"$",
"region",
")",
";",
"$",
"title",
"... | Gets a formatted region title from the region part of a time zone
identifier
@param string $region the region part of the time zone identifier.
@return string the formatted region title. | [
"Gets",
"a",
"formatted",
"region",
"title",
"from",
"the",
"region",
"part",
"of",
"a",
"time",
"zone",
"identifier"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTimeZoneEntry.php#L383-L394 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughProperties.php | ThroughProperties.callMe | public function callMe()
{
$output = $this->dispatchStartEvent();
// I need to preprocess them, since I do not want to render a
// reflection property.
/** @var \Brainworxx\Krexx\Service\Reflection\ReflectionClass $ref */
$ref = $this->parameters[static::PARAM_REF];
foreach ($this->parameters[static::PARAM_DATA] as $refProperty) {
// Check memory and runtime.
if ($this->pool->emergencyHandler->checkEmergencyBreak() === true) {
return '';
}
// Stitch together our additional info about the data:
// public access, protected access, private access and info if it was
// inherited from somewhere.
$additional = $this->getAdditionalData($refProperty, $ref);
// Every other additional string requires a special connector,
// so we do this here.
$connectorType = Connectors::NORMAL_PROPERTY;
/** @var \ReflectionProperty $refProperty */
$propName = $refProperty->getName();
// Static properties are very special.
if ($refProperty->isStatic() === true) {
$connectorType = Connectors::STATIC_PROPERTY;
// There is always a $ in front of a static property.
$propName = '$' . $propName;
}
$value = $ref->retrieveValue($refProperty);
if (isset($refProperty->isUnset) === true) {
$additional .= 'unset ';
}
if (isset($refProperty->isUndeclared) === true) {
// The property 'isUndeclared' is not a part of the reflectionProperty.
// @see \Brainworxx\Krexx\Analyse\Callback\Analyse\Objects
$additional .= 'dynamic property ';
// Check for very special chars in there.
// AFAIK this is only possible for dynamically declared properties
// which can never be static.
if ($this->isPropertyNameNormal($propName) === false) {
$propName = $this->pool->encodingService->encodeStringForCodeGeneration($propName);
$connectorType = Connectors::SPECIAL_CHARS_PROP;
}
// There is no comment ora declaration place for a dynamic property.
$comment = '';
$declarationPlace = 'undeclared';
} else {
// Since we are dealing with a declared Property here, we can
// get the comment and the declaration place.
$comment = $this->pool
->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Properties')
->getComment($refProperty);
$declarationPlace = $this->retrieveDeclarationPlace($refProperty);
}
// Stitch together our model
$output .= $this->pool->routing->analysisHub(
$this->dispatchEventWithModel(
__FUNCTION__ . static::EVENT_MARKER_END,
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setData($value)
->setName($this->pool->encodingService->encodeString($propName))
->addToJson(static::META_COMMENT, $comment)
->addToJson(static::META_DECLARED_IN, $declarationPlace)
->setAdditional($additional)
->setConnectorType($connectorType)
->setIsPublic($refProperty->isPublic())
)
);
}
return $output;
} | php | public function callMe()
{
$output = $this->dispatchStartEvent();
// I need to preprocess them, since I do not want to render a
// reflection property.
/** @var \Brainworxx\Krexx\Service\Reflection\ReflectionClass $ref */
$ref = $this->parameters[static::PARAM_REF];
foreach ($this->parameters[static::PARAM_DATA] as $refProperty) {
// Check memory and runtime.
if ($this->pool->emergencyHandler->checkEmergencyBreak() === true) {
return '';
}
// Stitch together our additional info about the data:
// public access, protected access, private access and info if it was
// inherited from somewhere.
$additional = $this->getAdditionalData($refProperty, $ref);
// Every other additional string requires a special connector,
// so we do this here.
$connectorType = Connectors::NORMAL_PROPERTY;
/** @var \ReflectionProperty $refProperty */
$propName = $refProperty->getName();
// Static properties are very special.
if ($refProperty->isStatic() === true) {
$connectorType = Connectors::STATIC_PROPERTY;
// There is always a $ in front of a static property.
$propName = '$' . $propName;
}
$value = $ref->retrieveValue($refProperty);
if (isset($refProperty->isUnset) === true) {
$additional .= 'unset ';
}
if (isset($refProperty->isUndeclared) === true) {
// The property 'isUndeclared' is not a part of the reflectionProperty.
// @see \Brainworxx\Krexx\Analyse\Callback\Analyse\Objects
$additional .= 'dynamic property ';
// Check for very special chars in there.
// AFAIK this is only possible for dynamically declared properties
// which can never be static.
if ($this->isPropertyNameNormal($propName) === false) {
$propName = $this->pool->encodingService->encodeStringForCodeGeneration($propName);
$connectorType = Connectors::SPECIAL_CHARS_PROP;
}
// There is no comment ora declaration place for a dynamic property.
$comment = '';
$declarationPlace = 'undeclared';
} else {
// Since we are dealing with a declared Property here, we can
// get the comment and the declaration place.
$comment = $this->pool
->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Properties')
->getComment($refProperty);
$declarationPlace = $this->retrieveDeclarationPlace($refProperty);
}
// Stitch together our model
$output .= $this->pool->routing->analysisHub(
$this->dispatchEventWithModel(
__FUNCTION__ . static::EVENT_MARKER_END,
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setData($value)
->setName($this->pool->encodingService->encodeString($propName))
->addToJson(static::META_COMMENT, $comment)
->addToJson(static::META_DECLARED_IN, $declarationPlace)
->setAdditional($additional)
->setConnectorType($connectorType)
->setIsPublic($refProperty->isPublic())
)
);
}
return $output;
} | [
"public",
"function",
"callMe",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"dispatchStartEvent",
"(",
")",
";",
"// I need to preprocess them, since I do not want to render a",
"// reflection property.",
"/** @var \\Brainworxx\\Krexx\\Service\\Reflection\\ReflectionCla... | Renders the properties of a class.
@return string
The generated markup. | [
"Renders",
"the",
"properties",
"of",
"a",
"class",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughProperties.php#L85-L166 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughProperties.php | ThroughProperties.getAdditionalData | protected function getAdditionalData(\ReflectionProperty $refProperty, \ReflectionClass $ref)
{
// Now that we have the key and the value, we can analyse it.
// Stitch together our additional info about the data:
// public access, protected access, private access, static declaration.
$additional = '';
if ($refProperty->isProtected() === true) {
$additional .= 'protected ';
} elseif ($refProperty->isPublic() === true) {
$additional .= 'public ';
} elseif ($refProperty->isPrivate() === true) {
$additional .= 'private ';
}
// Test if the property is inherited or not by testing the
// declaring class
if ($refProperty->getDeclaringClass()->getName() !== $ref->getName()) {
// This one got inherited fom a lower level.
$additional .= 'inherited ';
}
// Add the info, if this is static.
if ($refProperty->isStatic() === true) {
$additional .= 'static ';
}
return $additional;
} | php | protected function getAdditionalData(\ReflectionProperty $refProperty, \ReflectionClass $ref)
{
// Now that we have the key and the value, we can analyse it.
// Stitch together our additional info about the data:
// public access, protected access, private access, static declaration.
$additional = '';
if ($refProperty->isProtected() === true) {
$additional .= 'protected ';
} elseif ($refProperty->isPublic() === true) {
$additional .= 'public ';
} elseif ($refProperty->isPrivate() === true) {
$additional .= 'private ';
}
// Test if the property is inherited or not by testing the
// declaring class
if ($refProperty->getDeclaringClass()->getName() !== $ref->getName()) {
// This one got inherited fom a lower level.
$additional .= 'inherited ';
}
// Add the info, if this is static.
if ($refProperty->isStatic() === true) {
$additional .= 'static ';
}
return $additional;
} | [
"protected",
"function",
"getAdditionalData",
"(",
"\\",
"ReflectionProperty",
"$",
"refProperty",
",",
"\\",
"ReflectionClass",
"$",
"ref",
")",
"{",
"// Now that we have the key and the value, we can analyse it.",
"// Stitch together our additional info about the data:",
"// publ... | Adding declaration keywords to our data in the additional field.
@param \ReflectionProperty $refProperty
A reflection of the property we ara analysing.
@param \ReflectionClass $ref
A reflection of the class we are analysing.
@return string | [
"Adding",
"declaration",
"keywords",
"to",
"our",
"data",
"in",
"the",
"additional",
"field",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughProperties.php#L178-L205 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughProperties.php | ThroughProperties.retrieveDeclarationPlace | protected function retrieveDeclarationPlace(\ReflectionProperty $refProperty)
{
static $declarationCache = array();
// Early return from the cache.
$declaringClass = $refProperty->getDeclaringClass();
$key = $refProperty->name . '::' . $declaringClass->name;
if (isset($declarationCache[$key])) {
return $declarationCache[$key];
}
// A class can not redeclare a property from a trait that it is using.
// Hence, if one of the traits has the same property that we are
// analysing, it is probably declared there.
// Traits on the other hand can redeclare their properties.
// I'm not sure how to get the actual declaration place, when dealing
// with several layers of traits. We will not parse the source code
// for an answer.
$type = '<br />in class: ';
if (method_exists($declaringClass, 'getTraits')) {
foreach ($refProperty->getDeclaringClass()->getTraits() as $trait) {
if ($trait->hasProperty($refProperty->name)) {
if (count($trait->getTraitNames()) > 0) {
// Multiple layers of traits!
return $declarationCache[$key] = '';
}
// From a trait.
$declaringClass = $trait;
$type = '<br />in trait: ';
break;
}
}
}
$filename = $declaringClass->getFileName();
if (empty($filename) === true) {
return $declarationCache[$key] = static::UNKNOWN_DECLARATION;
}
return $declarationCache[$key] = $this->pool->fileService
->filterFilePath($declaringClass->getFileName()) . $type . $declaringClass->name;
} | php | protected function retrieveDeclarationPlace(\ReflectionProperty $refProperty)
{
static $declarationCache = array();
// Early return from the cache.
$declaringClass = $refProperty->getDeclaringClass();
$key = $refProperty->name . '::' . $declaringClass->name;
if (isset($declarationCache[$key])) {
return $declarationCache[$key];
}
// A class can not redeclare a property from a trait that it is using.
// Hence, if one of the traits has the same property that we are
// analysing, it is probably declared there.
// Traits on the other hand can redeclare their properties.
// I'm not sure how to get the actual declaration place, when dealing
// with several layers of traits. We will not parse the source code
// for an answer.
$type = '<br />in class: ';
if (method_exists($declaringClass, 'getTraits')) {
foreach ($refProperty->getDeclaringClass()->getTraits() as $trait) {
if ($trait->hasProperty($refProperty->name)) {
if (count($trait->getTraitNames()) > 0) {
// Multiple layers of traits!
return $declarationCache[$key] = '';
}
// From a trait.
$declaringClass = $trait;
$type = '<br />in trait: ';
break;
}
}
}
$filename = $declaringClass->getFileName();
if (empty($filename) === true) {
return $declarationCache[$key] = static::UNKNOWN_DECLARATION;
}
return $declarationCache[$key] = $this->pool->fileService
->filterFilePath($declaringClass->getFileName()) . $type . $declaringClass->name;
} | [
"protected",
"function",
"retrieveDeclarationPlace",
"(",
"\\",
"ReflectionProperty",
"$",
"refProperty",
")",
"{",
"static",
"$",
"declarationCache",
"=",
"array",
"(",
")",
";",
"// Early return from the cache.",
"$",
"declaringClass",
"=",
"$",
"refProperty",
"->",... | Retrieve the declaration place of a property.
@param \ReflectionProperty $refProperty
@return string | [
"Retrieve",
"the",
"declaration",
"place",
"of",
"a",
"property",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughProperties.php#L213-L255 | train |
rollun-com/rollun-datastore | src/DataStore/src/DataStore/Aspect/AspectTyped.php | AspectTyped.dtoToArray | protected function dtoToArray(BaseDto $dto)
{
$itemData = [];
foreach ($this->scheme as $fieldName => $fieldInfo) {
$getter = 'get' . ucfirst($fieldName);
if (!method_exists($dto, $getter)) {
throw new RuntimeException("Undefined method '$getter' in " . get_class($dto));
}
/** @var FormatterInterface $formatter */
$formatter = $this->formatterPluginManager->get($fieldInfo['formatter']);
$itemData[$fieldName] = $formatter->format($dto->$getter());
}
return $itemData;
} | php | protected function dtoToArray(BaseDto $dto)
{
$itemData = [];
foreach ($this->scheme as $fieldName => $fieldInfo) {
$getter = 'get' . ucfirst($fieldName);
if (!method_exists($dto, $getter)) {
throw new RuntimeException("Undefined method '$getter' in " . get_class($dto));
}
/** @var FormatterInterface $formatter */
$formatter = $this->formatterPluginManager->get($fieldInfo['formatter']);
$itemData[$fieldName] = $formatter->format($dto->$getter());
}
return $itemData;
} | [
"protected",
"function",
"dtoToArray",
"(",
"BaseDto",
"$",
"dto",
")",
"{",
"$",
"itemData",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"scheme",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldInfo",
")",
"{",
"$",
"getter",
"=",
"'get'",
".",... | Convert BaseDto object to array
@param BaseDto $dto
@return array | [
"Convert",
"BaseDto",
"object",
"to",
"array"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/Aspect/AspectTyped.php#L183-L201 | train |
rollun-com/rollun-datastore | src/DataStore/src/DataStore/Aspect/AspectTyped.php | AspectTyped.arrayToDto | protected function arrayToDto(array $itemData)
{
foreach ($itemData as $field => $value) {
if (!isset($this->scheme[$field])) {
throw new InvalidArgumentException("Undefined field '$field' in scheme");
}
$typeService = $this->scheme[$field]['type'];
$itemData[$field] = $this->typePluginManager->get($typeService, ['value' => $value]);
}
return new $this->dtoClassName($itemData);
} | php | protected function arrayToDto(array $itemData)
{
foreach ($itemData as $field => $value) {
if (!isset($this->scheme[$field])) {
throw new InvalidArgumentException("Undefined field '$field' in scheme");
}
$typeService = $this->scheme[$field]['type'];
$itemData[$field] = $this->typePluginManager->get($typeService, ['value' => $value]);
}
return new $this->dtoClassName($itemData);
} | [
"protected",
"function",
"arrayToDto",
"(",
"array",
"$",
"itemData",
")",
"{",
"foreach",
"(",
"$",
"itemData",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"scheme",
"[",
"$",
"field",
"]",
")... | Convert array to BaseDto object
@param array $itemData
@return BaseDto | [
"Convert",
"array",
"to",
"BaseDto",
"object"
] | ef433b58b94e1c311123ad1b2a0360e95a636bd1 | https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/Aspect/AspectTyped.php#L209-L221 | train |
brainworxx/kreXX | src/Analyse/Callback/Analyse/Objects/AbstractObjectAnalysis.php | AbstractObjectAnalysis.getReflectionPropertiesData | protected function getReflectionPropertiesData(array $refProps, ReflectionClass $ref, $label = null)
{
// We are dumping public properties direct into the main-level, without
// any "abstraction level", because they can be accessed directly.
/** @var Model $model */
$model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->addParameter(static::PARAM_DATA, $refProps)
->addParameter(static::PARAM_REF, $ref)
->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughProperties')
);
if (isset($label)) {
// Protected or private properties.
return $this->pool->render->renderExpandableChild(
$this->dispatchEventWithModel(
static::EVENT_MARKER_ANALYSES_END,
$model->setName($label)
->setType(static::TYPE_INTERNALS)
)
);
}
// Public properties.
// We render them directly in the object "root", so we call
// the render directly.
return $this->dispatchEventWithModel(
static::EVENT_MARKER_ANALYSES_END,
$model
)->renderMe();
} | php | protected function getReflectionPropertiesData(array $refProps, ReflectionClass $ref, $label = null)
{
// We are dumping public properties direct into the main-level, without
// any "abstraction level", because they can be accessed directly.
/** @var Model $model */
$model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->addParameter(static::PARAM_DATA, $refProps)
->addParameter(static::PARAM_REF, $ref)
->injectCallback(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughProperties')
);
if (isset($label)) {
// Protected or private properties.
return $this->pool->render->renderExpandableChild(
$this->dispatchEventWithModel(
static::EVENT_MARKER_ANALYSES_END,
$model->setName($label)
->setType(static::TYPE_INTERNALS)
)
);
}
// Public properties.
// We render them directly in the object "root", so we call
// the render directly.
return $this->dispatchEventWithModel(
static::EVENT_MARKER_ANALYSES_END,
$model
)->renderMe();
} | [
"protected",
"function",
"getReflectionPropertiesData",
"(",
"array",
"$",
"refProps",
",",
"ReflectionClass",
"$",
"ref",
",",
"$",
"label",
"=",
"null",
")",
"{",
"// We are dumping public properties direct into the main-level, without",
"// any \"abstraction level\", because... | Gets the properties from a reflection property of the object.
@param array $refProps
The list of the reflection properties.
@param ReflectionClass $ref
The reflection of the object we are currently analysing.
@param string $label
The additional part of the template file. If set, we will use a wrapper
around the analysis output.
@return string
The generated markup. | [
"Gets",
"the",
"properties",
"from",
"a",
"reflection",
"property",
"of",
"the",
"object",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/Objects/AbstractObjectAnalysis.php#L83-L113 | train |
brainworxx/kreXX | src/Analyse/Callback/Analyse/Objects/AbstractObjectAnalysis.php | AbstractObjectAnalysis.reflectionSorting | protected function reflectionSorting(\Reflector $reflectionA, \Reflector $reflectionB)
{
/** @var \ReflectionMethod | \ReflectionProperty $reflectionA */
/** @var \ReflectionMethod | \ReflectionProperty $reflectionB */
return strcmp($reflectionA->getName(), $reflectionB->getName());
} | php | protected function reflectionSorting(\Reflector $reflectionA, \Reflector $reflectionB)
{
/** @var \ReflectionMethod | \ReflectionProperty $reflectionA */
/** @var \ReflectionMethod | \ReflectionProperty $reflectionB */
return strcmp($reflectionA->getName(), $reflectionB->getName());
} | [
"protected",
"function",
"reflectionSorting",
"(",
"\\",
"Reflector",
"$",
"reflectionA",
",",
"\\",
"Reflector",
"$",
"reflectionB",
")",
"{",
"/** @var \\ReflectionMethod | \\ReflectionProperty $reflectionA */",
"/** @var \\ReflectionMethod | \\ReflectionProperty $reflectionB */",
... | Simple sorting callback for reflections.
@param \Reflector $reflectionA
The first reflection.
@param \Reflector $reflectionB
The second reflection.
@return int | [
"Simple",
"sorting",
"callback",
"for",
"reflections",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/Objects/AbstractObjectAnalysis.php#L124-L129 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evaluateSetting | public function evaluateSetting($group, $name, $value)
{
if ($group === 'feEditing') {
// Logging options can never be changed in the frontend.
// The debug methods will also not be editable.
return !in_array($name, $this->feConfigNoEdit);
}
// We simply call the configured evaluation method.
$callback = $this->feConfigFallback[$name][static::EVALUATE];
return $this->$callback($value, $name, $group);
} | php | public function evaluateSetting($group, $name, $value)
{
if ($group === 'feEditing') {
// Logging options can never be changed in the frontend.
// The debug methods will also not be editable.
return !in_array($name, $this->feConfigNoEdit);
}
// We simply call the configured evaluation method.
$callback = $this->feConfigFallback[$name][static::EVALUATE];
return $this->$callback($value, $name, $group);
} | [
"public",
"function",
"evaluateSetting",
"(",
"$",
"group",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"group",
"===",
"'feEditing'",
")",
"{",
"// Logging options can never be changed in the frontend.",
"// The debug methods will also not be editabl... | Evaluate a single setting from the cookies or the ini file.
@param string $group
The group value in the ini.
@param string $name
The name of the setting.
@param string $value
The value to evaluate.
@return bool
If it was evaluated. | [
"Evaluate",
"a",
"single",
"setting",
"from",
"the",
"cookies",
"or",
"the",
"ini",
"file",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L78-L89 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalDevHandle | protected function evalDevHandle($value, $name)
{
$result = preg_match('/[^a-zA-Z]/', $value) === 0;
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return $result;
} | php | protected function evalDevHandle($value, $name)
{
$result = preg_match('/[^a-zA-Z]/', $value) === 0;
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return $result;
} | [
"protected",
"function",
"evalDevHandle",
"(",
"$",
"value",
",",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"preg_match",
"(",
"'/[^a-zA-Z]/'",
",",
"$",
"value",
")",
"===",
"0",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"this",... | We check the dev handle for a-z and A-Z.
@param string $value
The value we want to evaluate
@param string $name
The name of the value we are checking, needed for the feedback text.
@return boolean
Whether it does evaluate or not. | [
"We",
"check",
"the",
"dev",
"handle",
"for",
"a",
"-",
"z",
"and",
"A",
"-",
"Z",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L102-L110 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalSkin | protected function evalSkin($value, $name)
{
$result = isset($this->skinConfiguration[$value]) &&
class_exists($this->skinConfiguration[$value][static::SKIN_CLASS]) &&
$this->pool->fileService->fileIsReadable(
$this->skinConfiguration[$value][static::SKIN_DIRECTORY] . 'header.html'
);
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return $result;
} | php | protected function evalSkin($value, $name)
{
$result = isset($this->skinConfiguration[$value]) &&
class_exists($this->skinConfiguration[$value][static::SKIN_CLASS]) &&
$this->pool->fileService->fileIsReadable(
$this->skinConfiguration[$value][static::SKIN_DIRECTORY] . 'header.html'
);
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return $result;
} | [
"protected",
"function",
"evalSkin",
"(",
"$",
"value",
",",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"isset",
"(",
"$",
"this",
"->",
"skinConfiguration",
"[",
"$",
"value",
"]",
")",
"&&",
"class_exists",
"(",
"$",
"this",
"->",
"skinConfiguration",
... | We check the configuration for this skin.
@param string $value
The value we want to evaluate
@param string $name
The name of the value we are checking, needed for the feedback text.
@return boolean
Whether it does evaluate or not. | [
"We",
"check",
"the",
"configuration",
"for",
"this",
"skin",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L123-L136 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalDestination | protected function evalDestination($value, $name)
{
$result = ($value === static::VALUE_BROWSER || $value === 'file');
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return $result;
} | php | protected function evalDestination($value, $name)
{
$result = ($value === static::VALUE_BROWSER || $value === 'file');
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return $result;
} | [
"protected",
"function",
"evalDestination",
"(",
"$",
"value",
",",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"(",
"$",
"value",
"===",
"static",
"::",
"VALUE_BROWSER",
"||",
"$",
"value",
"===",
"'file'",
")",
";",
"if",
"(",
"$",
"result",
"===",
... | We are expecting 'browser' or 'file'.
@param string $value
The value we want to evaluate
@param string $name
The name of the value we are checking, needed for the feedback text.
@return boolean
Whether it does evaluate or not. | [
"We",
"are",
"expecting",
"browser",
"or",
"file",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L149-L157 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalIpRange | protected function evalIpRange($value, $name)
{
$result = empty($value);
if ($result === true) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return !$result;
} | php | protected function evalIpRange($value, $name)
{
$result = empty($value);
if ($result === true) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR . ucfirst($name));
}
return !$result;
} | [
"protected",
"function",
"evalIpRange",
"(",
"$",
"value",
",",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"empty",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"pool",
"->",
"messages",
"->",
... | Evaluating the IP range, by testing that it is not empty.
@param string $value
The value we want to evaluate
@param string $name
The name of the value we are checking, needed for the feedback text.
@return boolean
Whether it does evaluate or not. | [
"Evaluating",
"the",
"IP",
"range",
"by",
"testing",
"that",
"it",
"is",
"not",
"empty",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L170-L178 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalMaxRuntime | protected function evalMaxRuntime($value, $name, $group)
{
// Check for integer first.
if ($this->evalInt($value, $name, $group) === false) {
return false;
}
$maxTime = (int)ini_get('max_execution_time');
// We need a maximum runtime in the first place
// and then check, if we have a value smaller than it.
if ($maxTime <= 0) {
// We were unable to get the maximum runtime from the server.
// No need to check any further.
return true;
}
if ($maxTime < (int)$value) {
$this->pool->messages->addMessage(
static::KEY_CONFIG_ERROR . ucfirst($name) . 'Big',
array($maxTime)
);
return false;
}
return true;
} | php | protected function evalMaxRuntime($value, $name, $group)
{
// Check for integer first.
if ($this->evalInt($value, $name, $group) === false) {
return false;
}
$maxTime = (int)ini_get('max_execution_time');
// We need a maximum runtime in the first place
// and then check, if we have a value smaller than it.
if ($maxTime <= 0) {
// We were unable to get the maximum runtime from the server.
// No need to check any further.
return true;
}
if ($maxTime < (int)$value) {
$this->pool->messages->addMessage(
static::KEY_CONFIG_ERROR . ucfirst($name) . 'Big',
array($maxTime)
);
return false;
}
return true;
} | [
"protected",
"function",
"evalMaxRuntime",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"group",
")",
"{",
"// Check for integer first.",
"if",
"(",
"$",
"this",
"->",
"evalInt",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"group",
")",
"===",
"fa... | Evaluation the maximum runtime, by looking at the server settings, as
well as checking for an integer value.
@param string $value
The value we want to evaluate
@param string $name
The name of the value we are checking, needed for the feedback text.
@param string $group
The name of the group that we are evaluating, needed for the feedback
text.
@return boolean
Whether it does evaluate or not. | [
"Evaluation",
"the",
"maximum",
"runtime",
"by",
"looking",
"at",
"the",
"server",
"settings",
"as",
"well",
"as",
"checking",
"for",
"an",
"integer",
"value",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L195-L220 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalBool | protected function evalBool($value, $name, $group)
{
$result = ($value === static::VALUE_TRUE || $value === static::VALUE_FALSE);
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR_BOOL, array($group, $name));
}
return $result;
} | php | protected function evalBool($value, $name, $group)
{
$result = ($value === static::VALUE_TRUE || $value === static::VALUE_FALSE);
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR_BOOL, array($group, $name));
}
return $result;
} | [
"protected",
"function",
"evalBool",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"group",
")",
"{",
"$",
"result",
"=",
"(",
"$",
"value",
"===",
"static",
"::",
"VALUE_TRUE",
"||",
"$",
"value",
"===",
"static",
"::",
"VALUE_FALSE",
")",
";",
"if... | Evaluates a string of 'true' or 'false'.
@param string $value
The string we want to evaluate.
@param string $name
The name of the value we are checking, needed for the feedback text.
@param string $group
The name of the group that we are evaluating, needed for the feedback
text.
@return bool
Whether it does evaluate or not. | [
"Evaluates",
"a",
"string",
"of",
"true",
"or",
"false",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L236-L244 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalInt | protected function evalInt($value, $name, $group)
{
$result = ((int) $value) > 0;
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR_INT, array($group, $name));
}
return $result;
} | php | protected function evalInt($value, $name, $group)
{
$result = ((int) $value) > 0;
if ($result === false) {
$this->pool->messages->addMessage(static::KEY_CONFIG_ERROR_INT, array($group, $name));
}
return $result;
} | [
"protected",
"function",
"evalInt",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"group",
")",
"{",
"$",
"result",
"=",
"(",
"(",
"int",
")",
"$",
"value",
")",
">",
"0",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"this",
... | Evaluates a string of integer.
It must be greater than 0 and smaller than 101.
@param string $value
The string we want to evaluate.
@param string $name
The name of the value we are checking, needed for the feedback text.
@param string $group
The name of the group that we are evaluating, needed for the feedback
text.
@return bool
Whether it does evaluate or not. | [
"Evaluates",
"a",
"string",
"of",
"integer",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L262-L270 | train |
brainworxx/kreXX | src/Service/Config/Security.php | Security.evalDebugMethods | protected function evalDebugMethods($value, $name, $group)
{
$list = explode(',', $value);
foreach ($list as $entry) {
// Test for whitespace and the blacklist.
if (in_array($entry, $this->methodBlacklist)) {
$this->pool->messages->addMessage(
static::KEY_CONFIG_ERROR_DEBUG_BLACKLIST,
array($group, $name, $entry)
);
return false;
}
if (strpos($entry, ' ') !== false) {
$this->pool->messages->addMessage(
static::KEY_CONFIG_ERROR_DEBUG_INVALID,
array($group, $name, $entry)
);
return false;
}
}
return true;
} | php | protected function evalDebugMethods($value, $name, $group)
{
$list = explode(',', $value);
foreach ($list as $entry) {
// Test for whitespace and the blacklist.
if (in_array($entry, $this->methodBlacklist)) {
$this->pool->messages->addMessage(
static::KEY_CONFIG_ERROR_DEBUG_BLACKLIST,
array($group, $name, $entry)
);
return false;
}
if (strpos($entry, ' ') !== false) {
$this->pool->messages->addMessage(
static::KEY_CONFIG_ERROR_DEBUG_INVALID,
array($group, $name, $entry)
);
return false;
}
}
return true;
} | [
"protected",
"function",
"evalDebugMethods",
"(",
"$",
"value",
",",
"$",
"name",
",",
"$",
"group",
")",
"{",
"$",
"list",
"=",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"entry",
")",
"{",
"// Test... | Sanity check, if the supplied debug methods are not obviously flawed.
@param string $value
Comma separated list of debug methods.
@param string $name
The name of the value we are checking, needed for the feedback text.
@param string $group
The name of the group that we are evaluating, needed for the feedback
text.
@return bool
Whether it does evaluate or not. | [
"Sanity",
"check",
"if",
"the",
"supplied",
"debug",
"methods",
"are",
"not",
"obviously",
"flawed",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Security.php#L297-L320 | train |
silverorange/swat | Swat/SwatLinkCellRenderer.php | SwatLinkCellRenderer.renderSensitive | protected function renderSensitive()
{
$anchor_tag = new SwatHtmlTag('a');
$anchor_tag->setContent($this->getText(), $this->content_type);
$anchor_tag->href = $this->getLink();
$anchor_tag->title = $this->getTitle();
$anchor_tag->class = $this->getCSSClassString();
$anchor_tag->display();
} | php | protected function renderSensitive()
{
$anchor_tag = new SwatHtmlTag('a');
$anchor_tag->setContent($this->getText(), $this->content_type);
$anchor_tag->href = $this->getLink();
$anchor_tag->title = $this->getTitle();
$anchor_tag->class = $this->getCSSClassString();
$anchor_tag->display();
} | [
"protected",
"function",
"renderSensitive",
"(",
")",
"{",
"$",
"anchor_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'a'",
")",
";",
"$",
"anchor_tag",
"->",
"setContent",
"(",
"$",
"this",
"->",
"getText",
"(",
")",
",",
"$",
"this",
"->",
"content_type",
")"... | Renders this link as sensitive | [
"Renders",
"this",
"link",
"as",
"sensitive"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatLinkCellRenderer.php#L122-L130 | train |
silverorange/swat | Swat/SwatLinkCellRenderer.php | SwatLinkCellRenderer.renderInsensitive | protected function renderInsensitive()
{
$span_tag = new SwatHtmlTag('span');
$span_tag->setContent($this->getText(), $this->content_type);
$span_tag->title = $this->getTitle();
$span_tag->class = $this->getCSSClassString();
$span_tag->display();
} | php | protected function renderInsensitive()
{
$span_tag = new SwatHtmlTag('span');
$span_tag->setContent($this->getText(), $this->content_type);
$span_tag->title = $this->getTitle();
$span_tag->class = $this->getCSSClassString();
$span_tag->display();
} | [
"protected",
"function",
"renderInsensitive",
"(",
")",
"{",
"$",
"span_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'span'",
")",
";",
"$",
"span_tag",
"->",
"setContent",
"(",
"$",
"this",
"->",
"getText",
"(",
")",
",",
"$",
"this",
"->",
"content_type",
")... | Renders this link as not sensitive | [
"Renders",
"this",
"link",
"as",
"not",
"sensitive"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatLinkCellRenderer.php#L138-L145 | train |
brainworxx/kreXX | src/Analyse/AbstractModel.php | AbstractModel.addToJson | public function addToJson($key, $value)
{
// Remove leftover linebreaks.
$value = trim(preg_replace("/\r|\n/", "", $value));
if ($value === '') {
unset($this->json[$key]);
} else {
$this->json[$key] = $value;
}
return $this;
} | php | public function addToJson($key, $value)
{
// Remove leftover linebreaks.
$value = trim(preg_replace("/\r|\n/", "", $value));
if ($value === '') {
unset($this->json[$key]);
} else {
$this->json[$key] = $value;
}
return $this;
} | [
"public",
"function",
"addToJson",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// Remove leftover linebreaks.",
"$",
"value",
"=",
"trim",
"(",
"preg_replace",
"(",
"\"/\\r|\\n/\"",
",",
"\"\"",
",",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"value... | We simply add more info to our info json.
Leftover linebreaks will be removed.
If the value is empty, we will remove a possible previous entry to this key.
@param string $key
The array key.
@param string $value
The value we want to set.
@return $this
$this for chaining. | [
"We",
"simply",
"add",
"more",
"info",
"to",
"our",
"info",
"json",
".",
"Leftover",
"linebreaks",
"will",
"be",
"removed",
".",
"If",
"the",
"value",
"is",
"empty",
"we",
"will",
"remove",
"a",
"possible",
"previous",
"entry",
"to",
"this",
"key",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/AbstractModel.php#L173-L184 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.duplicate | public function duplicate()
{
$class = get_class($this);
$new_wrapper = new $class();
foreach ($this->getArray() as $object) {
$object->setDatabase($this->db);
$duplicate_object = $object->duplicate();
$duplicate_object->setDatabase($this->db);
$new_wrapper->add($duplicate_object);
}
$new_wrapper->setDatabase($this->db);
return $new_wrapper;
} | php | public function duplicate()
{
$class = get_class($this);
$new_wrapper = new $class();
foreach ($this->getArray() as $object) {
$object->setDatabase($this->db);
$duplicate_object = $object->duplicate();
$duplicate_object->setDatabase($this->db);
$new_wrapper->add($duplicate_object);
}
$new_wrapper->setDatabase($this->db);
return $new_wrapper;
} | [
"public",
"function",
"duplicate",
"(",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"new_wrapper",
"=",
"new",
"$",
"class",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getArray",
"(",
")",
"as",
"$",
"object",... | Duplicates this record set wrapper
@return SwatDBRecordsetWrapper a duplicate of this object.
@see SwatDBDataobject::duplicate() | [
"Duplicates",
"this",
"record",
"set",
"wrapper"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L177-L192 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.setOptions | public function setOptions($options, $value = null)
{
// if options passed as string then second param is option value
if (is_string($options)) {
$options = array($options => $value);
}
if (!is_array($options)) {
throw new InvalidArgumentException(
'The $options parameter must either be an array or a string ' .
'containing the option name.'
);
}
// new options override existing options
$this->options = array_merge($options, $this->options);
return $this;
} | php | public function setOptions($options, $value = null)
{
// if options passed as string then second param is option value
if (is_string($options)) {
$options = array($options => $value);
}
if (!is_array($options)) {
throw new InvalidArgumentException(
'The $options parameter must either be an array or a string ' .
'containing the option name.'
);
}
// new options override existing options
$this->options = array_merge($options, $this->options);
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"$",
"options",
",",
"$",
"value",
"=",
"null",
")",
"{",
"// if options passed as string then second param is option value",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
... | Sets one or more options for this recordset wrapper
Subclasses may define additional options. The default options are:
- <kbd>boolean read_only</kbd> if true, records are initialized as
read only. Defaults to false.
@param array|string $options either an array containing key-value pairs
or a string cotnaining the option name to
set.
@param mixed $value optional. If <kbd>$options</kbd> was passed
as a string, this is the option value.
@return SwatDBRecordsetWrapper the current object for fluent interface. | [
"Sets",
"one",
"or",
"more",
"options",
"for",
"this",
"recordset",
"wrapper"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L213-L231 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.copyEmpty | public function copyEmpty()
{
$class_name = get_class($this);
$wrapper = new $class_name();
$wrapper->row_wrapper_class = $this->row_wrapper_class;
$wrapper->index_field = $this->index_field;
$wrapper->options = $this->options;
return $wrapper;
} | php | public function copyEmpty()
{
$class_name = get_class($this);
$wrapper = new $class_name();
$wrapper->row_wrapper_class = $this->row_wrapper_class;
$wrapper->index_field = $this->index_field;
$wrapper->options = $this->options;
return $wrapper;
} | [
"public",
"function",
"copyEmpty",
"(",
")",
"{",
"$",
"class_name",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"wrapper",
"=",
"new",
"$",
"class_name",
"(",
")",
";",
"$",
"wrapper",
"->",
"row_wrapper_class",
"=",
"$",
"this",
"->",
"row_wra... | Creates a new empty copy of this recordset wrapper
@return SwatDBRecordsetWrapper a new empty copy of this wrapper. | [
"Creates",
"a",
"new",
"empty",
"copy",
"of",
"this",
"recordset",
"wrapper"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L265-L275 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.instantiateRowWrapperObject | protected function instantiateRowWrapperObject($row)
{
if ($this->row_wrapper_class === null) {
$object = $row;
} else {
$object = new $this->row_wrapper_class(
$row,
$this->getOption('read_only')
);
}
return $object;
} | php | protected function instantiateRowWrapperObject($row)
{
if ($this->row_wrapper_class === null) {
$object = $row;
} else {
$object = new $this->row_wrapper_class(
$row,
$this->getOption('read_only')
);
}
return $object;
} | [
"protected",
"function",
"instantiateRowWrapperObject",
"(",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"row_wrapper_class",
"===",
"null",
")",
"{",
"$",
"object",
"=",
"$",
"row",
";",
"}",
"else",
"{",
"$",
"object",
"=",
"new",
"$",
"this"... | Creates a new dataobject
@param stdClass $row the data row to use.
@return mixed the instantiated data object or the original object if
no <i>$row_wrapper_class</i> is defined for this
recordset wrapper. | [
"Creates",
"a",
"new",
"dataobject"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L289-L301 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetExists | public function offsetExists($offset)
{
if ($this->index_field === null) {
return isset($this->objects[$offset]);
}
return isset($this->objects_by_index[$offset]);
} | php | public function offsetExists($offset)
{
if ($this->index_field === null) {
return isset($this->objects[$offset]);
}
return isset($this->objects_by_index[$offset]);
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"objects",
"[",
"$",
"offset",
"]",
")",
";",
"}",
"return",
"isset",... | Gets whether or not a value exists for the given offset
@param mixed $offset the offset to check. If this recordset has a
defined index field, the offset is an index
value. Otherwise, the offset is an ordinal value.
@return boolean true if this recordset has a value for the given offset
and false if it does not. | [
"Gets",
"whether",
"or",
"not",
"a",
"value",
"exists",
"for",
"the",
"given",
"offset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L355-L362 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetGet | public function offsetGet($offset)
{
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf('Index %s is out of bounds.', $offset)
);
}
if ($this->index_field === null) {
return $this->objects[$offset];
}
return $this->objects_by_index[$offset];
} | php | public function offsetGet($offset)
{
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf('Index %s is out of bounds.', $offset)
);
}
if ($this->index_field === null) {
return $this->objects[$offset];
}
return $this->objects_by_index[$offset];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'Index %s is out of bounds.'",
",",
"$",
"of... | Gets a record in this recordset by an offset value
@param mixed $offset the offset for which to get the record. If this
recordset has a defined index field, the offset is
an index value. Otherwise, the offset is an
ordinal value.
@return SwatDBDataObject the record at the specified offset.
@throws OutOfBoundsException if no record exists at the specified offset
in this recordset. | [
"Gets",
"a",
"record",
"in",
"this",
"recordset",
"by",
"an",
"offset",
"value"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L380-L393 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetSet | public function offsetSet($offset, $value)
{
if (
$this->row_wrapper_class !== null &&
!($value instanceof $this->row_wrapper_class)
) {
throw new UnexpectedValueException(
sprintf(
'Value should be an instance of %s.',
$this->row_wrapper_class
)
);
}
if ($offset === null) {
// add
$this->objects[] = $value;
// if index field is set, index the object
if (
$this->index_field !== null &&
isset($value->{$this->index_field})
) {
if ($value->hasInternalValue($this->index_field)) {
$index = $value->getInternalValue($this->index_field);
} else {
$index = $value->{$this->index_field};
}
$this->objects_by_index[$index] = $value;
}
} else {
// replace at offset
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf(
'No record to replace exists at offset %s.',
$offset
)
);
}
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
$this->objects[$offset] = $value;
} else {
$index_field = $this->index_field;
// update object index field value
$value->$index_field = $offset;
// find and replace ordinally indexed objects
foreach ($this->objects as $key => $object) {
if ($object->$index_field === $value->$index_field) {
$this->removed_objects[] = $object;
$this->objects[$key] = $value;
}
}
// add object to indexed array
$this->objects_by_index[$offset] = $value;
}
}
// only set the db on added object if it is set for this recordset
if ($this->db !== null && $value instanceof SwatDBRecordable) {
$value->setDatabase($this->db);
}
// Remove object from removed list if it was on list of removed
// objects. This step needs to happen after adding the new record
// for the case where we replaced an object with itself.
$keys = array_keys($this->removed_objects, $value, true);
foreach ($keys as $key) {
unset($this->removed_objects[$key]);
}
} | php | public function offsetSet($offset, $value)
{
if (
$this->row_wrapper_class !== null &&
!($value instanceof $this->row_wrapper_class)
) {
throw new UnexpectedValueException(
sprintf(
'Value should be an instance of %s.',
$this->row_wrapper_class
)
);
}
if ($offset === null) {
// add
$this->objects[] = $value;
// if index field is set, index the object
if (
$this->index_field !== null &&
isset($value->{$this->index_field})
) {
if ($value->hasInternalValue($this->index_field)) {
$index = $value->getInternalValue($this->index_field);
} else {
$index = $value->{$this->index_field};
}
$this->objects_by_index[$index] = $value;
}
} else {
// replace at offset
if (!isset($this[$offset])) {
throw new OutOfBoundsException(
sprintf(
'No record to replace exists at offset %s.',
$offset
)
);
}
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
$this->objects[$offset] = $value;
} else {
$index_field = $this->index_field;
// update object index field value
$value->$index_field = $offset;
// find and replace ordinally indexed objects
foreach ($this->objects as $key => $object) {
if ($object->$index_field === $value->$index_field) {
$this->removed_objects[] = $object;
$this->objects[$key] = $value;
}
}
// add object to indexed array
$this->objects_by_index[$offset] = $value;
}
}
// only set the db on added object if it is set for this recordset
if ($this->db !== null && $value instanceof SwatDBRecordable) {
$value->setDatabase($this->db);
}
// Remove object from removed list if it was on list of removed
// objects. This step needs to happen after adding the new record
// for the case where we replaced an object with itself.
$keys = array_keys($this->removed_objects, $value, true);
foreach ($keys as $key) {
unset($this->removed_objects[$key]);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"row_wrapper_class",
"!==",
"null",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"$",
"this",
"->",
"row_wrapper_class",
")",
")",
"{",
"th... | Sets a record at a specified offset
@param mixed $offset optional. The offset to set the record at. If this
recordset has a defined index field, the offset is
an index value. Otherwise, the offset is an
ordinal value. If no offset is given, the record
will be added at the end of this recordset.
@param mixed $value the record to add.
@throws UnexpectedValueException if this recordset has a defined row
wrapper class and the specified value
is not an instance of the row wrapper
class.
@throws OutOfBoundsException if the specified offset does not exist in
this recordset. Records can only be added
to the end of the recordset or replace
existing records in this recordset. | [
"Sets",
"a",
"record",
"at",
"a",
"specified",
"offset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L418-L493 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.offsetUnset | public function offsetUnset($offset)
{
if (isset($this[$offset])) {
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
unset($this->objects[$offset]);
// update iterator index
if (
$this->current_index >= $offset &&
$this->current_index > 0
) {
$this->current_index--;
}
} else {
$object = $this->objects_by_index[$offset];
$this->removed_objects[] = $object;
unset($this->objects_by_index[$offset]);
$keys = array_keys($this->objects, $object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if (
$this->current_index >= $key &&
$this->current_index > 0
) {
$this->current_index--;
}
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | php | public function offsetUnset($offset)
{
if (isset($this[$offset])) {
if ($this->index_field === null) {
$this->removed_objects[] = $this->objects[$offset];
unset($this->objects[$offset]);
// update iterator index
if (
$this->current_index >= $offset &&
$this->current_index > 0
) {
$this->current_index--;
}
} else {
$object = $this->objects_by_index[$offset];
$this->removed_objects[] = $object;
unset($this->objects_by_index[$offset]);
$keys = array_keys($this->objects, $object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if (
$this->current_index >= $key &&
$this->current_index > 0
) {
$this->current_index--;
}
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"removed_objec... | Unsets a record in this recordset at the specified offset
This removes the record at the specified offset from this recordset.
If no such record exists, nothing is done. The record object itself
still exists if there is an external reference to it elsewhere.
@param mixed $offset the offset for which to unset the record. If this
recordset has a defined index field, the offset is
an index value. Otherwise, the offset is an
ordinal value. | [
"Unsets",
"a",
"record",
"in",
"this",
"recordset",
"at",
"the",
"specified",
"offset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L510-L546 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.key | public function key()
{
if (
$this->index_field !== null &&
isset($this->current()->{$this->index_field})
) {
$key = $this->current()->{$this->index_field};
} else {
$key = $this->current_index;
}
return $key;
} | php | public function key()
{
if (
$this->index_field !== null &&
isset($this->current()->{$this->index_field})
) {
$key = $this->current()->{$this->index_field};
} else {
$key = $this->current_index;
}
return $key;
} | [
"public",
"function",
"key",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"this",
"->",
"current",
"(",
")",
"->",
"{",
"$",
"this",
"->",
"index_field",
"}",
")",
")",
"{",
"$",
"key",
"=",
... | Returns the key of the current record
If this recordset has an index field defined and the current record has
an index value, this gets the index value. Otherwise this gets the
ordinal position of the record in this recordset.
@return integer the key of the current record. | [
"Returns",
"the",
"key",
"of",
"the",
"current",
"record"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L575-L587 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getInternalValues | public function getInternalValues($name)
{
$values = array();
if (count($this) > 0) {
if (!$this->getFirst()->hasInternalValue($name)) {
throw new SwatDBException(
"Records in this recordset do not contain an internal " .
"field named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->getInternalValue($name);
}
}
return $values;
} | php | public function getInternalValues($name)
{
$values = array();
if (count($this) > 0) {
if (!$this->getFirst()->hasInternalValue($name)) {
throw new SwatDBException(
"Records in this recordset do not contain an internal " .
"field named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->getInternalValue($name);
}
}
return $values;
} | [
"public",
"function",
"getInternalValues",
"(",
"$",
"name",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getFirst",
"(",
")",
"->",
"ha... | Gets the values of an internal property for each record in this set
@param string $name name of the internal property to get.
@return array an array of values.
@throws SwatDBException if records in this recordset do not have an
internal value with the specified <i>$name</i>.
@see SwatDBDataObject::getInternalValue() | [
"Gets",
"the",
"values",
"of",
"an",
"internal",
"property",
"for",
"each",
"record",
"in",
"this",
"set"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L775-L793 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.loadAllSubDataObjects | public function loadAllSubDataObjects(
$name,
MDB2_Driver_Common $db,
$sql,
$wrapper,
$type = 'integer'
) {
$sub_data_objects = null;
$values = $this->getInternalValues($name);
$values = array_filter($values, function ($value) {
return $value !== null;
});
$values = array_unique($values);
if (count($values) > 0) {
$this->checkDB();
$this->db->loadModule('Datatype', null, true);
$quoted_values = $this->db->datatype->implodeArray($values, $type);
$sql = sprintf($sql, $quoted_values);
$sub_data_objects = SwatDB::query($db, $sql, $wrapper);
$this->attachSubDataObjects($name, $sub_data_objects);
}
return $sub_data_objects;
} | php | public function loadAllSubDataObjects(
$name,
MDB2_Driver_Common $db,
$sql,
$wrapper,
$type = 'integer'
) {
$sub_data_objects = null;
$values = $this->getInternalValues($name);
$values = array_filter($values, function ($value) {
return $value !== null;
});
$values = array_unique($values);
if (count($values) > 0) {
$this->checkDB();
$this->db->loadModule('Datatype', null, true);
$quoted_values = $this->db->datatype->implodeArray($values, $type);
$sql = sprintf($sql, $quoted_values);
$sub_data_objects = SwatDB::query($db, $sql, $wrapper);
$this->attachSubDataObjects($name, $sub_data_objects);
}
return $sub_data_objects;
} | [
"public",
"function",
"loadAllSubDataObjects",
"(",
"$",
"name",
",",
"MDB2_Driver_Common",
"$",
"db",
",",
"$",
"sql",
",",
"$",
"wrapper",
",",
"$",
"type",
"=",
"'integer'",
")",
"{",
"$",
"sub_data_objects",
"=",
"null",
";",
"$",
"values",
"=",
"$",... | Loads all sub-data-objects for an internal property of the data-objects
in this recordset
This is used to efficiently load sub-objects when there is a one-to-one
relationship between the objects in this recordset and the sub-objects.
This is usually the case when there is a foreign key constraint in the
database table for the objects in this recordset.
@param string $name name of the internal property to load.
@param MDB2_Driver_Common $db database object.
@param string $sql SQL to execute with placeholder for the set of
internal property values. For example:
<code>select * from Foo where id in (%s)</code>.
@param string $wrapper the class name of the recordset wrapper to use
for the sub-data-objects.
@param string $type optional. The MDB2 datatype of the internal property
values. If not specified, 'integer' is used.
@return SwatDBRecordsetWrapper an instance of the wrapper, or null. | [
"Loads",
"all",
"sub",
"-",
"data",
"-",
"objects",
"for",
"an",
"internal",
"property",
"of",
"the",
"data",
"-",
"objects",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L819-L846 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.attachSubDataObjects | public function attachSubDataObjects(
$name,
SwatDBRecordsetWrapper $sub_data_objects
) {
if ($sub_data_objects->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the sub-data-object ' .
'recordset wrapper class (%s::init()) ' .
'in order to attach recordset as sub-dataobjects.',
get_class($sub_data_objects)
)
);
}
foreach ($this->objects as $object) {
$value = $object->getInternalValue($name);
if (isset($sub_data_objects[$value])) {
$object->$name = $sub_data_objects[$value];
}
}
} | php | public function attachSubDataObjects(
$name,
SwatDBRecordsetWrapper $sub_data_objects
) {
if ($sub_data_objects->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the sub-data-object ' .
'recordset wrapper class (%s::init()) ' .
'in order to attach recordset as sub-dataobjects.',
get_class($sub_data_objects)
)
);
}
foreach ($this->objects as $object) {
$value = $object->getInternalValue($name);
if (isset($sub_data_objects[$value])) {
$object->$name = $sub_data_objects[$value];
}
}
} | [
"public",
"function",
"attachSubDataObjects",
"(",
"$",
"name",
",",
"SwatDBRecordsetWrapper",
"$",
"sub_data_objects",
")",
"{",
"if",
"(",
"$",
"sub_data_objects",
"->",
"index_field",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"sprintf",
... | Attach existing sub-dataobjects for an internal property of the
dataobjects in this recordset
@param string $name name of the property to attach to.
@param SwatDBRecordsetWrapper $sub_data_objects | [
"Attach",
"existing",
"sub",
"-",
"dataobjects",
"for",
"an",
"internal",
"property",
"of",
"the",
"dataobjects",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L858-L879 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getIndexes | public function getIndexes()
{
if ($this->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the recordset wrapper ' .
'class (%s::init()) in order to get the record indexes.',
get_class($this)
)
);
}
return array_keys($this->objects_by_index);
} | php | public function getIndexes()
{
if ($this->index_field === null) {
throw new SwatDBException(
sprintf(
'Index field must be specified in the recordset wrapper ' .
'class (%s::init()) in order to get the record indexes.',
get_class($this)
)
);
}
return array_keys($this->objects_by_index);
} | [
"public",
"function",
"getIndexes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"sprintf",
"(",
"'Index field must be specified in the recordset wrapper '",
".",
"'class (%s::init()) in o... | Gets the index values of the records in this recordset
@return array the index values of the records in this recordset. | [
"Gets",
"the",
"index",
"values",
"of",
"the",
"records",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1053-L1066 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getFirst | public function getFirst()
{
$first = null;
if (count($this->objects) > 0) {
$first = reset($this->objects);
}
return $first;
} | php | public function getFirst()
{
$first = null;
if (count($this->objects) > 0) {
$first = reset($this->objects);
}
return $first;
} | [
"public",
"function",
"getFirst",
"(",
")",
"{",
"$",
"first",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"objects",
")",
">",
"0",
")",
"{",
"$",
"first",
"=",
"reset",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"retu... | Retrieves the first object in this recordset
@return mixed the first object or null if there are no objects in this
recordset. | [
"Retrieves",
"the",
"first",
"object",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1091-L1100 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getLast | public function getLast()
{
$last = null;
if (count($this->objects) > 0) {
$last = end($this->objects);
}
return $last;
} | php | public function getLast()
{
$last = null;
if (count($this->objects) > 0) {
$last = end($this->objects);
}
return $last;
} | [
"public",
"function",
"getLast",
"(",
")",
"{",
"$",
"last",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"objects",
")",
">",
"0",
")",
"{",
"$",
"last",
"=",
"end",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"return",
... | Retrieves the last object in this recordset
@return mixed the last object or null if there are no objects in this
recordset. | [
"Retrieves",
"the",
"last",
"object",
"in",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1111-L1120 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.remove | public function remove(SwatDBDataObject $remove_object)
{
if (in_array($remove_object, $this->objects, true)) {
$this->removed_objects[] = $remove_object;
if ($this->index_field !== null) {
$index = $remove_object->{$this->index_field};
unset($this->objects_by_index[$index]);
}
$keys = array_keys($this->objects, $remove_object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if ($this->current_index >= $key && $this->current_index > 0) {
$this->current_index--;
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | php | public function remove(SwatDBDataObject $remove_object)
{
if (in_array($remove_object, $this->objects, true)) {
$this->removed_objects[] = $remove_object;
if ($this->index_field !== null) {
$index = $remove_object->{$this->index_field};
unset($this->objects_by_index[$index]);
}
$keys = array_keys($this->objects, $remove_object, true);
foreach ($keys as $key) {
unset($this->objects[$key]);
// update iterator index
if ($this->current_index >= $key && $this->current_index > 0) {
$this->current_index--;
}
}
// reindex ordinal array of records
$this->objects = array_values($this->objects);
}
} | [
"public",
"function",
"remove",
"(",
"SwatDBDataObject",
"$",
"remove_object",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"remove_object",
",",
"$",
"this",
"->",
"objects",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"[",
"]",
"=",... | Removes a record from this recordset
@param SwatDBDataObject $remove_object the record to remove. | [
"Removes",
"a",
"record",
"from",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1177-L1200 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.removeAll | public function removeAll()
{
$this->removed_objects = array_values($this->objects);
$this->objects = array();
$this->objects_by_index = array();
$this->current_index = 0;
} | php | public function removeAll()
{
$this->removed_objects = array_values($this->objects);
$this->objects = array();
$this->objects_by_index = array();
$this->current_index = 0;
} | [
"public",
"function",
"removeAll",
"(",
")",
"{",
"$",
"this",
"->",
"removed_objects",
"=",
"array_values",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"$",
"this",
"->",
"objects",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"objects_by_index",
... | Removes all records from this recordset | [
"Removes",
"all",
"records",
"from",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1230-L1236 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.reindex | public function reindex()
{
if ($this->index_field !== null) {
$this->objects_by_index = array();
$index_field = $this->index_field;
foreach ($this->objects as $object) {
if (isset($object->$index_field)) {
$this->objects_by_index[$object->$index_field] = $object;
}
}
}
} | php | public function reindex()
{
if ($this->index_field !== null) {
$this->objects_by_index = array();
$index_field = $this->index_field;
foreach ($this->objects as $object) {
if (isset($object->$index_field)) {
$this->objects_by_index[$object->$index_field] = $object;
}
}
}
} | [
"public",
"function",
"reindex",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"index_field",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"objects_by_index",
"=",
"array",
"(",
")",
";",
"$",
"index_field",
"=",
"$",
"this",
"->",
"index_field",
";",
... | Reindexes this recordset
Reindexing is useful when you have added new data-objects to this
recordset. Reindexing is only done if this recordset has a defined
index field. | [
"Reindexes",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1248-L1259 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.getPropertyValues | public function getPropertyValues($name)
{
$values = array();
if (count($this) > 0) {
if (!isset($this->getFirst()->$name)) {
throw new SwatDBException(
"Records in this recordset do not contain a property " .
"named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->$name;
}
}
return $values;
} | php | public function getPropertyValues($name)
{
$values = array();
if (count($this) > 0) {
if (!isset($this->getFirst()->$name)) {
throw new SwatDBException(
"Records in this recordset do not contain a property " .
"named '{$name}'."
);
}
foreach ($this->objects as $object) {
$values[] = $object->$name;
}
}
return $values;
} | [
"public",
"function",
"getPropertyValues",
"(",
"$",
"name",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getFirst",
"(",
... | Gets the values of a property for each record in this set
@param string $name name of the property to get.
@return array an array of values.
@throws SwatDBException if records in this recordset do not have a
property with the specified <i>$name</i>. | [
"Gets",
"the",
"values",
"of",
"a",
"property",
"for",
"each",
"record",
"in",
"this",
"set"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1274-L1292 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.setDatabase | public function setDatabase(MDB2_Driver_Common $db, array $set = array())
{
$key = spl_object_hash($this);
if (isset($set[$key])) {
// prevent infinite recursion on datastructure cycles
return;
}
$this->db = $db;
$set[$key] = true;
foreach ($this->objects as $object) {
if ($object instanceof SwatDBRecordable) {
$object->setDatabase($db, $set);
}
}
} | php | public function setDatabase(MDB2_Driver_Common $db, array $set = array())
{
$key = spl_object_hash($this);
if (isset($set[$key])) {
// prevent infinite recursion on datastructure cycles
return;
}
$this->db = $db;
$set[$key] = true;
foreach ($this->objects as $object) {
if ($object instanceof SwatDBRecordable) {
$object->setDatabase($db, $set);
}
}
} | [
"public",
"function",
"setDatabase",
"(",
"MDB2_Driver_Common",
"$",
"db",
",",
"array",
"$",
"set",
"=",
"array",
"(",
")",
")",
"{",
"$",
"key",
"=",
"spl_object_hash",
"(",
"$",
"this",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"set",
"[",
"$",
"k... | Sets the database driver for this recordset
The database is automatically set for all recordable records of this
recordset.
@param MDB2_Driver_Common $db the database driver to use for this
recordset.
@param array $set optional array of objects passed through
recursive call containing all objects that
have been set already. Prevents infinite
recursion. | [
"Sets",
"the",
"database",
"driver",
"for",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1312-L1329 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.save | public function save()
{
$this->checkDB();
$transaction = new SwatDBTransaction($this->db);
try {
foreach ($this->removed_objects as $object) {
$object->setDatabase($this->db);
$object->delete();
}
foreach ($this->objects as $object) {
$object->setDatabase($this->db);
$object->save();
}
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
throw $e;
}
$this->removed_objects = array();
$this->reindex();
} | php | public function save()
{
$this->checkDB();
$transaction = new SwatDBTransaction($this->db);
try {
foreach ($this->removed_objects as $object) {
$object->setDatabase($this->db);
$object->delete();
}
foreach ($this->objects as $object) {
$object->setDatabase($this->db);
$object->save();
}
$transaction->commit();
} catch (Exception $e) {
$transaction->rollback();
throw $e;
}
$this->removed_objects = array();
$this->reindex();
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"this",
"->",
"checkDB",
"(",
")",
";",
"$",
"transaction",
"=",
"new",
"SwatDBTransaction",
"(",
"$",
"this",
"->",
"db",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"removed_objects",
"... | Saves this recordset to the database
Saving a recordset works as follows:
1. Objects that were removed are deleted from the database.
2. Objects that were added are inserted into the database,
3. Objects that were modified are updated in the database,
Deleting is performed before adding incase a new row with the same
values as a deleted row is added. For example, a binding is removed and
an identical binding is added. | [
"Saves",
"this",
"recordset",
"to",
"the",
"database"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1346-L1369 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.load | public function load($object_indexes)
{
if (!is_array($object_indexes)) {
throw new SwatInvalidTypeException(
'The $object_indexes property must be an array.',
0,
$object_indexes
);
}
$interfaces = class_implements($this->row_wrapper_class);
if (!in_array('SwatDBRecordable', $interfaces)) {
throw new SwatInvalidClassException(
'The recordset must define a row wrapper class that is an ' .
'instance of SwatDBRecordable for recordset loading to work.',
0,
$this->row_wrapper_class
);
}
$success = true;
// try to load all records
$records = array();
$class_name = $this->row_wrapper_class;
foreach ($object_indexes as $index) {
$record = new $class_name();
$record->setDatabase($this->db);
if ($record->load($index)) {
$records[] = $record;
} else {
$success = false;
break;
}
}
// successfully loaded all records, set this set's records to the
// loaded records
if ($success) {
$this->objects = array();
$this->objects_by_index = array();
$this->removed_objects = array();
foreach ($records as $record) {
$this[] = $record;
}
$this->reindex();
}
return $success;
} | php | public function load($object_indexes)
{
if (!is_array($object_indexes)) {
throw new SwatInvalidTypeException(
'The $object_indexes property must be an array.',
0,
$object_indexes
);
}
$interfaces = class_implements($this->row_wrapper_class);
if (!in_array('SwatDBRecordable', $interfaces)) {
throw new SwatInvalidClassException(
'The recordset must define a row wrapper class that is an ' .
'instance of SwatDBRecordable for recordset loading to work.',
0,
$this->row_wrapper_class
);
}
$success = true;
// try to load all records
$records = array();
$class_name = $this->row_wrapper_class;
foreach ($object_indexes as $index) {
$record = new $class_name();
$record->setDatabase($this->db);
if ($record->load($index)) {
$records[] = $record;
} else {
$success = false;
break;
}
}
// successfully loaded all records, set this set's records to the
// loaded records
if ($success) {
$this->objects = array();
$this->objects_by_index = array();
$this->removed_objects = array();
foreach ($records as $record) {
$this[] = $record;
}
$this->reindex();
}
return $success;
} | [
"public",
"function",
"load",
"(",
"$",
"object_indexes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"object_indexes",
")",
")",
"{",
"throw",
"new",
"SwatInvalidTypeException",
"(",
"'The $object_indexes property must be an array.'",
",",
"0",
",",
"$",
"o... | Loads a set of records into this recordset
It is recommended for performance that you use recordset wrappers to
wrap a MDB2 result set rather than using this load() method. Using this
method performs N queries where N is the size of the passed array of
object indexes.
@param array $object_indexes the index field values of the records to
load into this recordset.
@return boolean true if all records loaded properly and false if one
or more records could not be loaded. If any records
fail to load, the recordset state remains unchanged.
@throws SwatInvalidTypeException if the <i>$object_indexes</i> property
is not an array.
@throws SwatInvalidClassException if this recordset's
{@link SwatDBRecordsetWrapper::$row_wrapper_class}
is not an instance of
{@link SwatDBRecordable}. | [
"Loads",
"a",
"set",
"of",
"records",
"into",
"this",
"recordset"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1396-L1447 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.isModified | public function isModified()
{
if (count($this->removed_objects) > 0) {
return true;
}
foreach ($this->objects as $name => $object) {
if ($object->isModified()) {
return true;
}
}
return false;
} | php | public function isModified()
{
if (count($this->removed_objects) > 0) {
return true;
}
foreach ($this->objects as $name => $object) {
if ($object->isModified()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isModified",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"removed_objects",
")",
">",
"0",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"name",
"=>",
"$",
"obje... | Returns true if this recordset has been modified since it was loaded
A recordset is considered modified if any of the contained records have
been modified or if any records have been removed from this set. Adding
an unmodified record to this set does not constitute modifying the set.
@return boolean true if this recordset was modified and false if this
recordset was not modified. | [
"Returns",
"true",
"if",
"this",
"recordset",
"has",
"been",
"modified",
"since",
"it",
"was",
"loaded"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1477-L1490 | train |
silverorange/swat | SwatDB/SwatDBRecordsetWrapper.php | SwatDBRecordsetWrapper.setFlushableCache | public function setFlushableCache(SwatDBCacheNsFlushable $cache)
{
foreach ($this->objects as $object) {
if ($object instanceof SwatDBFlushable) {
$object->setFlushableCache($cache);
}
}
} | php | public function setFlushableCache(SwatDBCacheNsFlushable $cache)
{
foreach ($this->objects as $object) {
if ($object instanceof SwatDBFlushable) {
$object->setFlushableCache($cache);
}
}
} | [
"public",
"function",
"setFlushableCache",
"(",
"SwatDBCacheNsFlushable",
"$",
"cache",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"SwatDBFlushable",
")",
"{",
"$",
"object",... | Sets the flushable cache to use for this record-set
Using a flushable cache allows clearing the cache when the records
are modified or deleted.
@param SwatDBCacheNsFlushable $cache The flushable cache to use for
this dataobject. | [
"Sets",
"the",
"flushable",
"cache",
"to",
"use",
"for",
"this",
"record",
"-",
"set"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBRecordsetWrapper.php#L1504-L1511 | train |
brainworxx/kreXX | src/Analyse/Routing/Process/ProcessInteger.php | ProcessInteger.process | public function process(Model $model)
{
return $this->pool->render->renderSingleChild(
$model->setNormal($model->getData())->setType(static::TYPE_INTEGER)
);
} | php | public function process(Model $model)
{
return $this->pool->render->renderSingleChild(
$model->setNormal($model->getData())->setType(static::TYPE_INTEGER)
);
} | [
"public",
"function",
"process",
"(",
"Model",
"$",
"model",
")",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"render",
"->",
"renderSingleChild",
"(",
"$",
"model",
"->",
"setNormal",
"(",
"$",
"model",
"->",
"getData",
"(",
")",
")",
"->",
"setTy... | Render a dump for a integer value.
@param Model $model
The data we are analysing.
@return string
The rendered markup. | [
"Render",
"a",
"dump",
"for",
"a",
"integer",
"value",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Routing/Process/ProcessInteger.php#L56-L61 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getModifiedProperties | public function getModifiedProperties()
{
if ($this->read_only) {
return array();
}
$modified_properties = array();
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
array_key_exists($name, $this->property_hashes) &&
$hashed_value !== $this->property_hashes[$name]
) {
$modified_properties[$name] = $value;
}
}
return $modified_properties;
} | php | public function getModifiedProperties()
{
if ($this->read_only) {
return array();
}
$modified_properties = array();
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
array_key_exists($name, $this->property_hashes) &&
$hashed_value !== $this->property_hashes[$name]
) {
$modified_properties[$name] = $value;
}
}
return $modified_properties;
} | [
"public",
"function",
"getModifiedProperties",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"modified_properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPr... | Gets a list of all the modified properties of this object
@return array an array of modified properties and their values in the
form of: name => value | [
"Gets",
"a",
"list",
"of",
"all",
"the",
"modified",
"properties",
"of",
"this",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L146-L164 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.duplicate | public function duplicate()
{
$class = get_class($this);
$new_object = new $class();
$id_field = new SwatDBField($this->id_field, 'integer');
// public properties
$properties = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
foreach ($properties as $name => $value) {
if ($name !== $id_field->name) {
$new_object->$name = $this->$name;
}
}
// sub-dataobjects
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
$object->setDatabase($this->db);
if (method_exists($this, $saver_method)) {
$new_object->$name = $object->duplicate();
} elseif (!array_key_exists($name, $this->internal_properties)) {
$new_object->$name = $object;
}
}
// internal properties
foreach ($this->internal_properties as $name => $value) {
if (
!(
array_key_exists(
$name,
$this->internal_property_accessible
) && $this->internal_property_accessible[$name]
)
) {
continue;
}
$autosave = $this->internal_property_autosave[$name];
if ($this->hasSubDataObject($name)) {
$object = $this->getSubDataObject($name);
if ($autosave) {
$new_object->$name = $object->duplicate();
} else {
$new_object->$name = $object;
}
} else {
$new_object->$name = $value;
}
}
$new_object->setDatabase($this->db);
return $new_object;
} | php | public function duplicate()
{
$class = get_class($this);
$new_object = new $class();
$id_field = new SwatDBField($this->id_field, 'integer');
// public properties
$properties = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
foreach ($properties as $name => $value) {
if ($name !== $id_field->name) {
$new_object->$name = $this->$name;
}
}
// sub-dataobjects
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
$object->setDatabase($this->db);
if (method_exists($this, $saver_method)) {
$new_object->$name = $object->duplicate();
} elseif (!array_key_exists($name, $this->internal_properties)) {
$new_object->$name = $object;
}
}
// internal properties
foreach ($this->internal_properties as $name => $value) {
if (
!(
array_key_exists(
$name,
$this->internal_property_accessible
) && $this->internal_property_accessible[$name]
)
) {
continue;
}
$autosave = $this->internal_property_autosave[$name];
if ($this->hasSubDataObject($name)) {
$object = $this->getSubDataObject($name);
if ($autosave) {
$new_object->$name = $object->duplicate();
} else {
$new_object->$name = $object;
}
} else {
$new_object->$name = $value;
}
}
$new_object->setDatabase($this->db);
return $new_object;
} | [
"public",
"function",
"duplicate",
"(",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"new_object",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"id_field",
"=",
"new",
"SwatDBField",
"(",
"$",
"this",
"->",
"id_field",
... | Duplicates this object
A duplicate is less of an exact copy than a true clone. Like a clone, a
duplicate has all the same public property values. Unlike a clone, a
duplicate does not have an id and therefore can be saved to the
database as a new row. This method recursively duplicates
sub-dataobjects which were registered with <i>$autosave</i> set to true.
@return SwatDBDataobject a duplicate of this object. | [
"Duplicates",
"this",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L436-L497 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.initFromRow | protected function initFromRow($row)
{
if ($row === null) {
throw new SwatDBException(
'Attempting to initialize dataobject with a null row.'
);
}
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
if (is_object($row)) {
$row = get_object_vars($row);
}
foreach ($property_array as $name => $value) {
// Use array_key_exists() instead of isset(), because isset() will
// return false when the value is null. Null values on properties
// should not be ignored - otherwise calling initFromRow() on an
// existing dataobject can leave out of date values on properties
// when those values were updated to null.
if (array_key_exists($name, $row)) {
if (
in_array($name, $this->date_properties) &&
$row[$name] !== null
) {
$this->$name = new SwatDate($row[$name]);
} else {
$this->$name = $row[$name];
}
}
}
foreach ($this->internal_properties as $name => $value) {
if (isset($row[$name])) {
$this->internal_properties[$name] = $row[$name];
}
}
$this->loaded_from_database = true;
} | php | protected function initFromRow($row)
{
if ($row === null) {
throw new SwatDBException(
'Attempting to initialize dataobject with a null row.'
);
}
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties()
);
if (is_object($row)) {
$row = get_object_vars($row);
}
foreach ($property_array as $name => $value) {
// Use array_key_exists() instead of isset(), because isset() will
// return false when the value is null. Null values on properties
// should not be ignored - otherwise calling initFromRow() on an
// existing dataobject can leave out of date values on properties
// when those values were updated to null.
if (array_key_exists($name, $row)) {
if (
in_array($name, $this->date_properties) &&
$row[$name] !== null
) {
$this->$name = new SwatDate($row[$name]);
} else {
$this->$name = $row[$name];
}
}
}
foreach ($this->internal_properties as $name => $value) {
if (isset($row[$name])) {
$this->internal_properties[$name] = $row[$name];
}
}
$this->loaded_from_database = true;
} | [
"protected",
"function",
"initFromRow",
"(",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"row",
"===",
"null",
")",
"{",
"throw",
"new",
"SwatDBException",
"(",
"'Attempting to initialize dataobject with a null row.'",
")",
";",
"}",
"$",
"property_array",
"=",
"array... | Takes a data row and sets the properties of this object according to
the values of the row
Subclasses can override this method to provide additional
functionality.
@param mixed $row the row to use as either an array or object. | [
"Takes",
"a",
"data",
"row",
"and",
"sets",
"the",
"properties",
"of",
"this",
"object",
"according",
"to",
"the",
"values",
"of",
"the",
"row"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L583-L625 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.generatePropertyHashes | protected function generatePropertyHashes()
{
if ($this->read_only) {
return;
}
// Note: SwatDBDataObject::generatePropertyHash() is not used
// here because it would mean calling the expensive getProperties()
// method in a loop.
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
$this->property_hashes[$name] = $hashed_value;
}
} | php | protected function generatePropertyHashes()
{
if ($this->read_only) {
return;
}
// Note: SwatDBDataObject::generatePropertyHash() is not used
// here because it would mean calling the expensive getProperties()
// method in a loop.
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
$this->property_hashes[$name] = $hashed_value;
}
} | [
"protected",
"function",
"generatePropertyHashes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
";",
"}",
"// Note: SwatDBDataObject::generatePropertyHash() is not used",
"// here because it would mean calling the expensive getProperties()",
"//... | Generates the set of md5 hashes for this data object
The md5 hashes represent all the public properties of this object and
are used to tell if a property has been modified. | [
"Generates",
"the",
"set",
"of",
"md5",
"hashes",
"for",
"this",
"data",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L636-L649 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.generatePropertyHash | protected function generatePropertyHash($property)
{
if ($this->read_only) {
return;
}
$property_array = $this->getProperties();
if (isset($property_array[$property])) {
$hashed_value = $this->getHashValue($property_array[$property]);
$this->property_hashes[$property] = $hashed_value;
}
} | php | protected function generatePropertyHash($property)
{
if ($this->read_only) {
return;
}
$property_array = $this->getProperties();
if (isset($property_array[$property])) {
$hashed_value = $this->getHashValue($property_array[$property]);
$this->property_hashes[$property] = $hashed_value;
}
} | [
"protected",
"function",
"generatePropertyHash",
"(",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
";",
"}",
"$",
"property_array",
"=",
"$",
"this",
"->",
"getProperties",
"(",
")",
";",
"if",
"(",
"isset",
... | Generates the MD5 hash for a property of this object
@param string $property the name of the property for which to generate
the hash. | [
"Generates",
"the",
"MD5",
"hash",
"for",
"a",
"property",
"of",
"this",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L660-L672 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getPublicProperties | private function getPublicProperties()
{
$class = get_class($this);
// cache class public property names since reflection is expensive
if (!array_key_exists($class, self::$public_properties_cache)) {
$public_properties = array();
$reflector = new ReflectionClass($class);
foreach ($reflector->getProperties() as $property) {
if ($property->isPublic() && !$property->isStatic()) {
$public_properties[] = $property->getName();
}
}
self::$public_properties_cache[$class] = $public_properties;
}
// get property values for this object
$names = self::$public_properties_cache[$class];
$properties = array();
foreach ($names as $name) {
$properties[$name] = $this->$name;
}
return $properties;
} | php | private function getPublicProperties()
{
$class = get_class($this);
// cache class public property names since reflection is expensive
if (!array_key_exists($class, self::$public_properties_cache)) {
$public_properties = array();
$reflector = new ReflectionClass($class);
foreach ($reflector->getProperties() as $property) {
if ($property->isPublic() && !$property->isStatic()) {
$public_properties[] = $property->getName();
}
}
self::$public_properties_cache[$class] = $public_properties;
}
// get property values for this object
$names = self::$public_properties_cache[$class];
$properties = array();
foreach ($names as $name) {
$properties[$name] = $this->$name;
}
return $properties;
} | [
"private",
"function",
"getPublicProperties",
"(",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"// cache class public property names since reflection is expensive",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"class",
",",
"self",
"::",
... | Gets the public properties of this data-object
Public properties should correspond directly to database fields.
@return array a reference to an associative array of public properties
of this data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"the",
"public",
"properties",
"of",
"this",
"data",
"-",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L802-L828 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getSerializableProtectedProperties | private function getSerializableProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// We want to maintain what is internally stored in this object so
// we don't want to use the getter. What the getter returns
// publicly may be different than what we have internally.
$properties[$property] = $this->$property;
}
return $properties;
} | php | private function getSerializableProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// We want to maintain what is internally stored in this object so
// we don't want to use the getter. What the getter returns
// publicly may be different than what we have internally.
$properties[$property] = $this->$property;
}
return $properties;
} | [
"private",
"function",
"getSerializableProtectedProperties",
"(",
")",
"{",
"$",
"properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getProtectedPropertyList",
"(",
")",
"as",
"$",
"property",
"=>",
"$",
"accessors",
")",
"{",
"// ... | Gets the serializable protected properties of this data-object.
Protected properties should correspond directly to database fields.
@return array a reference to an associative array of protected properties
of this data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"the",
"serializable",
"protected",
"properties",
"of",
"this",
"data",
"-",
"object",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L842-L853 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.getProtectedProperties | private function getProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// Use the getter for the property.
$properties[$property] = $this->{$accessors['get']}();
}
return $properties;
} | php | private function getProtectedProperties()
{
$properties = array();
foreach ($this->getProtectedPropertyList() as $property => $accessors) {
// Use the getter for the property.
$properties[$property] = $this->{$accessors['get']}();
}
return $properties;
} | [
"private",
"function",
"getProtectedProperties",
"(",
")",
"{",
"$",
"properties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getProtectedPropertyList",
"(",
")",
"as",
"$",
"property",
"=>",
"$",
"accessors",
")",
"{",
"// Use the gett... | Gets the protected properties of this data-object using the getter
accessor.
Protected properties should correspond directly to database fields.
@return array a reference to an associative array of protected properties
of this data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"the",
"protected",
"properties",
"of",
"this",
"data",
"-",
"object",
"using",
"the",
"getter",
"accessor",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L868-L877 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.& | private function &getProperties()
{
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties(),
$this->internal_properties
);
return $property_array;
} | php | private function &getProperties()
{
$property_array = array_merge(
$this->getPublicProperties(),
$this->getSerializableProtectedProperties(),
$this->internal_properties
);
return $property_array;
} | [
"private",
"function",
"&",
"getProperties",
"(",
")",
"{",
"$",
"property_array",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getPublicProperties",
"(",
")",
",",
"$",
"this",
"->",
"getSerializableProtectedProperties",
"(",
")",
",",
"$",
"this",
"->",
"i... | Gets all the modifyable properties of this data-object
This includes the public and protected properties that correspond to
database fields and the internal values that also correspond to database
fields.
@return array a reference to an associative array of properties of this
data-object. The array is of the form
'property name' => 'property value'. | [
"Gets",
"all",
"the",
"modifyable",
"properties",
"of",
"this",
"data",
"-",
"object"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L893-L902 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.isModified | public function isModified()
{
if ($this->read_only) {
return false;
}
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
isset($this->property_hashes[$name]) &&
$hashed_value !== $this->property_hashes[$name]
) {
return true;
}
}
foreach ($this->internal_property_autosave as $name => $autosave) {
if ($autosave && isset($this->sub_data_objects[$name])) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
if (method_exists($this, $saver_method)) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
return false;
} | php | public function isModified()
{
if ($this->read_only) {
return false;
}
foreach ($this->getProperties() as $name => $value) {
$hashed_value = $this->getHashValue($value);
if (
isset($this->property_hashes[$name]) &&
$hashed_value !== $this->property_hashes[$name]
) {
return true;
}
}
foreach ($this->internal_property_autosave as $name => $autosave) {
if ($autosave && isset($this->sub_data_objects[$name])) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
foreach ($this->sub_data_objects as $name => $object) {
$saver_method =
'save' . str_replace(' ', '', ucwords(strtr($name, '_', ' ')));
if (method_exists($this, $saver_method)) {
$object = $this->sub_data_objects[$name];
if (
$object instanceof SwatDBRecordable &&
$object->isModified()
) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"isModified",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"read_only",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getProperties",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",... | Returns true if this object has been modified since it was loaded
@return boolean true if this object was modified and false if this
object was not modified. | [
"Returns",
"true",
"if",
"this",
"object",
"has",
"been",
"modified",
"since",
"it",
"was",
"loaded"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L1144-L1188 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.saveNewBinding | protected function saveNewBinding()
{
$modified_properties = $this->getModifiedProperties();
if (count($modified_properties) === 0) {
return;
}
$fields = array();
$values = array();
foreach ($this->getModifiedProperties() as $name => $value) {
$type = $this->guessType($name, $value);
$fields[] = sprintf('%s:%s', $type, $name);
$values[$name] = $value;
}
SwatDB::insertRow($this->db, $this->table, $fields, $values);
$this->flushCacheNamespaces();
} | php | protected function saveNewBinding()
{
$modified_properties = $this->getModifiedProperties();
if (count($modified_properties) === 0) {
return;
}
$fields = array();
$values = array();
foreach ($this->getModifiedProperties() as $name => $value) {
$type = $this->guessType($name, $value);
$fields[] = sprintf('%s:%s', $type, $name);
$values[$name] = $value;
}
SwatDB::insertRow($this->db, $this->table, $fields, $values);
$this->flushCacheNamespaces();
} | [
"protected",
"function",
"saveNewBinding",
"(",
")",
"{",
"$",
"modified_properties",
"=",
"$",
"this",
"->",
"getModifiedProperties",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"modified_properties",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$",
... | Saves a new binding object without an id to the database
Only modified properties are saved. It is always inserted,
never updated. | [
"Saves",
"a",
"new",
"binding",
"object",
"without",
"an",
"id",
"to",
"the",
"database"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L1429-L1448 | train |
silverorange/swat | SwatDB/SwatDBDataObject.php | SwatDBDataObject.flushCacheNamespaces | public function flushCacheNamespaces($ns_array = null)
{
if ($ns_array === null) {
$ns_array = $this->getCacheNamespaces();
}
if ($this->flushable_cache instanceof SwatDBCacheNsFlushable) {
$ns_array = array_unique($ns_array);
foreach ($ns_array as $ns) {
$this->flushable_cache->flushNs($ns);
}
}
} | php | public function flushCacheNamespaces($ns_array = null)
{
if ($ns_array === null) {
$ns_array = $this->getCacheNamespaces();
}
if ($this->flushable_cache instanceof SwatDBCacheNsFlushable) {
$ns_array = array_unique($ns_array);
foreach ($ns_array as $ns) {
$this->flushable_cache->flushNs($ns);
}
}
} | [
"public",
"function",
"flushCacheNamespaces",
"(",
"$",
"ns_array",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"ns_array",
"===",
"null",
")",
"{",
"$",
"ns_array",
"=",
"$",
"this",
"->",
"getCacheNamespaces",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
... | Flushes the cache name-spaces for this object.
@param array $ns_array An optional array of name-spaces to flush.
If no name-spaces are specified,
{@link SwatDBDataObject::getCacheNamespaces()} is
used to get the array of name-spaces.
@see SwatDBDataObject::setFlushableCache()
@see SwatDBDataObject::getCacheNamespaces() | [
"Flushes",
"the",
"cache",
"name",
"-",
"spaces",
"for",
"this",
"object",
"."
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDBDataObject.php#L1544-L1556 | train |
honey-comb/core | src/Http/Controllers/HCBaseController.php | HCBaseController.getUserActions | protected function getUserActions(string $prefix, array $except = []): array
{
$actions = [];
if (!in_array('_search', $except)) {
$actions[] = 'search';
}
if (!in_array('_create', $except) && auth()->user()->can($prefix . '_create')) {
$actions[] = 'new';
}
if (!in_array('_update', $except) && auth()->user()->can($prefix . '_update')) {
$actions[] = 'update';
}
if (!in_array('_delete', $except) && auth()->user()->can($prefix . '_delete')) {
$actions[] = 'delete';
}
if (!in_array('_restore', $except) && auth()->user()->can($prefix . '_restore')) {
$actions[] = 'restore';
}
if (!in_array('_force_delete', $except) && auth()->user()->can($prefix . '_force_delete')) {
$actions[] = 'forceDelete';
}
if (!in_array('_merge', $except) && auth()->user()->can($prefix . '_merge')) {
$actions[] = 'merge';
}
if (!in_array('_clone', $except) && auth()->user()->can($prefix . '_clone')) {
$actions[] = 'clone';
}
return $actions;
} | php | protected function getUserActions(string $prefix, array $except = []): array
{
$actions = [];
if (!in_array('_search', $except)) {
$actions[] = 'search';
}
if (!in_array('_create', $except) && auth()->user()->can($prefix . '_create')) {
$actions[] = 'new';
}
if (!in_array('_update', $except) && auth()->user()->can($prefix . '_update')) {
$actions[] = 'update';
}
if (!in_array('_delete', $except) && auth()->user()->can($prefix . '_delete')) {
$actions[] = 'delete';
}
if (!in_array('_restore', $except) && auth()->user()->can($prefix . '_restore')) {
$actions[] = 'restore';
}
if (!in_array('_force_delete', $except) && auth()->user()->can($prefix . '_force_delete')) {
$actions[] = 'forceDelete';
}
if (!in_array('_merge', $except) && auth()->user()->can($prefix . '_merge')) {
$actions[] = 'merge';
}
if (!in_array('_clone', $except) && auth()->user()->can($prefix . '_clone')) {
$actions[] = 'clone';
}
return $actions;
} | [
"protected",
"function",
"getUserActions",
"(",
"string",
"$",
"prefix",
",",
"array",
"$",
"except",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"actions",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"'_search'",
",",
"$",
"except",
")",
... | Getting allowed actions for admin view
@param string $prefix
@param array $except
@return array
@throws \Illuminate\Contracts\Container\BindingResolutionException | [
"Getting",
"allowed",
"actions",
"for",
"admin",
"view"
] | 5c12aba31cae092e9681f0ae3e3664ed3fcec956 | https://github.com/honey-comb/core/blob/5c12aba31cae092e9681f0ae3e3664ed3fcec956/src/Http/Controllers/HCBaseController.php#L59-L96 | train |
brainworxx/kreXX | src/Analyse/Callback/Iterate/ThroughConstants.php | ThroughConstants.callMe | public function callMe()
{
$output = $this->dispatchStartEvent();
// We do not need to check the recursionHandler, this is class
// internal stuff. Is it even possible to create a recursion here?
// Iterate through.
foreach ($this->parameters[static::PARAM_DATA] as $k => &$v) {
$output .= $this->pool->routing->analysisHub(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setData($v)
->setName($k)
->setCustomConnectorLeft($this->parameters[static::PARAM_CLASSNAME] . '::')
);
}
return $output;
} | php | public function callMe()
{
$output = $this->dispatchStartEvent();
// We do not need to check the recursionHandler, this is class
// internal stuff. Is it even possible to create a recursion here?
// Iterate through.
foreach ($this->parameters[static::PARAM_DATA] as $k => &$v) {
$output .= $this->pool->routing->analysisHub(
$this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model')
->setData($v)
->setName($k)
->setCustomConnectorLeft($this->parameters[static::PARAM_CLASSNAME] . '::')
);
}
return $output;
} | [
"public",
"function",
"callMe",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"dispatchStartEvent",
"(",
")",
";",
"// We do not need to check the recursionHandler, this is class",
"// internal stuff. Is it even possible to create a recursion here?",
"// Iterate through."... | Simply iterate though object constants.
@return string
The generated markup. | [
"Simply",
"iterate",
"though",
"object",
"constants",
"."
] | a03beaa4507ffb391412b9ac61593d263d3f8bca | https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughConstants.php#L62-L79 | train |
silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.init | public function init()
{
parent::init();
// checks to see if there are duplicate values in the options array
$options_count = array();
foreach ($this->getOptions() as $option) {
$options_count[] = $option->value;
}
foreach (array_count_values($options_count) as $count) {
if ($count > 1) {
throw new SwatException(
sprintf('Duplicate option values found in %s', $this->id)
);
}
}
} | php | public function init()
{
parent::init();
// checks to see if there are duplicate values in the options array
$options_count = array();
foreach ($this->getOptions() as $option) {
$options_count[] = $option->value;
}
foreach (array_count_values($options_count) as $count) {
if ($count > 1) {
throw new SwatException(
sprintf('Duplicate option values found in %s', $this->id)
);
}
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// checks to see if there are duplicate values in the options array",
"$",
"options_count",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")... | Initializes this checkbox list
@throws SwatException if there are duplicate values in the options array | [
"Initializes",
"this",
"checkbox",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L83-L100 | train |
silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.process | public function process()
{
if (!$this->getForm()->isSubmitted()) {
return;
}
parent::process();
$this->processValues();
if (
$this->required &&
count($this->values) == 0 &&
$this->isSensitive()
) {
$this->addMessage($this->getValidationMessage('required'));
}
} | php | public function process()
{
if (!$this->getForm()->isSubmitted()) {
return;
}
parent::process();
$this->processValues();
if (
$this->required &&
count($this->values) == 0 &&
$this->isSensitive()
) {
$this->addMessage($this->getValidationMessage('required'));
}
} | [
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"return",
";",
"}",
"parent",
"::",
"process",
"(",
")",
";",
"$",
"this",
"->",
"processValues",
"(",
... | Processes this checkbox list widget | [
"Processes",
"this",
"checkbox",
"list",
"widget"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L197-L214 | train |
silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.processValues | protected function processValues()
{
$form = $this->getForm();
$data = &$form->getFormData();
if (isset($data[$this->id])) {
if (is_array($data[$this->id])) {
$this->values = $data[$this->id];
} elseif ($data[$this->id] != '') {
$this->values = array($data[$this->id]);
} else {
$this->values = array();
}
} else {
$this->values = array();
}
} | php | protected function processValues()
{
$form = $this->getForm();
$data = &$form->getFormData();
if (isset($data[$this->id])) {
if (is_array($data[$this->id])) {
$this->values = $data[$this->id];
} elseif ($data[$this->id] != '') {
$this->values = array($data[$this->id]);
} else {
$this->values = array();
}
} else {
$this->values = array();
}
} | [
"protected",
"function",
"processValues",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"$",
"data",
"=",
"&",
"$",
"form",
"->",
"getFormData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"this"... | Processes the values of this checkbox list from raw form data | [
"Processes",
"the",
"values",
"of",
"this",
"checkbox",
"list",
"from",
"raw",
"form",
"data"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L266-L282 | train |
silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.displayOption | protected function displayOption(SwatOption $option, $index)
{
$input_tag = new SwatHtmlTag('input');
$input_tag->type = 'checkbox';
$input_tag->name = $this->id . '[' . $index . ']';
$input_tag->value = (string) $option->value;
$input_tag->id = $this->id . '_' . $index;
$input_tag->removeAttribute('checked');
if (in_array($option->value, $this->values)) {
$input_tag->checked = 'checked';
}
if (!$this->isSensitive()) {
$input_tag->disabled = 'disabled';
}
$li_tag = $this->getLiTag($option);
$li_tag->open();
echo '<span class="swat-checkbox-wrapper">';
$input_tag->display();
echo '<span class="swat-checkbox-shim"></span>';
echo '</span>';
$this->displayOptionLabel($option, $index);
$li_tag->close();
} | php | protected function displayOption(SwatOption $option, $index)
{
$input_tag = new SwatHtmlTag('input');
$input_tag->type = 'checkbox';
$input_tag->name = $this->id . '[' . $index . ']';
$input_tag->value = (string) $option->value;
$input_tag->id = $this->id . '_' . $index;
$input_tag->removeAttribute('checked');
if (in_array($option->value, $this->values)) {
$input_tag->checked = 'checked';
}
if (!$this->isSensitive()) {
$input_tag->disabled = 'disabled';
}
$li_tag = $this->getLiTag($option);
$li_tag->open();
echo '<span class="swat-checkbox-wrapper">';
$input_tag->display();
echo '<span class="swat-checkbox-shim"></span>';
echo '</span>';
$this->displayOptionLabel($option, $index);
$li_tag->close();
} | [
"protected",
"function",
"displayOption",
"(",
"SwatOption",
"$",
"option",
",",
"$",
"index",
")",
"{",
"$",
"input_tag",
"=",
"new",
"SwatHtmlTag",
"(",
"'input'",
")",
";",
"$",
"input_tag",
"->",
"type",
"=",
"'checkbox'",
";",
"$",
"input_tag",
"->",
... | Helper method to display a single option of this checkbox list
@param SwatOption $option the option to display.
@param integer $index a numeric index indicating which option is being
displayed. Starts as 0. | [
"Helper",
"method",
"to",
"display",
"a",
"single",
"option",
"of",
"this",
"checkbox",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L294-L320 | train |
silverorange/swat | Swat/SwatCheckboxList.php | SwatCheckboxList.getInlineJavaScript | protected function getInlineJavaScript()
{
$javascript = sprintf(
'var %s_obj = new %s(%s);',
$this->id,
$this->getJavaScriptClassName(),
SwatString::quoteJavaScriptString($this->id)
);
// set check-all controller if it is visible
$check_all = $this->getCompositeWidget('check_all');
if ($check_all->visible) {
$javascript .= sprintf(
"\n%s_obj.setController(%s_obj);",
$check_all->id,
$this->id
);
}
return $javascript;
} | php | protected function getInlineJavaScript()
{
$javascript = sprintf(
'var %s_obj = new %s(%s);',
$this->id,
$this->getJavaScriptClassName(),
SwatString::quoteJavaScriptString($this->id)
);
// set check-all controller if it is visible
$check_all = $this->getCompositeWidget('check_all');
if ($check_all->visible) {
$javascript .= sprintf(
"\n%s_obj.setController(%s_obj);",
$check_all->id,
$this->id
);
}
return $javascript;
} | [
"protected",
"function",
"getInlineJavaScript",
"(",
")",
"{",
"$",
"javascript",
"=",
"sprintf",
"(",
"'var %s_obj = new %s(%s);'",
",",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"getJavaScriptClassName",
"(",
")",
",",
"SwatString",
"::",
"quoteJavaScri... | Gets the inline JavaScript for this checkbox list
@return string the inline JavaScript for this checkbox list. | [
"Gets",
"the",
"inline",
"JavaScript",
"for",
"this",
"checkbox",
"list"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCheckboxList.php#L379-L399 | train |
silverorange/swat | Swat/SwatWidgetCellRenderer.php | SwatWidgetCellRenderer.init | public function init()
{
$replicators = null;
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
if ($replicators !== null) {
foreach ($replicators as $replicator) {
$this->createClonedWidget($replicator);
}
}
}
if ($replicators === null) {
$this->prototype_widget->init();
}
} | php | public function init()
{
$replicators = null;
$form = $this->getForm();
if ($form !== null && $form->isSubmitted()) {
$replicators = $form->getHiddenField(
$this->getReplicatorFieldName()
);
if ($replicators !== null) {
foreach ($replicators as $replicator) {
$this->createClonedWidget($replicator);
}
}
}
if ($replicators === null) {
$this->prototype_widget->init();
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"replicators",
"=",
"null",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"$",
"form",
"!==",
"null",
"&&",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
... | Initializes this cell renderer
This calls {@link SwatWidget::init()} on this renderer's widget. | [
"Initializes",
"this",
"cell",
"renderer"
] | e65dc5bc351927c61f594068430cdeeb874c8bc5 | https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatWidgetCellRenderer.php#L140-L160 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.