id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
34,200
silverorange/swat
Swat/SwatTileView.php
SwatTileView.displayTileGroupHeaders
public function displayTileGroupHeaders($record, $next_record) { foreach ($this->groups as $group) { $group->display($record); } }
php
public function displayTileGroupHeaders($record, $next_record) { foreach ($this->groups as $group) { $group->display($record); } }
[ "public", "function", "displayTileGroupHeaders", "(", "$", "record", ",", "$", "next_record", ")", "{", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "$", "group", "->", "display", "(", "$", "record", ")", ";", "}", "}" ]
Displays tile group headers @param mixed $record the record to display. @param mixed $next_record the next record to display. If there is no next record, this is null.
[ "Displays", "tile", "group", "headers" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L384-L389
34,201
silverorange/swat
Swat/SwatTileView.php
SwatTileView.displayTileGroupFooters
public function displayTileGroupFooters($record, $next_record) { foreach ($this->groups as $group) { $group->displayFooter($record, $next_record); } }
php
public function displayTileGroupFooters($record, $next_record) { foreach ($this->groups as $group) { $group->displayFooter($record, $next_record); } }
[ "public", "function", "displayTileGroupFooters", "(", "$", "record", ",", "$", "next_record", ")", "{", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "$", "group", "->", "displayFooter", "(", "$", "record", ",", "$", "next_record", ")", ";", "}", "}" ]
Displays tile group footers @param mixed $record the record to display. @param mixed $next_record the next record to display. If there is no next record, this is null.
[ "Displays", "tile", "group", "footers" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L401-L406
34,202
silverorange/swat
Swat/SwatTileView.php
SwatTileView.getMessages
public function getMessages() { $messages = parent::getMessages(); if ($this->tile !== null) { $messages = array_merge($messages, $this->tile->getMessages()); } return $messages; }
php
public function getMessages() { $messages = parent::getMessages(); if ($this->tile !== null) { $messages = array_merge($messages, $this->tile->getMessages()); } return $messages; }
[ "public", "function", "getMessages", "(", ")", "{", "$", "messages", "=", "parent", "::", "getMessages", "(", ")", ";", "if", "(", "$", "this", "->", "tile", "!==", "null", ")", "{", "$", "messages", "=", "array_merge", "(", "$", "messages", ",", "$", "this", "->", "tile", "->", "getMessages", "(", ")", ")", ";", "}", "return", "$", "messages", ";", "}" ]
Gathers all messages from this tile view @return array an array of {@link SwatMessage} objects.
[ "Gathers", "all", "messages", "from", "this", "tile", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L600-L608
34,203
silverorange/swat
Swat/SwatTileView.php
SwatTileView.hasMessage
public function hasMessage() { $has_message = parent::hasMessage(); if (!$has_message && $this->tile !== null) { $has_message = $this->tile->hasMessage(); } return $has_message; }
php
public function hasMessage() { $has_message = parent::hasMessage(); if (!$has_message && $this->tile !== null) { $has_message = $this->tile->hasMessage(); } return $has_message; }
[ "public", "function", "hasMessage", "(", ")", "{", "$", "has_message", "=", "parent", "::", "hasMessage", "(", ")", ";", "if", "(", "!", "$", "has_message", "&&", "$", "this", "->", "tile", "!==", "null", ")", "{", "$", "has_message", "=", "$", "this", "->", "tile", "->", "hasMessage", "(", ")", ";", "}", "return", "$", "has_message", ";", "}" ]
Gets whether or not this tile view has any messages @return boolean true if this tile view has one or more messages and false if it does not.
[ "Gets", "whether", "or", "not", "this", "tile", "view", "has", "any", "messages" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L619-L627
34,204
silverorange/swat
Swat/SwatTileView.php
SwatTileView.getHtmlHeadEntrySet
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); if ($this->tile !== null) { $set->addEntrySet($this->tile->getHtmlHeadEntrySet()); } foreach ($this->groups as $group) { $set->addEntrySet($group->getHtmlHeadEntrySet()); } return $set; }
php
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); if ($this->tile !== null) { $set->addEntrySet($this->tile->getHtmlHeadEntrySet()); } foreach ($this->groups as $group) { $set->addEntrySet($group->getHtmlHeadEntrySet()); } return $set; }
[ "public", "function", "getHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getHtmlHeadEntrySet", "(", ")", ";", "if", "(", "$", "this", "->", "tile", "!==", "null", ")", "{", "$", "set", "->", "addEntrySet", "(", "$", "this", "->", "tile", "->", "getHtmlHeadEntrySet", "(", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "$", "set", "->", "addEntrySet", "(", "$", "group", "->", "getHtmlHeadEntrySet", "(", ")", ")", ";", "}", "return", "$", "set", ";", "}" ]
Gets the SwatHtmlHeadEntry objects needed by this tile view @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by this tile view. @see SwatUIObject::getHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "needed", "by", "this", "tile", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L640-L653
34,205
silverorange/swat
Swat/SwatTileView.php
SwatTileView.getAvailableHtmlHeadEntrySet
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); if ($this->tile !== null) { $set->addEntrySet($this->tile->getAvailableHtmlHeadEntrySet()); } foreach ($this->groups as $group) { $set->addEntrySet($group->getAvailableHtmlHeadEntrySet()); } return $set; }
php
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); if ($this->tile !== null) { $set->addEntrySet($this->tile->getAvailableHtmlHeadEntrySet()); } foreach ($this->groups as $group) { $set->addEntrySet($group->getAvailableHtmlHeadEntrySet()); } return $set; }
[ "public", "function", "getAvailableHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getAvailableHtmlHeadEntrySet", "(", ")", ";", "if", "(", "$", "this", "->", "tile", "!==", "null", ")", "{", "$", "set", "->", "addEntrySet", "(", "$", "this", "->", "tile", "->", "getAvailableHtmlHeadEntrySet", "(", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "groups", "as", "$", "group", ")", "{", "$", "set", "->", "addEntrySet", "(", "$", "group", "->", "getAvailableHtmlHeadEntrySet", "(", ")", ")", ";", "}", "return", "$", "set", ";", "}" ]
Gets the SwatHtmlHeadEntry objects that may be needed by this tile view @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects that may be needed by this tile view. @see SwatUIObject::getAvailableHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "that", "may", "be", "needed", "by", "this", "tile", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L666-L679
34,206
silverorange/swat
Swat/SwatTileView.php
SwatTileView.getInlineJavaScript
protected function getInlineJavaScript() { $javascript = sprintf( "var %s = new SwatTileView('%s');", $this->id, $this->id ); if ($this->tile !== null) { $tile_javascript = $this->tile->getRendererInlineJavaScript(); if ($tile_javascript != '') { $javascript .= $tile_javascript; } $tile_javascript = $this->tile->getInlineJavaScript(); if ($tile_javascript != '') { $javascript .= "\n" . $tile_javascript; } } if ($this->showCheckAll()) { $check_all = $this->getCompositeWidget('check_all'); $renderer = $this->getCheckboxCellRenderer(); $javascript .= "\n" . $check_all->getInlineJavascript(); // set the controller of the check-all widget $javascript .= sprintf( "\n%s_obj.setController(%s);", $check_all->id, $renderer->id ); } return $javascript; }
php
protected function getInlineJavaScript() { $javascript = sprintf( "var %s = new SwatTileView('%s');", $this->id, $this->id ); if ($this->tile !== null) { $tile_javascript = $this->tile->getRendererInlineJavaScript(); if ($tile_javascript != '') { $javascript .= $tile_javascript; } $tile_javascript = $this->tile->getInlineJavaScript(); if ($tile_javascript != '') { $javascript .= "\n" . $tile_javascript; } } if ($this->showCheckAll()) { $check_all = $this->getCompositeWidget('check_all'); $renderer = $this->getCheckboxCellRenderer(); $javascript .= "\n" . $check_all->getInlineJavascript(); // set the controller of the check-all widget $javascript .= sprintf( "\n%s_obj.setController(%s);", $check_all->id, $renderer->id ); } return $javascript; }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "$", "javascript", "=", "sprintf", "(", "\"var %s = new SwatTileView('%s');\"", ",", "$", "this", "->", "id", ",", "$", "this", "->", "id", ")", ";", "if", "(", "$", "this", "->", "tile", "!==", "null", ")", "{", "$", "tile_javascript", "=", "$", "this", "->", "tile", "->", "getRendererInlineJavaScript", "(", ")", ";", "if", "(", "$", "tile_javascript", "!=", "''", ")", "{", "$", "javascript", ".=", "$", "tile_javascript", ";", "}", "$", "tile_javascript", "=", "$", "this", "->", "tile", "->", "getInlineJavaScript", "(", ")", ";", "if", "(", "$", "tile_javascript", "!=", "''", ")", "{", "$", "javascript", ".=", "\"\\n\"", ".", "$", "tile_javascript", ";", "}", "}", "if", "(", "$", "this", "->", "showCheckAll", "(", ")", ")", "{", "$", "check_all", "=", "$", "this", "->", "getCompositeWidget", "(", "'check_all'", ")", ";", "$", "renderer", "=", "$", "this", "->", "getCheckboxCellRenderer", "(", ")", ";", "$", "javascript", ".=", "\"\\n\"", ".", "$", "check_all", "->", "getInlineJavascript", "(", ")", ";", "// set the controller of the check-all widget", "$", "javascript", ".=", "sprintf", "(", "\"\\n%s_obj.setController(%s);\"", ",", "$", "check_all", "->", "id", ",", "$", "renderer", "->", "id", ")", ";", "}", "return", "$", "javascript", ";", "}" ]
Gets the inline JavaScript required for this tile view @return string the inline JavaScript required for this tile view. @see SwatTile::getInlineJavaScript()
[ "Gets", "the", "inline", "JavaScript", "required", "for", "this", "tile", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L731-L766
34,207
silverorange/swat
Swat/SwatTileView.php
SwatTileView.showCheckAll
protected function showCheckAll() { if ( $this->getCheckboxCellRenderer() === null || $this->getFirstAncestor('SwatForm') === null ) { $show = false; } elseif ($this->show_check_all === null && count($this->model) > 1) { $show = true; } elseif ($this->show_check_all === true) { $show = true; } else { $show = false; } return $show; }
php
protected function showCheckAll() { if ( $this->getCheckboxCellRenderer() === null || $this->getFirstAncestor('SwatForm') === null ) { $show = false; } elseif ($this->show_check_all === null && count($this->model) > 1) { $show = true; } elseif ($this->show_check_all === true) { $show = true; } else { $show = false; } return $show; }
[ "protected", "function", "showCheckAll", "(", ")", "{", "if", "(", "$", "this", "->", "getCheckboxCellRenderer", "(", ")", "===", "null", "||", "$", "this", "->", "getFirstAncestor", "(", "'SwatForm'", ")", "===", "null", ")", "{", "$", "show", "=", "false", ";", "}", "elseif", "(", "$", "this", "->", "show_check_all", "===", "null", "&&", "count", "(", "$", "this", "->", "model", ")", ">", "1", ")", "{", "$", "show", "=", "true", ";", "}", "elseif", "(", "$", "this", "->", "show_check_all", "===", "true", ")", "{", "$", "show", "=", "true", ";", "}", "else", "{", "$", "show", "=", "false", ";", "}", "return", "$", "show", ";", "}" ]
Whether or not a check-all widget is to be displayed for the tiles of this tile view This depends on the {@link SwatTileView::$show_check_all} property as well as whether or not this tile view contains a {@link SwatCheckboxCellRenderer} and whether or not this tile view contains enough tiles to warrent having a check-all widget @return boolean true if a check-all widget is to be displayed for this tile view and false if it is not.
[ "Whether", "or", "not", "a", "check", "-", "all", "widget", "is", "to", "be", "displayed", "for", "the", "tiles", "of", "this", "tile", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L799-L815
34,208
silverorange/swat
Swat/SwatTileView.php
SwatTileView.getCheckboxCellRenderer
protected function getCheckboxCellRenderer() { $checkbox_cell_renderer = null; foreach ($this->tile->getRenderers() as $renderer) { if ($renderer instanceof SwatCheckboxCellRenderer) { $checkbox_cell_renderer = $renderer; break; } } return $checkbox_cell_renderer; }
php
protected function getCheckboxCellRenderer() { $checkbox_cell_renderer = null; foreach ($this->tile->getRenderers() as $renderer) { if ($renderer instanceof SwatCheckboxCellRenderer) { $checkbox_cell_renderer = $renderer; break; } } return $checkbox_cell_renderer; }
[ "protected", "function", "getCheckboxCellRenderer", "(", ")", "{", "$", "checkbox_cell_renderer", "=", "null", ";", "foreach", "(", "$", "this", "->", "tile", "->", "getRenderers", "(", ")", "as", "$", "renderer", ")", "{", "if", "(", "$", "renderer", "instanceof", "SwatCheckboxCellRenderer", ")", "{", "$", "checkbox_cell_renderer", "=", "$", "renderer", ";", "break", ";", "}", "}", "return", "$", "checkbox_cell_renderer", ";", "}" ]
Gets the first checkbox cell renderer in this tile view's tile @return SwatCheckboxCellRenderer the first checkbox cell renderer in this tile view's tile or null if no such cell renderer exists.
[ "Gets", "the", "first", "checkbox", "cell", "renderer", "in", "this", "tile", "view", "s", "tile" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L827-L839
34,209
silverorange/swat
Swat/SwatTileView.php
SwatTileView.setTile
public function setTile(SwatTile $tile) { // if we're overwriting an existing tile, remove it's parent link if ($this->tile !== null) { $this->tile->parent = null; } $this->tile = $tile; $tile->parent = $this; }
php
public function setTile(SwatTile $tile) { // if we're overwriting an existing tile, remove it's parent link if ($this->tile !== null) { $this->tile->parent = null; } $this->tile = $tile; $tile->parent = $this; }
[ "public", "function", "setTile", "(", "SwatTile", "$", "tile", ")", "{", "// if we're overwriting an existing tile, remove it's parent link", "if", "(", "$", "this", "->", "tile", "!==", "null", ")", "{", "$", "this", "->", "tile", "->", "parent", "=", "null", ";", "}", "$", "this", "->", "tile", "=", "$", "tile", ";", "$", "tile", "->", "parent", "=", "$", "this", ";", "}" ]
Sets a tile of this tile view @param SwatTile $tile the tile to set
[ "Sets", "a", "tile", "of", "this", "tile", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L878-L887
34,210
silverorange/swat
Swat/SwatTileView.php
SwatTileView.validateGroup
protected function validateGroup(SwatTileViewGroup $group) { // note: This works because the id property is set before children are // added to parents in SwatUI. if ($group->id !== null) { if (array_key_exists($group->id, $this->groups_by_id)) { throw new SwatDuplicateIdException( "A group with the id '{$group->id}' already exists " . 'in this tile view.', 0, $group->id ); } } }
php
protected function validateGroup(SwatTileViewGroup $group) { // note: This works because the id property is set before children are // added to parents in SwatUI. if ($group->id !== null) { if (array_key_exists($group->id, $this->groups_by_id)) { throw new SwatDuplicateIdException( "A group with the id '{$group->id}' already exists " . 'in this tile view.', 0, $group->id ); } } }
[ "protected", "function", "validateGroup", "(", "SwatTileViewGroup", "$", "group", ")", "{", "// note: This works because the id property is set before children are", "// added to parents in SwatUI.", "if", "(", "$", "group", "->", "id", "!==", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "group", "->", "id", ",", "$", "this", "->", "groups_by_id", ")", ")", "{", "throw", "new", "SwatDuplicateIdException", "(", "\"A group with the id '{$group->id}' already exists \"", ".", "'in this tile view.'", ",", "0", ",", "$", "group", "->", "id", ")", ";", "}", "}", "}" ]
Ensures a group added to this tile-view is valid for this tile-view @param SwatTileViewGroup $group the group to check. @throws SwatDuplicateIdException if the group has the same id as a group already in this tile-view.
[ "Ensures", "a", "group", "added", "to", "this", "tile", "-", "view", "is", "valid", "for", "this", "tile", "-", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileView.php#L990-L1004
34,211
silverorange/swat
Swat/SwatRating.php
SwatRating.init
public function init() { parent::init(); $flydown = $this->getCompositeWidget('flydown'); $flydown->addOptionsByArray($this->getRatings()); }
php
public function init() { parent::init(); $flydown = $this->getCompositeWidget('flydown'); $flydown->addOptionsByArray($this->getRatings()); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "flydown", "=", "$", "this", "->", "getCompositeWidget", "(", "'flydown'", ")", ";", "$", "flydown", "->", "addOptionsByArray", "(", "$", "this", "->", "getRatings", "(", ")", ")", ";", "}" ]
Initializes this rating control
[ "Initializes", "this", "rating", "control" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRating.php#L56-L62
34,212
silverorange/swat
Swat/SwatRating.php
SwatRating.process
public function process() { parent::process(); $flydown = $this->getCompositeWidget('flydown'); if ($flydown->value == '') { $this->value = null; } else { $this->value = (int) $flydown->value; } }
php
public function process() { parent::process(); $flydown = $this->getCompositeWidget('flydown'); if ($flydown->value == '') { $this->value = null; } else { $this->value = (int) $flydown->value; } }
[ "public", "function", "process", "(", ")", "{", "parent", "::", "process", "(", ")", ";", "$", "flydown", "=", "$", "this", "->", "getCompositeWidget", "(", "'flydown'", ")", ";", "if", "(", "$", "flydown", "->", "value", "==", "''", ")", "{", "$", "this", "->", "value", "=", "null", ";", "}", "else", "{", "$", "this", "->", "value", "=", "(", "int", ")", "$", "flydown", "->", "value", ";", "}", "}" ]
Processes this rating control
[ "Processes", "this", "rating", "control" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRating.php#L70-L80
34,213
silverorange/swat
Swat/SwatRating.php
SwatRating.display
public function display() { parent::display(); if (!$this->visible) { return; } $flydown = $this->getCompositeWidget('flydown'); $flydown->value = (string) $this->value; $div = new SwatHtmlTag('div'); $div->id = $this->id; $div->class = $this->getCSSClassString(); if (!$this->isSensitive()) { $div->class .= ' swat-insensitive'; } $div->open(); $flydown->display(); $div->close(); Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
php
public function display() { parent::display(); if (!$this->visible) { return; } $flydown = $this->getCompositeWidget('flydown'); $flydown->value = (string) $this->value; $div = new SwatHtmlTag('div'); $div->id = $this->id; $div->class = $this->getCSSClassString(); if (!$this->isSensitive()) { $div->class .= ' swat-insensitive'; } $div->open(); $flydown->display(); $div->close(); Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
[ "public", "function", "display", "(", ")", "{", "parent", "::", "display", "(", ")", ";", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "$", "flydown", "=", "$", "this", "->", "getCompositeWidget", "(", "'flydown'", ")", ";", "$", "flydown", "->", "value", "=", "(", "string", ")", "$", "this", "->", "value", ";", "$", "div", "=", "new", "SwatHtmlTag", "(", "'div'", ")", ";", "$", "div", "->", "id", "=", "$", "this", "->", "id", ";", "$", "div", "->", "class", "=", "$", "this", "->", "getCSSClassString", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isSensitive", "(", ")", ")", "{", "$", "div", "->", "class", ".=", "' swat-insensitive'", ";", "}", "$", "div", "->", "open", "(", ")", ";", "$", "flydown", "->", "display", "(", ")", ";", "$", "div", "->", "close", "(", ")", ";", "Swat", "::", "displayInlineJavaScript", "(", "$", "this", "->", "getInlineJavaScript", "(", ")", ")", ";", "}" ]
Displays this rating control
[ "Displays", "this", "rating", "control" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRating.php#L88-L110
34,214
silverorange/swat
Swat/SwatRating.php
SwatRating.getInlineJavaScript
protected function getInlineJavaScript() { $quoted_string = SwatString::quoteJavaScriptString($this->id); return sprintf( 'var %s_obj = new SwatRating(%s, %s);', $this->id, $quoted_string, intval($this->maximum_value) ); }
php
protected function getInlineJavaScript() { $quoted_string = SwatString::quoteJavaScriptString($this->id); return sprintf( 'var %s_obj = new SwatRating(%s, %s);', $this->id, $quoted_string, intval($this->maximum_value) ); }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "$", "quoted_string", "=", "SwatString", "::", "quoteJavaScriptString", "(", "$", "this", "->", "id", ")", ";", "return", "sprintf", "(", "'var %s_obj = new SwatRating(%s, %s);'", ",", "$", "this", "->", "id", ",", "$", "quoted_string", ",", "intval", "(", "$", "this", "->", "maximum_value", ")", ")", ";", "}" ]
Gets the inline JavaScript for this rating control @return string the inline JavaScript required for this rating control.
[ "Gets", "the", "inline", "JavaScript", "for", "this", "rating", "control" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRating.php#L150-L159
34,215
silverorange/swat
Swat/SwatRating.php
SwatRating.createCompositeWidgets
protected function createCompositeWidgets() { $flydown = new SwatFlydown(); $flydown->id = $this->id . '_flydown'; $flydown->serialize_values = false; $this->addCompositeWidget($flydown, 'flydown'); }
php
protected function createCompositeWidgets() { $flydown = new SwatFlydown(); $flydown->id = $this->id . '_flydown'; $flydown->serialize_values = false; $this->addCompositeWidget($flydown, 'flydown'); }
[ "protected", "function", "createCompositeWidgets", "(", ")", "{", "$", "flydown", "=", "new", "SwatFlydown", "(", ")", ";", "$", "flydown", "->", "id", "=", "$", "this", "->", "id", ".", "'_flydown'", ";", "$", "flydown", "->", "serialize_values", "=", "false", ";", "$", "this", "->", "addCompositeWidget", "(", "$", "flydown", ",", "'flydown'", ")", ";", "}" ]
Creates the composite flydown used by this rating control @see SwatWidget::createCompositeWidgets()
[ "Creates", "the", "composite", "flydown", "used", "by", "this", "rating", "control" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatRating.php#L169-L175
34,216
silverorange/swat
Swat/SwatForm.php
SwatForm.display
public function display() { if (!$this->visible) { return; } SwatWidget::display(); $this->addHiddenField(self::PROCESS_FIELD, $this->id); $form_tag = $this->getFormTag(); $form_tag->open(); $this->displayChildren(); $this->displayHiddenFields(); $form_tag->close(); if ($this->connection_close_uri != '') { $yui = new SwatYUI(array('event')); $this->html_head_entry_set->addEntrySet( $yui->getHtmlHeadEntrySet() ); } Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
php
public function display() { if (!$this->visible) { return; } SwatWidget::display(); $this->addHiddenField(self::PROCESS_FIELD, $this->id); $form_tag = $this->getFormTag(); $form_tag->open(); $this->displayChildren(); $this->displayHiddenFields(); $form_tag->close(); if ($this->connection_close_uri != '') { $yui = new SwatYUI(array('event')); $this->html_head_entry_set->addEntrySet( $yui->getHtmlHeadEntrySet() ); } Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "SwatWidget", "::", "display", "(", ")", ";", "$", "this", "->", "addHiddenField", "(", "self", "::", "PROCESS_FIELD", ",", "$", "this", "->", "id", ")", ";", "$", "form_tag", "=", "$", "this", "->", "getFormTag", "(", ")", ";", "$", "form_tag", "->", "open", "(", ")", ";", "$", "this", "->", "displayChildren", "(", ")", ";", "$", "this", "->", "displayHiddenFields", "(", ")", ";", "$", "form_tag", "->", "close", "(", ")", ";", "if", "(", "$", "this", "->", "connection_close_uri", "!=", "''", ")", "{", "$", "yui", "=", "new", "SwatYUI", "(", "array", "(", "'event'", ")", ")", ";", "$", "this", "->", "html_head_entry_set", "->", "addEntrySet", "(", "$", "yui", "->", "getHtmlHeadEntrySet", "(", ")", ")", ";", "}", "Swat", "::", "displayInlineJavaScript", "(", "$", "this", "->", "getInlineJavaScript", "(", ")", ")", ";", "}" ]
Displays this form Outputs the HTML form tag and calls the display() method on each child widget of this form. Then, after all the child widgets are displayed, displays all hidden fields. This method also adds a hidden field called 'process' that is given the unique identifier of this form as a value.
[ "Displays", "this", "form" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L311-L336
34,217
silverorange/swat
Swat/SwatForm.php
SwatForm.process
public function process() { $this->processed = $this->isSubmitted(); if ($this->processed) { $this->processEncoding(); $this->processHiddenFields(); foreach ($this->children as $child) { if ($child !== null && !$child->isProcessed()) { $child->process(); } } } }
php
public function process() { $this->processed = $this->isSubmitted(); if ($this->processed) { $this->processEncoding(); $this->processHiddenFields(); foreach ($this->children as $child) { if ($child !== null && !$child->isProcessed()) { $child->process(); } } } }
[ "public", "function", "process", "(", ")", "{", "$", "this", "->", "processed", "=", "$", "this", "->", "isSubmitted", "(", ")", ";", "if", "(", "$", "this", "->", "processed", ")", "{", "$", "this", "->", "processEncoding", "(", ")", ";", "$", "this", "->", "processHiddenFields", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "!==", "null", "&&", "!", "$", "child", "->", "isProcessed", "(", ")", ")", "{", "$", "child", "->", "process", "(", ")", ";", "}", "}", "}", "}" ]
Processes this form If this form has been submitted then calls the process() method on each child widget. Then processes hidden form fields. This form is only marked as processed if it was submitted by the user. @return true if this form was actually submitted, false otherwise. @see SwatContainer::process()
[ "Processes", "this", "form" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L353-L367
34,218
silverorange/swat
Swat/SwatForm.php
SwatForm.getHiddenField
public function getHiddenField($name) { $data = null; if (isset($this->hidden_fields[$name])) { // Get value of a hidden field we've already unserialized after // processing this form. $data = $this->hidden_fields[$name]; } elseif (!$this->processed && $this->isSubmitted()) { // Otherwise, make sure this form was processed and get hidden // field from raw form data. $raw_data = $this->getFormData(); $serialized_field_name = self::SERIALIZED_PREFIX . $name; if (isset($raw_data[$serialized_field_name])) { $data = $this->unserializeHiddenField( $raw_data[$serialized_field_name] ); } } return $data; }
php
public function getHiddenField($name) { $data = null; if (isset($this->hidden_fields[$name])) { // Get value of a hidden field we've already unserialized after // processing this form. $data = $this->hidden_fields[$name]; } elseif (!$this->processed && $this->isSubmitted()) { // Otherwise, make sure this form was processed and get hidden // field from raw form data. $raw_data = $this->getFormData(); $serialized_field_name = self::SERIALIZED_PREFIX . $name; if (isset($raw_data[$serialized_field_name])) { $data = $this->unserializeHiddenField( $raw_data[$serialized_field_name] ); } } return $data; }
[ "public", "function", "getHiddenField", "(", "$", "name", ")", "{", "$", "data", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "hidden_fields", "[", "$", "name", "]", ")", ")", "{", "// Get value of a hidden field we've already unserialized after", "// processing this form.", "$", "data", "=", "$", "this", "->", "hidden_fields", "[", "$", "name", "]", ";", "}", "elseif", "(", "!", "$", "this", "->", "processed", "&&", "$", "this", "->", "isSubmitted", "(", ")", ")", "{", "// Otherwise, make sure this form was processed and get hidden", "// field from raw form data.", "$", "raw_data", "=", "$", "this", "->", "getFormData", "(", ")", ";", "$", "serialized_field_name", "=", "self", "::", "SERIALIZED_PREFIX", ".", "$", "name", ";", "if", "(", "isset", "(", "$", "raw_data", "[", "$", "serialized_field_name", "]", ")", ")", "{", "$", "data", "=", "$", "this", "->", "unserializeHiddenField", "(", "$", "raw_data", "[", "$", "serialized_field_name", "]", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
Gets the value of a hidden form field @param string $name the name of the field whose value to get. @return mixed the value of the field. The type of the field is preserved from the call to {@link SwatForm::addHiddenField()}. If the field does not exist, null is returned. @throws SwatInvalidSerializedDataException if the serialized form data does not match the signature data. @see SwatForm::addHiddenField()
[ "Gets", "the", "value", "of", "a", "hidden", "form", "field" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L423-L444
34,219
silverorange/swat
Swat/SwatForm.php
SwatForm.addWithField
public function addWithField(SwatWidget $widget, $title) { $field = new SwatFormField(); $field->add($widget); $field->title = $title; $this->add($field); }
php
public function addWithField(SwatWidget $widget, $title) { $field = new SwatFormField(); $field->add($widget); $field->title = $title; $this->add($field); }
[ "public", "function", "addWithField", "(", "SwatWidget", "$", "widget", ",", "$", "title", ")", "{", "$", "field", "=", "new", "SwatFormField", "(", ")", ";", "$", "field", "->", "add", "(", "$", "widget", ")", ";", "$", "field", "->", "title", "=", "$", "title", ";", "$", "this", "->", "add", "(", "$", "field", ")", ";", "}" ]
Adds a widget within a new SwatFormField This is a convenience method that does the following: - creates a new SwatFormField, - adds the widget as a child of the form field, - and then adds the SwatFormField to this form. @param SwatWidget $widget a reference to a widget to add. @param string $title the visible title of the form field.
[ "Adds", "a", "widget", "within", "a", "new", "SwatFormField" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L471-L477
34,220
silverorange/swat
Swat/SwatForm.php
SwatForm.&
public function &getFormData() { $data = null; switch ($this->method) { case self::METHOD_POST: $data = &$_POST; break; case self::METHOD_GET: $data = &$_GET; break; } return $data; }
php
public function &getFormData() { $data = null; switch ($this->method) { case self::METHOD_POST: $data = &$_POST; break; case self::METHOD_GET: $data = &$_GET; break; } return $data; }
[ "public", "function", "&", "getFormData", "(", ")", "{", "$", "data", "=", "null", ";", "switch", "(", "$", "this", "->", "method", ")", "{", "case", "self", "::", "METHOD_POST", ":", "$", "data", "=", "&", "$", "_POST", ";", "break", ";", "case", "self", "::", "METHOD_GET", ":", "$", "data", "=", "&", "$", "_GET", ";", "break", ";", "}", "return", "$", "data", ";", "}" ]
Returns the super-global array with this form's data Returns a reference to the super-global array containing this form's data. The array is chosen based on this form's method. @return array a reference to the super-global array containing this form's data.
[ "Returns", "the", "super", "-", "global", "array", "with", "this", "form", "s", "data" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L491-L505
34,221
silverorange/swat
Swat/SwatForm.php
SwatForm.isSubmitted
public function isSubmitted() { $raw_data = $this->getFormData(); return isset($raw_data[self::PROCESS_FIELD]) && $raw_data[self::PROCESS_FIELD] == $this->id; }
php
public function isSubmitted() { $raw_data = $this->getFormData(); return isset($raw_data[self::PROCESS_FIELD]) && $raw_data[self::PROCESS_FIELD] == $this->id; }
[ "public", "function", "isSubmitted", "(", ")", "{", "$", "raw_data", "=", "$", "this", "->", "getFormData", "(", ")", ";", "return", "isset", "(", "$", "raw_data", "[", "self", "::", "PROCESS_FIELD", "]", ")", "&&", "$", "raw_data", "[", "self", "::", "PROCESS_FIELD", "]", "==", "$", "this", "->", "id", ";", "}" ]
Whether or not this form was submitted on the previous page request This method may be called before or after the SwatForm::process() method. and is thus sometimes more useful than SwatForm::isProcessed() which only returns a meaningful value after SwatForm::process() is called. @return boolean true if this form was submitted on the previous page request and false if it was not.
[ "Whether", "or", "not", "this", "form", "was", "submitted", "on", "the", "previous", "page", "request" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L520-L526
34,222
silverorange/swat
Swat/SwatForm.php
SwatForm.isAuthenticated
public function isAuthenticated() { /* * If this form was not submitted, consider it authenticated. Processing * should be safe on forms that were not submitted. */ if (!$this->isSubmitted()) { return true; } $raw_data = $this->getFormData(); $token = null; if (isset($raw_data[self::AUTHENTICATION_TOKEN_FIELD])) { $token = SwatString::signedUnserialize( $raw_data[self::AUTHENTICATION_TOKEN_FIELD], $this->salt ); } /* * If this form's authentication token is set, the token in submitted * data must match. */ return self::$authentication_token === null || self::$authentication_token === $token; }
php
public function isAuthenticated() { /* * If this form was not submitted, consider it authenticated. Processing * should be safe on forms that were not submitted. */ if (!$this->isSubmitted()) { return true; } $raw_data = $this->getFormData(); $token = null; if (isset($raw_data[self::AUTHENTICATION_TOKEN_FIELD])) { $token = SwatString::signedUnserialize( $raw_data[self::AUTHENTICATION_TOKEN_FIELD], $this->salt ); } /* * If this form's authentication token is set, the token in submitted * data must match. */ return self::$authentication_token === null || self::$authentication_token === $token; }
[ "public", "function", "isAuthenticated", "(", ")", "{", "/*\n * If this form was not submitted, consider it authenticated. Processing\n * should be safe on forms that were not submitted.\n */", "if", "(", "!", "$", "this", "->", "isSubmitted", "(", ")", ")", "{", "return", "true", ";", "}", "$", "raw_data", "=", "$", "this", "->", "getFormData", "(", ")", ";", "$", "token", "=", "null", ";", "if", "(", "isset", "(", "$", "raw_data", "[", "self", "::", "AUTHENTICATION_TOKEN_FIELD", "]", ")", ")", "{", "$", "token", "=", "SwatString", "::", "signedUnserialize", "(", "$", "raw_data", "[", "self", "::", "AUTHENTICATION_TOKEN_FIELD", "]", ",", "$", "this", "->", "salt", ")", ";", "}", "/*\n * If this form's authentication token is set, the token in submitted\n * data must match.\n */", "return", "self", "::", "$", "authentication_token", "===", "null", "||", "self", "::", "$", "authentication_token", "===", "$", "token", ";", "}" ]
Whether or not this form is authenticated This can be used to catch cross-site request forgeries if the {@link SwatForm::setAuthenticationToken()} method was previously called. If form authentication is used, processing should only be performed on authenticated forms. An unauthenticated form may be a malicious request. @return boolean true if this form is authenticated or if this form does not use authentication. False if this form is not authenticated.
[ "Whether", "or", "not", "this", "form", "is", "authenticated" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L545-L571
34,223
silverorange/swat
Swat/SwatForm.php
SwatForm.processHiddenFields
protected function processHiddenFields() { $raw_data = $this->getFormData(); $serialized_field_name = self::HIDDEN_FIELD; if (isset($raw_data[$serialized_field_name])) { $fields = SwatString::signedUnserialize( $raw_data[$serialized_field_name], $this->salt ); } else { return; } foreach ($fields as $name) { $serialized_field_name = self::SERIALIZED_PREFIX . $name; if (isset($raw_data[$serialized_field_name])) { $this->hidden_fields[$name] = $this->unserializeHiddenField( $raw_data[$serialized_field_name] ); } } }
php
protected function processHiddenFields() { $raw_data = $this->getFormData(); $serialized_field_name = self::HIDDEN_FIELD; if (isset($raw_data[$serialized_field_name])) { $fields = SwatString::signedUnserialize( $raw_data[$serialized_field_name], $this->salt ); } else { return; } foreach ($fields as $name) { $serialized_field_name = self::SERIALIZED_PREFIX . $name; if (isset($raw_data[$serialized_field_name])) { $this->hidden_fields[$name] = $this->unserializeHiddenField( $raw_data[$serialized_field_name] ); } } }
[ "protected", "function", "processHiddenFields", "(", ")", "{", "$", "raw_data", "=", "$", "this", "->", "getFormData", "(", ")", ";", "$", "serialized_field_name", "=", "self", "::", "HIDDEN_FIELD", ";", "if", "(", "isset", "(", "$", "raw_data", "[", "$", "serialized_field_name", "]", ")", ")", "{", "$", "fields", "=", "SwatString", "::", "signedUnserialize", "(", "$", "raw_data", "[", "$", "serialized_field_name", "]", ",", "$", "this", "->", "salt", ")", ";", "}", "else", "{", "return", ";", "}", "foreach", "(", "$", "fields", "as", "$", "name", ")", "{", "$", "serialized_field_name", "=", "self", "::", "SERIALIZED_PREFIX", ".", "$", "name", ";", "if", "(", "isset", "(", "$", "raw_data", "[", "$", "serialized_field_name", "]", ")", ")", "{", "$", "this", "->", "hidden_fields", "[", "$", "name", "]", "=", "$", "this", "->", "unserializeHiddenField", "(", "$", "raw_data", "[", "$", "serialized_field_name", "]", ")", ";", "}", "}", "}" ]
Checks submitted form data for hidden fields Checks submitted form data for hidden fields. If hidden fields are found, properly re-adds them to this form. @throws SwatInvalidSerializedDataException if the serialized form data does not match the signature data.
[ "Checks", "submitted", "form", "data", "for", "hidden", "fields" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L739-L761
34,224
silverorange/swat
Swat/SwatForm.php
SwatForm.processEncoding
protected function processEncoding() { $raw_data = &$this->getFormData(); if ( $this->_8bit_encoding !== null && isset($raw_data[self::ENCODING_FIELD]) ) { $value = $raw_data[self::ENCODING_FIELD]; if ($value === self::ENCODING_8BIT_VALUE) { // convert from our 8-bit encoding to utf-8 foreach ($raw_data as $key => &$value) { if (!mb_check_encoding($value, $this->_8bit_encoding)) { // The 8-bit data is not valid for the 8-bit character // encoding. This can happen, for example, if robots // submit the 8-bit detection value and then submit // UTF-8 encoded values. throw new SwatInvalidCharacterEncodingException( sprintf( "Form submitted with 8-bit encoding but form " . "data is not valid %s. If this form data is " . "expected, use the " . "SwatForm::set8BitEncoding() method to set an " . "appropriate 8-bit encoding value.\n\nForm " . "data: \n%s", $this->_8bit_encoding, file_get_contents('php://input') ) ); } $value = iconv($this->_8bit_encoding, 'utf-8', $value); } foreach ($_FILES as &$file) { $filename = $file['name']; if (!mb_check_encoding($filename, $this->_8bit_encoding)) { // The 8-bit data is not valid for the 8-bit character // encoding. This can happen, for example, if robots // submit the 8-bit detection value and then submit // UTF-8 encoded values. throw new SwatInvalidCharacterEncodingException( sprintf( "Form submitted with 8-bit encoding but form " . "data is not valid %s. If this form data is " . "expected, use the " . "SwatForm::set8BitEncoding() method to set an " . "appropriate 8-bit encoding value.\n\nForm " . "data: \n%s", $this->_8bit_encoding, file_get_contents('php://input') ) ); } $file['name'] = iconv( $this->_8bit_encoding, 'utf-8', $filename ); } } elseif ($value !== self::ENCODING_UTF8_VALUE) { // it's not 8-bit or UTF-8. Time to panic! throw new SwatInvalidCharacterEncodingException( "Unknown form data character encoding. Form data: \n" . file_get_contents('php://input') ); } } }
php
protected function processEncoding() { $raw_data = &$this->getFormData(); if ( $this->_8bit_encoding !== null && isset($raw_data[self::ENCODING_FIELD]) ) { $value = $raw_data[self::ENCODING_FIELD]; if ($value === self::ENCODING_8BIT_VALUE) { // convert from our 8-bit encoding to utf-8 foreach ($raw_data as $key => &$value) { if (!mb_check_encoding($value, $this->_8bit_encoding)) { // The 8-bit data is not valid for the 8-bit character // encoding. This can happen, for example, if robots // submit the 8-bit detection value and then submit // UTF-8 encoded values. throw new SwatInvalidCharacterEncodingException( sprintf( "Form submitted with 8-bit encoding but form " . "data is not valid %s. If this form data is " . "expected, use the " . "SwatForm::set8BitEncoding() method to set an " . "appropriate 8-bit encoding value.\n\nForm " . "data: \n%s", $this->_8bit_encoding, file_get_contents('php://input') ) ); } $value = iconv($this->_8bit_encoding, 'utf-8', $value); } foreach ($_FILES as &$file) { $filename = $file['name']; if (!mb_check_encoding($filename, $this->_8bit_encoding)) { // The 8-bit data is not valid for the 8-bit character // encoding. This can happen, for example, if robots // submit the 8-bit detection value and then submit // UTF-8 encoded values. throw new SwatInvalidCharacterEncodingException( sprintf( "Form submitted with 8-bit encoding but form " . "data is not valid %s. If this form data is " . "expected, use the " . "SwatForm::set8BitEncoding() method to set an " . "appropriate 8-bit encoding value.\n\nForm " . "data: \n%s", $this->_8bit_encoding, file_get_contents('php://input') ) ); } $file['name'] = iconv( $this->_8bit_encoding, 'utf-8', $filename ); } } elseif ($value !== self::ENCODING_UTF8_VALUE) { // it's not 8-bit or UTF-8. Time to panic! throw new SwatInvalidCharacterEncodingException( "Unknown form data character encoding. Form data: \n" . file_get_contents('php://input') ); } } }
[ "protected", "function", "processEncoding", "(", ")", "{", "$", "raw_data", "=", "&", "$", "this", "->", "getFormData", "(", ")", ";", "if", "(", "$", "this", "->", "_8bit_encoding", "!==", "null", "&&", "isset", "(", "$", "raw_data", "[", "self", "::", "ENCODING_FIELD", "]", ")", ")", "{", "$", "value", "=", "$", "raw_data", "[", "self", "::", "ENCODING_FIELD", "]", ";", "if", "(", "$", "value", "===", "self", "::", "ENCODING_8BIT_VALUE", ")", "{", "// convert from our 8-bit encoding to utf-8", "foreach", "(", "$", "raw_data", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "!", "mb_check_encoding", "(", "$", "value", ",", "$", "this", "->", "_8bit_encoding", ")", ")", "{", "// The 8-bit data is not valid for the 8-bit character", "// encoding. This can happen, for example, if robots", "// submit the 8-bit detection value and then submit", "// UTF-8 encoded values.", "throw", "new", "SwatInvalidCharacterEncodingException", "(", "sprintf", "(", "\"Form submitted with 8-bit encoding but form \"", ".", "\"data is not valid %s. If this form data is \"", ".", "\"expected, use the \"", ".", "\"SwatForm::set8BitEncoding() method to set an \"", ".", "\"appropriate 8-bit encoding value.\\n\\nForm \"", ".", "\"data: \\n%s\"", ",", "$", "this", "->", "_8bit_encoding", ",", "file_get_contents", "(", "'php://input'", ")", ")", ")", ";", "}", "$", "value", "=", "iconv", "(", "$", "this", "->", "_8bit_encoding", ",", "'utf-8'", ",", "$", "value", ")", ";", "}", "foreach", "(", "$", "_FILES", "as", "&", "$", "file", ")", "{", "$", "filename", "=", "$", "file", "[", "'name'", "]", ";", "if", "(", "!", "mb_check_encoding", "(", "$", "filename", ",", "$", "this", "->", "_8bit_encoding", ")", ")", "{", "// The 8-bit data is not valid for the 8-bit character", "// encoding. This can happen, for example, if robots", "// submit the 8-bit detection value and then submit", "// UTF-8 encoded values.", "throw", "new", "SwatInvalidCharacterEncodingException", "(", "sprintf", "(", "\"Form submitted with 8-bit encoding but form \"", ".", "\"data is not valid %s. If this form data is \"", ".", "\"expected, use the \"", ".", "\"SwatForm::set8BitEncoding() method to set an \"", ".", "\"appropriate 8-bit encoding value.\\n\\nForm \"", ".", "\"data: \\n%s\"", ",", "$", "this", "->", "_8bit_encoding", ",", "file_get_contents", "(", "'php://input'", ")", ")", ")", ";", "}", "$", "file", "[", "'name'", "]", "=", "iconv", "(", "$", "this", "->", "_8bit_encoding", ",", "'utf-8'", ",", "$", "filename", ")", ";", "}", "}", "elseif", "(", "$", "value", "!==", "self", "::", "ENCODING_UTF8_VALUE", ")", "{", "// it's not 8-bit or UTF-8. Time to panic!", "throw", "new", "SwatInvalidCharacterEncodingException", "(", "\"Unknown form data character encoding. Form data: \\n\"", ".", "file_get_contents", "(", "'php://input'", ")", ")", ";", "}", "}", "}" ]
Detects 8-bit character encoding in form data and converts data to UTF-8 Conversion is only performed if this form's 8-bit encoding is set. This form's 8-bit encoding may be set automatically if the SwatForm default 8-bit encoding is set. This algorithm is adapted from a blog post at {@link http://blogs.sun.com/shankar/entry/how_to_handle_utf_8}. @throws SwatException if an 8-bit encoding is set and the form data is neither 8-bit nor UTF-8.
[ "Detects", "8", "-", "bit", "character", "encoding", "in", "form", "data", "and", "converts", "data", "to", "UTF", "-", "8" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L779-L848
34,225
silverorange/swat
Swat/SwatForm.php
SwatForm.displayHiddenFields
protected function displayHiddenFields() { $input_tag = new SwatHtmlTag('input'); $input_tag->type = 'hidden'; echo '<div class="swat-hidden">'; if ($this->_8bit_encoding !== null) { // The character encoding detection field is intentionally not using // SwatHtmlTag to avoid minimizing entities. echo '<input type="hidden" ', 'name="', self::ENCODING_FIELD, '" ', 'value="', self::ENCODING_ENTITY_VALUE, '" />'; } foreach ($this->hidden_fields as $name => $value) { // display unserialized value for primative types if ($value !== null && !is_array($value) && !is_object($value)) { // SwatHtmlTag uses SwatString::minimizeEntities(), which // prevents double-escaping entities. For hidden form-fields, // we want data to be returned exactly as it was specified. This // necessitates double-escaping to ensure any entities that were // specified in the hidden field value are returned correctly. $escaped_value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); $input_tag->name = $name; $input_tag->value = $escaped_value; $input_tag->display(); } // display serialized value $serialized_data = $this->serializeHiddenField($value); // SwatHtmlTag uses SwatString::minimizeEntities(), which prevents // double-escaping entities. For hidden form-fields, we want data // to be returned exactly as it was specified. This necessitates // double-escaping to ensure any entities that were specified in // the hidden field value are returned correctly. $escaped_serialized_data = htmlspecialchars( $serialized_data, ENT_COMPAT, 'UTF-8' ); $input_tag->name = self::SERIALIZED_PREFIX . $name; $input_tag->value = $escaped_serialized_data; $input_tag->display(); } // display hidden field names if (count($this->hidden_fields) > 0) { // array of field names $serialized_data = SwatString::signedSerialize( array_keys($this->hidden_fields), $this->salt ); $input_tag->name = self::HIDDEN_FIELD; $input_tag->value = $serialized_data; $input_tag->display(); } // display authentication token if (self::$authentication_token !== null) { $serialized_data = SwatString::signedSerialize( self::$authentication_token, $this->salt ); $input_tag = new SwatHtmlTag('input'); $input_tag->type = 'hidden'; $input_tag->name = self::AUTHENTICATION_TOKEN_FIELD; $input_tag->value = $serialized_data; $input_tag->display(); } echo '</div>'; }
php
protected function displayHiddenFields() { $input_tag = new SwatHtmlTag('input'); $input_tag->type = 'hidden'; echo '<div class="swat-hidden">'; if ($this->_8bit_encoding !== null) { // The character encoding detection field is intentionally not using // SwatHtmlTag to avoid minimizing entities. echo '<input type="hidden" ', 'name="', self::ENCODING_FIELD, '" ', 'value="', self::ENCODING_ENTITY_VALUE, '" />'; } foreach ($this->hidden_fields as $name => $value) { // display unserialized value for primative types if ($value !== null && !is_array($value) && !is_object($value)) { // SwatHtmlTag uses SwatString::minimizeEntities(), which // prevents double-escaping entities. For hidden form-fields, // we want data to be returned exactly as it was specified. This // necessitates double-escaping to ensure any entities that were // specified in the hidden field value are returned correctly. $escaped_value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); $input_tag->name = $name; $input_tag->value = $escaped_value; $input_tag->display(); } // display serialized value $serialized_data = $this->serializeHiddenField($value); // SwatHtmlTag uses SwatString::minimizeEntities(), which prevents // double-escaping entities. For hidden form-fields, we want data // to be returned exactly as it was specified. This necessitates // double-escaping to ensure any entities that were specified in // the hidden field value are returned correctly. $escaped_serialized_data = htmlspecialchars( $serialized_data, ENT_COMPAT, 'UTF-8' ); $input_tag->name = self::SERIALIZED_PREFIX . $name; $input_tag->value = $escaped_serialized_data; $input_tag->display(); } // display hidden field names if (count($this->hidden_fields) > 0) { // array of field names $serialized_data = SwatString::signedSerialize( array_keys($this->hidden_fields), $this->salt ); $input_tag->name = self::HIDDEN_FIELD; $input_tag->value = $serialized_data; $input_tag->display(); } // display authentication token if (self::$authentication_token !== null) { $serialized_data = SwatString::signedSerialize( self::$authentication_token, $this->salt ); $input_tag = new SwatHtmlTag('input'); $input_tag->type = 'hidden'; $input_tag->name = self::AUTHENTICATION_TOKEN_FIELD; $input_tag->value = $serialized_data; $input_tag->display(); } echo '</div>'; }
[ "protected", "function", "displayHiddenFields", "(", ")", "{", "$", "input_tag", "=", "new", "SwatHtmlTag", "(", "'input'", ")", ";", "$", "input_tag", "->", "type", "=", "'hidden'", ";", "echo", "'<div class=\"swat-hidden\">'", ";", "if", "(", "$", "this", "->", "_8bit_encoding", "!==", "null", ")", "{", "// The character encoding detection field is intentionally not using", "// SwatHtmlTag to avoid minimizing entities.", "echo", "'<input type=\"hidden\" '", ",", "'name=\"'", ",", "self", "::", "ENCODING_FIELD", ",", "'\" '", ",", "'value=\"'", ",", "self", "::", "ENCODING_ENTITY_VALUE", ",", "'\" />'", ";", "}", "foreach", "(", "$", "this", "->", "hidden_fields", "as", "$", "name", "=>", "$", "value", ")", "{", "// display unserialized value for primative types", "if", "(", "$", "value", "!==", "null", "&&", "!", "is_array", "(", "$", "value", ")", "&&", "!", "is_object", "(", "$", "value", ")", ")", "{", "// SwatHtmlTag uses SwatString::minimizeEntities(), which", "// prevents double-escaping entities. For hidden form-fields,", "// we want data to be returned exactly as it was specified. This", "// necessitates double-escaping to ensure any entities that were", "// specified in the hidden field value are returned correctly.", "$", "escaped_value", "=", "htmlspecialchars", "(", "$", "value", ",", "ENT_COMPAT", ",", "'UTF-8'", ")", ";", "$", "input_tag", "->", "name", "=", "$", "name", ";", "$", "input_tag", "->", "value", "=", "$", "escaped_value", ";", "$", "input_tag", "->", "display", "(", ")", ";", "}", "// display serialized value", "$", "serialized_data", "=", "$", "this", "->", "serializeHiddenField", "(", "$", "value", ")", ";", "// SwatHtmlTag uses SwatString::minimizeEntities(), which prevents", "// double-escaping entities. For hidden form-fields, we want data", "// to be returned exactly as it was specified. This necessitates", "// double-escaping to ensure any entities that were specified in", "// the hidden field value are returned correctly.", "$", "escaped_serialized_data", "=", "htmlspecialchars", "(", "$", "serialized_data", ",", "ENT_COMPAT", ",", "'UTF-8'", ")", ";", "$", "input_tag", "->", "name", "=", "self", "::", "SERIALIZED_PREFIX", ".", "$", "name", ";", "$", "input_tag", "->", "value", "=", "$", "escaped_serialized_data", ";", "$", "input_tag", "->", "display", "(", ")", ";", "}", "// display hidden field names", "if", "(", "count", "(", "$", "this", "->", "hidden_fields", ")", ">", "0", ")", "{", "// array of field names", "$", "serialized_data", "=", "SwatString", "::", "signedSerialize", "(", "array_keys", "(", "$", "this", "->", "hidden_fields", ")", ",", "$", "this", "->", "salt", ")", ";", "$", "input_tag", "->", "name", "=", "self", "::", "HIDDEN_FIELD", ";", "$", "input_tag", "->", "value", "=", "$", "serialized_data", ";", "$", "input_tag", "->", "display", "(", ")", ";", "}", "// display authentication token", "if", "(", "self", "::", "$", "authentication_token", "!==", "null", ")", "{", "$", "serialized_data", "=", "SwatString", "::", "signedSerialize", "(", "self", "::", "$", "authentication_token", ",", "$", "this", "->", "salt", ")", ";", "$", "input_tag", "=", "new", "SwatHtmlTag", "(", "'input'", ")", ";", "$", "input_tag", "->", "type", "=", "'hidden'", ";", "$", "input_tag", "->", "name", "=", "self", "::", "AUTHENTICATION_TOKEN_FIELD", ";", "$", "input_tag", "->", "value", "=", "$", "serialized_data", ";", "$", "input_tag", "->", "display", "(", ")", ";", "}", "echo", "'</div>'", ";", "}" ]
Displays hidden form fields Displays hiden form fields as <input type="hidden" /> XHTML elements. This method automatically handles array type values so they will be returned correctly as arrays. This methods also generates an array of hidden field names and passes them as hidden fields. If an authentication token is set on this form to prevent cross-site request forgeries, the token is displayed in a hidden field.
[ "Displays", "hidden", "form", "fields" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L896-L977
34,226
silverorange/swat
Swat/SwatForm.php
SwatForm.getFormTag
protected function getFormTag() { $form_tag = new SwatHtmlTag('form'); $form_tag->addAttributes(array( 'id' => $this->id, 'method' => $this->method, 'enctype' => $this->encoding_type, 'accept-charset' => $this->accept_charset, 'action' => $this->action, 'class' => $this->getCSSClassString() )); // we're going to validate data on the server, so turn off HTML5 // form validation $form_tag->novalidate = 'novalidate'; return $form_tag; }
php
protected function getFormTag() { $form_tag = new SwatHtmlTag('form'); $form_tag->addAttributes(array( 'id' => $this->id, 'method' => $this->method, 'enctype' => $this->encoding_type, 'accept-charset' => $this->accept_charset, 'action' => $this->action, 'class' => $this->getCSSClassString() )); // we're going to validate data on the server, so turn off HTML5 // form validation $form_tag->novalidate = 'novalidate'; return $form_tag; }
[ "protected", "function", "getFormTag", "(", ")", "{", "$", "form_tag", "=", "new", "SwatHtmlTag", "(", "'form'", ")", ";", "$", "form_tag", "->", "addAttributes", "(", "array", "(", "'id'", "=>", "$", "this", "->", "id", ",", "'method'", "=>", "$", "this", "->", "method", ",", "'enctype'", "=>", "$", "this", "->", "encoding_type", ",", "'accept-charset'", "=>", "$", "this", "->", "accept_charset", ",", "'action'", "=>", "$", "this", "->", "action", ",", "'class'", "=>", "$", "this", "->", "getCSSClassString", "(", ")", ")", ")", ";", "// we're going to validate data on the server, so turn off HTML5", "// form validation", "$", "form_tag", "->", "novalidate", "=", "'novalidate'", ";", "return", "$", "form_tag", ";", "}" ]
Gets the XHTML form tag used to display this form @return SwatHtmlTag the XHTML form tag used to display this form.
[ "Gets", "the", "XHTML", "form", "tag", "used", "to", "display", "this", "form" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L987-L1005
34,227
silverorange/swat
Swat/SwatForm.php
SwatForm.getInlineJavaScript
protected function getInlineJavaScript() { $javascript = sprintf( "var %s_obj = new %s(%s, %s);", $this->id, $this->getJavaScriptClass(), SwatString::quoteJavaScriptString($this->id), SwatString::quoteJavaScriptString($this->connection_close_uri) ); if ($this->autofocus) { $focusable = true; if ($this->default_focused_control === null) { $control = $this->getFirstDescendant('SwatControl'); if ($control === null) { $focusable = false; } else { $focus_id = $control->getFocusableHtmlId(); if ($focus_id === null) { $focusable = false; } } } else { $focus_id = $this->default_focused_control->getFocusableHtmlId(); if ($focus_id === null) { $focusable = false; } } if ($focusable) { $javascript .= "\n{$this->id}_obj.setDefaultFocus('{$focus_id}');"; } } if (!$this->autocomplete) { $javascript .= "\n{$this->id}_obj.setAutocomplete(false);"; } return $javascript; }
php
protected function getInlineJavaScript() { $javascript = sprintf( "var %s_obj = new %s(%s, %s);", $this->id, $this->getJavaScriptClass(), SwatString::quoteJavaScriptString($this->id), SwatString::quoteJavaScriptString($this->connection_close_uri) ); if ($this->autofocus) { $focusable = true; if ($this->default_focused_control === null) { $control = $this->getFirstDescendant('SwatControl'); if ($control === null) { $focusable = false; } else { $focus_id = $control->getFocusableHtmlId(); if ($focus_id === null) { $focusable = false; } } } else { $focus_id = $this->default_focused_control->getFocusableHtmlId(); if ($focus_id === null) { $focusable = false; } } if ($focusable) { $javascript .= "\n{$this->id}_obj.setDefaultFocus('{$focus_id}');"; } } if (!$this->autocomplete) { $javascript .= "\n{$this->id}_obj.setAutocomplete(false);"; } return $javascript; }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "$", "javascript", "=", "sprintf", "(", "\"var %s_obj = new %s(%s, %s);\"", ",", "$", "this", "->", "id", ",", "$", "this", "->", "getJavaScriptClass", "(", ")", ",", "SwatString", "::", "quoteJavaScriptString", "(", "$", "this", "->", "id", ")", ",", "SwatString", "::", "quoteJavaScriptString", "(", "$", "this", "->", "connection_close_uri", ")", ")", ";", "if", "(", "$", "this", "->", "autofocus", ")", "{", "$", "focusable", "=", "true", ";", "if", "(", "$", "this", "->", "default_focused_control", "===", "null", ")", "{", "$", "control", "=", "$", "this", "->", "getFirstDescendant", "(", "'SwatControl'", ")", ";", "if", "(", "$", "control", "===", "null", ")", "{", "$", "focusable", "=", "false", ";", "}", "else", "{", "$", "focus_id", "=", "$", "control", "->", "getFocusableHtmlId", "(", ")", ";", "if", "(", "$", "focus_id", "===", "null", ")", "{", "$", "focusable", "=", "false", ";", "}", "}", "}", "else", "{", "$", "focus_id", "=", "$", "this", "->", "default_focused_control", "->", "getFocusableHtmlId", "(", ")", ";", "if", "(", "$", "focus_id", "===", "null", ")", "{", "$", "focusable", "=", "false", ";", "}", "}", "if", "(", "$", "focusable", ")", "{", "$", "javascript", ".=", "\"\\n{$this->id}_obj.setDefaultFocus('{$focus_id}');\"", ";", "}", "}", "if", "(", "!", "$", "this", "->", "autocomplete", ")", "{", "$", "javascript", ".=", "\"\\n{$this->id}_obj.setAutocomplete(false);\"", ";", "}", "return", "$", "javascript", ";", "}" ]
Gets inline JavaScript required for this form Right now, this JavaScript focuses the first SwatControl in the form. @return string inline JavaScript required for this form.
[ "Gets", "inline", "JavaScript", "required", "for", "this", "form" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L1032-L1072
34,228
silverorange/swat
Swat/SwatForm.php
SwatForm.serializeHiddenField
protected function serializeHiddenField($value) { $value = SwatString::signedSerialize($value, $this->salt); // escape special characters that confuse browsers (mostly IE; // null characters confuse all browsers) $value = str_replace('\\', '\\\\', $value); $value = str_replace("\x00", '\x00', $value); $value = str_replace("\x0a", '\x0a', $value); $value = str_replace("\x0d", '\x0d', $value); return $value; }
php
protected function serializeHiddenField($value) { $value = SwatString::signedSerialize($value, $this->salt); // escape special characters that confuse browsers (mostly IE; // null characters confuse all browsers) $value = str_replace('\\', '\\\\', $value); $value = str_replace("\x00", '\x00', $value); $value = str_replace("\x0a", '\x0a', $value); $value = str_replace("\x0d", '\x0d', $value); return $value; }
[ "protected", "function", "serializeHiddenField", "(", "$", "value", ")", "{", "$", "value", "=", "SwatString", "::", "signedSerialize", "(", "$", "value", ",", "$", "this", "->", "salt", ")", ";", "// escape special characters that confuse browsers (mostly IE;", "// null characters confuse all browsers)", "$", "value", "=", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "value", ")", ";", "$", "value", "=", "str_replace", "(", "\"\\x00\"", ",", "'\\x00'", ",", "$", "value", ")", ";", "$", "value", "=", "str_replace", "(", "\"\\x0a\"", ",", "'\\x0a'", ",", "$", "value", ")", ";", "$", "value", "=", "str_replace", "(", "\"\\x0d\"", ",", "'\\x0d'", ",", "$", "value", ")", ";", "return", "$", "value", ";", "}" ]
Serializes a hidden field value into a string safe for including in form data @param mixed $value the hidden field value to serialize. @return string the hidden field value serialized for safely including in form data.
[ "Serializes", "a", "hidden", "field", "value", "into", "a", "string", "safe", "for", "including", "in", "form", "data" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatForm.php#L1103-L1115
34,229
brainworxx/kreXX
src/Krexx.php
Krexx.timerMoment
public static function timerMoment($string) { Pool::createPool(); // Disabled? // We do not use the config settings here, because we do not have any // output whatsoever. The config settings are either on or off, during // the entire run, meaning the can not be changed (by normal api means) // from the outside. // We also do not use the static ForcedLog methods here, because they // are somewhat time costly. if (AbstractController::$analysisInProgress || Config::$disabledByPhp) { return; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\TimerController') ->noFatalForKrexx() ->timerAction($string) ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; }
php
public static function timerMoment($string) { Pool::createPool(); // Disabled? // We do not use the config settings here, because we do not have any // output whatsoever. The config settings are either on or off, during // the entire run, meaning the can not be changed (by normal api means) // from the outside. // We also do not use the static ForcedLog methods here, because they // are somewhat time costly. if (AbstractController::$analysisInProgress || Config::$disabledByPhp) { return; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\TimerController') ->noFatalForKrexx() ->timerAction($string) ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; }
[ "public", "static", "function", "timerMoment", "(", "$", "string", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled?", "// We do not use the config settings here, because we do not have any", "// output whatsoever. The config settings are either on or off, during", "// the entire run, meaning the can not be changed (by normal api means)", "// from the outside.", "// We also do not use the static ForcedLog methods here, because they", "// are somewhat time costly.", "if", "(", "AbstractController", "::", "$", "analysisInProgress", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", ";", "}", "AbstractController", "::", "$", "analysisInProgress", "=", "true", ";", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\TimerController'", ")", "->", "noFatalForKrexx", "(", ")", "->", "timerAction", "(", "$", "string", ")", "->", "reFatalAfterKrexx", "(", ")", ";", "AbstractController", "::", "$", "analysisInProgress", "=", "false", ";", "}" ]
Takes a "moment". @api @param string $string Defines a "moment" during a benchmark test. The string should be something meaningful, like "Model invoice db call".
[ "Takes", "a", "moment", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L98-L121
34,230
brainworxx/kreXX
src/Krexx.php
Krexx.timerEnd
public static function timerEnd() { Pool::createPool(); // Disabled ? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || AbstractController::$analysisInProgress || Config::$disabledByPhp ) { return; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\TimerController') ->noFatalForKrexx() ->timerEndAction() ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; }
php
public static function timerEnd() { Pool::createPool(); // Disabled ? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || AbstractController::$analysisInProgress || Config::$disabledByPhp ) { return; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\TimerController') ->noFatalForKrexx() ->timerEndAction() ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; }
[ "public", "static", "function", "timerEnd", "(", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled ?", "if", "(", "static", "::", "$", "pool", "->", "config", "->", "getSetting", "(", "Fallback", "::", "SETTING_DISABLED", ")", "||", "AbstractController", "::", "$", "analysisInProgress", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", ";", "}", "AbstractController", "::", "$", "analysisInProgress", "=", "true", ";", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\TimerController'", ")", "->", "noFatalForKrexx", "(", ")", "->", "timerEndAction", "(", ")", "->", "reFatalAfterKrexx", "(", ")", ";", "AbstractController", "::", "$", "analysisInProgress", "=", "false", ";", "}" ]
Takes a "moment" and outputs the timer. @api
[ "Takes", "a", "moment", "and", "outputs", "the", "timer", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L128-L148
34,231
brainworxx/kreXX
src/Krexx.php
Krexx.open
public static function open($data = null) { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || AbstractController::$analysisInProgress || Config::$disabledByPhp ) { return $data; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\DumpController') ->noFatalForKrexx() ->dumpAction($data) ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; return $data; }
php
public static function open($data = null) { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || AbstractController::$analysisInProgress || Config::$disabledByPhp ) { return $data; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\DumpController') ->noFatalForKrexx() ->dumpAction($data) ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; return $data; }
[ "public", "static", "function", "open", "(", "$", "data", "=", "null", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled?", "if", "(", "static", "::", "$", "pool", "->", "config", "->", "getSetting", "(", "Fallback", "::", "SETTING_DISABLED", ")", "||", "AbstractController", "::", "$", "analysisInProgress", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", "$", "data", ";", "}", "AbstractController", "::", "$", "analysisInProgress", "=", "true", ";", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\DumpController'", ")", "->", "noFatalForKrexx", "(", ")", "->", "dumpAction", "(", "$", "data", ")", "->", "reFatalAfterKrexx", "(", ")", ";", "AbstractController", "::", "$", "analysisInProgress", "=", "false", ";", "return", "$", "data", ";", "}" ]
Starts the analysis of a variable. @api @param mixed $data The variable we want to analyse. @return mixed Return the original anslysis value.
[ "Starts", "the", "analysis", "of", "a", "variable", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L161-L183
34,232
brainworxx/kreXX
src/Krexx.php
Krexx.backtrace
public static function backtrace(array $backtrace = null) { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || AbstractController::$analysisInProgress || Config::$disabledByPhp ) { return; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\BacktraceController') ->noFatalForKrexx() ->backtraceAction($backtrace) ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; }
php
public static function backtrace(array $backtrace = null) { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || AbstractController::$analysisInProgress || Config::$disabledByPhp ) { return; } AbstractController::$analysisInProgress = true; static::$pool->createClass('Brainworxx\\Krexx\\Controller\\BacktraceController') ->noFatalForKrexx() ->backtraceAction($backtrace) ->reFatalAfterKrexx(); AbstractController::$analysisInProgress = false; }
[ "public", "static", "function", "backtrace", "(", "array", "$", "backtrace", "=", "null", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled?", "if", "(", "static", "::", "$", "pool", "->", "config", "->", "getSetting", "(", "Fallback", "::", "SETTING_DISABLED", ")", "||", "AbstractController", "::", "$", "analysisInProgress", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", ";", "}", "AbstractController", "::", "$", "analysisInProgress", "=", "true", ";", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\BacktraceController'", ")", "->", "noFatalForKrexx", "(", ")", "->", "backtraceAction", "(", "$", "backtrace", ")", "->", "reFatalAfterKrexx", "(", ")", ";", "AbstractController", "::", "$", "analysisInProgress", "=", "false", ";", "}" ]
Prints a debug backtrace. When there are classes found inside the backtrace, they will be analysed. @param array|null $backtrace An already existing backtrace. @api
[ "Prints", "a", "debug", "backtrace", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L196-L216
34,233
brainworxx/kreXX
src/Krexx.php
Krexx.disable
public static function disable() { Pool::createPool(); static::$pool->config->setDisabled(true); static::$pool->createClass('Brainworxx\\Krexx\\Controller\\DumpController') ->noFatalForKrexx(); Config::$disabledByPhp = true; }
php
public static function disable() { Pool::createPool(); static::$pool->config->setDisabled(true); static::$pool->createClass('Brainworxx\\Krexx\\Controller\\DumpController') ->noFatalForKrexx(); Config::$disabledByPhp = true; }
[ "public", "static", "function", "disable", "(", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "static", "::", "$", "pool", "->", "config", "->", "setDisabled", "(", "true", ")", ";", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\DumpController'", ")", "->", "noFatalForKrexx", "(", ")", ";", "Config", "::", "$", "disabledByPhp", "=", "true", ";", "}" ]
Disable kreXX. @api
[ "Disable", "kreXX", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L223-L232
34,234
brainworxx/kreXX
src/Krexx.php
Krexx.editSettings
public static function editSettings() { Pool::createPool(); // Disabled? // We are ignoring local settings here. if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || Config::$disabledByPhp ) { return; } static::$pool->createClass('Brainworxx\\Krexx\\Controller\\EditSettingsController') ->noFatalForKrexx() ->editSettingsAction() ->reFatalAfterKrexx(); }
php
public static function editSettings() { Pool::createPool(); // Disabled? // We are ignoring local settings here. if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || Config::$disabledByPhp ) { return; } static::$pool->createClass('Brainworxx\\Krexx\\Controller\\EditSettingsController') ->noFatalForKrexx() ->editSettingsAction() ->reFatalAfterKrexx(); }
[ "public", "static", "function", "editSettings", "(", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled?", "// We are ignoring local settings here.", "if", "(", "static", "::", "$", "pool", "->", "config", "->", "getSetting", "(", "Fallback", "::", "SETTING_DISABLED", ")", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", ";", "}", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\EditSettingsController'", ")", "->", "noFatalForKrexx", "(", ")", "->", "editSettingsAction", "(", ")", "->", "reFatalAfterKrexx", "(", ")", ";", "}" ]
Displays the edit settings part, no analysis. Ignores the 'disabled' settings in the cookie. @api
[ "Displays", "the", "edit", "settings", "part", "no", "analysis", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L241-L257
34,235
brainworxx/kreXX
src/Krexx.php
Krexx.registerFatal
public static function registerFatal() { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || Config::$disabledByPhp ) { return; } // Wrong PHP version? if (version_compare(phpversion(), '7.0.0', '>=')) { static::$pool->messages->addMessage('php7'); // In case that there is no other kreXX output, we show the configuration // with the message. static::editSettings(); return; } static::$pool->createClass('Brainworxx\\Krexx\\Controller\\ErrorController') ->registerFatalAction(); }
php
public static function registerFatal() { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || Config::$disabledByPhp ) { return; } // Wrong PHP version? if (version_compare(phpversion(), '7.0.0', '>=')) { static::$pool->messages->addMessage('php7'); // In case that there is no other kreXX output, we show the configuration // with the message. static::editSettings(); return; } static::$pool->createClass('Brainworxx\\Krexx\\Controller\\ErrorController') ->registerFatalAction(); }
[ "public", "static", "function", "registerFatal", "(", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled?", "if", "(", "static", "::", "$", "pool", "->", "config", "->", "getSetting", "(", "Fallback", "::", "SETTING_DISABLED", ")", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", ";", "}", "// Wrong PHP version?", "if", "(", "version_compare", "(", "phpversion", "(", ")", ",", "'7.0.0'", ",", "'>='", ")", ")", "{", "static", "::", "$", "pool", "->", "messages", "->", "addMessage", "(", "'php7'", ")", ";", "// In case that there is no other kreXX output, we show the configuration", "// with the message.", "static", "::", "editSettings", "(", ")", ";", "return", ";", "}", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\ErrorController'", ")", "->", "registerFatalAction", "(", ")", ";", "}" ]
Registers a shutdown function. Our fatal errorhandler is located there. @api
[ "Registers", "a", "shutdown", "function", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L266-L288
34,236
brainworxx/kreXX
src/Krexx.php
Krexx.unregisterFatal
public static function unregisterFatal() { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || Config::$disabledByPhp ) { return; } static::$pool->createClass('Brainworxx\\Krexx\\Controller\\ErrorController') ->unregisterFatalAction(); }
php
public static function unregisterFatal() { Pool::createPool(); // Disabled? if (static::$pool->config->getSetting(Fallback::SETTING_DISABLED) || Config::$disabledByPhp ) { return; } static::$pool->createClass('Brainworxx\\Krexx\\Controller\\ErrorController') ->unregisterFatalAction(); }
[ "public", "static", "function", "unregisterFatal", "(", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Disabled?", "if", "(", "static", "::", "$", "pool", "->", "config", "->", "getSetting", "(", "Fallback", "::", "SETTING_DISABLED", ")", "||", "Config", "::", "$", "disabledByPhp", ")", "{", "return", ";", "}", "static", "::", "$", "pool", "->", "createClass", "(", "'Brainworxx\\\\Krexx\\\\Controller\\\\ErrorController'", ")", "->", "unregisterFatalAction", "(", ")", ";", "}" ]
Tells the registered shutdown function to do nothing. We can not unregister a once declared shutdown function, so we need to tell our errorhandler to do nothing, in case there is a fatal. @api
[ "Tells", "the", "registered", "shutdown", "function", "to", "do", "nothing", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L299-L312
34,237
brainworxx/kreXX
src/Krexx.php
Krexx.startForcedLog
protected static function startForcedLog() { Pool::createPool(); // Output destination: file static::$pool->config ->settings[Fallback::SETTING_DESTINATION] ->setSource('forced logging') ->setValue(Fallback::VALUE_FILE); // Do not care about ajax requests. static::$pool->config ->settings[Fallback::SETTING_DETECT_AJAX] ->setSource('forced logging') ->setValue(false); // Reload the disabled settings with the new ajax setting. static::$pool->config ->loadConfigValue(Fallback::SETTING_DISABLED); }
php
protected static function startForcedLog() { Pool::createPool(); // Output destination: file static::$pool->config ->settings[Fallback::SETTING_DESTINATION] ->setSource('forced logging') ->setValue(Fallback::VALUE_FILE); // Do not care about ajax requests. static::$pool->config ->settings[Fallback::SETTING_DETECT_AJAX] ->setSource('forced logging') ->setValue(false); // Reload the disabled settings with the new ajax setting. static::$pool->config ->loadConfigValue(Fallback::SETTING_DISABLED); }
[ "protected", "static", "function", "startForcedLog", "(", ")", "{", "Pool", "::", "createPool", "(", ")", ";", "// Output destination: file", "static", "::", "$", "pool", "->", "config", "->", "settings", "[", "Fallback", "::", "SETTING_DESTINATION", "]", "->", "setSource", "(", "'forced logging'", ")", "->", "setValue", "(", "Fallback", "::", "VALUE_FILE", ")", ";", "// Do not care about ajax requests.", "static", "::", "$", "pool", "->", "config", "->", "settings", "[", "Fallback", "::", "SETTING_DETECT_AJAX", "]", "->", "setSource", "(", "'forced logging'", ")", "->", "setValue", "(", "false", ")", ";", "// Reload the disabled settings with the new ajax setting.", "static", "::", "$", "pool", "->", "config", "->", "loadConfigValue", "(", "Fallback", "::", "SETTING_DISABLED", ")", ";", "}" ]
Configure everything to start the forced logging.
[ "Configure", "everything", "to", "start", "the", "forced", "logging", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Krexx.php#L367-L386
34,238
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson._getEntity
protected function _getEntity(KModelEntityInterface $entity) { if ($this->_layout == 'stream') { $activity = $entity; $renderer = $this->getRenderer(); $item = array( 'id' => $activity->getActivityId(), 'title' => $renderer->render($activity, array('escaped_urls' => false, 'fqr' => true)), 'story' => $renderer->render($activity, array('html' => false)), 'published' => $activity->getActivityPublished()->format('c'), 'verb' => $activity->getActivityVerb(), 'format' => $activity->getActivityFormat(), 'locale' => $activity->getLocale() ); if ($icon = $activity->getActivityIcon()) { $item['icon'] = $this->_getMediaLinkData($icon); } foreach ($activity->objects as $name => $object) { $clone = clone $object; if ($object->isTranslatable()) { $translator = $activity->getTranslator(); $clone->setDisplayName($translator->translateActivityToken($clone, $activity)); } $item[$name] = $this->_getObjectData($clone); } } else { $item = $entity->toArray(); if (!empty($this->_fields)) { $item = array_intersect_key($item, array_flip($this->_fields)); } } return $item; }
php
protected function _getEntity(KModelEntityInterface $entity) { if ($this->_layout == 'stream') { $activity = $entity; $renderer = $this->getRenderer(); $item = array( 'id' => $activity->getActivityId(), 'title' => $renderer->render($activity, array('escaped_urls' => false, 'fqr' => true)), 'story' => $renderer->render($activity, array('html' => false)), 'published' => $activity->getActivityPublished()->format('c'), 'verb' => $activity->getActivityVerb(), 'format' => $activity->getActivityFormat(), 'locale' => $activity->getLocale() ); if ($icon = $activity->getActivityIcon()) { $item['icon'] = $this->_getMediaLinkData($icon); } foreach ($activity->objects as $name => $object) { $clone = clone $object; if ($object->isTranslatable()) { $translator = $activity->getTranslator(); $clone->setDisplayName($translator->translateActivityToken($clone, $activity)); } $item[$name] = $this->_getObjectData($clone); } } else { $item = $entity->toArray(); if (!empty($this->_fields)) { $item = array_intersect_key($item, array_flip($this->_fields)); } } return $item; }
[ "protected", "function", "_getEntity", "(", "KModelEntityInterface", "$", "entity", ")", "{", "if", "(", "$", "this", "->", "_layout", "==", "'stream'", ")", "{", "$", "activity", "=", "$", "entity", ";", "$", "renderer", "=", "$", "this", "->", "getRenderer", "(", ")", ";", "$", "item", "=", "array", "(", "'id'", "=>", "$", "activity", "->", "getActivityId", "(", ")", ",", "'title'", "=>", "$", "renderer", "->", "render", "(", "$", "activity", ",", "array", "(", "'escaped_urls'", "=>", "false", ",", "'fqr'", "=>", "true", ")", ")", ",", "'story'", "=>", "$", "renderer", "->", "render", "(", "$", "activity", ",", "array", "(", "'html'", "=>", "false", ")", ")", ",", "'published'", "=>", "$", "activity", "->", "getActivityPublished", "(", ")", "->", "format", "(", "'c'", ")", ",", "'verb'", "=>", "$", "activity", "->", "getActivityVerb", "(", ")", ",", "'format'", "=>", "$", "activity", "->", "getActivityFormat", "(", ")", ",", "'locale'", "=>", "$", "activity", "->", "getLocale", "(", ")", ")", ";", "if", "(", "$", "icon", "=", "$", "activity", "->", "getActivityIcon", "(", ")", ")", "{", "$", "item", "[", "'icon'", "]", "=", "$", "this", "->", "_getMediaLinkData", "(", "$", "icon", ")", ";", "}", "foreach", "(", "$", "activity", "->", "objects", "as", "$", "name", "=>", "$", "object", ")", "{", "$", "clone", "=", "clone", "$", "object", ";", "if", "(", "$", "object", "->", "isTranslatable", "(", ")", ")", "{", "$", "translator", "=", "$", "activity", "->", "getTranslator", "(", ")", ";", "$", "clone", "->", "setDisplayName", "(", "$", "translator", "->", "translateActivityToken", "(", "$", "clone", ",", "$", "activity", ")", ")", ";", "}", "$", "item", "[", "$", "name", "]", "=", "$", "this", "->", "_getObjectData", "(", "$", "clone", ")", ";", "}", "}", "else", "{", "$", "item", "=", "$", "entity", "->", "toArray", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "_fields", ")", ")", "{", "$", "item", "=", "array_intersect_key", "(", "$", "item", ",", "array_flip", "(", "$", "this", "->", "_fields", ")", ")", ";", "}", "}", "return", "$", "item", ";", "}" ]
Get the entity data @link http://activitystrea.ms/specs/json/1.0/#json See JSON serialization. @param KModelEntityInterface $entity The model entity. @return array The array with data to be encoded to JSON.
[ "Get", "the", "entity", "data" ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L75-L118
34,239
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson.getRenderer
public function getRenderer() { if (!$this->_renderer instanceof KTemplateHelperInterface) { // Make sure we have an identifier if(!($this->_renderer instanceof KObjectIdentifier)) { $this->setRenderer($this->_renderer); } $this->_renderer = $this->getObject($this->_renderer); if(!$this->_renderer instanceof ComActivitiesActivityRendererInterface) { throw new UnexpectedValueException( 'Renderer: '.get_class($this->_renderer).' does not implement ComActivitiesActivityRendererInterface' ); } $this->_renderer->getTemplate()->registerFunction('url', array($this, 'getUrl')); } return $this->_renderer; }
php
public function getRenderer() { if (!$this->_renderer instanceof KTemplateHelperInterface) { // Make sure we have an identifier if(!($this->_renderer instanceof KObjectIdentifier)) { $this->setRenderer($this->_renderer); } $this->_renderer = $this->getObject($this->_renderer); if(!$this->_renderer instanceof ComActivitiesActivityRendererInterface) { throw new UnexpectedValueException( 'Renderer: '.get_class($this->_renderer).' does not implement ComActivitiesActivityRendererInterface' ); } $this->_renderer->getTemplate()->registerFunction('url', array($this, 'getUrl')); } return $this->_renderer; }
[ "public", "function", "getRenderer", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_renderer", "instanceof", "KTemplateHelperInterface", ")", "{", "// Make sure we have an identifier", "if", "(", "!", "(", "$", "this", "->", "_renderer", "instanceof", "KObjectIdentifier", ")", ")", "{", "$", "this", "->", "setRenderer", "(", "$", "this", "->", "_renderer", ")", ";", "}", "$", "this", "->", "_renderer", "=", "$", "this", "->", "getObject", "(", "$", "this", "->", "_renderer", ")", ";", "if", "(", "!", "$", "this", "->", "_renderer", "instanceof", "ComActivitiesActivityRendererInterface", ")", "{", "throw", "new", "UnexpectedValueException", "(", "'Renderer: '", ".", "get_class", "(", "$", "this", "->", "_renderer", ")", ".", "' does not implement ComActivitiesActivityRendererInterface'", ")", ";", "}", "$", "this", "->", "_renderer", "->", "getTemplate", "(", ")", "->", "registerFunction", "(", "'url'", ",", "array", "(", "$", "this", ",", "'getUrl'", ")", ")", ";", "}", "return", "$", "this", "->", "_renderer", ";", "}" ]
Get the activity renderer. @throws UnexpectedValueException if renderer has the wrong type. @return ComActivitiesActivityRendererInterface The activity renderer.
[ "Get", "the", "activity", "renderer", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L126-L148
34,240
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson.setRenderer
public function setRenderer($renderer) { if(!$renderer instanceof ComActivitiesActivityRendererInterface) { if(is_string($renderer) && strpos($renderer, '.') === false ) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('template', 'helper'); $identifier['name'] = $renderer; $identifier = $this->getIdentifier($identifier); } else $identifier = $this->getIdentifier($renderer); $renderer = $identifier; } $this->_renderer = $renderer; return $this; }
php
public function setRenderer($renderer) { if(!$renderer instanceof ComActivitiesActivityRendererInterface) { if(is_string($renderer) && strpos($renderer, '.') === false ) { $identifier = $this->getIdentifier()->toArray(); $identifier['path'] = array('template', 'helper'); $identifier['name'] = $renderer; $identifier = $this->getIdentifier($identifier); } else $identifier = $this->getIdentifier($renderer); $renderer = $identifier; } $this->_renderer = $renderer; return $this; }
[ "public", "function", "setRenderer", "(", "$", "renderer", ")", "{", "if", "(", "!", "$", "renderer", "instanceof", "ComActivitiesActivityRendererInterface", ")", "{", "if", "(", "is_string", "(", "$", "renderer", ")", "&&", "strpos", "(", "$", "renderer", ",", "'.'", ")", "===", "false", ")", "{", "$", "identifier", "=", "$", "this", "->", "getIdentifier", "(", ")", "->", "toArray", "(", ")", ";", "$", "identifier", "[", "'path'", "]", "=", "array", "(", "'template'", ",", "'helper'", ")", ";", "$", "identifier", "[", "'name'", "]", "=", "$", "renderer", ";", "$", "identifier", "=", "$", "this", "->", "getIdentifier", "(", "$", "identifier", ")", ";", "}", "else", "$", "identifier", "=", "$", "this", "->", "getIdentifier", "(", "$", "renderer", ")", ";", "$", "renderer", "=", "$", "identifier", ";", "}", "$", "this", "->", "_renderer", "=", "$", "renderer", ";", "return", "$", "this", ";", "}" ]
Set the activity renderer. @param mixed $renderer An activity renderer instance, identifier object or string. @return ComActivitiesViewActivitiesJson
[ "Set", "the", "activity", "renderer", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L156-L176
34,241
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson._getObjectData
protected function _getObjectData(ComActivitiesActivityObjectInterface $object) { $data = $object->toArray(); // Make sure we get fully qualified URLs. if ($url = $object->getUrl()) { $data['url'] = $this->_getUrl($url); } $attachments = array(); // Handle attachments recursively. foreach ($object->getAttachments() as $attachment) { $attachments[] = $this->_getObjectData($attachment); } $data['attachments'] = $attachments; // Convert date objects to date time strings. foreach (array('published', 'updated') as $property) { $method = 'get' . ucfirst($property); if ($date = $object->$method()) { $data[$property] = $date->format('M d Y H:i:s'); } } foreach ($object as $key => $value) { if ($value instanceof ComActivitiesActivityObjectInterface) { $data[$key] = $this->_getObjectData($value); } if ($value instanceof ComActivitiesActivityMedialinkInterface) { $data[$key] = $this->_getMedialinkData($value); } } return $this->_cleanupData($data); }
php
protected function _getObjectData(ComActivitiesActivityObjectInterface $object) { $data = $object->toArray(); // Make sure we get fully qualified URLs. if ($url = $object->getUrl()) { $data['url'] = $this->_getUrl($url); } $attachments = array(); // Handle attachments recursively. foreach ($object->getAttachments() as $attachment) { $attachments[] = $this->_getObjectData($attachment); } $data['attachments'] = $attachments; // Convert date objects to date time strings. foreach (array('published', 'updated') as $property) { $method = 'get' . ucfirst($property); if ($date = $object->$method()) { $data[$property] = $date->format('M d Y H:i:s'); } } foreach ($object as $key => $value) { if ($value instanceof ComActivitiesActivityObjectInterface) { $data[$key] = $this->_getObjectData($value); } if ($value instanceof ComActivitiesActivityMedialinkInterface) { $data[$key] = $this->_getMedialinkData($value); } } return $this->_cleanupData($data); }
[ "protected", "function", "_getObjectData", "(", "ComActivitiesActivityObjectInterface", "$", "object", ")", "{", "$", "data", "=", "$", "object", "->", "toArray", "(", ")", ";", "// Make sure we get fully qualified URLs.", "if", "(", "$", "url", "=", "$", "object", "->", "getUrl", "(", ")", ")", "{", "$", "data", "[", "'url'", "]", "=", "$", "this", "->", "_getUrl", "(", "$", "url", ")", ";", "}", "$", "attachments", "=", "array", "(", ")", ";", "// Handle attachments recursively.", "foreach", "(", "$", "object", "->", "getAttachments", "(", ")", "as", "$", "attachment", ")", "{", "$", "attachments", "[", "]", "=", "$", "this", "->", "_getObjectData", "(", "$", "attachment", ")", ";", "}", "$", "data", "[", "'attachments'", "]", "=", "$", "attachments", ";", "// Convert date objects to date time strings.", "foreach", "(", "array", "(", "'published'", ",", "'updated'", ")", "as", "$", "property", ")", "{", "$", "method", "=", "'get'", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "$", "date", "=", "$", "object", "->", "$", "method", "(", ")", ")", "{", "$", "data", "[", "$", "property", "]", "=", "$", "date", "->", "format", "(", "'M d Y H:i:s'", ")", ";", "}", "}", "foreach", "(", "$", "object", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "ComActivitiesActivityObjectInterface", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_getObjectData", "(", "$", "value", ")", ";", "}", "if", "(", "$", "value", "instanceof", "ComActivitiesActivityMedialinkInterface", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "_getMedialinkData", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", "->", "_cleanupData", "(", "$", "data", ")", ";", "}" ]
Activity object data getter. @param ComActivitiesActivityObjectInterface $object The activity object. @return array The object data.
[ "Activity", "object", "data", "getter", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L184-L224
34,242
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson._getMedialinkData
protected function _getMedialinkData(ComActivitiesActivityMedialinkInterface $medialink) { $data = $medialink->toArray(); $data['url'] = $this->_getUrl($medialink->getUrl()); return $this->_cleanupData($data); }
php
protected function _getMedialinkData(ComActivitiesActivityMedialinkInterface $medialink) { $data = $medialink->toArray(); $data['url'] = $this->_getUrl($medialink->getUrl()); return $this->_cleanupData($data); }
[ "protected", "function", "_getMedialinkData", "(", "ComActivitiesActivityMedialinkInterface", "$", "medialink", ")", "{", "$", "data", "=", "$", "medialink", "->", "toArray", "(", ")", ";", "$", "data", "[", "'url'", "]", "=", "$", "this", "->", "_getUrl", "(", "$", "medialink", "->", "getUrl", "(", ")", ")", ";", "return", "$", "this", "->", "_cleanupData", "(", "$", "data", ")", ";", "}" ]
Activity medialink data getter. @param ComActivitiesActivityMedialinkInterface $medialink The medialink object. @return array The object data.
[ "Activity", "medialink", "data", "getter", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L232-L239
34,243
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson._cleanupData
protected function _cleanupData(array $data = array()) { $clean = array(); foreach ($data as $key => $value) { if (!empty($value)) { $clean[$key] = $value; } } return $clean; }
php
protected function _cleanupData(array $data = array()) { $clean = array(); foreach ($data as $key => $value) { if (!empty($value)) { $clean[$key] = $value; } } return $clean; }
[ "protected", "function", "_cleanupData", "(", "array", "$", "data", "=", "array", "(", ")", ")", "{", "$", "clean", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "clean", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "clean", ";", "}" ]
Removes entries with empty values. @param array $data The data to cleanup. @return array The cleaned up data.
[ "Removes", "entries", "with", "empty", "values", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L247-L259
34,244
joomlatools/joomlatools-framework-activities
view/activities/json.php
ComActivitiesViewActivitiesJson._getUrl
protected function _getUrl(KHttpUrlInterface $url) { if (!$url->getHost() && !$url->getScheme()) { $url->setUrl($this->getUrl()->toString(KHttpUrl::AUTHORITY)); } return $url->toString(KHttpUrl::FULL, false); }
php
protected function _getUrl(KHttpUrlInterface $url) { if (!$url->getHost() && !$url->getScheme()) { $url->setUrl($this->getUrl()->toString(KHttpUrl::AUTHORITY)); } return $url->toString(KHttpUrl::FULL, false); }
[ "protected", "function", "_getUrl", "(", "KHttpUrlInterface", "$", "url", ")", "{", "if", "(", "!", "$", "url", "->", "getHost", "(", ")", "&&", "!", "$", "url", "->", "getScheme", "(", ")", ")", "{", "$", "url", "->", "setUrl", "(", "$", "this", "->", "getUrl", "(", ")", "->", "toString", "(", "KHttpUrl", "::", "AUTHORITY", ")", ")", ";", "}", "return", "$", "url", "->", "toString", "(", "KHttpUrl", "::", "FULL", ",", "false", ")", ";", "}" ]
URL getter. Provides a fully qualified and un-escaped URL provided a URL object. @param KHttpUrlInterface $url The URL. @return string The fully qualified un-escaped URL.
[ "URL", "getter", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/view/activities/json.php#L269-L276
34,245
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setObjectName
public function setObjectName($name) { if (!is_null($name)) { $name = (string) $name; } $this->objectName = $name; return $this; }
php
public function setObjectName($name) { if (!is_null($name)) { $name = (string) $name; } $this->objectName = $name; return $this; }
[ "public", "function", "setObjectName", "(", "$", "name", ")", "{", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "(", "string", ")", "$", "name", ";", "}", "$", "this", "->", "objectName", "=", "$", "name", ";", "return", "$", "this", ";", "}" ]
Set the activity object name. @see ComActivitiesActivityObject::getObjectName @param string|null $name The activity object name. @return ComActivitiesActivityObject
[ "Set", "the", "activity", "object", "name", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L58-L66
34,246
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setDisplayName
public function setDisplayName($name) { if (!is_null($name)) { $name = (string) $name; } $this->displayName = $name; return $this; }
php
public function setDisplayName($name) { if (!is_null($name)) { $name = (string) $name; } $this->displayName = $name; return $this; }
[ "public", "function", "setDisplayName", "(", "$", "name", ")", "{", "if", "(", "!", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "(", "string", ")", "$", "name", ";", "}", "$", "this", "->", "displayName", "=", "$", "name", ";", "return", "$", "this", ";", "}" ]
Set the display name. @link http://activitystrea.ms/specs/json/1.0/#object See displayName property. @param string|null $name The display name. @return ComActivitiesActivityObject
[ "Set", "the", "display", "name", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L88-L96
34,247
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setAttachments
public function setAttachments(array $attachments, $merge = true) { if ($merge) { $this->attachments = array_merge($this->attachments, $attachments); } else { $this->attachments = $attachments; } return $this; }
php
public function setAttachments(array $attachments, $merge = true) { if ($merge) { $this->attachments = array_merge($this->attachments, $attachments); } else { $this->attachments = $attachments; } return $this; }
[ "public", "function", "setAttachments", "(", "array", "$", "attachments", ",", "$", "merge", "=", "true", ")", "{", "if", "(", "$", "merge", ")", "{", "$", "this", "->", "attachments", "=", "array_merge", "(", "$", "this", "->", "attachments", ",", "$", "attachments", ")", ";", "}", "else", "{", "$", "this", "->", "attachments", "=", "$", "attachments", ";", "}", "return", "$", "this", ";", "}" ]
Set the attachments. @link http://activitystrea.ms/specs/json/1.0/#object See attachments property. @param array $attachments An array of {@link ComActivitiesActivityObjectInterface} objects. @param bool $merge Tells if attachments should be replaced or merged with current existing attachments. @return ComActivitiesActivityObject
[ "Set", "the", "attachments", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L120-L129
34,248
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setAuthor
public function setAuthor($author) { if (!is_null($author) && !$author instanceof ComActivitiesActivityObjectInterface) { throw new InvalidArgumentException('Invalid author type.'); } $this->author = $author; return $this; }
php
public function setAuthor($author) { if (!is_null($author) && !$author instanceof ComActivitiesActivityObjectInterface) { throw new InvalidArgumentException('Invalid author type.'); } $this->author = $author; return $this; }
[ "public", "function", "setAuthor", "(", "$", "author", ")", "{", "if", "(", "!", "is_null", "(", "$", "author", ")", "&&", "!", "$", "author", "instanceof", "ComActivitiesActivityObjectInterface", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid author type.'", ")", ";", "}", "$", "this", "->", "author", "=", "$", "author", ";", "return", "$", "this", ";", "}" ]
Set the author. @link http://activitystrea.ms/specs/json/1.0/#object See author property. @param ComActivitiesActivityObjectInterface|null $author The author. @return ComActivitiesActivityObject
[ "Set", "the", "author", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L151-L159
34,249
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setContent
public function setContent($content) { if (!is_null($content)) { $content = (string) $content; } $this->content = $content; return $this; }
php
public function setContent($content) { if (!is_null($content)) { $content = (string) $content; } $this->content = $content; return $this; }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "if", "(", "!", "is_null", "(", "$", "content", ")", ")", "{", "$", "content", "=", "(", "string", ")", "$", "content", ";", "}", "$", "this", "->", "content", "=", "$", "content", ";", "return", "$", "this", ";", "}" ]
Set the content. @link http://activitystrea.ms/specs/json/1.0/#object See content property. @param string $content The content. @return ComActivitiesActivityObject
[ "Set", "the", "content", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L181-L189
34,250
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setDownstreamDuplicates
public function setDownstreamDuplicates(array $duplicates, $merge = true) { if ($merge) { $this->downstreamDuplicates = array_merge($this->downstreamDuplicates, $duplicates); } else { $this->downstreamDuplicates = $duplicates; } return $this; }
php
public function setDownstreamDuplicates(array $duplicates, $merge = true) { if ($merge) { $this->downstreamDuplicates = array_merge($this->downstreamDuplicates, $duplicates); } else { $this->downstreamDuplicates = $duplicates; } return $this; }
[ "public", "function", "setDownstreamDuplicates", "(", "array", "$", "duplicates", ",", "$", "merge", "=", "true", ")", "{", "if", "(", "$", "merge", ")", "{", "$", "this", "->", "downstreamDuplicates", "=", "array_merge", "(", "$", "this", "->", "downstreamDuplicates", ",", "$", "duplicates", ")", ";", "}", "else", "{", "$", "this", "->", "downstreamDuplicates", "=", "$", "duplicates", ";", "}", "return", "$", "this", ";", "}" ]
Set the downstream duplicates. @link http://activitystrea.ms/specs/json/1.0/#object See downstreamDuplicates property. @param array $duplicates An array of {@link ComActivitiesActivityObjectInterface} objects. @param bool $merge Tells if downstream duplicates should be replaced or merged with current existing downstream duplicates. @return ComActivitiesActivityObject
[ "Set", "the", "downstream", "duplicates", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L213-L222
34,251
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setId
public function setId($id) { if (!is_null($id)) { $id = (string) $id; } $this->id = $id; return $this; }
php
public function setId($id) { if (!is_null($id)) { $id = (string) $id; } $this->id = $id; return $this; }
[ "public", "function", "setId", "(", "$", "id", ")", "{", "if", "(", "!", "is_null", "(", "$", "id", ")", ")", "{", "$", "id", "=", "(", "string", ")", "$", "id", ";", "}", "$", "this", "->", "id", "=", "$", "id", ";", "return", "$", "this", ";", "}" ]
Set the Id. @link http://activitystrea.ms/specs/json/1.0/#object See id property. @param string|null $id The Id. @return ComActivitiesActivityObject
[ "Set", "the", "Id", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L244-L252
34,252
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setUuid
public function setUuid($uuid) { if (!is_null($uuid)) { $uuid = (string) $uuid; } $this->uuid = $uuid; return $this; }
php
public function setUuid($uuid) { if (!is_null($uuid)) { $uuid = (string) $uuid; } $this->uuid = $uuid; return $this; }
[ "public", "function", "setUuid", "(", "$", "uuid", ")", "{", "if", "(", "!", "is_null", "(", "$", "uuid", ")", ")", "{", "$", "uuid", "=", "(", "string", ")", "$", "uuid", ";", "}", "$", "this", "->", "uuid", "=", "$", "uuid", ";", "return", "$", "this", ";", "}" ]
Set the Universally Unique Identifier. @param string|null $uuid The Universally Unique Identifier. @return ComActivitiesActivityObjectInterface
[ "Set", "the", "Universally", "Unique", "Identifier", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L271-L279
34,253
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setImage
public function setImage($image) { if (!is_null($image) && !$image instanceof ComActivitiesActivityMedialinkInterface) { throw new InvalidArgumentException('Invalid image type.'); } $this->image = $image; return $this; }
php
public function setImage($image) { if (!is_null($image) && !$image instanceof ComActivitiesActivityMedialinkInterface) { throw new InvalidArgumentException('Invalid image type.'); } $this->image = $image; return $this; }
[ "public", "function", "setImage", "(", "$", "image", ")", "{", "if", "(", "!", "is_null", "(", "$", "image", ")", "&&", "!", "$", "image", "instanceof", "ComActivitiesActivityMedialinkInterface", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid image type.'", ")", ";", "}", "$", "this", "->", "image", "=", "$", "image", ";", "return", "$", "this", ";", "}" ]
Set the image. @link http://activitystrea.ms/specs/json/1.0/#object See image property. @param ComActivitiesActivityMedialinkInterface|null $image The image. @return ComActivitiesActivityObject
[ "Set", "the", "image", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L303-L311
34,254
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setPublished
public function setPublished($date) { if (!is_null($date) && !$date instanceof KDate) { throw new InvalidArgumentException('Invalid date type.'); } $this->published = $date; return $this; }
php
public function setPublished($date) { if (!is_null($date) && !$date instanceof KDate) { throw new InvalidArgumentException('Invalid date type.'); } $this->published = $date; return $this; }
[ "public", "function", "setPublished", "(", "$", "date", ")", "{", "if", "(", "!", "is_null", "(", "$", "date", ")", "&&", "!", "$", "date", "instanceof", "KDate", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid date type.'", ")", ";", "}", "$", "this", "->", "published", "=", "$", "date", ";", "return", "$", "this", ";", "}" ]
Set the published date. @link http://activitystrea.ms/specs/json/1.0/#object See published property. @param KDate $date The published date. @return ComActivitiesActivityObject
[ "Set", "the", "published", "date", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L363-L371
34,255
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setSummary
public function setSummary($summary) { if (!is_null($summary)) { $summary = (string) $summary; } $this->summary = $summary; return $this; }
php
public function setSummary($summary) { if (!is_null($summary)) { $summary = (string) $summary; } $this->summary = $summary; return $this; }
[ "public", "function", "setSummary", "(", "$", "summary", ")", "{", "if", "(", "!", "is_null", "(", "$", "summary", ")", ")", "{", "$", "summary", "=", "(", "string", ")", "$", "summary", ";", "}", "$", "this", "->", "summary", "=", "$", "summary", ";", "return", "$", "this", ";", "}" ]
Set the summary. @link http://activitystrea.ms/specs/json/1.0/#object See summary property. @param mixed $summary The summary. @return ComActivitiesActivityObject
[ "Set", "the", "summary", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L393-L401
34,256
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setUpdated
public function setUpdated($date) { if (!is_null($date) && !$date instanceof KDate) { throw new InvalidArgumentException('Invalid date type.'); } $this->updated = $date; return $this; }
php
public function setUpdated($date) { if (!is_null($date) && !$date instanceof KDate) { throw new InvalidArgumentException('Invalid date type.'); } $this->updated = $date; return $this; }
[ "public", "function", "setUpdated", "(", "$", "date", ")", "{", "if", "(", "!", "is_null", "(", "$", "date", ")", "&&", "!", "$", "date", "instanceof", "KDate", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid date type.'", ")", ";", "}", "$", "this", "->", "updated", "=", "$", "date", ";", "return", "$", "this", ";", "}" ]
Set the updated date. @link http://activitystrea.ms/specs/json/1.0/#object See updated property. @param KDate|null $date The updated date. @return ComActivitiesActivityObject
[ "Set", "the", "updated", "date", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L423-L431
34,257
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setUpstreamDuplicates
public function setUpstreamDuplicates(array $duplicates, $merge = true) { if ($merge) { $this->downstreamDuplicates = array_merge($this->downstreamDuplicates, $duplicates); } else { $this->upstreamDuplicates = $duplicates; } return $this; }
php
public function setUpstreamDuplicates(array $duplicates, $merge = true) { if ($merge) { $this->downstreamDuplicates = array_merge($this->downstreamDuplicates, $duplicates); } else { $this->upstreamDuplicates = $duplicates; } return $this; }
[ "public", "function", "setUpstreamDuplicates", "(", "array", "$", "duplicates", ",", "$", "merge", "=", "true", ")", "{", "if", "(", "$", "merge", ")", "{", "$", "this", "->", "downstreamDuplicates", "=", "array_merge", "(", "$", "this", "->", "downstreamDuplicates", ",", "$", "duplicates", ")", ";", "}", "else", "{", "$", "this", "->", "upstreamDuplicates", "=", "$", "duplicates", ";", "}", "return", "$", "this", ";", "}" ]
Set the upstream duplicates. @link http://activitystrea.ms/specs/json/1.0/#object See upstreamDuplicates property. @param array $duplicates An array of {@link ComActivitiesActivityObjectInterface} objects. @param bool $merge Tells if upstream duplicates should be replaced or merged with current existing upstream duplicates. @return ComActivitiesActivityObject
[ "Set", "the", "upstream", "duplicates", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L455-L464
34,258
joomlatools/joomlatools-framework-activities
activity/object/object.php
ComActivitiesActivityObject.setAttributes
public function setAttributes(array $attribs = array(), $merge = true) { if ($merge) { $this->attributes = array_merge($this->attributes, $attribs); } else { $this->attributes = $attribs; } return $this; }
php
public function setAttributes(array $attribs = array(), $merge = true) { if ($merge) { $this->attributes = array_merge($this->attributes, $attribs); } else { $this->attributes = $attribs; } return $this; }
[ "public", "function", "setAttributes", "(", "array", "$", "attribs", "=", "array", "(", ")", ",", "$", "merge", "=", "true", ")", "{", "if", "(", "$", "merge", ")", "{", "$", "this", "->", "attributes", "=", "array_merge", "(", "$", "this", "->", "attributes", ",", "$", "attribs", ")", ";", "}", "else", "{", "$", "this", "->", "attributes", "=", "$", "attribs", ";", "}", "return", "$", "this", ";", "}" ]
Set the attributes. @param array $attributes The attributes. @param bool $merge Tells if attributes should be replaced or merged with current existing attributes. @return ComActivitiesActivityObject
[ "Set", "the", "attributes", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/object/object.php#L513-L522
34,259
joomlatools/joomlatools-framework-activities
controller/activity.php
ComActivitiesControllerActivity.getRequest
public function getRequest() { $request = parent::getRequest(); // Force set the 'package' in the request $request->query->package = $this->getIdentifier()->package; return $request; }
php
public function getRequest() { $request = parent::getRequest(); // Force set the 'package' in the request $request->query->package = $this->getIdentifier()->package; return $request; }
[ "public", "function", "getRequest", "(", ")", "{", "$", "request", "=", "parent", "::", "getRequest", "(", ")", ";", "// Force set the 'package' in the request", "$", "request", "->", "query", "->", "package", "=", "$", "this", "->", "getIdentifier", "(", ")", "->", "package", ";", "return", "$", "request", ";", "}" ]
Overridden for forcing the package model state.
[ "Overridden", "for", "forcing", "the", "package", "model", "state", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/activity.php#L111-L119
34,260
joomlatools/joomlatools-framework-activities
controller/activity.php
ComActivitiesControllerActivity._beforeAdd
protected function _beforeAdd(KControllerContextInterface $context) { $context->request->data->ip = $this->getObject('request')->getAddress(); }
php
protected function _beforeAdd(KControllerContextInterface $context) { $context->request->data->ip = $this->getObject('request')->getAddress(); }
[ "protected", "function", "_beforeAdd", "(", "KControllerContextInterface", "$", "context", ")", "{", "$", "context", "->", "request", "->", "data", "->", "ip", "=", "$", "this", "->", "getObject", "(", "'request'", ")", "->", "getAddress", "(", ")", ";", "}" ]
Set the IP address if we are adding a new activity. @param KControllerContextInterface $context A command context object. @return KModelEntityInterface
[ "Set", "the", "IP", "address", "if", "we", "are", "adding", "a", "new", "activity", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/activity.php#L127-L130
34,261
netgen-layouts/content-browser-ezplatform
lib/Backend/EzTagsBackend.php
EzTagsBackend.buildLocation
private function buildLocation(): Location { $tag = $this->getRootTag(); $tagName = $this->translationHelper->getTranslatedByMethod( $tag, 'getKeyword' ); return new Location($tag, (string) $tagName); }
php
private function buildLocation(): Location { $tag = $this->getRootTag(); $tagName = $this->translationHelper->getTranslatedByMethod( $tag, 'getKeyword' ); return new Location($tag, (string) $tagName); }
[ "private", "function", "buildLocation", "(", ")", ":", "Location", "{", "$", "tag", "=", "$", "this", "->", "getRootTag", "(", ")", ";", "$", "tagName", "=", "$", "this", "->", "translationHelper", "->", "getTranslatedByMethod", "(", "$", "tag", ",", "'getKeyword'", ")", ";", "return", "new", "Location", "(", "$", "tag", ",", "(", "string", ")", "$", "tagName", ")", ";", "}" ]
Builds the location.
[ "Builds", "the", "location", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzTagsBackend.php#L167-L177
34,262
netgen-layouts/content-browser-ezplatform
lib/Backend/EzTagsBackend.php
EzTagsBackend.buildItem
private function buildItem(Tag $tag): Item { $tagName = $this->translationHelper->getTranslatedByMethod( $tag, 'getKeyword' ); return new Item($tag, (string) $tagName); }
php
private function buildItem(Tag $tag): Item { $tagName = $this->translationHelper->getTranslatedByMethod( $tag, 'getKeyword' ); return new Item($tag, (string) $tagName); }
[ "private", "function", "buildItem", "(", "Tag", "$", "tag", ")", ":", "Item", "{", "$", "tagName", "=", "$", "this", "->", "translationHelper", "->", "getTranslatedByMethod", "(", "$", "tag", ",", "'getKeyword'", ")", ";", "return", "new", "Item", "(", "$", "tag", ",", "(", "string", ")", "$", "tagName", ")", ";", "}" ]
Builds the item from provided tag.
[ "Builds", "the", "item", "from", "provided", "tag", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzTagsBackend.php#L182-L190
34,263
netgen-layouts/content-browser-ezplatform
lib/Backend/EzTagsBackend.php
EzTagsBackend.buildItems
private function buildItems(array $tags): array { return array_map( function (Tag $tag): Item { return $this->buildItem($tag); }, $tags ); }
php
private function buildItems(array $tags): array { return array_map( function (Tag $tag): Item { return $this->buildItem($tag); }, $tags ); }
[ "private", "function", "buildItems", "(", "array", "$", "tags", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "Tag", "$", "tag", ")", ":", "Item", "{", "return", "$", "this", "->", "buildItem", "(", "$", "tag", ")", ";", "}", ",", "$", "tags", ")", ";", "}" ]
Builds the items from provided tags. @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag[] $tags @return \Netgen\ContentBrowser\Ez\Item\EzTags\Item[]
[ "Builds", "the", "items", "from", "provided", "tags", "." ]
1f189f154933b92757d8072aea1ba95ac07c1167
https://github.com/netgen-layouts/content-browser-ezplatform/blob/1f189f154933b92757d8072aea1ba95ac07c1167/lib/Backend/EzTagsBackend.php#L199-L207
34,264
joomlatools/joomlatools-framework-activities
controller/behavior/loggable.php
ComActivitiesControllerBehaviorLoggable.attachLogger
public function attachLogger($logger, $config = array()) { $identifier = $this->getIdentifier($logger); if (!$this->__queue->hasIdentifier($identifier)) { $logger = $this->getObject($identifier, $config); if (!($logger instanceof ComActivitiesActivityLoggerInterface)) { throw new UnexpectedValueException( "Logger $identifier does not implement ComActivitiesActivityLoggerInterface" ); } $this->__queue->enqueue($logger, self::PRIORITY_NORMAL); } return $this; }
php
public function attachLogger($logger, $config = array()) { $identifier = $this->getIdentifier($logger); if (!$this->__queue->hasIdentifier($identifier)) { $logger = $this->getObject($identifier, $config); if (!($logger instanceof ComActivitiesActivityLoggerInterface)) { throw new UnexpectedValueException( "Logger $identifier does not implement ComActivitiesActivityLoggerInterface" ); } $this->__queue->enqueue($logger, self::PRIORITY_NORMAL); } return $this; }
[ "public", "function", "attachLogger", "(", "$", "logger", ",", "$", "config", "=", "array", "(", ")", ")", "{", "$", "identifier", "=", "$", "this", "->", "getIdentifier", "(", "$", "logger", ")", ";", "if", "(", "!", "$", "this", "->", "__queue", "->", "hasIdentifier", "(", "$", "identifier", ")", ")", "{", "$", "logger", "=", "$", "this", "->", "getObject", "(", "$", "identifier", ",", "$", "config", ")", ";", "if", "(", "!", "(", "$", "logger", "instanceof", "ComActivitiesActivityLoggerInterface", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "\"Logger $identifier does not implement ComActivitiesActivityLoggerInterface\"", ")", ";", "}", "$", "this", "->", "__queue", "->", "enqueue", "(", "$", "logger", ",", "self", "::", "PRIORITY_NORMAL", ")", ";", "}", "return", "$", "this", ";", "}" ]
Attach a logger. @param mixed $logger An object that implements ObjectInterface, ObjectIdentifier object or valid identifier string. @param array $config An optional associative array of configuration settings. @throws UnexpectedValueException if the logger does not implement ComActivitiesActivityLoggerInterface. @return ComActivitiesControllerBehaviorLoggable
[ "Attach", "a", "logger", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/behavior/loggable.php#L144-L163
34,265
joomlatools/joomlatools-framework-activities
controller/behavior/resourceable.php
ComActivitiesControllerBehaviorResourceable._getResource
protected function _getResource($entity) { $model = $this->_getController()->getModel(); $model->reset()->getState()->setValues(array( 'package' => $entity->package, 'name' => $entity->name, 'resource_id' => $entity->row )); return $model->fetch(); }
php
protected function _getResource($entity) { $model = $this->_getController()->getModel(); $model->reset()->getState()->setValues(array( 'package' => $entity->package, 'name' => $entity->name, 'resource_id' => $entity->row )); return $model->fetch(); }
[ "protected", "function", "_getResource", "(", "$", "entity", ")", "{", "$", "model", "=", "$", "this", "->", "_getController", "(", ")", "->", "getModel", "(", ")", ";", "$", "model", "->", "reset", "(", ")", "->", "getState", "(", ")", "->", "setValues", "(", "array", "(", "'package'", "=>", "$", "entity", "->", "package", ",", "'name'", "=>", "$", "entity", "->", "name", ",", "'resource_id'", "=>", "$", "entity", "->", "row", ")", ")", ";", "return", "$", "model", "->", "fetch", "(", ")", ";", "}" ]
Resource getter. @param KModelEntityInterface $entity The entity to get the resource from @return KModelEntityInterface|null The resource
[ "Resource", "getter", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/behavior/resourceable.php#L81-L92
34,266
joomlatools/joomlatools-framework-activities
controller/behavior/resourceable.php
ComActivitiesControllerBehaviorResourceable._getData
protected function _getData(KModelEntityInterface $entity) { $data = array( 'package' => $entity->package, 'name' => $entity->name, 'resource_id' => $entity->row, 'title' => $entity->title ); if ($uuid = $entity->getActivityObject()->getUuid()) { $data['uuid'] = $uuid; } return $data; }
php
protected function _getData(KModelEntityInterface $entity) { $data = array( 'package' => $entity->package, 'name' => $entity->name, 'resource_id' => $entity->row, 'title' => $entity->title ); if ($uuid = $entity->getActivityObject()->getUuid()) { $data['uuid'] = $uuid; } return $data; }
[ "protected", "function", "_getData", "(", "KModelEntityInterface", "$", "entity", ")", "{", "$", "data", "=", "array", "(", "'package'", "=>", "$", "entity", "->", "package", ",", "'name'", "=>", "$", "entity", "->", "name", ",", "'resource_id'", "=>", "$", "entity", "->", "row", ",", "'title'", "=>", "$", "entity", "->", "title", ")", ";", "if", "(", "$", "uuid", "=", "$", "entity", "->", "getActivityObject", "(", ")", "->", "getUuid", "(", ")", ")", "{", "$", "data", "[", "'uuid'", "]", "=", "$", "uuid", ";", "}", "return", "$", "data", ";", "}" ]
Entity data getter @param KModelEntityInterface $entity The entity to get data from @return array The entity data
[ "Entity", "data", "getter" ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/behavior/resourceable.php#L101-L115
34,267
joomlatools/joomlatools-framework-activities
controller/behavior/resourceable.php
ComActivitiesControllerBehaviorResourceable._getController
protected function _getController() { if (!$this->_controller instanceof KControllerInterface) { $this->_controller = $this->getObject($this->_controller); } return $this->_controller; }
php
protected function _getController() { if (!$this->_controller instanceof KControllerInterface) { $this->_controller = $this->getObject($this->_controller); } return $this->_controller; }
[ "protected", "function", "_getController", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_controller", "instanceof", "KControllerInterface", ")", "{", "$", "this", "->", "_controller", "=", "$", "this", "->", "getObject", "(", "$", "this", "->", "_controller", ")", ";", "}", "return", "$", "this", "->", "_controller", ";", "}" ]
Resource controller getter. @return KControllerInterface The controller
[ "Resource", "controller", "getter", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/controller/behavior/resourceable.php#L122-L129
34,268
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver._loadSubClasses
protected function _loadSubClasses(): void { // Load the sql and util class for the driver $thisClass = \get_class($this); $nsArray = explode("\\", $thisClass); array_pop($nsArray); $driver = array_pop($nsArray); $sqlClass = __NAMESPACE__ . "\\{$driver}\\SQL"; $utilClass = __NAMESPACE__ . "\\{$driver}\\Util"; $this->sql = new $sqlClass(); $this->util = new $utilClass($this); }
php
protected function _loadSubClasses(): void { // Load the sql and util class for the driver $thisClass = \get_class($this); $nsArray = explode("\\", $thisClass); array_pop($nsArray); $driver = array_pop($nsArray); $sqlClass = __NAMESPACE__ . "\\{$driver}\\SQL"; $utilClass = __NAMESPACE__ . "\\{$driver}\\Util"; $this->sql = new $sqlClass(); $this->util = new $utilClass($this); }
[ "protected", "function", "_loadSubClasses", "(", ")", ":", "void", "{", "// Load the sql and util class for the driver", "$", "thisClass", "=", "\\", "get_class", "(", "$", "this", ")", ";", "$", "nsArray", "=", "explode", "(", "\"\\\\\"", ",", "$", "thisClass", ")", ";", "array_pop", "(", "$", "nsArray", ")", ";", "$", "driver", "=", "array_pop", "(", "$", "nsArray", ")", ";", "$", "sqlClass", "=", "__NAMESPACE__", ".", "\"\\\\{$driver}\\\\SQL\"", ";", "$", "utilClass", "=", "__NAMESPACE__", ".", "\"\\\\{$driver}\\\\Util\"", ";", "$", "this", "->", "sql", "=", "new", "$", "sqlClass", "(", ")", ";", "$", "this", "->", "util", "=", "new", "$", "utilClass", "(", "$", "this", ")", ";", "}" ]
Loads the subclasses for the driver @return void
[ "Loads", "the", "subclasses", "for", "the", "driver" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L100-L112
34,269
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.prepareQuery
public function prepareQuery(string $sql, array $data): ?PDOStatement { // Prepare the sql, save the statement for easy access later $this->statement = $this->prepare($sql); // Bind the parameters foreach($data as $k => $value) { // Parameters are 1-based, the data is 0-based // So, if the key is numeric, add 1 if(is_numeric($k)) { $k++; } $this->statement->bindValue($k, $value); } return $this->statement; }
php
public function prepareQuery(string $sql, array $data): ?PDOStatement { // Prepare the sql, save the statement for easy access later $this->statement = $this->prepare($sql); // Bind the parameters foreach($data as $k => $value) { // Parameters are 1-based, the data is 0-based // So, if the key is numeric, add 1 if(is_numeric($k)) { $k++; } $this->statement->bindValue($k, $value); } return $this->statement; }
[ "public", "function", "prepareQuery", "(", "string", "$", "sql", ",", "array", "$", "data", ")", ":", "?", "PDOStatement", "{", "// Prepare the sql, save the statement for easy access later", "$", "this", "->", "statement", "=", "$", "this", "->", "prepare", "(", "$", "sql", ")", ";", "// Bind the parameters", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "value", ")", "{", "// Parameters are 1-based, the data is 0-based", "// So, if the key is numeric, add 1", "if", "(", "is_numeric", "(", "$", "k", ")", ")", "{", "$", "k", "++", ";", "}", "$", "this", "->", "statement", "->", "bindValue", "(", "$", "k", ",", "$", "value", ")", ";", "}", "return", "$", "this", "->", "statement", ";", "}" ]
Simplifies prepared statements for database queries @param string $sql @param array $data @return PDOStatement | FALSE @throws InvalidArgumentException
[ "Simplifies", "prepared", "statements", "for", "database", "queries" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L202-L220
34,270
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.prepareExecute
public function prepareExecute(string $sql, array $params): ?PDOStatement { $this->statement = $this->prepareQuery($sql, $params); $this->statement->execute(); return $this->statement; }
php
public function prepareExecute(string $sql, array $params): ?PDOStatement { $this->statement = $this->prepareQuery($sql, $params); $this->statement->execute(); return $this->statement; }
[ "public", "function", "prepareExecute", "(", "string", "$", "sql", ",", "array", "$", "params", ")", ":", "?", "PDOStatement", "{", "$", "this", "->", "statement", "=", "$", "this", "->", "prepareQuery", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "this", "->", "statement", "->", "execute", "(", ")", ";", "return", "$", "this", "->", "statement", ";", "}" ]
Create and execute a prepared statement with the provided parameters @param string $sql @param array $params @throws InvalidArgumentException @return PDOStatement
[ "Create", "and", "execute", "a", "prepared", "statement", "with", "the", "provided", "parameters" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L230-L236
34,271
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.prefixTable
public function prefixTable(string $table): string { // Add the prefix to the table name // before quoting it if ( ! empty($this->tablePrefix)) { // Split identifier by period, will split into: // database.schema.table OR // schema.table OR // database.table OR // table $identifiers = explode('.', $table); $segments = count($identifiers); // Quote the last item, and add the database prefix $identifiers[$segments - 1] = $this->_prefix(end($identifiers)); // Rejoin $table = implode('.', $identifiers); } return $table; }
php
public function prefixTable(string $table): string { // Add the prefix to the table name // before quoting it if ( ! empty($this->tablePrefix)) { // Split identifier by period, will split into: // database.schema.table OR // schema.table OR // database.table OR // table $identifiers = explode('.', $table); $segments = count($identifiers); // Quote the last item, and add the database prefix $identifiers[$segments - 1] = $this->_prefix(end($identifiers)); // Rejoin $table = implode('.', $identifiers); } return $table; }
[ "public", "function", "prefixTable", "(", "string", "$", "table", ")", ":", "string", "{", "// Add the prefix to the table name", "// before quoting it", "if", "(", "!", "empty", "(", "$", "this", "->", "tablePrefix", ")", ")", "{", "// Split identifier by period, will split into:", "// database.schema.table OR", "// schema.table OR", "// database.table OR", "// table", "$", "identifiers", "=", "explode", "(", "'.'", ",", "$", "table", ")", ";", "$", "segments", "=", "count", "(", "$", "identifiers", ")", ";", "// Quote the last item, and add the database prefix", "$", "identifiers", "[", "$", "segments", "-", "1", "]", "=", "$", "this", "->", "_prefix", "(", "end", "(", "$", "identifiers", ")", ")", ";", "// Rejoin", "$", "table", "=", "implode", "(", "'.'", ",", "$", "identifiers", ")", ";", "}", "return", "$", "table", ";", "}" ]
Prefixes a table if it is not already prefixed @param string $table @return string
[ "Prefixes", "a", "table", "if", "it", "is", "not", "already", "prefixed" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L254-L276
34,272
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.quoteTable
public function quoteTable($table): string { $table = $this->prefixTable($table); // Finally, quote the table return $this->quoteIdent($table); }
php
public function quoteTable($table): string { $table = $this->prefixTable($table); // Finally, quote the table return $this->quoteIdent($table); }
[ "public", "function", "quoteTable", "(", "$", "table", ")", ":", "string", "{", "$", "table", "=", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ";", "// Finally, quote the table", "return", "$", "this", "->", "quoteIdent", "(", "$", "table", ")", ";", "}" ]
Quote database table name, and set prefix @param string $table @return string
[ "Quote", "database", "table", "name", "and", "set", "prefix" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L284-L290
34,273
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.quoteIdent
public function quoteIdent($identifier) { if (\is_array($identifier)) { return array_map([$this, __METHOD__], $identifier); } // Handle comma-separated identifiers if (strpos($identifier, ',') !== FALSE) { $parts = array_map('mb_trim', explode(',', $identifier)); $parts = array_map([$this, __METHOD__], $parts); $identifier = implode(',', $parts); } // Split each identifier by the period $hiers = explode('.', $identifier); $hiers = array_map('mb_trim', $hiers); // Re-compile the string $raw = implode('.', array_map([$this, '_quote'], $hiers)); // Fix functions $funcs = []; preg_match_all("#{$this->escapeCharOpen}([a-zA-Z0-9_]+(\((.*?)\))){$this->escapeCharClose}#iu", $raw, $funcs, PREG_SET_ORDER); foreach($funcs as $f) { // Unquote the function $raw = str_replace($f[0], $f[1], $raw); // Quote the inside identifiers $raw = str_replace($f[3], $this->quoteIdent($f[3]), $raw); } return $raw; }
php
public function quoteIdent($identifier) { if (\is_array($identifier)) { return array_map([$this, __METHOD__], $identifier); } // Handle comma-separated identifiers if (strpos($identifier, ',') !== FALSE) { $parts = array_map('mb_trim', explode(',', $identifier)); $parts = array_map([$this, __METHOD__], $parts); $identifier = implode(',', $parts); } // Split each identifier by the period $hiers = explode('.', $identifier); $hiers = array_map('mb_trim', $hiers); // Re-compile the string $raw = implode('.', array_map([$this, '_quote'], $hiers)); // Fix functions $funcs = []; preg_match_all("#{$this->escapeCharOpen}([a-zA-Z0-9_]+(\((.*?)\))){$this->escapeCharClose}#iu", $raw, $funcs, PREG_SET_ORDER); foreach($funcs as $f) { // Unquote the function $raw = str_replace($f[0], $f[1], $raw); // Quote the inside identifiers $raw = str_replace($f[3], $this->quoteIdent($f[3]), $raw); } return $raw; }
[ "public", "function", "quoteIdent", "(", "$", "identifier", ")", "{", "if", "(", "\\", "is_array", "(", "$", "identifier", ")", ")", "{", "return", "array_map", "(", "[", "$", "this", ",", "__METHOD__", "]", ",", "$", "identifier", ")", ";", "}", "// Handle comma-separated identifiers", "if", "(", "strpos", "(", "$", "identifier", ",", "','", ")", "!==", "FALSE", ")", "{", "$", "parts", "=", "array_map", "(", "'mb_trim'", ",", "explode", "(", "','", ",", "$", "identifier", ")", ")", ";", "$", "parts", "=", "array_map", "(", "[", "$", "this", ",", "__METHOD__", "]", ",", "$", "parts", ")", ";", "$", "identifier", "=", "implode", "(", "','", ",", "$", "parts", ")", ";", "}", "// Split each identifier by the period", "$", "hiers", "=", "explode", "(", "'.'", ",", "$", "identifier", ")", ";", "$", "hiers", "=", "array_map", "(", "'mb_trim'", ",", "$", "hiers", ")", ";", "// Re-compile the string", "$", "raw", "=", "implode", "(", "'.'", ",", "array_map", "(", "[", "$", "this", ",", "'_quote'", "]", ",", "$", "hiers", ")", ")", ";", "// Fix functions", "$", "funcs", "=", "[", "]", ";", "preg_match_all", "(", "\"#{$this->escapeCharOpen}([a-zA-Z0-9_]+(\\((.*?)\\))){$this->escapeCharClose}#iu\"", ",", "$", "raw", ",", "$", "funcs", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "$", "funcs", "as", "$", "f", ")", "{", "// Unquote the function", "$", "raw", "=", "str_replace", "(", "$", "f", "[", "0", "]", ",", "$", "f", "[", "1", "]", ",", "$", "raw", ")", ";", "// Quote the inside identifiers", "$", "raw", "=", "str_replace", "(", "$", "f", "[", "3", "]", ",", "$", "this", "->", "quoteIdent", "(", "$", "f", "[", "3", "]", ")", ",", "$", "raw", ")", ";", "}", "return", "$", "raw", ";", "}" ]
Surrounds the string with the databases identifier escape characters @param mixed $identifier @return string|array
[ "Surrounds", "the", "string", "with", "the", "databases", "identifier", "escape", "characters" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L298-L333
34,274
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.getColumns
public function getColumns($table): ?array { return $this->driverQuery($this->getSql()->columnList($this->prefixTable($table)), FALSE); }
php
public function getColumns($table): ?array { return $this->driverQuery($this->getSql()->columnList($this->prefixTable($table)), FALSE); }
[ "public", "function", "getColumns", "(", "$", "table", ")", ":", "?", "array", "{", "return", "$", "this", "->", "driverQuery", "(", "$", "this", "->", "getSql", "(", ")", "->", "columnList", "(", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ")", ",", "FALSE", ")", ";", "}" ]
Retrieve column information for the current database table @param string $table @return array
[ "Retrieve", "column", "information", "for", "the", "current", "database", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L436-L439
34,275
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.getIndexes
public function getIndexes($table): ?array { return $this->driverQuery($this->getSql()->indexList($this->prefixTable($table)), FALSE); }
php
public function getIndexes($table): ?array { return $this->driverQuery($this->getSql()->indexList($this->prefixTable($table)), FALSE); }
[ "public", "function", "getIndexes", "(", "$", "table", ")", ":", "?", "array", "{", "return", "$", "this", "->", "driverQuery", "(", "$", "this", "->", "getSql", "(", ")", "->", "indexList", "(", "$", "this", "->", "prefixTable", "(", "$", "table", ")", ")", ",", "FALSE", ")", ";", "}" ]
Retrieve indexes for the table @param string $table @return array
[ "Retrieve", "indexes", "for", "the", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L458-L461
34,276
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.driverQuery
public function driverQuery($query, $filteredIndex=TRUE): ?array { // Call the appropriate method, if it exists if (\is_string($query) && method_exists($this->sql, $query)) { $query = $this->getSql()->$query(); } // Return if the values are returned instead of a query, // or if the query doesn't apply to the driver if ( ! \is_string($query)) { return $query; } // Run the query! $res = $this->query($query); $flag = $filteredIndex ? PDO::FETCH_NUM : PDO::FETCH_ASSOC; $all = $res->fetchAll($flag); return $filteredIndex ? \dbFilter($all, 0) : $all; }
php
public function driverQuery($query, $filteredIndex=TRUE): ?array { // Call the appropriate method, if it exists if (\is_string($query) && method_exists($this->sql, $query)) { $query = $this->getSql()->$query(); } // Return if the values are returned instead of a query, // or if the query doesn't apply to the driver if ( ! \is_string($query)) { return $query; } // Run the query! $res = $this->query($query); $flag = $filteredIndex ? PDO::FETCH_NUM : PDO::FETCH_ASSOC; $all = $res->fetchAll($flag); return $filteredIndex ? \dbFilter($all, 0) : $all; }
[ "public", "function", "driverQuery", "(", "$", "query", ",", "$", "filteredIndex", "=", "TRUE", ")", ":", "?", "array", "{", "// Call the appropriate method, if it exists", "if", "(", "\\", "is_string", "(", "$", "query", ")", "&&", "method_exists", "(", "$", "this", "->", "sql", ",", "$", "query", ")", ")", "{", "$", "query", "=", "$", "this", "->", "getSql", "(", ")", "->", "$", "query", "(", ")", ";", "}", "// Return if the values are returned instead of a query,", "// or if the query doesn't apply to the driver", "if", "(", "!", "\\", "is_string", "(", "$", "query", ")", ")", "{", "return", "$", "query", ";", "}", "// Run the query!", "$", "res", "=", "$", "this", "->", "query", "(", "$", "query", ")", ";", "$", "flag", "=", "$", "filteredIndex", "?", "PDO", "::", "FETCH_NUM", ":", "PDO", "::", "FETCH_ASSOC", ";", "$", "all", "=", "$", "res", "->", "fetchAll", "(", "$", "flag", ")", ";", "return", "$", "filteredIndex", "?", "\\", "dbFilter", "(", "$", "all", ",", "0", ")", ":", "$", "all", ";", "}" ]
Method to simplify retrieving db results for meta-data queries @param string|array|null $query @param bool $filteredIndex @return array|null
[ "Method", "to", "simplify", "retrieving", "db", "results", "for", "meta", "-", "data", "queries" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L480-L502
34,277
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.numRows
public function numRows(): ?int { $regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i'; $output = []; if (preg_match($regex, $this->lastQuery, $output) > 0) { $stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}"); return (int) $stmt->fetchColumn(); } return NULL; }
php
public function numRows(): ?int { $regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i'; $output = []; if (preg_match($regex, $this->lastQuery, $output) > 0) { $stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}"); return (int) $stmt->fetchColumn(); } return NULL; }
[ "public", "function", "numRows", "(", ")", ":", "?", "int", "{", "$", "regex", "=", "'/^SELECT\\s+(?:ALL\\s+|DISTINCT\\s+)?(?:.*?)\\s+FROM\\s+(.*)$/i'", ";", "$", "output", "=", "[", "]", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "this", "->", "lastQuery", ",", "$", "output", ")", ">", "0", ")", "{", "$", "stmt", "=", "$", "this", "->", "query", "(", "\"SELECT COUNT(*) FROM {$output[1]}\"", ")", ";", "return", "(", "int", ")", "$", "stmt", "->", "fetchColumn", "(", ")", ";", "}", "return", "NULL", ";", "}" ]
Return the number of rows returned for a SELECT query @see http://us3.php.net/manual/en/pdostatement.rowcount.php#87110 @return int|null
[ "Return", "the", "number", "of", "rows", "returned", "for", "a", "SELECT", "query" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L510-L522
34,278
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver.truncate
public function truncate(string $table): PDOStatement { $sql = $this->hasTruncate ? 'TRUNCATE TABLE ' : 'DELETE FROM '; $sql .= $this->quoteTable($table); $this->statement = $this->query($sql); return $this->statement; }
php
public function truncate(string $table): PDOStatement { $sql = $this->hasTruncate ? 'TRUNCATE TABLE ' : 'DELETE FROM '; $sql .= $this->quoteTable($table); $this->statement = $this->query($sql); return $this->statement; }
[ "public", "function", "truncate", "(", "string", "$", "table", ")", ":", "PDOStatement", "{", "$", "sql", "=", "$", "this", "->", "hasTruncate", "?", "'TRUNCATE TABLE '", ":", "'DELETE FROM '", ";", "$", "sql", ".=", "$", "this", "->", "quoteTable", "(", "$", "table", ")", ";", "$", "this", "->", "statement", "=", "$", "this", "->", "query", "(", "$", "sql", ")", ";", "return", "$", "this", "->", "statement", ";", "}" ]
Empty the passed table @param string $table @return PDOStatement
[ "Empty", "the", "passed", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L581-L591
34,279
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver._quote
public function _quote($str) { // Check that the current value is a string, // and is not already quoted before quoting // that value, otherwise, return the original value return ( \is_string($str) && strpos($str, $this->escapeCharOpen) !== 0 && strrpos($str, $this->escapeCharClose) !== 0 ) ? "{$this->escapeCharOpen}{$str}{$this->escapeCharClose}" : $str; }
php
public function _quote($str) { // Check that the current value is a string, // and is not already quoted before quoting // that value, otherwise, return the original value return ( \is_string($str) && strpos($str, $this->escapeCharOpen) !== 0 && strrpos($str, $this->escapeCharClose) !== 0 ) ? "{$this->escapeCharOpen}{$str}{$this->escapeCharClose}" : $str; }
[ "public", "function", "_quote", "(", "$", "str", ")", "{", "// Check that the current value is a string,", "// and is not already quoted before quoting", "// that value, otherwise, return the original value", "return", "(", "\\", "is_string", "(", "$", "str", ")", "&&", "strpos", "(", "$", "str", ",", "$", "this", "->", "escapeCharOpen", ")", "!==", "0", "&&", "strrpos", "(", "$", "str", ",", "$", "this", "->", "escapeCharClose", ")", "!==", "0", ")", "?", "\"{$this->escapeCharOpen}{$str}{$this->escapeCharClose}\"", ":", "$", "str", ";", "}" ]
Helper method for quote_ident @param mixed $str @return mixed
[ "Helper", "method", "for", "quote_ident" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L599-L612
34,280
aviat4ion/Query
src/Drivers/AbstractDriver.php
AbstractDriver._prefix
protected function _prefix(string $str): string { // Don't prefix an already prefixed table if (strpos($str, $this->tablePrefix) !== FALSE) { return $str; } return $this->tablePrefix . $str; }
php
protected function _prefix(string $str): string { // Don't prefix an already prefixed table if (strpos($str, $this->tablePrefix) !== FALSE) { return $str; } return $this->tablePrefix . $str; }
[ "protected", "function", "_prefix", "(", "string", "$", "str", ")", ":", "string", "{", "// Don't prefix an already prefixed table", "if", "(", "strpos", "(", "$", "str", ",", "$", "this", "->", "tablePrefix", ")", "!==", "FALSE", ")", "{", "return", "$", "str", ";", "}", "return", "$", "this", "->", "tablePrefix", ".", "$", "str", ";", "}" ]
Sets the table prefix on the passed string @param string $str @return string
[ "Sets", "the", "table", "prefix", "on", "the", "passed", "string" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/AbstractDriver.php#L620-L629
34,281
aviat4ion/Query
RoboFile.php
RoboFile.analyze
public function analyze() { $this->prepare(); $this->lint(); $this->phploc(TRUE); $this->phpcs(TRUE); $this->dependencyReport(); $this->phpcpdReport(); }
php
public function analyze() { $this->prepare(); $this->lint(); $this->phploc(TRUE); $this->phpcs(TRUE); $this->dependencyReport(); $this->phpcpdReport(); }
[ "public", "function", "analyze", "(", ")", "{", "$", "this", "->", "prepare", "(", ")", ";", "$", "this", "->", "lint", "(", ")", ";", "$", "this", "->", "phploc", "(", "TRUE", ")", ";", "$", "this", "->", "phpcs", "(", "TRUE", ")", ";", "$", "this", "->", "dependencyReport", "(", ")", ";", "$", "this", "->", "phpcpdReport", "(", ")", ";", "}" ]
Do static analysis tasks
[ "Do", "static", "analysis", "tasks" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/RoboFile.php#L54-L62
34,282
aviat4ion/Query
RoboFile.php
RoboFile.phploc
public function phploc($report = FALSE) { // Command for generating reports $report_cmd_parts = [ 'vendor/bin/phploc', '--count-tests', '--log-csv=build/logs/phploc.csv', '--log-xml=build/logs/phploc.xml', 'src', 'tests' ]; // Command for generating direct output $normal_cmd_parts = [ 'vendor/bin/phploc', '--count-tests', 'src', 'tests' ]; $cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts; $this->_run($cmd_parts); }
php
public function phploc($report = FALSE) { // Command for generating reports $report_cmd_parts = [ 'vendor/bin/phploc', '--count-tests', '--log-csv=build/logs/phploc.csv', '--log-xml=build/logs/phploc.xml', 'src', 'tests' ]; // Command for generating direct output $normal_cmd_parts = [ 'vendor/bin/phploc', '--count-tests', 'src', 'tests' ]; $cmd_parts = ($report) ? $report_cmd_parts : $normal_cmd_parts; $this->_run($cmd_parts); }
[ "public", "function", "phploc", "(", "$", "report", "=", "FALSE", ")", "{", "// Command for generating reports", "$", "report_cmd_parts", "=", "[", "'vendor/bin/phploc'", ",", "'--count-tests'", ",", "'--log-csv=build/logs/phploc.csv'", ",", "'--log-xml=build/logs/phploc.xml'", ",", "'src'", ",", "'tests'", "]", ";", "// Command for generating direct output", "$", "normal_cmd_parts", "=", "[", "'vendor/bin/phploc'", ",", "'--count-tests'", ",", "'src'", ",", "'tests'", "]", ";", "$", "cmd_parts", "=", "(", "$", "report", ")", "?", "$", "report_cmd_parts", ":", "$", "normal_cmd_parts", ";", "$", "this", "->", "_run", "(", "$", "cmd_parts", ")", ";", "}" ]
Run the phploc tool @param bool $report - if true, generates reports instead of direct output
[ "Run", "the", "phploc", "tool" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/RoboFile.php#L153-L176
34,283
aviat4ion/Query
RoboFile.php
RoboFile.watch
public function watch() { $this->taskWatch() ->monitor('composer.json', function() { $this->taskComposerUpdate()->run(); }) ->monitor('src', function () { $this->taskExec('test')->run(); }) ->monitor('tests', function () { $this->taskExec('test')->run(); }) ->run(); }
php
public function watch() { $this->taskWatch() ->monitor('composer.json', function() { $this->taskComposerUpdate()->run(); }) ->monitor('src', function () { $this->taskExec('test')->run(); }) ->monitor('tests', function () { $this->taskExec('test')->run(); }) ->run(); }
[ "public", "function", "watch", "(", ")", "{", "$", "this", "->", "taskWatch", "(", ")", "->", "monitor", "(", "'composer.json'", ",", "function", "(", ")", "{", "$", "this", "->", "taskComposerUpdate", "(", ")", "->", "run", "(", ")", ";", "}", ")", "->", "monitor", "(", "'src'", ",", "function", "(", ")", "{", "$", "this", "->", "taskExec", "(", "'test'", ")", "->", "run", "(", ")", ";", "}", ")", "->", "monitor", "(", "'tests'", ",", "function", "(", ")", "{", "$", "this", "->", "taskExec", "(", "'test'", ")", "->", "run", "(", ")", ";", "}", ")", "->", "run", "(", ")", ";", "}" ]
Watches for file updates, and automatically runs appropriate actions
[ "Watches", "for", "file", "updates", "and", "automatically", "runs", "appropriate", "actions" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/RoboFile.php#L201-L214
34,284
aviat4ion/Query
RoboFile.php
RoboFile.getAllSourceFiles
protected function getAllSourceFiles() { $files = array_merge( glob_recursive('build/*.php'), glob_recursive('src/*.php'), glob_recursive('tests/*.php'), glob('*.php') ); sort($files); return $files; }
php
protected function getAllSourceFiles() { $files = array_merge( glob_recursive('build/*.php'), glob_recursive('src/*.php'), glob_recursive('tests/*.php'), glob('*.php') ); sort($files); return $files; }
[ "protected", "function", "getAllSourceFiles", "(", ")", "{", "$", "files", "=", "array_merge", "(", "glob_recursive", "(", "'build/*.php'", ")", ",", "glob_recursive", "(", "'src/*.php'", ")", ",", "glob_recursive", "(", "'tests/*.php'", ")", ",", "glob", "(", "'*.php'", ")", ")", ";", "sort", "(", "$", "files", ")", ";", "return", "$", "files", ";", "}" ]
Get the total list of source files, including tests @return array
[ "Get", "the", "total", "list", "of", "source", "files", "including", "tests" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/RoboFile.php#L236-L248
34,285
aviat4ion/Query
RoboFile.php
RoboFile.parallelLint
protected function parallelLint(array $chunk) { $task = $this->taskParallelExec() ->timeout(5) ->printed(FALSE); foreach($chunk as $file) { $task = $task->process("php -l {$file}"); } $task->run(); }
php
protected function parallelLint(array $chunk) { $task = $this->taskParallelExec() ->timeout(5) ->printed(FALSE); foreach($chunk as $file) { $task = $task->process("php -l {$file}"); } $task->run(); }
[ "protected", "function", "parallelLint", "(", "array", "$", "chunk", ")", "{", "$", "task", "=", "$", "this", "->", "taskParallelExec", "(", ")", "->", "timeout", "(", "5", ")", "->", "printed", "(", "FALSE", ")", ";", "foreach", "(", "$", "chunk", "as", "$", "file", ")", "{", "$", "task", "=", "$", "task", "->", "process", "(", "\"php -l {$file}\"", ")", ";", "}", "$", "task", "->", "run", "(", ")", ";", "}" ]
Run php's linter in one parallel task for the passed chunk @param array $chunk
[ "Run", "php", "s", "linter", "in", "one", "parallel", "task", "for", "the", "passed", "chunk" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/RoboFile.php#L255-L267
34,286
aviat4ion/Query
src/Drivers/Sqlite/Driver.php
Driver.getTables
public function getTables(): array { $sql = $this->sql->tableList(); $res = $this->query($sql); return dbFilter($res->fetchAll(PDO::FETCH_ASSOC), 'name'); }
php
public function getTables(): array { $sql = $this->sql->tableList(); $res = $this->query($sql); return dbFilter($res->fetchAll(PDO::FETCH_ASSOC), 'name'); }
[ "public", "function", "getTables", "(", ")", ":", "array", "{", "$", "sql", "=", "$", "this", "->", "sql", "->", "tableList", "(", ")", ";", "$", "res", "=", "$", "this", "->", "query", "(", "$", "sql", ")", ";", "return", "dbFilter", "(", "$", "res", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ",", "'name'", ")", ";", "}" ]
List tables for the current database @return mixed
[ "List", "tables", "for", "the", "current", "database" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/Sqlite/Driver.php#L55-L60
34,287
aviat4ion/Query
src/Drivers/Sqlite/Driver.php
Driver.getFks
public function getFks($table): array { $returnRows = []; foreach(parent::getFks($table) as $row) { $returnRows[] = [ 'child_column' => $row['from'], 'parent_table' => $row['table'], 'parent_column' => $row['to'], 'update' => $row['on_update'], 'delete' => $row['on_delete'] ]; } return $returnRows; }
php
public function getFks($table): array { $returnRows = []; foreach(parent::getFks($table) as $row) { $returnRows[] = [ 'child_column' => $row['from'], 'parent_table' => $row['table'], 'parent_column' => $row['to'], 'update' => $row['on_update'], 'delete' => $row['on_delete'] ]; } return $returnRows; }
[ "public", "function", "getFks", "(", "$", "table", ")", ":", "array", "{", "$", "returnRows", "=", "[", "]", ";", "foreach", "(", "parent", "::", "getFks", "(", "$", "table", ")", "as", "$", "row", ")", "{", "$", "returnRows", "[", "]", "=", "[", "'child_column'", "=>", "$", "row", "[", "'from'", "]", ",", "'parent_table'", "=>", "$", "row", "[", "'table'", "]", ",", "'parent_column'", "=>", "$", "row", "[", "'to'", "]", ",", "'update'", "=>", "$", "row", "[", "'on_update'", "]", ",", "'delete'", "=>", "$", "row", "[", "'on_delete'", "]", "]", ";", "}", "return", "$", "returnRows", ";", "}" ]
Retrieve foreign keys for the table @param string $table @return array
[ "Retrieve", "foreign", "keys", "for", "the", "table" ]
172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650
https://github.com/aviat4ion/Query/blob/172eb3f6ebdfb7295b42e32cc74bf37c3ebd7650/src/Drivers/Sqlite/Driver.php#L68-L84
34,288
joomlatools/joomlatools-framework-activities
model/behavior/searchable.php
ComActivitiesModelBehaviorSearchable._afterReset
protected function _afterReset(KModelContextInterface $context) { $reset_columns = false; if ($context->modified) { if (in_array('search', $context->modified->toArray())) { $reset_columns = true; } } else $reset_columns = true; if ($reset_columns && ($key = array_search('ip', $this->_columns))) { unset($this->_columns[$key]); } }
php
protected function _afterReset(KModelContextInterface $context) { $reset_columns = false; if ($context->modified) { if (in_array('search', $context->modified->toArray())) { $reset_columns = true; } } else $reset_columns = true; if ($reset_columns && ($key = array_search('ip', $this->_columns))) { unset($this->_columns[$key]); } }
[ "protected", "function", "_afterReset", "(", "KModelContextInterface", "$", "context", ")", "{", "$", "reset_columns", "=", "false", ";", "if", "(", "$", "context", "->", "modified", ")", "{", "if", "(", "in_array", "(", "'search'", ",", "$", "context", "->", "modified", "->", "toArray", "(", ")", ")", ")", "{", "$", "reset_columns", "=", "true", ";", "}", "}", "else", "$", "reset_columns", "=", "true", ";", "if", "(", "$", "reset_columns", "&&", "(", "$", "key", "=", "array_search", "(", "'ip'", ",", "$", "this", "->", "_columns", ")", ")", ")", "{", "unset", "(", "$", "this", "->", "_columns", "[", "$", "key", "]", ")", ";", "}", "}" ]
Resets the columns property by making sure that ip if removed when the state gets reset.
[ "Resets", "the", "columns", "property", "by", "making", "sure", "that", "ip", "if", "removed", "when", "the", "state", "gets", "reset", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/behavior/searchable.php#L50-L65
34,289
wpsharks/css-minifier
src/includes/classes/Core.php
Core.selfMin
protected function selfMin() { if (!$this->css) { return $this->css; } $static = &static::$static[__FUNCTION__.'_map']; if (!isset($static['replace'], $static['with'], $static['colors'])) { $de_spacifiables = array( '{', '}', '!=', '|=', '^=', '$=', '*=', '~=', '=', '~', ';', ',', '>', ); $de_spacifiables = array_map( function ($string) { return preg_quote($string, '/'); }, $de_spacifiables ); $de_spacifiables = implode('|', $de_spacifiables); $static['replace'] = array( 'comments' => '/\/\*.*?\*\//s', 'line_breaks' => '/['."\r\n".']+/', 'extra_spaces' => '/\s{2,}/', 'de_spacifiables' => '/ *('.$de_spacifiables.') */', 'unnecessary_;s' => '/;\}/', ); $static['with'] = array('', ' ', ' ', '${1}', '}'); $static['colors'] = '/(?P<context>[:,\h]+#)(?P<hex>[a-z0-9]{6})/i'; } $this->css = preg_replace($static['replace'], $static['with'], $this->css); $this->css = preg_replace_callback($static['colors'], array($this, 'selfMaybeCompressCssColorCb'), $this->css); $this->css = trim($this->css); return $this->css; }
php
protected function selfMin() { if (!$this->css) { return $this->css; } $static = &static::$static[__FUNCTION__.'_map']; if (!isset($static['replace'], $static['with'], $static['colors'])) { $de_spacifiables = array( '{', '}', '!=', '|=', '^=', '$=', '*=', '~=', '=', '~', ';', ',', '>', ); $de_spacifiables = array_map( function ($string) { return preg_quote($string, '/'); }, $de_spacifiables ); $de_spacifiables = implode('|', $de_spacifiables); $static['replace'] = array( 'comments' => '/\/\*.*?\*\//s', 'line_breaks' => '/['."\r\n".']+/', 'extra_spaces' => '/\s{2,}/', 'de_spacifiables' => '/ *('.$de_spacifiables.') */', 'unnecessary_;s' => '/;\}/', ); $static['with'] = array('', ' ', ' ', '${1}', '}'); $static['colors'] = '/(?P<context>[:,\h]+#)(?P<hex>[a-z0-9]{6})/i'; } $this->css = preg_replace($static['replace'], $static['with'], $this->css); $this->css = preg_replace_callback($static['colors'], array($this, 'selfMaybeCompressCssColorCb'), $this->css); $this->css = trim($this->css); return $this->css; }
[ "protected", "function", "selfMin", "(", ")", "{", "if", "(", "!", "$", "this", "->", "css", ")", "{", "return", "$", "this", "->", "css", ";", "}", "$", "static", "=", "&", "static", "::", "$", "static", "[", "__FUNCTION__", ".", "'_map'", "]", ";", "if", "(", "!", "isset", "(", "$", "static", "[", "'replace'", "]", ",", "$", "static", "[", "'with'", "]", ",", "$", "static", "[", "'colors'", "]", ")", ")", "{", "$", "de_spacifiables", "=", "array", "(", "'{'", ",", "'}'", ",", "'!='", ",", "'|='", ",", "'^='", ",", "'$='", ",", "'*='", ",", "'~='", ",", "'='", ",", "'~'", ",", "';'", ",", "','", ",", "'>'", ",", ")", ";", "$", "de_spacifiables", "=", "array_map", "(", "function", "(", "$", "string", ")", "{", "return", "preg_quote", "(", "$", "string", ",", "'/'", ")", ";", "}", ",", "$", "de_spacifiables", ")", ";", "$", "de_spacifiables", "=", "implode", "(", "'|'", ",", "$", "de_spacifiables", ")", ";", "$", "static", "[", "'replace'", "]", "=", "array", "(", "'comments'", "=>", "'/\\/\\*.*?\\*\\//s'", ",", "'line_breaks'", "=>", "'/['", ".", "\"\\r\\n\"", ".", "']+/'", ",", "'extra_spaces'", "=>", "'/\\s{2,}/'", ",", "'de_spacifiables'", "=>", "'/ *('", ".", "$", "de_spacifiables", ".", "') */'", ",", "'unnecessary_;s'", "=>", "'/;\\}/'", ",", ")", ";", "$", "static", "[", "'with'", "]", "=", "array", "(", "''", ",", "' '", ",", "' '", ",", "'${1}'", ",", "'}'", ")", ";", "$", "static", "[", "'colors'", "]", "=", "'/(?P<context>[:,\\h]+#)(?P<hex>[a-z0-9]{6})/i'", ";", "}", "$", "this", "->", "css", "=", "preg_replace", "(", "$", "static", "[", "'replace'", "]", ",", "$", "static", "[", "'with'", "]", ",", "$", "this", "->", "css", ")", ";", "$", "this", "->", "css", "=", "preg_replace_callback", "(", "$", "static", "[", "'colors'", "]", ",", "array", "(", "$", "this", ",", "'selfMaybeCompressCssColorCb'", ")", ",", "$", "this", "->", "css", ")", ";", "$", "this", "->", "css", "=", "trim", "(", "$", "this", "->", "css", ")", ";", "return", "$", "this", "->", "css", ";", "}" ]
Self minifier. @since 15xxxx Adding SCSS compiler. @return string Output (minified) CSS.
[ "Self", "minifier", "." ]
f70806d752ba262fbcfdab21ae850fe490a51816
https://github.com/wpsharks/css-minifier/blob/f70806d752ba262fbcfdab21ae850fe490a51816/src/includes/classes/Core.php#L77-L123
34,290
wpsharks/css-minifier
src/includes/classes/Core.php
Core.selfMaybeCompressCssColorCb
protected function selfMaybeCompressCssColorCb(array $m) { $m['hex'] = strtoupper($m['hex']); // Convert to uppercase for easy comparison. if ($m['hex'][0] === $m['hex'][1] && $m['hex'][2] === $m['hex'][3] && $m['hex'][4] === $m['hex'][5]) { return $m['context'].$m['hex'][0].$m['hex'][2].$m['hex'][4]; } return $m[0]; }
php
protected function selfMaybeCompressCssColorCb(array $m) { $m['hex'] = strtoupper($m['hex']); // Convert to uppercase for easy comparison. if ($m['hex'][0] === $m['hex'][1] && $m['hex'][2] === $m['hex'][3] && $m['hex'][4] === $m['hex'][5]) { return $m['context'].$m['hex'][0].$m['hex'][2].$m['hex'][4]; } return $m[0]; }
[ "protected", "function", "selfMaybeCompressCssColorCb", "(", "array", "$", "m", ")", "{", "$", "m", "[", "'hex'", "]", "=", "strtoupper", "(", "$", "m", "[", "'hex'", "]", ")", ";", "// Convert to uppercase for easy comparison.", "if", "(", "$", "m", "[", "'hex'", "]", "[", "0", "]", "===", "$", "m", "[", "'hex'", "]", "[", "1", "]", "&&", "$", "m", "[", "'hex'", "]", "[", "2", "]", "===", "$", "m", "[", "'hex'", "]", "[", "3", "]", "&&", "$", "m", "[", "'hex'", "]", "[", "4", "]", "===", "$", "m", "[", "'hex'", "]", "[", "5", "]", ")", "{", "return", "$", "m", "[", "'context'", "]", ".", "$", "m", "[", "'hex'", "]", "[", "0", "]", ".", "$", "m", "[", "'hex'", "]", "[", "2", "]", ".", "$", "m", "[", "'hex'", "]", "[", "4", "]", ";", "}", "return", "$", "m", "[", "0", "]", ";", "}" ]
Compresses HEX color codes. @since 140417 Initial release. @param array $m Regular expression matches. @return string Full match with compressed HEX color code.
[ "Compresses", "HEX", "color", "codes", "." ]
f70806d752ba262fbcfdab21ae850fe490a51816
https://github.com/wpsharks/css-minifier/blob/f70806d752ba262fbcfdab21ae850fe490a51816/src/includes/classes/Core.php#L134-L142
34,291
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator.translateActivityFormat
public function translateActivityFormat(ComActivitiesActivityInterface $activity) { $tokens = $this->getActivityTokens($activity); $format = $activity->getActivityFormat(); $parameters = array(); foreach ($tokens as $key => $value) { if ($value instanceof ComActivitiesActivityObjectInterface && $value->getObjectName()) { $value = $value->getObjectName(); } if (is_scalar($value)) { $parameters[$key] = $value; } } $formats = array(); for ($i = 0; $i < 2; $i++) { $catalogue = $this->getCatalogue(); if ($length = $catalogue->getConfig()->key_length) { $catalogue->getConfig()->key_length = false; } $formats[] = $this->translate($this->_getOverride($format, $parameters), array()); if ($length) { $catalogue->getConfig()->key_length = $length; } if ($i == 0 && isset($this->_locales[$formats[0]])) { break; // Format already localized, no need to compare } else { $this->_switchCatalogues(); } } if (count($formats) > 1) { list($format, $decorator_format) = $formats; $this->_locales[$format] = ($format == $decorator_format) ? $this->getLocaleFallback() : $this->getLocale(); } else $format = $formats[0]; // Set the activity locale. $activity->setLocale($this->_locales[$format]); return $format; }
php
public function translateActivityFormat(ComActivitiesActivityInterface $activity) { $tokens = $this->getActivityTokens($activity); $format = $activity->getActivityFormat(); $parameters = array(); foreach ($tokens as $key => $value) { if ($value instanceof ComActivitiesActivityObjectInterface && $value->getObjectName()) { $value = $value->getObjectName(); } if (is_scalar($value)) { $parameters[$key] = $value; } } $formats = array(); for ($i = 0; $i < 2; $i++) { $catalogue = $this->getCatalogue(); if ($length = $catalogue->getConfig()->key_length) { $catalogue->getConfig()->key_length = false; } $formats[] = $this->translate($this->_getOverride($format, $parameters), array()); if ($length) { $catalogue->getConfig()->key_length = $length; } if ($i == 0 && isset($this->_locales[$formats[0]])) { break; // Format already localized, no need to compare } else { $this->_switchCatalogues(); } } if (count($formats) > 1) { list($format, $decorator_format) = $formats; $this->_locales[$format] = ($format == $decorator_format) ? $this->getLocaleFallback() : $this->getLocale(); } else $format = $formats[0]; // Set the activity locale. $activity->setLocale($this->_locales[$format]); return $format; }
[ "public", "function", "translateActivityFormat", "(", "ComActivitiesActivityInterface", "$", "activity", ")", "{", "$", "tokens", "=", "$", "this", "->", "getActivityTokens", "(", "$", "activity", ")", ";", "$", "format", "=", "$", "activity", "->", "getActivityFormat", "(", ")", ";", "$", "parameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "tokens", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "ComActivitiesActivityObjectInterface", "&&", "$", "value", "->", "getObjectName", "(", ")", ")", "{", "$", "value", "=", "$", "value", "->", "getObjectName", "(", ")", ";", "}", "if", "(", "is_scalar", "(", "$", "value", ")", ")", "{", "$", "parameters", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "formats", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "2", ";", "$", "i", "++", ")", "{", "$", "catalogue", "=", "$", "this", "->", "getCatalogue", "(", ")", ";", "if", "(", "$", "length", "=", "$", "catalogue", "->", "getConfig", "(", ")", "->", "key_length", ")", "{", "$", "catalogue", "->", "getConfig", "(", ")", "->", "key_length", "=", "false", ";", "}", "$", "formats", "[", "]", "=", "$", "this", "->", "translate", "(", "$", "this", "->", "_getOverride", "(", "$", "format", ",", "$", "parameters", ")", ",", "array", "(", ")", ")", ";", "if", "(", "$", "length", ")", "{", "$", "catalogue", "->", "getConfig", "(", ")", "->", "key_length", "=", "$", "length", ";", "}", "if", "(", "$", "i", "==", "0", "&&", "isset", "(", "$", "this", "->", "_locales", "[", "$", "formats", "[", "0", "]", "]", ")", ")", "{", "break", ";", "// Format already localized, no need to compare", "}", "else", "{", "$", "this", "->", "_switchCatalogues", "(", ")", ";", "}", "}", "if", "(", "count", "(", "$", "formats", ")", ">", "1", ")", "{", "list", "(", "$", "format", ",", "$", "decorator_format", ")", "=", "$", "formats", ";", "$", "this", "->", "_locales", "[", "$", "format", "]", "=", "(", "$", "format", "==", "$", "decorator_format", ")", "?", "$", "this", "->", "getLocaleFallback", "(", ")", ":", "$", "this", "->", "getLocale", "(", ")", ";", "}", "else", "$", "format", "=", "$", "formats", "[", "0", "]", ";", "// Set the activity locale.", "$", "activity", "->", "setLocale", "(", "$", "this", "->", "_locales", "[", "$", "format", "]", ")", ";", "return", "$", "format", ";", "}" ]
Translates an activity format. @param string $string The activity format to translate. @return string The translated activity format.
[ "Translates", "an", "activity", "format", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L252-L304
34,292
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator.translateActivityToken
public function translateActivityToken($token, ComActivitiesActivityInterface $activity) { if (is_string($token)) { $tokens = $this->getActivityTokens($activity); if (isset($tokens[$token])) { $token = $tokens[$token]; } } if (!$token instanceof ComActivitiesActivityObjectInterface) { throw new RuntimeException('Invalid token'); } $result = $token->getDisplayName(); if ($token->isTranslatable()) { if ($activity->getLocale() == $this->getLocaleFallback()) { // Use decorator catalogue instead $this->_switchCatalogues(); $result = $this->translate($result); $this->_switchCatalogues(); } else $result = $this->translate($result); } return $result; }
php
public function translateActivityToken($token, ComActivitiesActivityInterface $activity) { if (is_string($token)) { $tokens = $this->getActivityTokens($activity); if (isset($tokens[$token])) { $token = $tokens[$token]; } } if (!$token instanceof ComActivitiesActivityObjectInterface) { throw new RuntimeException('Invalid token'); } $result = $token->getDisplayName(); if ($token->isTranslatable()) { if ($activity->getLocale() == $this->getLocaleFallback()) { // Use decorator catalogue instead $this->_switchCatalogues(); $result = $this->translate($result); $this->_switchCatalogues(); } else $result = $this->translate($result); } return $result; }
[ "public", "function", "translateActivityToken", "(", "$", "token", ",", "ComActivitiesActivityInterface", "$", "activity", ")", "{", "if", "(", "is_string", "(", "$", "token", ")", ")", "{", "$", "tokens", "=", "$", "this", "->", "getActivityTokens", "(", "$", "activity", ")", ";", "if", "(", "isset", "(", "$", "tokens", "[", "$", "token", "]", ")", ")", "{", "$", "token", "=", "$", "tokens", "[", "$", "token", "]", ";", "}", "}", "if", "(", "!", "$", "token", "instanceof", "ComActivitiesActivityObjectInterface", ")", "{", "throw", "new", "RuntimeException", "(", "'Invalid token'", ")", ";", "}", "$", "result", "=", "$", "token", "->", "getDisplayName", "(", ")", ";", "if", "(", "$", "token", "->", "isTranslatable", "(", ")", ")", "{", "if", "(", "$", "activity", "->", "getLocale", "(", ")", "==", "$", "this", "->", "getLocaleFallback", "(", ")", ")", "{", "// Use decorator catalogue instead", "$", "this", "->", "_switchCatalogues", "(", ")", ";", "$", "result", "=", "$", "this", "->", "translate", "(", "$", "result", ")", ";", "$", "this", "->", "_switchCatalogues", "(", ")", ";", "}", "else", "$", "result", "=", "$", "this", "->", "translate", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Translates an activity token. @param string|ComActivitiesActivityObjectInterface $token The activity token. @param ComActivitiesActivityInterface $activity The activity object. @return string The translated token.
[ "Translates", "an", "activity", "token", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L313-L342
34,293
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator._getFallbackCatalogue
protected function _getFallbackCatalogue() { if (!$this->_fallback_catalogue instanceof KTranslatorCatalogueInterface) { $this->_setFallbackCatalogue($this->getObject($this->_fallback_catalogue)); } return $this->_fallback_catalogue; }
php
protected function _getFallbackCatalogue() { if (!$this->_fallback_catalogue instanceof KTranslatorCatalogueInterface) { $this->_setFallbackCatalogue($this->getObject($this->_fallback_catalogue)); } return $this->_fallback_catalogue; }
[ "protected", "function", "_getFallbackCatalogue", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_fallback_catalogue", "instanceof", "KTranslatorCatalogueInterface", ")", "{", "$", "this", "->", "_setFallbackCatalogue", "(", "$", "this", "->", "getObject", "(", "$", "this", "->", "_fallback_catalogue", ")", ")", ";", "}", "return", "$", "this", "->", "_fallback_catalogue", ";", "}" ]
Decorator catalogue getter. @return KTranslatorCatalogueInterface The decorator catalogue.
[ "Decorator", "catalogue", "getter", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L361-L368
34,294
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator._getOverride
protected function _getOverride($format, $parameters = array()) { $override = $format; $locale = $this->getLocale(); if (!isset($this->_overrides[$locale])) { $this->_overrides[$locale] = array(); } if ($parameters) { $key = $this->_getOverrideKey($format, $parameters); if (!isset($this->_overrides[$locale][$key])) { foreach ($this->_getOverrides($format, $parameters) as $candidate) { // Check if the override is translatable. if ($this->isTranslatable($candidate)) { $override = $candidate; break; } } $this->_overrides[$locale][$key] = $override; } else $override = $this->_overrides[$locale][$key]; } return $override; }
php
protected function _getOverride($format, $parameters = array()) { $override = $format; $locale = $this->getLocale(); if (!isset($this->_overrides[$locale])) { $this->_overrides[$locale] = array(); } if ($parameters) { $key = $this->_getOverrideKey($format, $parameters); if (!isset($this->_overrides[$locale][$key])) { foreach ($this->_getOverrides($format, $parameters) as $candidate) { // Check if the override is translatable. if ($this->isTranslatable($candidate)) { $override = $candidate; break; } } $this->_overrides[$locale][$key] = $override; } else $override = $this->_overrides[$locale][$key]; } return $override; }
[ "protected", "function", "_getOverride", "(", "$", "format", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "override", "=", "$", "format", ";", "$", "locale", "=", "$", "this", "->", "getLocale", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_overrides", "[", "$", "locale", "]", ")", ")", "{", "$", "this", "->", "_overrides", "[", "$", "locale", "]", "=", "array", "(", ")", ";", "}", "if", "(", "$", "parameters", ")", "{", "$", "key", "=", "$", "this", "->", "_getOverrideKey", "(", "$", "format", ",", "$", "parameters", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_overrides", "[", "$", "locale", "]", "[", "$", "key", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_getOverrides", "(", "$", "format", ",", "$", "parameters", ")", "as", "$", "candidate", ")", "{", "// Check if the override is translatable.", "if", "(", "$", "this", "->", "isTranslatable", "(", "$", "candidate", ")", ")", "{", "$", "override", "=", "$", "candidate", ";", "break", ";", "}", "}", "$", "this", "->", "_overrides", "[", "$", "locale", "]", "[", "$", "key", "]", "=", "$", "override", ";", "}", "else", "$", "override", "=", "$", "this", "->", "_overrides", "[", "$", "locale", "]", "[", "$", "key", "]", ";", "}", "return", "$", "override", ";", "}" ]
Get an activity format override. @param string $format The activity format. @param array $parameters Associative array containing parameters. @return string The activity format override. If an override was not found, the original activity format is returned instead.
[ "Get", "an", "activity", "format", "override", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L378-L410
34,295
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator._getOverrideKey
protected function _getOverrideKey($format, $parameters = array()) { $result = $format; foreach ($parameters as $key => $value) { $result = str_replace(sprintf('{%s}', $key), $value, $result); } return $result; }
php
protected function _getOverrideKey($format, $parameters = array()) { $result = $format; foreach ($parameters as $key => $value) { $result = str_replace(sprintf('{%s}', $key), $value, $result); } return $result; }
[ "protected", "function", "_getOverrideKey", "(", "$", "format", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "result", "=", "$", "format", ";", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "=", "str_replace", "(", "sprintf", "(", "'{%s}'", ",", "$", "key", ")", ",", "$", "value", ",", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get an activity format override key. @param string $format The activity format. @param array $parameters Associative array containing parameters. @return string The activity format override key.
[ "Get", "an", "activity", "format", "override", "key", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L419-L428
34,296
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator._getOverrides
protected function _getOverrides($format, $parameters = array()) { $overrides = array(); if (!empty($parameters)) { // Get the power set of the set of parameters and construct a list of string overrides from it. foreach ($this->_getPowerSet(array_keys($parameters)) as $subset) { $override = $format; foreach ($subset as $key) { $override = str_replace(sprintf('{%s}', $key), $parameters[$key], $override); } $overrides[] = $override; } } return $overrides; }
php
protected function _getOverrides($format, $parameters = array()) { $overrides = array(); if (!empty($parameters)) { // Get the power set of the set of parameters and construct a list of string overrides from it. foreach ($this->_getPowerSet(array_keys($parameters)) as $subset) { $override = $format; foreach ($subset as $key) { $override = str_replace(sprintf('{%s}', $key), $parameters[$key], $override); } $overrides[] = $override; } } return $overrides; }
[ "protected", "function", "_getOverrides", "(", "$", "format", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "overrides", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "parameters", ")", ")", "{", "// Get the power set of the set of parameters and construct a list of string overrides from it.", "foreach", "(", "$", "this", "->", "_getPowerSet", "(", "array_keys", "(", "$", "parameters", ")", ")", "as", "$", "subset", ")", "{", "$", "override", "=", "$", "format", ";", "foreach", "(", "$", "subset", "as", "$", "key", ")", "{", "$", "override", "=", "str_replace", "(", "sprintf", "(", "'{%s}'", ",", "$", "key", ")", ",", "$", "parameters", "[", "$", "key", "]", ",", "$", "override", ")", ";", "}", "$", "overrides", "[", "]", "=", "$", "override", ";", "}", "}", "return", "$", "overrides", ";", "}" ]
Returns a list of activity format overrides. @param string $format The activity format. @param array $parameters Associative array containing parameters. @return array A list of activity format overrides.
[ "Returns", "a", "list", "of", "activity", "format", "overrides", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L437-L457
34,297
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator._getPowerSet
protected function _getPowerSet(array $set = array(), $min_length = 1) { $elements = count($set); $size = pow(2, $elements); $members = array(); for ($i = 0; $i < $size; $i++) { $b = sprintf("%0" . $elements . "b", $i); $member = array(); for ($j = 0; $j < $elements; $j++) { if ($b{$j} == '1') $member[] = $set[$j]; } if (count($member) >= $min_length) { if (!isset($members[count($member)])) { $members[count($member)] = array(); } // Group members by number of elements they contain. $members[count($member)][] = $member; } } // Sort members by number of elements (key value). ksort($members, SORT_NUMERIC); $power = array(); // We want members with greater amount of elements first. foreach (array_reverse($members) as $subsets) { $power = array_merge($power, $subsets); } return $power; }
php
protected function _getPowerSet(array $set = array(), $min_length = 1) { $elements = count($set); $size = pow(2, $elements); $members = array(); for ($i = 0; $i < $size; $i++) { $b = sprintf("%0" . $elements . "b", $i); $member = array(); for ($j = 0; $j < $elements; $j++) { if ($b{$j} == '1') $member[] = $set[$j]; } if (count($member) >= $min_length) { if (!isset($members[count($member)])) { $members[count($member)] = array(); } // Group members by number of elements they contain. $members[count($member)][] = $member; } } // Sort members by number of elements (key value). ksort($members, SORT_NUMERIC); $power = array(); // We want members with greater amount of elements first. foreach (array_reverse($members) as $subsets) { $power = array_merge($power, $subsets); } return $power; }
[ "protected", "function", "_getPowerSet", "(", "array", "$", "set", "=", "array", "(", ")", ",", "$", "min_length", "=", "1", ")", "{", "$", "elements", "=", "count", "(", "$", "set", ")", ";", "$", "size", "=", "pow", "(", "2", ",", "$", "elements", ")", ";", "$", "members", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "size", ";", "$", "i", "++", ")", "{", "$", "b", "=", "sprintf", "(", "\"%0\"", ".", "$", "elements", ".", "\"b\"", ",", "$", "i", ")", ";", "$", "member", "=", "array", "(", ")", ";", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "elements", ";", "$", "j", "++", ")", "{", "if", "(", "$", "b", "{", "$", "j", "}", "==", "'1'", ")", "$", "member", "[", "]", "=", "$", "set", "[", "$", "j", "]", ";", "}", "if", "(", "count", "(", "$", "member", ")", ">=", "$", "min_length", ")", "{", "if", "(", "!", "isset", "(", "$", "members", "[", "count", "(", "$", "member", ")", "]", ")", ")", "{", "$", "members", "[", "count", "(", "$", "member", ")", "]", "=", "array", "(", ")", ";", "}", "// Group members by number of elements they contain.", "$", "members", "[", "count", "(", "$", "member", ")", "]", "[", "]", "=", "$", "member", ";", "}", "}", "// Sort members by number of elements (key value).", "ksort", "(", "$", "members", ",", "SORT_NUMERIC", ")", ";", "$", "power", "=", "array", "(", ")", ";", "// We want members with greater amount of elements first.", "foreach", "(", "array_reverse", "(", "$", "members", ")", "as", "$", "subsets", ")", "{", "$", "power", "=", "array_merge", "(", "$", "power", ",", "$", "subsets", ")", ";", "}", "return", "$", "power", ";", "}" ]
Returns the power set of a set represented by the elements contained in an array. For convenience, the elements are ordered from size (subsets with more elements first). @param array $set The set to get the power set from. @param int $min_length The minimum amount of elements that a subset from the power set may contain. @return array The power set represented by an array of arrays containing elements from the provided set.
[ "Returns", "the", "power", "set", "of", "a", "set", "represented", "by", "the", "elements", "contained", "in", "an", "array", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L468-L504
34,298
joomlatools/joomlatools-framework-activities
activity/translator/translator.php
ComActivitiesActivityTranslator._switchCatalogues
protected function _switchCatalogues() { // Switch Catalogues $catalogue = $this->_getFallbackCatalogue(); $this->_setFallbackCatalogue($this->getCatalogue()); $this->setCatalogue($catalogue); return $this; }
php
protected function _switchCatalogues() { // Switch Catalogues $catalogue = $this->_getFallbackCatalogue(); $this->_setFallbackCatalogue($this->getCatalogue()); $this->setCatalogue($catalogue); return $this; }
[ "protected", "function", "_switchCatalogues", "(", ")", "{", "// Switch Catalogues", "$", "catalogue", "=", "$", "this", "->", "_getFallbackCatalogue", "(", ")", ";", "$", "this", "->", "_setFallbackCatalogue", "(", "$", "this", "->", "getCatalogue", "(", ")", ")", ";", "$", "this", "->", "setCatalogue", "(", "$", "catalogue", ")", ";", "return", "$", "this", ";", "}" ]
Switch translator catalogues. The translator and fallback catalogues are switched. @return ComActivitiesActivityTranslatorInterface
[ "Switch", "translator", "catalogues", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/activity/translator/translator.php#L552-L560
34,299
joomlatools/joomlatools-framework-activities
model/entity/activity.php
ComActivitiesModelEntityActivity.getTranslator
public function getTranslator() { if (!$this->_translator instanceof ComActivitiesActivityTranslatorInterface) { $translator = $this->getObject('translator'); if (!$translator instanceof ComActivitiesActivityTranslatorInterface) { $translator = $translator->decorate($this->_translator); $this->getObject('manager')->setObject('translator', $translator); } $this->setTranslator($translator); } return $this->_translator; }
php
public function getTranslator() { if (!$this->_translator instanceof ComActivitiesActivityTranslatorInterface) { $translator = $this->getObject('translator'); if (!$translator instanceof ComActivitiesActivityTranslatorInterface) { $translator = $translator->decorate($this->_translator); $this->getObject('manager')->setObject('translator', $translator); } $this->setTranslator($translator); } return $this->_translator; }
[ "public", "function", "getTranslator", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_translator", "instanceof", "ComActivitiesActivityTranslatorInterface", ")", "{", "$", "translator", "=", "$", "this", "->", "getObject", "(", "'translator'", ")", ";", "if", "(", "!", "$", "translator", "instanceof", "ComActivitiesActivityTranslatorInterface", ")", "{", "$", "translator", "=", "$", "translator", "->", "decorate", "(", "$", "this", "->", "_translator", ")", ";", "$", "this", "->", "getObject", "(", "'manager'", ")", "->", "setObject", "(", "'translator'", ",", "$", "translator", ")", ";", "}", "$", "this", "->", "setTranslator", "(", "$", "translator", ")", ";", "}", "return", "$", "this", "->", "_translator", ";", "}" ]
Set the activity translator. @param ComActivitiesActivityTranslatorInterface $translator @return ComActivitiesActivityInterface
[ "Set", "the", "activity", "translator", "." ]
701abf6186729f62643bc834055cdebc08c25c21
https://github.com/joomlatools/joomlatools-framework-activities/blob/701abf6186729f62643bc834055cdebc08c25c21/model/entity/activity.php#L361-L376