repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
TYPO3-extensions/gridelements
Classes/Xclass/DatabaseRecordList.php
DatabaseRecordList.addActionToCellGroup
public function addActionToCellGroup(&$cells, $action, $actionKey) { $cellsMap = [ 'primary' => [ 'view', 'edit', 'hide', 'delete', 'stat', ], 'secondary' => [ 'viewBig', 'history', 'perms', 'new', 'move', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'version', ], ]; $classification = in_array($actionKey, $cellsMap['primary']) ? 'primary' : 'secondary'; $cells[$classification][$actionKey] = $action; unset($cells[$actionKey]); }
php
public function addActionToCellGroup(&$cells, $action, $actionKey) { $cellsMap = [ 'primary' => [ 'view', 'edit', 'hide', 'delete', 'stat', ], 'secondary' => [ 'viewBig', 'history', 'perms', 'new', 'move', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'version', ], ]; $classification = in_array($actionKey, $cellsMap['primary']) ? 'primary' : 'secondary'; $cells[$classification][$actionKey] = $action; unset($cells[$actionKey]); }
[ "public", "function", "addActionToCellGroup", "(", "&", "$", "cells", ",", "$", "action", ",", "$", "actionKey", ")", "{", "$", "cellsMap", "=", "[", "'primary'", "=>", "[", "'view'", ",", "'edit'", ",", "'hide'", ",", "'delete'", ",", "'stat'", ",", "]", ",", "'secondary'", "=>", "[", "'viewBig'", ",", "'history'", ",", "'perms'", ",", "'new'", ",", "'move'", ",", "'moveUp'", ",", "'moveDown'", ",", "'moveLeft'", ",", "'moveRight'", ",", "'version'", ",", "]", ",", "]", ";", "$", "classification", "=", "in_array", "(", "$", "actionKey", ",", "$", "cellsMap", "[", "'primary'", "]", ")", "?", "'primary'", ":", "'secondary'", ";", "$", "cells", "[", "$", "classification", "]", "[", "$", "actionKey", "]", "=", "$", "action", ";", "unset", "(", "$", "cells", "[", "$", "actionKey", "]", ")", ";", "}" ]
add action into correct section @param array $cells @param string $action @param string $actionKey
[ "add", "action", "into", "correct", "section" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2080-L2106
TYPO3-extensions/gridelements
Classes/Xclass/DatabaseRecordList.php
DatabaseRecordList.showNewRecLink
public function showNewRecLink($table) { // No deny/allow tables are set: if (empty($this->allowedNewTables) && empty($this->deniedNewTables)) { return true; } return !in_array($table, $this->deniedNewTables) && (empty($this->allowedNewTables) || in_array($table, $this->allowedNewTables)); }
php
public function showNewRecLink($table) { // No deny/allow tables are set: if (empty($this->allowedNewTables) && empty($this->deniedNewTables)) { return true; } return !in_array($table, $this->deniedNewTables) && (empty($this->allowedNewTables) || in_array($table, $this->allowedNewTables)); }
[ "public", "function", "showNewRecLink", "(", "$", "table", ")", "{", "// No deny/allow tables are set:", "if", "(", "empty", "(", "$", "this", "->", "allowedNewTables", ")", "&&", "empty", "(", "$", "this", "->", "deniedNewTables", ")", ")", "{", "return", "true", ";", "}", "return", "!", "in_array", "(", "$", "table", ",", "$", "this", "->", "deniedNewTables", ")", "&&", "(", "empty", "(", "$", "this", "->", "allowedNewTables", ")", "||", "in_array", "(", "$", "table", ",", "$", "this", "->", "allowedNewTables", ")", ")", ";", "}" ]
Returns TRUE if a link for creating new records should be displayed for $table @param string $table Table name @return bool Returns TRUE if a link for creating new records should be displayed for $table @see \TYPO3\CMS\Backend\Controller\NewRecordController::showNewRecLink
[ "Returns", "TRUE", "if", "a", "link", "for", "creating", "new", "records", "should", "be", "displayed", "for", "$table" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2125-L2133
TYPO3-extensions/gridelements
Classes/Xclass/DatabaseRecordList.php
DatabaseRecordList.makeClip
public function makeClip($table, $row) { // Return blank, if disabled: if (!$this->getModule()->MOD_SETTINGS['clipBoard']) { return ''; } $cells = []; $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon); // Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them // For page translations these icons should never be shown $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0; // Return blank, if disabled: // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel: // For the "Normal" pad: if ($this->clipObj->current === 'normal') { // Show copy/cut icons: $isSel = (string)$this->clipObj->isSelected($table, $row['uid']); if ($isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)) { $cells['copy'] = $this->spaceIcon; $cells['cut'] = $this->spaceIcon; } else { $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL); $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL); if ($isSel === 'copy') { $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL); } elseif ($isSel === 'cut') { $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL); } $cells['copy'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB( $table, $row['uid'], 1, ($isSel === 'copy'), ['returnUrl' => ''] )) . ');') . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">' . $copyIcon->render() . '</a>'; // Check permission to cut page or content if ($table === 'pages') { $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord( 'pages', $row['uid'] )); $permsEdit = $localCalcPerms & Permission::PAGE_EDIT; } else { $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT; } $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit); // If the listed table is 'pages' we have to request the permission settings for each page: if ($table === 'pages') { if ($permsEdit) { $cells['cut'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB( $table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''] )) . ');') . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">' . $cutIcon->render() . '</a>'; } else { $cells['cut'] = $this->spaceIcon; } } else { if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT) { $cells['cut'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB( $table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''] )) . ');') . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">' . $cutIcon->render() . '</a>'; } else { $cells['cut'] = $this->spaceIcon; } } } } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off) // Setting name of the element in ->CBnames array: $n = $table . '|' . $row['uid']; $this->CBnames[] = $n; // Check if the current element is selected and if so, prepare to set the checkbox as selected: $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : ''; // If the "duplicateField" value is set then select all elements which are duplicates... if ($this->duplicateField && isset($row[$this->duplicateField])) { $checked = ''; if (in_array($row[$this->duplicateField], $this->duplicateStack)) { $checked = 'checked="checked" '; } $this->duplicateStack[] = $row[$this->duplicateField]; } // Adding the checkbox to the panel: $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"' . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>'; } // Now, looking for selected elements from the current table: $elFromTable = $this->clipObj->elFromTable($table); if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) { // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon: $cells['pasteAfter'] = $isL10nOverlay || !$this->overlayEditLockPermissions($table, $row) ? $this->spaceIcon : '<a class="btn btn-default t3js-modal-trigger"' . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"' . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText( $table, $row, 'after', $elFromTable )) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . '</a>'; } // Now, looking for elements in general: $elFromTable = $this->clipObj->elFromTable(''); if ($table === 'pages' && !$isL10nOverlay && !empty($elFromTable)) { $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"' . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText( $table, $row, 'into', $elFromTable )) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>'; } /* * hook: makeClip: Allows to change clip-icons of records in list-module * usage: This hook method gets passed the current $cells array as third parameter. * This array contains values for the clipboard icons generated for each record in Web>List. * Each array entry is accessible by an index-key. * The order of the icons is depending on the order of those array entries. */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof RecordListHookInterface) { throw new \UnexpectedValueException( $className . ' must implement interface ' . RecordListHookInterface::class, 1195567845 ); } $cells = $hookObject->makeClip($table, $row, $cells, $this); } return '<div class="btn-group" role="group">' . implode('', $cells) . '</div>'; }
php
public function makeClip($table, $row) { // Return blank, if disabled: if (!$this->getModule()->MOD_SETTINGS['clipBoard']) { return ''; } $cells = []; $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon); // Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them // For page translations these icons should never be shown $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0; // Return blank, if disabled: // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel: // For the "Normal" pad: if ($this->clipObj->current === 'normal') { // Show copy/cut icons: $isSel = (string)$this->clipObj->isSelected($table, $row['uid']); if ($isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)) { $cells['copy'] = $this->spaceIcon; $cells['cut'] = $this->spaceIcon; } else { $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL); $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL); if ($isSel === 'copy') { $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL); } elseif ($isSel === 'cut') { $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL); } $cells['copy'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB( $table, $row['uid'], 1, ($isSel === 'copy'), ['returnUrl' => ''] )) . ');') . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">' . $copyIcon->render() . '</a>'; // Check permission to cut page or content if ($table === 'pages') { $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord( 'pages', $row['uid'] )); $permsEdit = $localCalcPerms & Permission::PAGE_EDIT; } else { $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT; } $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit); // If the listed table is 'pages' we have to request the permission settings for each page: if ($table === 'pages') { if ($permsEdit) { $cells['cut'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB( $table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''] )) . ');') . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">' . $cutIcon->render() . '</a>'; } else { $cells['cut'] = $this->spaceIcon; } } else { if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT) { $cells['cut'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB( $table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''] )) . ');') . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">' . $cutIcon->render() . '</a>'; } else { $cells['cut'] = $this->spaceIcon; } } } } else { // For the numeric clipboard pads (showing checkboxes where one can select elements on/off) // Setting name of the element in ->CBnames array: $n = $table . '|' . $row['uid']; $this->CBnames[] = $n; // Check if the current element is selected and if so, prepare to set the checkbox as selected: $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : ''; // If the "duplicateField" value is set then select all elements which are duplicates... if ($this->duplicateField && isset($row[$this->duplicateField])) { $checked = ''; if (in_array($row[$this->duplicateField], $this->duplicateStack)) { $checked = 'checked="checked" '; } $this->duplicateStack[] = $row[$this->duplicateField]; } // Adding the checkbox to the panel: $cells['select'] = $isL10nOverlay ? $this->spaceIcon : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"' . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>'; } // Now, looking for selected elements from the current table: $elFromTable = $this->clipObj->elFromTable($table); if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) { // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon: $cells['pasteAfter'] = $isL10nOverlay || !$this->overlayEditLockPermissions($table, $row) ? $this->spaceIcon : '<a class="btn btn-default t3js-modal-trigger"' . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"' . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText( $table, $row, 'after', $elFromTable )) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . '</a>'; } // Now, looking for elements in general: $elFromTable = $this->clipObj->elFromTable(''); if ($table === 'pages' && !$isL10nOverlay && !empty($elFromTable)) { $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"' . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"' . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"' . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText( $table, $row, 'into', $elFromTable )) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>'; } /* * hook: makeClip: Allows to change clip-icons of records in list-module * usage: This hook method gets passed the current $cells array as third parameter. * This array contains values for the clipboard icons generated for each record in Web>List. * Each array entry is accessible by an index-key. * The order of the icons is depending on the order of those array entries. */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof RecordListHookInterface) { throw new \UnexpectedValueException( $className . ' must implement interface ' . RecordListHookInterface::class, 1195567845 ); } $cells = $hookObject->makeClip($table, $row, $cells, $this); } return '<div class="btn-group" role="group">' . implode('', $cells) . '</div>'; }
[ "public", "function", "makeClip", "(", "$", "table", ",", "$", "row", ")", "{", "// Return blank, if disabled:", "if", "(", "!", "$", "this", "->", "getModule", "(", ")", "->", "MOD_SETTINGS", "[", "'clipBoard'", "]", ")", "{", "return", "''", ";", "}", "$", "cells", "=", "[", "]", ";", "$", "cells", "[", "'pasteAfter'", "]", "=", "(", "$", "cells", "[", "'pasteInto'", "]", "=", "$", "this", "->", "spaceIcon", ")", ";", "// Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them", "// For page translations these icons should never be shown", "$", "isL10nOverlay", "=", "$", "table", "===", "'pages'", "&&", "$", "row", "[", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "table", "]", "[", "'ctrl'", "]", "[", "'transOrigPointerField'", "]", "]", "!=", "0", ";", "// Return blank, if disabled:", "// Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:", "// For the \"Normal\" pad:", "if", "(", "$", "this", "->", "clipObj", "->", "current", "===", "'normal'", ")", "{", "// Show copy/cut icons:", "$", "isSel", "=", "(", "string", ")", "$", "this", "->", "clipObj", "->", "isSelected", "(", "$", "table", ",", "$", "row", "[", "'uid'", "]", ")", ";", "if", "(", "$", "isL10nOverlay", "||", "!", "$", "this", "->", "overlayEditLockPermissions", "(", "$", "table", ",", "$", "row", ")", ")", "{", "$", "cells", "[", "'copy'", "]", "=", "$", "this", "->", "spaceIcon", ";", "$", "cells", "[", "'cut'", "]", "=", "$", "this", "->", "spaceIcon", ";", "}", "else", "{", "$", "copyIcon", "=", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-edit-copy'", ",", "Icon", "::", "SIZE_SMALL", ")", ";", "$", "cutIcon", "=", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-edit-cut'", ",", "Icon", "::", "SIZE_SMALL", ")", ";", "if", "(", "$", "isSel", "===", "'copy'", ")", "{", "$", "copyIcon", "=", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-edit-copy-release'", ",", "Icon", "::", "SIZE_SMALL", ")", ";", "}", "elseif", "(", "$", "isSel", "===", "'cut'", ")", "{", "$", "cutIcon", "=", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-edit-cut-release'", ",", "Icon", "::", "SIZE_SMALL", ")", ";", "}", "$", "cells", "[", "'copy'", "]", "=", "'<a class=\"btn btn-default\" href=\"#\" onclick=\"'", ".", "htmlspecialchars", "(", "'return jumpSelf('", ".", "GeneralUtility", "::", "quoteJSvalue", "(", "$", "this", "->", "clipObj", "->", "selUrlDB", "(", "$", "table", ",", "$", "row", "[", "'uid'", "]", ",", "1", ",", "(", "$", "isSel", "===", "'copy'", ")", ",", "[", "'returnUrl'", "=>", "''", "]", ")", ")", ".", "');'", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.copy'", ")", ")", ".", "'\">'", ".", "$", "copyIcon", "->", "render", "(", ")", ".", "'</a>'", ";", "// Check permission to cut page or content", "if", "(", "$", "table", "===", "'pages'", ")", "{", "$", "localCalcPerms", "=", "$", "this", "->", "getBackendUserAuthentication", "(", ")", "->", "calcPerms", "(", "BackendUtility", "::", "getRecord", "(", "'pages'", ",", "$", "row", "[", "'uid'", "]", ")", ")", ";", "$", "permsEdit", "=", "$", "localCalcPerms", "&", "Permission", "::", "PAGE_EDIT", ";", "}", "else", "{", "$", "permsEdit", "=", "$", "this", "->", "calcPerms", "&", "Permission", "::", "CONTENT_EDIT", ";", "}", "$", "permsEdit", "=", "$", "this", "->", "overlayEditLockPermissions", "(", "$", "table", ",", "$", "row", ",", "$", "permsEdit", ")", ";", "// If the listed table is 'pages' we have to request the permission settings for each page:", "if", "(", "$", "table", "===", "'pages'", ")", "{", "if", "(", "$", "permsEdit", ")", "{", "$", "cells", "[", "'cut'", "]", "=", "'<a class=\"btn btn-default\" href=\"#\" onclick=\"'", ".", "htmlspecialchars", "(", "'return jumpSelf('", ".", "GeneralUtility", "::", "quoteJSvalue", "(", "$", "this", "->", "clipObj", "->", "selUrlDB", "(", "$", "table", ",", "$", "row", "[", "'uid'", "]", ",", "0", ",", "(", "$", "isSel", "===", "'cut'", ")", ",", "[", "'returnUrl'", "=>", "''", "]", ")", ")", ".", "');'", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut'", ")", ")", ".", "'\">'", ".", "$", "cutIcon", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "else", "{", "$", "cells", "[", "'cut'", "]", "=", "$", "this", "->", "spaceIcon", ";", "}", "}", "else", "{", "if", "(", "$", "table", "!==", "'pages'", "&&", "$", "this", "->", "calcPerms", "&", "Permission", "::", "CONTENT_EDIT", ")", "{", "$", "cells", "[", "'cut'", "]", "=", "'<a class=\"btn btn-default\" href=\"#\" onclick=\"'", ".", "htmlspecialchars", "(", "'return jumpSelf('", ".", "GeneralUtility", "::", "quoteJSvalue", "(", "$", "this", "->", "clipObj", "->", "selUrlDB", "(", "$", "table", ",", "$", "row", "[", "'uid'", "]", ",", "0", ",", "(", "$", "isSel", "===", "'cut'", ")", ",", "[", "'returnUrl'", "=>", "''", "]", ")", ")", ".", "');'", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut'", ")", ")", ".", "'\">'", ".", "$", "cutIcon", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "else", "{", "$", "cells", "[", "'cut'", "]", "=", "$", "this", "->", "spaceIcon", ";", "}", "}", "}", "}", "else", "{", "// For the numeric clipboard pads (showing checkboxes where one can select elements on/off)", "// Setting name of the element in ->CBnames array:", "$", "n", "=", "$", "table", ".", "'|'", ".", "$", "row", "[", "'uid'", "]", ";", "$", "this", "->", "CBnames", "[", "]", "=", "$", "n", ";", "// Check if the current element is selected and if so, prepare to set the checkbox as selected:", "$", "checked", "=", "$", "this", "->", "clipObj", "->", "isSelected", "(", "$", "table", ",", "$", "row", "[", "'uid'", "]", ")", "?", "'checked=\"checked\" '", ":", "''", ";", "// If the \"duplicateField\" value is set then select all elements which are duplicates...", "if", "(", "$", "this", "->", "duplicateField", "&&", "isset", "(", "$", "row", "[", "$", "this", "->", "duplicateField", "]", ")", ")", "{", "$", "checked", "=", "''", ";", "if", "(", "in_array", "(", "$", "row", "[", "$", "this", "->", "duplicateField", "]", ",", "$", "this", "->", "duplicateStack", ")", ")", "{", "$", "checked", "=", "'checked=\"checked\" '", ";", "}", "$", "this", "->", "duplicateStack", "[", "]", "=", "$", "row", "[", "$", "this", "->", "duplicateField", "]", ";", "}", "// Adding the checkbox to the panel:", "$", "cells", "[", "'select'", "]", "=", "$", "isL10nOverlay", "?", "$", "this", "->", "spaceIcon", ":", "'<input type=\"hidden\" name=\"CBH['", ".", "$", "n", ".", "']\" value=\"0\" /><label class=\"btn btn-default btn-checkbox\"><input type=\"checkbox\"'", ".", "' name=\"CBC['", ".", "$", "n", ".", "']\" value=\"1\" '", ".", "$", "checked", ".", "'/><span class=\"t3-icon fa\"></span></label>'", ";", "}", "// Now, looking for selected elements from the current table:", "$", "elFromTable", "=", "$", "this", "->", "clipObj", "->", "elFromTable", "(", "$", "table", ")", ";", "if", "(", "!", "empty", "(", "$", "elFromTable", ")", "&&", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "table", "]", "[", "'ctrl'", "]", "[", "'sortby'", "]", ")", "{", "// IF elements are found, they can be individually ordered and are not locked by editlock, then add a \"paste after\" icon:", "$", "cells", "[", "'pasteAfter'", "]", "=", "$", "isL10nOverlay", "||", "!", "$", "this", "->", "overlayEditLockPermissions", "(", "$", "table", ",", "$", "row", ")", "?", "$", "this", "->", "spaceIcon", ":", "'<a class=\"btn btn-default t3js-modal-trigger\"'", ".", "' href=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "clipObj", "->", "pasteUrl", "(", "$", "table", ",", "-", "$", "row", "[", "'uid'", "]", ")", ")", ".", "'\"'", ".", "' title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "getLL", "(", "'clip_pasteAfter'", ")", ")", ".", "'\"'", ".", "' data-title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "getLL", "(", "'clip_pasteAfter'", ")", ")", ".", "'\"'", ".", "' data-content=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "clipObj", "->", "confirmMsgText", "(", "$", "table", ",", "$", "row", ",", "'after'", ",", "$", "elFromTable", ")", ")", ".", "'\"'", ".", "' data-severity=\"warning\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-paste-after'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "// Now, looking for elements in general:", "$", "elFromTable", "=", "$", "this", "->", "clipObj", "->", "elFromTable", "(", "''", ")", ";", "if", "(", "$", "table", "===", "'pages'", "&&", "!", "$", "isL10nOverlay", "&&", "!", "empty", "(", "$", "elFromTable", ")", ")", "{", "$", "cells", "[", "'pasteInto'", "]", "=", "'<a class=\"btn btn-default t3js-modal-trigger\"'", ".", "' href=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "clipObj", "->", "pasteUrl", "(", "''", ",", "$", "row", "[", "'uid'", "]", ")", ")", ".", "'\"'", ".", "' title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "getLL", "(", "'clip_pasteInto'", ")", ")", ".", "'\"'", ".", "' data-title=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "getLanguageService", "(", ")", "->", "getLL", "(", "'clip_pasteInto'", ")", ")", ".", "'\"'", ".", "' data-content=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "clipObj", "->", "confirmMsgText", "(", "$", "table", ",", "$", "row", ",", "'into'", ",", "$", "elFromTable", ")", ")", ".", "'\"'", ".", "' data-severity=\"warning\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-paste-into'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "/*\n * hook: makeClip: Allows to change clip-icons of records in list-module\n * usage: This hook method gets passed the current $cells array as third parameter.\n * This array contains values for the clipboard icons generated for each record in Web>List.\n * Each array entry is accessible by an index-key.\n * The order of the icons is depending on the order of those array entries.\n */", "foreach", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'SC_OPTIONS'", "]", "[", "'typo3/class.db_list_extra.inc'", "]", "[", "'actions'", "]", "??", "[", "]", "as", "$", "className", ")", "{", "$", "hookObject", "=", "GeneralUtility", "::", "makeInstance", "(", "$", "className", ")", ";", "if", "(", "!", "$", "hookObject", "instanceof", "RecordListHookInterface", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "$", "className", ".", "' must implement interface '", ".", "RecordListHookInterface", "::", "class", ",", "1195567845", ")", ";", "}", "$", "cells", "=", "$", "hookObject", "->", "makeClip", "(", "$", "table", ",", "$", "row", ",", "$", "cells", ",", "$", "this", ")", ";", "}", "return", "'<div class=\"btn-group\" role=\"group\">'", ".", "implode", "(", "''", ",", "$", "cells", ")", ".", "'</div>'", ";", "}" ]
Creates the clipboard panel for a single record in the listing. @param string $table The table @param mixed[] $row The record for which to make the clipboard panel. @throws \UnexpectedValueException @return string HTML table with the clipboard panel (unless disabled)
[ "Creates", "the", "clipboard", "panel", "for", "a", "single", "record", "in", "the", "listing", "." ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2155-L2315
TYPO3-extensions/gridelements
Classes/Xclass/DatabaseRecordList.php
DatabaseRecordList.makeLocalizationPanel
public function makeLocalizationPanel($table, $row) { $out = [ 0 => '', 1 => '', ]; // Reset translations $this->translations = []; // Language title and icon: $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]); // Guard clause so we can quickly return if a record is localized to "all languages" // It should only be possible to localize a record off default (uid 0) // Reasoning: The Parent is for ALL languages... why overlay with a localization? if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) { return $out; } $translations = $this->getTranslateTools()->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList); if (is_array($translations)) { $this->translations = $translations['translations']; // Traverse page translations and add icon for each language that does NOT yet exist: $lNew = ''; foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) { if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) { $url = $this->listURL(); $href = BackendUtility::getLinkToDataHandlerAction( '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage, $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage) ); $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title'); if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) { $lC = $this->iconFactory->getIcon( $this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL )->render(); } else { $lC = $this->languageIconTitles[$lUid_OnPage]['title']; } $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> '; $lNew .= $lC; } } if ($lNew) { $out[1] .= $lNew; } } elseif ($row['l18n_parent']) { $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;' . $out[0]; } return $out; }
php
public function makeLocalizationPanel($table, $row) { $out = [ 0 => '', 1 => '', ]; // Reset translations $this->translations = []; // Language title and icon: $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]); // Guard clause so we can quickly return if a record is localized to "all languages" // It should only be possible to localize a record off default (uid 0) // Reasoning: The Parent is for ALL languages... why overlay with a localization? if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) { return $out; } $translations = $this->getTranslateTools()->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList); if (is_array($translations)) { $this->translations = $translations['translations']; // Traverse page translations and add icon for each language that does NOT yet exist: $lNew = ''; foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) { if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) { $url = $this->listURL(); $href = BackendUtility::getLinkToDataHandlerAction( '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage, $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage) ); $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title'); if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) { $lC = $this->iconFactory->getIcon( $this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL )->render(); } else { $lC = $this->languageIconTitles[$lUid_OnPage]['title']; } $lC = '<a href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> '; $lNew .= $lC; } } if ($lNew) { $out[1] .= $lNew; } } elseif ($row['l18n_parent']) { $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;' . $out[0]; } return $out; }
[ "public", "function", "makeLocalizationPanel", "(", "$", "table", ",", "$", "row", ")", "{", "$", "out", "=", "[", "0", "=>", "''", ",", "1", "=>", "''", ",", "]", ";", "// Reset translations", "$", "this", "->", "translations", "=", "[", "]", ";", "// Language title and icon:", "$", "out", "[", "0", "]", "=", "$", "this", "->", "languageFlag", "(", "$", "row", "[", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "table", "]", "[", "'ctrl'", "]", "[", "'languageField'", "]", "]", ")", ";", "// Guard clause so we can quickly return if a record is localized to \"all languages\"", "// It should only be possible to localize a record off default (uid 0)", "// Reasoning: The Parent is for ALL languages... why overlay with a localization?", "if", "(", "(", "int", ")", "$", "row", "[", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "table", "]", "[", "'ctrl'", "]", "[", "'languageField'", "]", "]", "===", "-", "1", ")", "{", "return", "$", "out", ";", "}", "$", "translations", "=", "$", "this", "->", "getTranslateTools", "(", ")", "->", "translationInfo", "(", "$", "table", ",", "$", "row", "[", "'uid'", "]", ",", "0", ",", "$", "row", ",", "$", "this", "->", "selFieldList", ")", ";", "if", "(", "is_array", "(", "$", "translations", ")", ")", "{", "$", "this", "->", "translations", "=", "$", "translations", "[", "'translations'", "]", ";", "// Traverse page translations and add icon for each language that does NOT yet exist:", "$", "lNew", "=", "''", ";", "foreach", "(", "$", "this", "->", "pageOverlays", "as", "$", "lUid_OnPage", "=>", "$", "lsysRec", ")", "{", "if", "(", "$", "this", "->", "isEditable", "(", "$", "table", ")", "&&", "!", "isset", "(", "$", "translations", "[", "'translations'", "]", "[", "$", "lUid_OnPage", "]", ")", "&&", "$", "this", "->", "getBackendUserAuthentication", "(", ")", "->", "checkLanguageAccess", "(", "$", "lUid_OnPage", ")", ")", "{", "$", "url", "=", "$", "this", "->", "listURL", "(", ")", ";", "$", "href", "=", "BackendUtility", "::", "getLinkToDataHandlerAction", "(", "'&cmd['", ".", "$", "table", ".", "']['", ".", "$", "row", "[", "'uid'", "]", ".", "'][localize]='", ".", "$", "lUid_OnPage", ",", "$", "url", ".", "'&justLocalized='", ".", "rawurlencode", "(", "$", "table", ".", "':'", ".", "$", "row", "[", "'uid'", "]", ".", "':'", ".", "$", "lUid_OnPage", ")", ")", ";", "$", "language", "=", "BackendUtility", "::", "getRecord", "(", "'sys_language'", ",", "$", "lUid_OnPage", ",", "'title'", ")", ";", "if", "(", "$", "this", "->", "languageIconTitles", "[", "$", "lUid_OnPage", "]", "[", "'flagIcon'", "]", ")", "{", "$", "lC", "=", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "$", "this", "->", "languageIconTitles", "[", "$", "lUid_OnPage", "]", "[", "'flagIcon'", "]", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ";", "}", "else", "{", "$", "lC", "=", "$", "this", "->", "languageIconTitles", "[", "$", "lUid_OnPage", "]", "[", "'title'", "]", ";", "}", "$", "lC", "=", "'<a href=\"'", ".", "htmlspecialchars", "(", "$", "href", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "language", "[", "'title'", "]", ")", ".", "'\" class=\"btn btn-default\">'", ".", "$", "lC", ".", "'</a> '", ";", "$", "lNew", ".=", "$", "lC", ";", "}", "}", "if", "(", "$", "lNew", ")", "{", "$", "out", "[", "1", "]", ".=", "$", "lNew", ";", "}", "}", "elseif", "(", "$", "row", "[", "'l18n_parent'", "]", ")", "{", "$", "out", "[", "0", "]", "=", "'&nbsp;&nbsp;&nbsp;&nbsp;'", ".", "$", "out", "[", "0", "]", ";", "}", "return", "$", "out", ";", "}" ]
Creates the localization panel @param string $table The table @param mixed[] $row The record for which to make the localization panel. @return string[] Array with key 0/1 with content for column 1 and 2
[ "Creates", "the", "localization", "panel" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2324-L2375
TYPO3-extensions/gridelements
Classes/Xclass/DatabaseRecordList.php
DatabaseRecordList.addElement
public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', $colType = 'td', $level = 0) { if ($colType === 'pagination') { $colType = 'td'; $pagination = true; } else { $colType = ($colType === 'th') ? 'th' : 'td'; $pagination = false; } $noWrap = $this->no_noWrap ? '' : ' nowrap="nowrap"'; // Start up: $parent = isset($data['_l10nparent_']) ? (int)$data['_l10nparent_'] : 0; $out = ' <!-- Element, begin: --> <tr ' . $rowParams . ' data-uid="' . (int)$data['uid'] . '" data-l10nparent="' . $parent . '"' . ((int)$data['tx_gridelements_container'] > 0 ? ' data-grid-container="' . $data['tx_gridelements_container'] . '"' : '') . ((int)$data['_triggerContainer'] > 0 ? ' data-trigger-container="' . $data['_triggerContainer'] . '"' : '') . '>'; if (count($data) > 1) { for ($i = 0; $i < $level; $i++) { $out .= '<' . $colType . '></' . $colType . '>'; } if ($data['_EXPANDABLE_'] && (!$this->localizationView || !$parent)) { $sortField = GeneralUtility::_GP('sortField') ? GeneralUtility::_GP('sortField') . ':' . (int)GeneralUtility::_GP('sortRev') : ''; $contentCollapseIcon = ''; /** * @hook contentCollapseIcon * @date 2014-02-11 * @request Alexander Grein <alexander.grein@in2code.de> */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (is_object($hookObject) && method_exists($hookObject, 'contentCollapseIcon')) { $hookObject->contentCollapseIcon($data, $sortField, $level, $contentCollapseIcon, $this); } } $out .= '<' . $colType . ' nowrap="nowrap" class="col-icon">' . $contentCollapseIcon . '</' . $colType . '>'; } else { if ($colType === 'td') { $out .= '<' . $colType . '></' . $colType . '>'; } } } // Show icon and lines if ($this->showIcon) { $out .= ' <' . $colType . ' nowrap="nowrap" class="col-icon"' . ($colType === 'th' ? ' colspan="' . ($this->maxDepth - $level) . '"' : '') . '>'; if (!$h) { $out .= '&nbsp;'; } else { for ($a = 0; $a < $h; $a++) { if (!$a) { if ($icon) { $out .= $icon; } } } } $out .= '</' . $colType . '> '; } // Init rendering. $colsp = ''; $lastKey = ''; $c = 0; $ccount = 0; // __label is used as the label key to circumvent problems with uid used as label (see #67756) // as it was introduced later on, check if it really exists before using it $fields = $this->fieldArray; if ($colType === 'td' && array_key_exists('__label', $data)) { $fields[0] = '__label'; } // Traverse field array which contains the data to present: foreach ($fields as $vKey) { if (isset($data[$vKey])) { if ($lastKey) { $cssClass = $this->addElement_tdCssClass[$lastKey]; if ($this->oddColumnsCssClass && $ccount % 2 == 0) { $cssClass = implode( ' ', [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass] ); } $out .= ' <' . $colType . $noWrap . ' class="' . $cssClass . '"' . $colsp . $this->addElement_tdParams[$lastKey] . '>' . $data[$lastKey] . '</' . $colType . '>'; } $lastKey = $vKey; $c = 1; $ccount++; } else { if (!$lastKey) { $lastKey = $vKey; } $c++; } if (count($data) == 1) { $c++; } if ($pagination) { $colsp = ' colspan="' . ($this->totalColumnCount - 1) . '"'; } elseif ($c > 1) { $colsp = ' colspan="2"'; } elseif ($ccount === 1 && $colType === 'td') { $colsp = ' colspan="' . ($this->maxDepth - $level - 1) . '"'; } else { $colsp = ''; } } if ($lastKey) { $cssClass = $this->addElement_tdCssClass[$lastKey]; if ($this->oddColumnsCssClass) { $cssClass = implode(' ', [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass]); } $out .= ' <' . $colType . $noWrap . ' class="' . $cssClass . '"' . $colsp . $this->addElement_tdParams[$lastKey] . '>' . $data[$lastKey] . '</' . $colType . '>'; } // End row $out .= ' </tr>'; // Return row. return $out; }
php
public function addElement($h, $icon, $data, $rowParams = '', $_ = '', $_2 = '', $colType = 'td', $level = 0) { if ($colType === 'pagination') { $colType = 'td'; $pagination = true; } else { $colType = ($colType === 'th') ? 'th' : 'td'; $pagination = false; } $noWrap = $this->no_noWrap ? '' : ' nowrap="nowrap"'; // Start up: $parent = isset($data['_l10nparent_']) ? (int)$data['_l10nparent_'] : 0; $out = ' <!-- Element, begin: --> <tr ' . $rowParams . ' data-uid="' . (int)$data['uid'] . '" data-l10nparent="' . $parent . '"' . ((int)$data['tx_gridelements_container'] > 0 ? ' data-grid-container="' . $data['tx_gridelements_container'] . '"' : '') . ((int)$data['_triggerContainer'] > 0 ? ' data-trigger-container="' . $data['_triggerContainer'] . '"' : '') . '>'; if (count($data) > 1) { for ($i = 0; $i < $level; $i++) { $out .= '<' . $colType . '></' . $colType . '>'; } if ($data['_EXPANDABLE_'] && (!$this->localizationView || !$parent)) { $sortField = GeneralUtility::_GP('sortField') ? GeneralUtility::_GP('sortField') . ':' . (int)GeneralUtility::_GP('sortRev') : ''; $contentCollapseIcon = ''; /** * @hook contentCollapseIcon * @date 2014-02-11 * @request Alexander Grein <alexander.grein@in2code.de> */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (is_object($hookObject) && method_exists($hookObject, 'contentCollapseIcon')) { $hookObject->contentCollapseIcon($data, $sortField, $level, $contentCollapseIcon, $this); } } $out .= '<' . $colType . ' nowrap="nowrap" class="col-icon">' . $contentCollapseIcon . '</' . $colType . '>'; } else { if ($colType === 'td') { $out .= '<' . $colType . '></' . $colType . '>'; } } } // Show icon and lines if ($this->showIcon) { $out .= ' <' . $colType . ' nowrap="nowrap" class="col-icon"' . ($colType === 'th' ? ' colspan="' . ($this->maxDepth - $level) . '"' : '') . '>'; if (!$h) { $out .= '&nbsp;'; } else { for ($a = 0; $a < $h; $a++) { if (!$a) { if ($icon) { $out .= $icon; } } } } $out .= '</' . $colType . '> '; } // Init rendering. $colsp = ''; $lastKey = ''; $c = 0; $ccount = 0; // __label is used as the label key to circumvent problems with uid used as label (see #67756) // as it was introduced later on, check if it really exists before using it $fields = $this->fieldArray; if ($colType === 'td' && array_key_exists('__label', $data)) { $fields[0] = '__label'; } // Traverse field array which contains the data to present: foreach ($fields as $vKey) { if (isset($data[$vKey])) { if ($lastKey) { $cssClass = $this->addElement_tdCssClass[$lastKey]; if ($this->oddColumnsCssClass && $ccount % 2 == 0) { $cssClass = implode( ' ', [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass] ); } $out .= ' <' . $colType . $noWrap . ' class="' . $cssClass . '"' . $colsp . $this->addElement_tdParams[$lastKey] . '>' . $data[$lastKey] . '</' . $colType . '>'; } $lastKey = $vKey; $c = 1; $ccount++; } else { if (!$lastKey) { $lastKey = $vKey; } $c++; } if (count($data) == 1) { $c++; } if ($pagination) { $colsp = ' colspan="' . ($this->totalColumnCount - 1) . '"'; } elseif ($c > 1) { $colsp = ' colspan="2"'; } elseif ($ccount === 1 && $colType === 'td') { $colsp = ' colspan="' . ($this->maxDepth - $level - 1) . '"'; } else { $colsp = ''; } } if ($lastKey) { $cssClass = $this->addElement_tdCssClass[$lastKey]; if ($this->oddColumnsCssClass) { $cssClass = implode(' ', [$this->addElement_tdCssClass[$lastKey], $this->oddColumnsCssClass]); } $out .= ' <' . $colType . $noWrap . ' class="' . $cssClass . '"' . $colsp . $this->addElement_tdParams[$lastKey] . '>' . $data[$lastKey] . '</' . $colType . '>'; } // End row $out .= ' </tr>'; // Return row. return $out; }
[ "public", "function", "addElement", "(", "$", "h", ",", "$", "icon", ",", "$", "data", ",", "$", "rowParams", "=", "''", ",", "$", "_", "=", "''", ",", "$", "_2", "=", "''", ",", "$", "colType", "=", "'td'", ",", "$", "level", "=", "0", ")", "{", "if", "(", "$", "colType", "===", "'pagination'", ")", "{", "$", "colType", "=", "'td'", ";", "$", "pagination", "=", "true", ";", "}", "else", "{", "$", "colType", "=", "(", "$", "colType", "===", "'th'", ")", "?", "'th'", ":", "'td'", ";", "$", "pagination", "=", "false", ";", "}", "$", "noWrap", "=", "$", "this", "->", "no_noWrap", "?", "''", ":", "' nowrap=\"nowrap\"'", ";", "// Start up:", "$", "parent", "=", "isset", "(", "$", "data", "[", "'_l10nparent_'", "]", ")", "?", "(", "int", ")", "$", "data", "[", "'_l10nparent_'", "]", ":", "0", ";", "$", "out", "=", "'\n\t\t<!-- Element, begin: -->\n\t\t<tr '", ".", "$", "rowParams", ".", "' data-uid=\"'", ".", "(", "int", ")", "$", "data", "[", "'uid'", "]", ".", "'\" data-l10nparent=\"'", ".", "$", "parent", ".", "'\"'", ".", "(", "(", "int", ")", "$", "data", "[", "'tx_gridelements_container'", "]", ">", "0", "?", "' data-grid-container=\"'", ".", "$", "data", "[", "'tx_gridelements_container'", "]", ".", "'\"'", ":", "''", ")", ".", "(", "(", "int", ")", "$", "data", "[", "'_triggerContainer'", "]", ">", "0", "?", "' data-trigger-container=\"'", ".", "$", "data", "[", "'_triggerContainer'", "]", ".", "'\"'", ":", "''", ")", ".", "'>'", ";", "if", "(", "count", "(", "$", "data", ")", ">", "1", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "level", ";", "$", "i", "++", ")", "{", "$", "out", ".=", "'<'", ".", "$", "colType", ".", "'></'", ".", "$", "colType", ".", "'>'", ";", "}", "if", "(", "$", "data", "[", "'_EXPANDABLE_'", "]", "&&", "(", "!", "$", "this", "->", "localizationView", "||", "!", "$", "parent", ")", ")", "{", "$", "sortField", "=", "GeneralUtility", "::", "_GP", "(", "'sortField'", ")", "?", "GeneralUtility", "::", "_GP", "(", "'sortField'", ")", ".", "':'", ".", "(", "int", ")", "GeneralUtility", "::", "_GP", "(", "'sortRev'", ")", ":", "''", ";", "$", "contentCollapseIcon", "=", "''", ";", "/**\n * @hook contentCollapseIcon\n * @date 2014-02-11\n * @request Alexander Grein <alexander.grein@in2code.de>\n */", "foreach", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'SC_OPTIONS'", "]", "[", "'typo3/class.db_list_extra.inc'", "]", "[", "'actions'", "]", "??", "[", "]", "as", "$", "className", ")", "{", "$", "hookObject", "=", "GeneralUtility", "::", "makeInstance", "(", "$", "className", ")", ";", "if", "(", "is_object", "(", "$", "hookObject", ")", "&&", "method_exists", "(", "$", "hookObject", ",", "'contentCollapseIcon'", ")", ")", "{", "$", "hookObject", "->", "contentCollapseIcon", "(", "$", "data", ",", "$", "sortField", ",", "$", "level", ",", "$", "contentCollapseIcon", ",", "$", "this", ")", ";", "}", "}", "$", "out", ".=", "'<'", ".", "$", "colType", ".", "' nowrap=\"nowrap\" class=\"col-icon\">'", ".", "$", "contentCollapseIcon", ".", "'</'", ".", "$", "colType", ".", "'>'", ";", "}", "else", "{", "if", "(", "$", "colType", "===", "'td'", ")", "{", "$", "out", ".=", "'<'", ".", "$", "colType", ".", "'></'", ".", "$", "colType", ".", "'>'", ";", "}", "}", "}", "// Show icon and lines", "if", "(", "$", "this", "->", "showIcon", ")", "{", "$", "out", ".=", "'\n\t\t\t<'", ".", "$", "colType", ".", "' nowrap=\"nowrap\" class=\"col-icon\"'", ".", "(", "$", "colType", "===", "'th'", "?", "' colspan=\"'", ".", "(", "$", "this", "->", "maxDepth", "-", "$", "level", ")", ".", "'\"'", ":", "''", ")", ".", "'>'", ";", "if", "(", "!", "$", "h", ")", "{", "$", "out", ".=", "'&nbsp;'", ";", "}", "else", "{", "for", "(", "$", "a", "=", "0", ";", "$", "a", "<", "$", "h", ";", "$", "a", "++", ")", "{", "if", "(", "!", "$", "a", ")", "{", "if", "(", "$", "icon", ")", "{", "$", "out", ".=", "$", "icon", ";", "}", "}", "}", "}", "$", "out", ".=", "'</'", ".", "$", "colType", ".", "'>\n\t\t\t'", ";", "}", "// Init rendering.", "$", "colsp", "=", "''", ";", "$", "lastKey", "=", "''", ";", "$", "c", "=", "0", ";", "$", "ccount", "=", "0", ";", "// __label is used as the label key to circumvent problems with uid used as label (see #67756)", "// as it was introduced later on, check if it really exists before using it", "$", "fields", "=", "$", "this", "->", "fieldArray", ";", "if", "(", "$", "colType", "===", "'td'", "&&", "array_key_exists", "(", "'__label'", ",", "$", "data", ")", ")", "{", "$", "fields", "[", "0", "]", "=", "'__label'", ";", "}", "// Traverse field array which contains the data to present:", "foreach", "(", "$", "fields", "as", "$", "vKey", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "vKey", "]", ")", ")", "{", "if", "(", "$", "lastKey", ")", "{", "$", "cssClass", "=", "$", "this", "->", "addElement_tdCssClass", "[", "$", "lastKey", "]", ";", "if", "(", "$", "this", "->", "oddColumnsCssClass", "&&", "$", "ccount", "%", "2", "==", "0", ")", "{", "$", "cssClass", "=", "implode", "(", "' '", ",", "[", "$", "this", "->", "addElement_tdCssClass", "[", "$", "lastKey", "]", ",", "$", "this", "->", "oddColumnsCssClass", "]", ")", ";", "}", "$", "out", ".=", "'\n\t\t\t\t\t\t<'", ".", "$", "colType", ".", "$", "noWrap", ".", "' class=\"'", ".", "$", "cssClass", ".", "'\"'", ".", "$", "colsp", ".", "$", "this", "->", "addElement_tdParams", "[", "$", "lastKey", "]", ".", "'>'", ".", "$", "data", "[", "$", "lastKey", "]", ".", "'</'", ".", "$", "colType", ".", "'>'", ";", "}", "$", "lastKey", "=", "$", "vKey", ";", "$", "c", "=", "1", ";", "$", "ccount", "++", ";", "}", "else", "{", "if", "(", "!", "$", "lastKey", ")", "{", "$", "lastKey", "=", "$", "vKey", ";", "}", "$", "c", "++", ";", "}", "if", "(", "count", "(", "$", "data", ")", "==", "1", ")", "{", "$", "c", "++", ";", "}", "if", "(", "$", "pagination", ")", "{", "$", "colsp", "=", "' colspan=\"'", ".", "(", "$", "this", "->", "totalColumnCount", "-", "1", ")", ".", "'\"'", ";", "}", "elseif", "(", "$", "c", ">", "1", ")", "{", "$", "colsp", "=", "' colspan=\"2\"'", ";", "}", "elseif", "(", "$", "ccount", "===", "1", "&&", "$", "colType", "===", "'td'", ")", "{", "$", "colsp", "=", "' colspan=\"'", ".", "(", "$", "this", "->", "maxDepth", "-", "$", "level", "-", "1", ")", ".", "'\"'", ";", "}", "else", "{", "$", "colsp", "=", "''", ";", "}", "}", "if", "(", "$", "lastKey", ")", "{", "$", "cssClass", "=", "$", "this", "->", "addElement_tdCssClass", "[", "$", "lastKey", "]", ";", "if", "(", "$", "this", "->", "oddColumnsCssClass", ")", "{", "$", "cssClass", "=", "implode", "(", "' '", ",", "[", "$", "this", "->", "addElement_tdCssClass", "[", "$", "lastKey", "]", ",", "$", "this", "->", "oddColumnsCssClass", "]", ")", ";", "}", "$", "out", ".=", "'\n\t\t\t\t<'", ".", "$", "colType", ".", "$", "noWrap", ".", "' class=\"'", ".", "$", "cssClass", ".", "'\"'", ".", "$", "colsp", ".", "$", "this", "->", "addElement_tdParams", "[", "$", "lastKey", "]", ".", "'>'", ".", "$", "data", "[", "$", "lastKey", "]", ".", "'</'", ".", "$", "colType", ".", "'>'", ";", "}", "// End row", "$", "out", ".=", "'\n\t\t</tr>'", ";", "// Return row.", "return", "$", "out", ";", "}" ]
Returns a table-row with the content from the fields in the input data array. OBS: $this->fieldArray MUST be set! (represents the list of fields to display) @param int $h Is an integer >=0 and denotes how tall an element is. Set to '0' makes a halv line, -1 = full line, set to 1 makes a 'join' and above makes 'line' @param string $icon Is the <img>+<a> of the record. If not supplied the first 'join'-icon will be a 'line' instead @param array $data Is the dataarray, record with the fields. Notice: These fields are (currently) NOT htmlspecialchar'ed before being wrapped in <td>-tags @param string $rowParams Is insert in the <tr>-tags. Must carry a ' ' as first character @param string $_ OBSOLETE - NOT USED ANYMORE. $lMargin is the leftMargin (int) @param string $_2 OBSOLETE - NOT USED ANYMORE. Is the HTML <img>-tag for an alternative 'gfx/ol/line.gif'-icon (used in the top) @param string $colType Defines the tag being used for the columns. Default is td. @param int $level @return string HTML content for the table row
[ "Returns", "a", "table", "-", "row", "with", "the", "content", "from", "the", "fields", "in", "the", "input", "data", "array", ".", "OBS", ":", "$this", "-", ">", "fieldArray", "MUST", "be", "set!", "(", "represents", "the", "list", "of", "fields", "to", "display", ")" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2392-L2515
TYPO3-extensions/gridelements
Classes/Xclass/DatabaseRecordList.php
DatabaseRecordList.renderListHeader
public function renderListHeader($table, $currentIdList) { $lang = $this->getLanguageService(); // Init: $theData = []; $icon = ''; /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); // Traverse the fields: foreach ($this->fieldArray as $fCol) { // Calculate users permissions to edit records in the table: $permsEdit = $this->calcPerms & ($table === 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table); switch ((string)$fCol) { case '_PATH_': // Path $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>'; break; case '_REF_': // References $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_')) . ']</i>'; break; case '_LOCALIZATION_': // Path $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>'; break; case '_LOCALIZATION_b': // Path $theData[$fCol] = htmlspecialchars($lang->getLL('Localize')); break; case '_CLIPBOARD_': if (!$this->getModule()->MOD_SETTINGS['clipBoard']) { break; } // Clipboard: $cells = []; // If there are elements on the clipboard for this table, and the parent page is not locked by editlock // then display the "paste into" icon: $elFromTable = $this->clipObj->elFromTable($table); if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) { $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id)); $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable); $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"' . ' href="' . $href . '"' . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"' . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"' . ' data-content="' . htmlspecialchars($confirmMessage) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>'; } // If the numeric clipboard pads are enabled, display the control icons for that: if ($this->clipObj->current !== 'normal') { // The "select" link: $spriteIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render(); $cells['copyMarked'] = $this->linkClipboardHeaderIcon( $spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked') ); // The "edit marked" link: $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit') . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit' . '&returnUrl={T3_THIS_LOCATION}'; $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"' . ' data-uri="' . htmlspecialchars($editUri) . '"' . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>'; // The "Delete marked" link: $cells['delete'] = $this->linkClipboardHeaderIcon( $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(), $table, 'delete', sprintf( $lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']) ), $lang->getLL('clip_deleteMarked') ); // The "Select all" link: $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility::quoteJSvalue(implode( ',', $this->CBnames )) . ', this); return false;')); $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('clip_markRecords')) . '">' . $this->iconFactory->getIcon( 'actions-document-select', Icon::SIZE_SMALL )->render() . '</a>'; } else { $cells['empty'] = ''; } /* * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers * usage: Above each listed table in Web>List a header row is shown. * This hook allows to modify the icons responsible for the clipboard functions * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected), * or other "Action" functions which perform operations on the listed records. */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof RecordListHookInterface) { throw new \UnexpectedValueException( $className . ' must implement interface ' . RecordListHookInterface::class, 1195567850 ); } $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this); } $theData[$fCol] = ''; if (isset($cells['edit']) && isset($cells['delete'])) { $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>'; unset($cells['edit'], $cells['delete']); } $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>'; break; case '_CONTROL_': // Control panel: if ($this->isEditable($table)) { // If new records can be created on this page, add links: $permsAdditional = $table === 'pages' ? 8 : 16; if ($table === 'tt_content') { $expandTitle = $lang->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandAllElements'); $collapseTitle = $lang->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseAllElements'); $containerIds = implode(',', array_flip(array_flip($this->currentContainerIdList))); $icon = '<a class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-collapse-all" id="t3-gridelements-collapse-all" title="' . $collapseTitle . '" data-container-ids="' . $containerIds . '">' . $this->iconFactory->getIcon( 'actions-view-list-collapse', 'small' )->render() . '</a><a class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expand-all" id="t3-gridelements-expand-all" title="' . $expandTitle . '" data-container-ids="' . $containerIds . '">' . $this->iconFactory->getIcon( 'actions-view-list-expand', 'small' )->render() . '</a>'; } if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) { $spriteIcon = $table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL); if ($table === 'tt_content') { // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead: $newContentElementWizard = BackendUtility::getPagesTSconfig($this->pageinfo['uid'])['mod.']['newContentElementWizard.']['override'] ?? 'new_content_element_wizard'; $url = (string)$uriBuilder->buildUriFromRoute( $newContentElementWizard, [ 'id' => $this->id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ] ); $icon = '<a href="#" data-url="' . htmlspecialchars($url) . '"' . ' data-title="' . htmlspecialchars($lang->getLL('new')) . '"' . ' class="btn btn-default t3js-toggle-new-content-element-wizard">' . $spriteIcon->render() . '</a>'; } elseif ($table === 'pages') { $parameters = [ 'id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $href = (string)$uriBuilder->buildUriFromRoute('db_new', $parameters); $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>'; } else { $params = '&edit[' . $table . '][' . $this->id . ']=new'; if ($table === 'pages') { $params .= '&overrideVals[pages][doktype]=' . (int)$this->pageRow['doktype']; } $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick( $params, '', -1 )) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>'; } } // If the table can be edited, add link for editing ALL SHOWN fields for all listed records: if ($permsEdit && $this->table && is_array($currentIdList)) { $entityIdentifiers = 'entityIdentifiers'; if ($this->clipNumPane()) { $entityIdentifiers .= ':editList'; } $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit') . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit' . '&columnsOnly=' . implode(',', $this->fieldArray) . '&returnUrl={T3_THIS_LOCATION}'; $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"' . ' data-uri="' . htmlspecialchars($editUri) . '"' . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">' . $this->iconFactory->getIcon( 'actions-document-open', Icon::SIZE_SMALL )->render() . '</a>'; $icon = '<div class="btn-group" role="group">' . $icon . '</div>'; } // Add an empty entry, so column count fits again after moving this into $icon $theData[$fCol] = '&nbsp;'; } break; default: // Regular fields header: $theData[$fCol] = ''; // Check if $fCol is really a field and get the label and remove the colons // at the end $sortLabel = BackendUtility::getItemLabel($table, $fCol); if ($sortLabel !== null) { $sortLabel = htmlspecialchars($lang->sL($sortLabel)); $sortLabel = rtrim(trim($sortLabel), ':'); } else { // No TCA field, only output the $fCol variable with square brackets [] $sortLabel = htmlspecialchars($fCol); $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>'; } if ($this->table && is_array($currentIdList)) { // If the numeric clipboard pads are selected, show duplicate sorting link: if ($this->clipNumPane()) { $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL( '', '-1' ) . '&duplicateField=' . $fCol) . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">' . $this->iconFactory->getIcon( 'actions-document-duplicates-select', Icon::SIZE_SMALL )->render() . '</a>'; } // If the table can be edited, add link for editing THIS field for all // listed records: if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) { $entityIdentifiers = 'entityIdentifiers'; if ($this->clipNumPane()) { $entityIdentifiers .= ':editList'; } $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit') . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit' . '&columnsOnly=' . $fCol . '&returnUrl={T3_THIS_LOCATION}'; $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel); $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"' . ' data-uri="' . htmlspecialchars($editUri) . '"' . ' title="' . htmlspecialchars($iTitle) . '">' . $this->iconFactory->getIcon( 'actions-document-open', Icon::SIZE_SMALL )->render() . '</a>'; } if (strlen($theData[$fCol]) > 0) { $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> '; } } $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table); } } $this->totalColumnCount = 10 + count($theData); $headerOutput = '<colgroup>'; for ($i = -10; $i < count($theData); $i++) { if ($i < -1) { $headerOutput .= '<col class="col-icon" width="40" />'; } else { $headerOutput .= '<col width="auto" />'; } } $headerOutput .= '</colgroup>'; /** * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers * @usage Above each listed table in Web>List a header row is shown. * Containing the labels of all shown fields and additional icons to create new records for this * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc. */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof RecordListHookInterface) { throw new \UnexpectedValueException( $className . ' must implement interface ' . RecordListHookInterface::class, 1195567855 ); } $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this); } // Create and return header table row: return $headerOutput . '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>'; }
php
public function renderListHeader($table, $currentIdList) { $lang = $this->getLanguageService(); // Init: $theData = []; $icon = ''; /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); // Traverse the fields: foreach ($this->fieldArray as $fCol) { // Calculate users permissions to edit records in the table: $permsEdit = $this->calcPerms & ($table === 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table); switch ((string)$fCol) { case '_PATH_': // Path $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>'; break; case '_REF_': // References $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_')) . ']</i>'; break; case '_LOCALIZATION_': // Path $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>'; break; case '_LOCALIZATION_b': // Path $theData[$fCol] = htmlspecialchars($lang->getLL('Localize')); break; case '_CLIPBOARD_': if (!$this->getModule()->MOD_SETTINGS['clipBoard']) { break; } // Clipboard: $cells = []; // If there are elements on the clipboard for this table, and the parent page is not locked by editlock // then display the "paste into" icon: $elFromTable = $this->clipObj->elFromTable($table); if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) { $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id)); $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable); $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"' . ' href="' . $href . '"' . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"' . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"' . ' data-content="' . htmlspecialchars($confirmMessage) . '"' . ' data-severity="warning">' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>'; } // If the numeric clipboard pads are enabled, display the control icons for that: if ($this->clipObj->current !== 'normal') { // The "select" link: $spriteIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render(); $cells['copyMarked'] = $this->linkClipboardHeaderIcon( $spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked') ); // The "edit marked" link: $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit') . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit' . '&returnUrl={T3_THIS_LOCATION}'; $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"' . ' data-uri="' . htmlspecialchars($editUri) . '"' . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>'; // The "Delete marked" link: $cells['delete'] = $this->linkClipboardHeaderIcon( $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(), $table, 'delete', sprintf( $lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']) ), $lang->getLL('clip_deleteMarked') ); // The "Select all" link: $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility::quoteJSvalue(implode( ',', $this->CBnames )) . ', this); return false;')); $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('clip_markRecords')) . '">' . $this->iconFactory->getIcon( 'actions-document-select', Icon::SIZE_SMALL )->render() . '</a>'; } else { $cells['empty'] = ''; } /* * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers * usage: Above each listed table in Web>List a header row is shown. * This hook allows to modify the icons responsible for the clipboard functions * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected), * or other "Action" functions which perform operations on the listed records. */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof RecordListHookInterface) { throw new \UnexpectedValueException( $className . ' must implement interface ' . RecordListHookInterface::class, 1195567850 ); } $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this); } $theData[$fCol] = ''; if (isset($cells['edit']) && isset($cells['delete'])) { $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>'; unset($cells['edit'], $cells['delete']); } $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>'; break; case '_CONTROL_': // Control panel: if ($this->isEditable($table)) { // If new records can be created on this page, add links: $permsAdditional = $table === 'pages' ? 8 : 16; if ($table === 'tt_content') { $expandTitle = $lang->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandAllElements'); $collapseTitle = $lang->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseAllElements'); $containerIds = implode(',', array_flip(array_flip($this->currentContainerIdList))); $icon = '<a class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-collapse-all" id="t3-gridelements-collapse-all" title="' . $collapseTitle . '" data-container-ids="' . $containerIds . '">' . $this->iconFactory->getIcon( 'actions-view-list-collapse', 'small' )->render() . '</a><a class="btn btn-default t3js-toggle-gridelements-all" href="#t3-gridelements-expand-all" id="t3-gridelements-expand-all" title="' . $expandTitle . '" data-container-ids="' . $containerIds . '">' . $this->iconFactory->getIcon( 'actions-view-list-expand', 'small' )->render() . '</a>'; } if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) { $spriteIcon = $table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL); if ($table === 'tt_content') { // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead: $newContentElementWizard = BackendUtility::getPagesTSconfig($this->pageinfo['uid'])['mod.']['newContentElementWizard.']['override'] ?? 'new_content_element_wizard'; $url = (string)$uriBuilder->buildUriFromRoute( $newContentElementWizard, [ 'id' => $this->id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ] ); $icon = '<a href="#" data-url="' . htmlspecialchars($url) . '"' . ' data-title="' . htmlspecialchars($lang->getLL('new')) . '"' . ' class="btn btn-default t3js-toggle-new-content-element-wizard">' . $spriteIcon->render() . '</a>'; } elseif ($table === 'pages') { $parameters = [ 'id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'), ]; $href = (string)$uriBuilder->buildUriFromRoute('db_new', $parameters); $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>'; } else { $params = '&edit[' . $table . '][' . $this->id . ']=new'; if ($table === 'pages') { $params .= '&overrideVals[pages][doktype]=' . (int)$this->pageRow['doktype']; } $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick( $params, '', -1 )) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>'; } } // If the table can be edited, add link for editing ALL SHOWN fields for all listed records: if ($permsEdit && $this->table && is_array($currentIdList)) { $entityIdentifiers = 'entityIdentifiers'; if ($this->clipNumPane()) { $entityIdentifiers .= ':editList'; } $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit') . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit' . '&columnsOnly=' . implode(',', $this->fieldArray) . '&returnUrl={T3_THIS_LOCATION}'; $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"' . ' data-uri="' . htmlspecialchars($editUri) . '"' . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">' . $this->iconFactory->getIcon( 'actions-document-open', Icon::SIZE_SMALL )->render() . '</a>'; $icon = '<div class="btn-group" role="group">' . $icon . '</div>'; } // Add an empty entry, so column count fits again after moving this into $icon $theData[$fCol] = '&nbsp;'; } break; default: // Regular fields header: $theData[$fCol] = ''; // Check if $fCol is really a field and get the label and remove the colons // at the end $sortLabel = BackendUtility::getItemLabel($table, $fCol); if ($sortLabel !== null) { $sortLabel = htmlspecialchars($lang->sL($sortLabel)); $sortLabel = rtrim(trim($sortLabel), ':'); } else { // No TCA field, only output the $fCol variable with square brackets [] $sortLabel = htmlspecialchars($fCol); $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>'; } if ($this->table && is_array($currentIdList)) { // If the numeric clipboard pads are selected, show duplicate sorting link: if ($this->clipNumPane()) { $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL( '', '-1' ) . '&duplicateField=' . $fCol) . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">' . $this->iconFactory->getIcon( 'actions-document-duplicates-select', Icon::SIZE_SMALL )->render() . '</a>'; } // If the table can be edited, add link for editing THIS field for all // listed records: if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) { $entityIdentifiers = 'entityIdentifiers'; if ($this->clipNumPane()) { $entityIdentifiers .= ':editList'; } $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit') . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit' . '&columnsOnly=' . $fCol . '&returnUrl={T3_THIS_LOCATION}'; $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel); $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"' . ' data-uri="' . htmlspecialchars($editUri) . '"' . ' title="' . htmlspecialchars($iTitle) . '">' . $this->iconFactory->getIcon( 'actions-document-open', Icon::SIZE_SMALL )->render() . '</a>'; } if (strlen($theData[$fCol]) > 0) { $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> '; } } $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table); } } $this->totalColumnCount = 10 + count($theData); $headerOutput = '<colgroup>'; for ($i = -10; $i < count($theData); $i++) { if ($i < -1) { $headerOutput .= '<col class="col-icon" width="40" />'; } else { $headerOutput .= '<col width="auto" />'; } } $headerOutput .= '</colgroup>'; /** * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers * @usage Above each listed table in Web>List a header row is shown. * Containing the labels of all shown fields and additional icons to create new records for this * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc. */ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) { $hookObject = GeneralUtility::makeInstance($className); if (!$hookObject instanceof RecordListHookInterface) { throw new \UnexpectedValueException( $className . ' must implement interface ' . RecordListHookInterface::class, 1195567855 ); } $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this); } // Create and return header table row: return $headerOutput . '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>'; }
[ "public", "function", "renderListHeader", "(", "$", "table", ",", "$", "currentIdList", ")", "{", "$", "lang", "=", "$", "this", "->", "getLanguageService", "(", ")", ";", "// Init:", "$", "theData", "=", "[", "]", ";", "$", "icon", "=", "''", ";", "/** @var \\TYPO3\\CMS\\Backend\\Routing\\UriBuilder $uriBuilder */", "$", "uriBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "\\", "TYPO3", "\\", "CMS", "\\", "Backend", "\\", "Routing", "\\", "UriBuilder", "::", "class", ")", ";", "// Traverse the fields:", "foreach", "(", "$", "this", "->", "fieldArray", "as", "$", "fCol", ")", "{", "// Calculate users permissions to edit records in the table:", "$", "permsEdit", "=", "$", "this", "->", "calcPerms", "&", "(", "$", "table", "===", "'pages'", "?", "2", ":", "16", ")", "&&", "$", "this", "->", "overlayEditLockPermissions", "(", "$", "table", ")", ";", "switch", "(", "(", "string", ")", "$", "fCol", ")", "{", "case", "'_PATH_'", ":", "// Path", "$", "theData", "[", "$", "fCol", "]", "=", "'<i>['", ".", "htmlspecialchars", "(", "$", "lang", "->", "sL", "(", "'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._PATH_'", ")", ")", ".", "']</i>'", ";", "break", ";", "case", "'_REF_'", ":", "// References", "$", "theData", "[", "$", "fCol", "]", "=", "'<i>['", ".", "htmlspecialchars", "(", "$", "lang", "->", "sL", "(", "'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_'", ")", ")", ".", "']</i>'", ";", "break", ";", "case", "'_LOCALIZATION_'", ":", "// Path", "$", "theData", "[", "$", "fCol", "]", "=", "'<i>['", ".", "htmlspecialchars", "(", "$", "lang", "->", "sL", "(", "'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_'", ")", ")", ".", "']</i>'", ";", "break", ";", "case", "'_LOCALIZATION_b'", ":", "// Path", "$", "theData", "[", "$", "fCol", "]", "=", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'Localize'", ")", ")", ";", "break", ";", "case", "'_CLIPBOARD_'", ":", "if", "(", "!", "$", "this", "->", "getModule", "(", ")", "->", "MOD_SETTINGS", "[", "'clipBoard'", "]", ")", "{", "break", ";", "}", "// Clipboard:", "$", "cells", "=", "[", "]", ";", "// If there are elements on the clipboard for this table, and the parent page is not locked by editlock", "// then display the \"paste into\" icon:", "$", "elFromTable", "=", "$", "this", "->", "clipObj", "->", "elFromTable", "(", "$", "table", ")", ";", "if", "(", "!", "empty", "(", "$", "elFromTable", ")", "&&", "$", "this", "->", "overlayEditLockPermissions", "(", "$", "table", ")", ")", "{", "$", "href", "=", "htmlspecialchars", "(", "$", "this", "->", "clipObj", "->", "pasteUrl", "(", "$", "table", ",", "$", "this", "->", "id", ")", ")", ";", "$", "confirmMessage", "=", "$", "this", "->", "clipObj", "->", "confirmMsgText", "(", "'pages'", ",", "$", "this", "->", "pageRow", ",", "'into'", ",", "$", "elFromTable", ")", ";", "$", "cells", "[", "'pasteAfter'", "]", "=", "'<a class=\"btn btn-default t3js-modal-trigger\"'", ".", "' href=\"'", ".", "$", "href", ".", "'\"'", ".", "' title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'clip_paste'", ")", ")", ".", "'\"'", ".", "' data-title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'clip_paste'", ")", ")", ".", "'\"'", ".", "' data-content=\"'", ".", "htmlspecialchars", "(", "$", "confirmMessage", ")", ".", "'\"'", ".", "' data-severity=\"warning\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-paste-into'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "// If the numeric clipboard pads are enabled, display the control icons for that:", "if", "(", "$", "this", "->", "clipObj", "->", "current", "!==", "'normal'", ")", "{", "// The \"select\" link:", "$", "spriteIcon", "=", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-edit-copy'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ";", "$", "cells", "[", "'copyMarked'", "]", "=", "$", "this", "->", "linkClipboardHeaderIcon", "(", "$", "spriteIcon", ",", "$", "table", ",", "'setCB'", ",", "''", ",", "$", "lang", "->", "getLL", "(", "'clip_selectMarked'", ")", ")", ";", "// The \"edit marked\" link:", "$", "editUri", "=", "(", "string", ")", "$", "uriBuilder", "->", "buildUriFromRoute", "(", "'record_edit'", ")", ".", "'&edit['", ".", "$", "table", ".", "'][{entityIdentifiers:editList}]=edit'", ".", "'&returnUrl={T3_THIS_LOCATION}'", ";", "$", "cells", "[", "'edit'", "]", "=", "'<a class=\"btn btn-default t3js-record-edit-multiple\" href=\"#\"'", ".", "' data-uri=\"'", ".", "htmlspecialchars", "(", "$", "editUri", ")", ".", "'\"'", ".", "' title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'clip_editMarked'", ")", ")", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-open'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "// The \"Delete marked\" link:", "$", "cells", "[", "'delete'", "]", "=", "$", "this", "->", "linkClipboardHeaderIcon", "(", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-edit-delete'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ",", "$", "table", ",", "'delete'", ",", "sprintf", "(", "$", "lang", "->", "getLL", "(", "'clip_deleteMarkedWarning'", ")", ",", "$", "lang", "->", "sL", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "table", "]", "[", "'ctrl'", "]", "[", "'title'", "]", ")", ")", ",", "$", "lang", "->", "getLL", "(", "'clip_deleteMarked'", ")", ")", ";", "// The \"Select all\" link:", "$", "onClick", "=", "htmlspecialchars", "(", "(", "'checkOffCB('", ".", "GeneralUtility", "::", "quoteJSvalue", "(", "implode", "(", "','", ",", "$", "this", "->", "CBnames", ")", ")", ".", "', this); return false;'", ")", ")", ";", "$", "cells", "[", "'markAll'", "]", "=", "'<a class=\"btn btn-default\" rel=\"\" href=\"#\" onclick=\"'", ".", "$", "onClick", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'clip_markRecords'", ")", ")", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-select'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "else", "{", "$", "cells", "[", "'empty'", "]", "=", "''", ";", "}", "/*\n * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers\n * usage: Above each listed table in Web>List a header row is shown.\n * This hook allows to modify the icons responsible for the clipboard functions\n * (shown above the clipboard checkboxes when a clipboard other than \"Normal\" is selected),\n * or other \"Action\" functions which perform operations on the listed records.\n */", "foreach", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'SC_OPTIONS'", "]", "[", "'typo3/class.db_list_extra.inc'", "]", "[", "'actions'", "]", "??", "[", "]", "as", "$", "className", ")", "{", "$", "hookObject", "=", "GeneralUtility", "::", "makeInstance", "(", "$", "className", ")", ";", "if", "(", "!", "$", "hookObject", "instanceof", "RecordListHookInterface", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "$", "className", ".", "' must implement interface '", ".", "RecordListHookInterface", "::", "class", ",", "1195567850", ")", ";", "}", "$", "cells", "=", "$", "hookObject", "->", "renderListHeaderActions", "(", "$", "table", ",", "$", "currentIdList", ",", "$", "cells", ",", "$", "this", ")", ";", "}", "$", "theData", "[", "$", "fCol", "]", "=", "''", ";", "if", "(", "isset", "(", "$", "cells", "[", "'edit'", "]", ")", "&&", "isset", "(", "$", "cells", "[", "'delete'", "]", ")", ")", "{", "$", "theData", "[", "$", "fCol", "]", ".=", "'<div class=\"btn-group\" role=\"group\">'", ".", "$", "cells", "[", "'edit'", "]", ".", "$", "cells", "[", "'delete'", "]", ".", "'</div>'", ";", "unset", "(", "$", "cells", "[", "'edit'", "]", ",", "$", "cells", "[", "'delete'", "]", ")", ";", "}", "$", "theData", "[", "$", "fCol", "]", ".=", "'<div class=\"btn-group\" role=\"group\">'", ".", "implode", "(", "''", ",", "$", "cells", ")", ".", "'</div>'", ";", "break", ";", "case", "'_CONTROL_'", ":", "// Control panel:", "if", "(", "$", "this", "->", "isEditable", "(", "$", "table", ")", ")", "{", "// If new records can be created on this page, add links:", "$", "permsAdditional", "=", "$", "table", "===", "'pages'", "?", "8", ":", "16", ";", "if", "(", "$", "table", "===", "'tt_content'", ")", "{", "$", "expandTitle", "=", "$", "lang", "->", "sL", "(", "'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandAllElements'", ")", ";", "$", "collapseTitle", "=", "$", "lang", "->", "sL", "(", "'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseAllElements'", ")", ";", "$", "containerIds", "=", "implode", "(", "','", ",", "array_flip", "(", "array_flip", "(", "$", "this", "->", "currentContainerIdList", ")", ")", ")", ";", "$", "icon", "=", "'<a\n class=\"btn btn-default t3js-toggle-gridelements-all\" href=\"#t3-gridelements-collapse-all\" id=\"t3-gridelements-collapse-all\"\n title=\"'", ".", "$", "collapseTitle", ".", "'\" data-container-ids=\"'", ".", "$", "containerIds", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-view-list-collapse'", ",", "'small'", ")", "->", "render", "(", ")", ".", "'</a><a\n class=\"btn btn-default t3js-toggle-gridelements-all\" href=\"#t3-gridelements-expand-all\" id=\"t3-gridelements-expand-all\"\n title=\"'", ".", "$", "expandTitle", ".", "'\" data-container-ids=\"'", ".", "$", "containerIds", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-view-list-expand'", ",", "'small'", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "if", "(", "$", "this", "->", "calcPerms", "&", "$", "permsAdditional", "&&", "$", "this", "->", "showNewRecLink", "(", "$", "table", ")", ")", "{", "$", "spriteIcon", "=", "$", "table", "===", "'pages'", "?", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-page-new'", ",", "Icon", "::", "SIZE_SMALL", ")", ":", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-add'", ",", "Icon", "::", "SIZE_SMALL", ")", ";", "if", "(", "$", "table", "===", "'tt_content'", ")", "{", "// If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:", "$", "newContentElementWizard", "=", "BackendUtility", "::", "getPagesTSconfig", "(", "$", "this", "->", "pageinfo", "[", "'uid'", "]", ")", "[", "'mod.'", "]", "[", "'newContentElementWizard.'", "]", "[", "'override'", "]", "??", "'new_content_element_wizard'", ";", "$", "url", "=", "(", "string", ")", "$", "uriBuilder", "->", "buildUriFromRoute", "(", "$", "newContentElementWizard", ",", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'returnUrl'", "=>", "GeneralUtility", "::", "getIndpEnv", "(", "'REQUEST_URI'", ")", ",", "]", ")", ";", "$", "icon", "=", "'<a href=\"#\" data-url=\"'", ".", "htmlspecialchars", "(", "$", "url", ")", ".", "'\"'", ".", "' data-title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'new'", ")", ")", ".", "'\"'", ".", "' class=\"btn btn-default t3js-toggle-new-content-element-wizard\">'", ".", "$", "spriteIcon", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "elseif", "(", "$", "table", "===", "'pages'", ")", "{", "$", "parameters", "=", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'pagesOnly'", "=>", "1", ",", "'returnUrl'", "=>", "GeneralUtility", "::", "getIndpEnv", "(", "'REQUEST_URI'", ")", ",", "]", ";", "$", "href", "=", "(", "string", ")", "$", "uriBuilder", "->", "buildUriFromRoute", "(", "'db_new'", ",", "$", "parameters", ")", ";", "$", "icon", "=", "'<a class=\"btn btn-default\" href=\"'", ".", "htmlspecialchars", "(", "$", "href", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'new'", ")", ")", ".", "'\">'", ".", "$", "spriteIcon", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "else", "{", "$", "params", "=", "'&edit['", ".", "$", "table", ".", "']['", ".", "$", "this", "->", "id", ".", "']=new'", ";", "if", "(", "$", "table", "===", "'pages'", ")", "{", "$", "params", ".=", "'&overrideVals[pages][doktype]='", ".", "(", "int", ")", "$", "this", "->", "pageRow", "[", "'doktype'", "]", ";", "}", "$", "icon", "=", "'<a class=\"btn btn-default\" href=\"#\" onclick=\"'", ".", "htmlspecialchars", "(", "BackendUtility", "::", "editOnClick", "(", "$", "params", ",", "''", ",", "-", "1", ")", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'new'", ")", ")", ".", "'\">'", ".", "$", "spriteIcon", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "}", "// If the table can be edited, add link for editing ALL SHOWN fields for all listed records:", "if", "(", "$", "permsEdit", "&&", "$", "this", "->", "table", "&&", "is_array", "(", "$", "currentIdList", ")", ")", "{", "$", "entityIdentifiers", "=", "'entityIdentifiers'", ";", "if", "(", "$", "this", "->", "clipNumPane", "(", ")", ")", "{", "$", "entityIdentifiers", ".=", "':editList'", ";", "}", "$", "editUri", "=", "(", "string", ")", "$", "uriBuilder", "->", "buildUriFromRoute", "(", "'record_edit'", ")", ".", "'&edit['", ".", "$", "table", ".", "'][{'", ".", "$", "entityIdentifiers", ".", "'}]=edit'", ".", "'&columnsOnly='", ".", "implode", "(", "','", ",", "$", "this", "->", "fieldArray", ")", ".", "'&returnUrl={T3_THIS_LOCATION}'", ";", "$", "icon", ".=", "'<a class=\"btn btn-default t3js-record-edit-multiple\" href=\"#\"'", ".", "' data-uri=\"'", ".", "htmlspecialchars", "(", "$", "editUri", ")", ".", "'\"'", ".", "' title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'editShownColumns'", ")", ")", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-open'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "$", "icon", "=", "'<div class=\"btn-group\" role=\"group\">'", ".", "$", "icon", ".", "'</div>'", ";", "}", "// Add an empty entry, so column count fits again after moving this into $icon", "$", "theData", "[", "$", "fCol", "]", "=", "'&nbsp;'", ";", "}", "break", ";", "default", ":", "// Regular fields header:", "$", "theData", "[", "$", "fCol", "]", "=", "''", ";", "// Check if $fCol is really a field and get the label and remove the colons", "// at the end", "$", "sortLabel", "=", "BackendUtility", "::", "getItemLabel", "(", "$", "table", ",", "$", "fCol", ")", ";", "if", "(", "$", "sortLabel", "!==", "null", ")", "{", "$", "sortLabel", "=", "htmlspecialchars", "(", "$", "lang", "->", "sL", "(", "$", "sortLabel", ")", ")", ";", "$", "sortLabel", "=", "rtrim", "(", "trim", "(", "$", "sortLabel", ")", ",", "':'", ")", ";", "}", "else", "{", "// No TCA field, only output the $fCol variable with square brackets []", "$", "sortLabel", "=", "htmlspecialchars", "(", "$", "fCol", ")", ";", "$", "sortLabel", "=", "'<i>['", ".", "rtrim", "(", "trim", "(", "$", "sortLabel", ")", ",", "':'", ")", ".", "']</i>'", ";", "}", "if", "(", "$", "this", "->", "table", "&&", "is_array", "(", "$", "currentIdList", ")", ")", "{", "// If the numeric clipboard pads are selected, show duplicate sorting link:", "if", "(", "$", "this", "->", "clipNumPane", "(", ")", ")", "{", "$", "theData", "[", "$", "fCol", "]", ".=", "'<a class=\"btn btn-default\" href=\"'", ".", "htmlspecialchars", "(", "$", "this", "->", "listURL", "(", "''", ",", "'-1'", ")", ".", "'&duplicateField='", ".", "$", "fCol", ")", ".", "'\" title=\"'", ".", "htmlspecialchars", "(", "$", "lang", "->", "getLL", "(", "'clip_duplicates'", ")", ")", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-duplicates-select'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "// If the table can be edited, add link for editing THIS field for all", "// listed records:", "if", "(", "$", "this", "->", "isEditable", "(", "$", "table", ")", "&&", "$", "permsEdit", "&&", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "table", "]", "[", "'columns'", "]", "[", "$", "fCol", "]", ")", "{", "$", "entityIdentifiers", "=", "'entityIdentifiers'", ";", "if", "(", "$", "this", "->", "clipNumPane", "(", ")", ")", "{", "$", "entityIdentifiers", ".=", "':editList'", ";", "}", "$", "editUri", "=", "(", "string", ")", "$", "uriBuilder", "->", "buildUriFromRoute", "(", "'record_edit'", ")", ".", "'&edit['", ".", "$", "table", ".", "'][{'", ".", "$", "entityIdentifiers", ".", "'}]=edit'", ".", "'&columnsOnly='", ".", "$", "fCol", ".", "'&returnUrl={T3_THIS_LOCATION}'", ";", "$", "iTitle", "=", "sprintf", "(", "$", "lang", "->", "getLL", "(", "'editThisColumn'", ")", ",", "$", "sortLabel", ")", ";", "$", "theData", "[", "$", "fCol", "]", ".=", "'<a class=\"btn btn-default t3js-record-edit-multiple\" href=\"#\"'", ".", "' data-uri=\"'", ".", "htmlspecialchars", "(", "$", "editUri", ")", ".", "'\"'", ".", "' title=\"'", ".", "htmlspecialchars", "(", "$", "iTitle", ")", ".", "'\">'", ".", "$", "this", "->", "iconFactory", "->", "getIcon", "(", "'actions-document-open'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ";", "}", "if", "(", "strlen", "(", "$", "theData", "[", "$", "fCol", "]", ")", ">", "0", ")", "{", "$", "theData", "[", "$", "fCol", "]", "=", "'<div class=\"btn-group\" role=\"group\">'", ".", "$", "theData", "[", "$", "fCol", "]", ".", "'</div> '", ";", "}", "}", "$", "theData", "[", "$", "fCol", "]", ".=", "$", "this", "->", "addSortLink", "(", "$", "sortLabel", ",", "$", "fCol", ",", "$", "table", ")", ";", "}", "}", "$", "this", "->", "totalColumnCount", "=", "10", "+", "count", "(", "$", "theData", ")", ";", "$", "headerOutput", "=", "'<colgroup>'", ";", "for", "(", "$", "i", "=", "-", "10", ";", "$", "i", "<", "count", "(", "$", "theData", ")", ";", "$", "i", "++", ")", "{", "if", "(", "$", "i", "<", "-", "1", ")", "{", "$", "headerOutput", ".=", "'<col class=\"col-icon\" width=\"40\" />'", ";", "}", "else", "{", "$", "headerOutput", ".=", "'<col width=\"auto\" />'", ";", "}", "}", "$", "headerOutput", ".=", "'</colgroup>'", ";", "/**\n * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers\n * @usage Above each listed table in Web>List a header row is shown.\n * Containing the labels of all shown fields and additional icons to create new records for this\n * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.\n */", "foreach", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'SC_OPTIONS'", "]", "[", "'typo3/class.db_list_extra.inc'", "]", "[", "'actions'", "]", "??", "[", "]", "as", "$", "className", ")", "{", "$", "hookObject", "=", "GeneralUtility", "::", "makeInstance", "(", "$", "className", ")", ";", "if", "(", "!", "$", "hookObject", "instanceof", "RecordListHookInterface", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "$", "className", ".", "' must implement interface '", ".", "RecordListHookInterface", "::", "class", ",", "1195567855", ")", ";", "}", "$", "theData", "=", "$", "hookObject", "->", "renderListHeader", "(", "$", "table", ",", "$", "currentIdList", ",", "$", "theData", ",", "$", "this", ")", ";", "}", "// Create and return header table row:", "return", "$", "headerOutput", ".", "'<thead>'", ".", "$", "this", "->", "addElement", "(", "1", ",", "$", "icon", ",", "$", "theData", ",", "''", ",", "''", ",", "''", ",", "'th'", ")", ".", "'</thead>'", ";", "}" ]
Rendering the header row for a table @param string $table Table name @param int[] $currentIdList Array of the currently displayed uids of the table @throws \UnexpectedValueException @throws RouteNotFoundException @return string Header table row @see getTable()
[ "Rendering", "the", "header", "row", "for", "a", "table" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Xclass/DatabaseRecordList.php#L2527-L2816
TYPO3-extensions/gridelements
Classes/Hooks/TtContentFlexForm.php
TtContentFlexForm.getDataStructureIdentifierPreProcess
public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fieldName, array $row) { if ($tableName === 'tt_content' && $fieldName === 'pi_flexform' && $row['CType'] === 'gridelements_pi1') { if (!empty($row['tx_gridelements_backend_layout'])) { $pageUid = $row['pid']; $layoutId = $row['tx_gridelements_backend_layout']; /** @var $layoutSetupInstance LayoutSetup */ $layoutSetupInstance = GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid); $layoutSetup = $layoutSetupInstance->getLayoutSetup($layoutId); if ($layoutSetup['pi_flexform_ds_file']) { // Our data structure is in a record. Re-use core internal syntax to resolve that. $identifier = [ 'type' => 'record', 'tableName' => 'tx_gridelements_backend_layout', 'uid' => $layoutId, 'fieldName' => 'pi_flexform_ds_file', 'flexformDS' => 'FILE:' . $layoutSetup['pi_flexform_ds_file'], ]; } elseif ($layoutSetup['pi_flexform_ds']) { $identifier = [ 'type' => 'record', 'tableName' => 'tx_gridelements_backend_layout', 'uid' => $layoutId, 'fieldName' => 'pi_flexform_ds', 'flexformDS' => $layoutSetup['pi_flexform_ds'], ]; } else { // This could be an additional core patch that allows referencing a DS file directly. // If so, the second hook below would be obsolete. $identifier = [ 'type' => 'gridelements-dummy', ]; } } else { $identifier = [ 'type' => 'gridelements-dummy', ]; } } else { // Not my business $identifier = []; } return $identifier; }
php
public function getDataStructureIdentifierPreProcess(array $tca, $tableName, $fieldName, array $row) { if ($tableName === 'tt_content' && $fieldName === 'pi_flexform' && $row['CType'] === 'gridelements_pi1') { if (!empty($row['tx_gridelements_backend_layout'])) { $pageUid = $row['pid']; $layoutId = $row['tx_gridelements_backend_layout']; /** @var $layoutSetupInstance LayoutSetup */ $layoutSetupInstance = GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid); $layoutSetup = $layoutSetupInstance->getLayoutSetup($layoutId); if ($layoutSetup['pi_flexform_ds_file']) { // Our data structure is in a record. Re-use core internal syntax to resolve that. $identifier = [ 'type' => 'record', 'tableName' => 'tx_gridelements_backend_layout', 'uid' => $layoutId, 'fieldName' => 'pi_flexform_ds_file', 'flexformDS' => 'FILE:' . $layoutSetup['pi_flexform_ds_file'], ]; } elseif ($layoutSetup['pi_flexform_ds']) { $identifier = [ 'type' => 'record', 'tableName' => 'tx_gridelements_backend_layout', 'uid' => $layoutId, 'fieldName' => 'pi_flexform_ds', 'flexformDS' => $layoutSetup['pi_flexform_ds'], ]; } else { // This could be an additional core patch that allows referencing a DS file directly. // If so, the second hook below would be obsolete. $identifier = [ 'type' => 'gridelements-dummy', ]; } } else { $identifier = [ 'type' => 'gridelements-dummy', ]; } } else { // Not my business $identifier = []; } return $identifier; }
[ "public", "function", "getDataStructureIdentifierPreProcess", "(", "array", "$", "tca", ",", "$", "tableName", ",", "$", "fieldName", ",", "array", "$", "row", ")", "{", "if", "(", "$", "tableName", "===", "'tt_content'", "&&", "$", "fieldName", "===", "'pi_flexform'", "&&", "$", "row", "[", "'CType'", "]", "===", "'gridelements_pi1'", ")", "{", "if", "(", "!", "empty", "(", "$", "row", "[", "'tx_gridelements_backend_layout'", "]", ")", ")", "{", "$", "pageUid", "=", "$", "row", "[", "'pid'", "]", ";", "$", "layoutId", "=", "$", "row", "[", "'tx_gridelements_backend_layout'", "]", ";", "/** @var $layoutSetupInstance LayoutSetup */", "$", "layoutSetupInstance", "=", "GeneralUtility", "::", "makeInstance", "(", "LayoutSetup", "::", "class", ")", "->", "init", "(", "$", "pageUid", ")", ";", "$", "layoutSetup", "=", "$", "layoutSetupInstance", "->", "getLayoutSetup", "(", "$", "layoutId", ")", ";", "if", "(", "$", "layoutSetup", "[", "'pi_flexform_ds_file'", "]", ")", "{", "// Our data structure is in a record. Re-use core internal syntax to resolve that.", "$", "identifier", "=", "[", "'type'", "=>", "'record'", ",", "'tableName'", "=>", "'tx_gridelements_backend_layout'", ",", "'uid'", "=>", "$", "layoutId", ",", "'fieldName'", "=>", "'pi_flexform_ds_file'", ",", "'flexformDS'", "=>", "'FILE:'", ".", "$", "layoutSetup", "[", "'pi_flexform_ds_file'", "]", ",", "]", ";", "}", "elseif", "(", "$", "layoutSetup", "[", "'pi_flexform_ds'", "]", ")", "{", "$", "identifier", "=", "[", "'type'", "=>", "'record'", ",", "'tableName'", "=>", "'tx_gridelements_backend_layout'", ",", "'uid'", "=>", "$", "layoutId", ",", "'fieldName'", "=>", "'pi_flexform_ds'", ",", "'flexformDS'", "=>", "$", "layoutSetup", "[", "'pi_flexform_ds'", "]", ",", "]", ";", "}", "else", "{", "// This could be an additional core patch that allows referencing a DS file directly.", "// If so, the second hook below would be obsolete.", "$", "identifier", "=", "[", "'type'", "=>", "'gridelements-dummy'", ",", "]", ";", "}", "}", "else", "{", "$", "identifier", "=", "[", "'type'", "=>", "'gridelements-dummy'", ",", "]", ";", "}", "}", "else", "{", "// Not my business", "$", "identifier", "=", "[", "]", ";", "}", "return", "$", "identifier", ";", "}" ]
Method to find flex form configuration of a tt_content gridelements content element. @param array $tca @param $tableName @param $fieldName @param array $row @return array
[ "Method", "to", "find", "flex", "form", "configuration", "of", "a", "tt_content", "gridelements", "content", "element", "." ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/TtContentFlexForm.php#L45-L88
TYPO3-extensions/gridelements
Classes/DataHandler/AbstractDataHandler.php
AbstractDataHandler.init
public function init($table, $uidPid, DataHandler $dataHandler) { $this->setTable($table); if ($table === 'tt_content' && (int)$uidPid < 0) { $this->setContentUid(abs($uidPid)); $pageUid = Helper::getInstance()->getPidFromUid($this->getContentUid()); $this->setPageUid($pageUid); } else { $this->setPageUid((int)$uidPid); } $this->setTceMain($dataHandler); if (!$this->layoutSetup instanceof LayoutSetup) { $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($this->getPageUid())); } }
php
public function init($table, $uidPid, DataHandler $dataHandler) { $this->setTable($table); if ($table === 'tt_content' && (int)$uidPid < 0) { $this->setContentUid(abs($uidPid)); $pageUid = Helper::getInstance()->getPidFromUid($this->getContentUid()); $this->setPageUid($pageUid); } else { $this->setPageUid((int)$uidPid); } $this->setTceMain($dataHandler); if (!$this->layoutSetup instanceof LayoutSetup) { $this->injectLayoutSetup(GeneralUtility::makeInstance(LayoutSetup::class)->init($this->getPageUid())); } }
[ "public", "function", "init", "(", "$", "table", ",", "$", "uidPid", ",", "DataHandler", "$", "dataHandler", ")", "{", "$", "this", "->", "setTable", "(", "$", "table", ")", ";", "if", "(", "$", "table", "===", "'tt_content'", "&&", "(", "int", ")", "$", "uidPid", "<", "0", ")", "{", "$", "this", "->", "setContentUid", "(", "abs", "(", "$", "uidPid", ")", ")", ";", "$", "pageUid", "=", "Helper", "::", "getInstance", "(", ")", "->", "getPidFromUid", "(", "$", "this", "->", "getContentUid", "(", ")", ")", ";", "$", "this", "->", "setPageUid", "(", "$", "pageUid", ")", ";", "}", "else", "{", "$", "this", "->", "setPageUid", "(", "(", "int", ")", "$", "uidPid", ")", ";", "}", "$", "this", "->", "setTceMain", "(", "$", "dataHandler", ")", ";", "if", "(", "!", "$", "this", "->", "layoutSetup", "instanceof", "LayoutSetup", ")", "{", "$", "this", "->", "injectLayoutSetup", "(", "GeneralUtility", "::", "makeInstance", "(", "LayoutSetup", "::", "class", ")", "->", "init", "(", "$", "this", "->", "getPageUid", "(", ")", ")", ")", ";", "}", "}" ]
initializes this class @param string $table : The name of the table the data should be saved to @param int $uidPid : The uid of the record or page we are currently working on @param DataHandler $dataHandler
[ "initializes", "this", "class" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AbstractDataHandler.php#L78-L92
TYPO3-extensions/gridelements
Classes/DataHandler/AbstractDataHandler.php
AbstractDataHandler.cleanupWorkspacesAfterFinalizing
public function cleanupWorkspacesAfterFinalizing() { $queryBuilder = $this->getQueryBuilder(); $constraints = [ $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT) ), $queryBuilder->expr()->eq( 't3ver_wsid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ), $queryBuilder->expr()->gt( 't3ver_id', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ) ), ]; $queryBuilder->delete('tt_content') ->where(...$constraints) ->execute(); }
php
public function cleanupWorkspacesAfterFinalizing() { $queryBuilder = $this->getQueryBuilder(); $constraints = [ $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter(-1, \PDO::PARAM_INT) ), $queryBuilder->expr()->eq( 't3ver_wsid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ), $queryBuilder->expr()->gt( 't3ver_id', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ) ), ]; $queryBuilder->delete('tt_content') ->where(...$constraints) ->execute(); }
[ "public", "function", "cleanupWorkspacesAfterFinalizing", "(", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "constraints", "=", "[", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "-", "1", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'t3ver_wsid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "0", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "gt", "(", "'t3ver_id'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "0", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", ",", "]", ";", "$", "queryBuilder", "->", "delete", "(", "'tt_content'", ")", "->", "where", "(", "...", "$", "constraints", ")", "->", "execute", "(", ")", ";", "}" ]
Function to remove any remains of versioned records after finalizing a workspace action via 'Discard' or 'Publish' commands
[ "Function", "to", "remove", "any", "remains", "of", "versioned", "records", "after", "finalizing", "a", "workspace", "action", "via", "Discard", "or", "Publish", "commands" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AbstractDataHandler.php#L158-L182
TYPO3-extensions/gridelements
Classes/DataHandler/AbstractDataHandler.php
AbstractDataHandler.getQueryBuilder
public function getQueryBuilder($table = 'tt_content') { /**@var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($table); $queryBuilder->getRestrictions() ->removeByType(HiddenRestriction::class) ->removeByType(StartTimeRestriction::class) ->removeByType(EndTimeRestriction::class); return $queryBuilder; }
php
public function getQueryBuilder($table = 'tt_content') { /**@var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($table); $queryBuilder->getRestrictions() ->removeByType(HiddenRestriction::class) ->removeByType(StartTimeRestriction::class) ->removeByType(EndTimeRestriction::class); return $queryBuilder; }
[ "public", "function", "getQueryBuilder", "(", "$", "table", "=", "'tt_content'", ")", "{", "/**@var $queryBuilder QueryBuilder */", "$", "queryBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getQueryBuilderForTable", "(", "$", "table", ")", ";", "$", "queryBuilder", "->", "getRestrictions", "(", ")", "->", "removeByType", "(", "HiddenRestriction", "::", "class", ")", "->", "removeByType", "(", "StartTimeRestriction", "::", "class", ")", "->", "removeByType", "(", "EndTimeRestriction", "::", "class", ")", ";", "return", "$", "queryBuilder", ";", "}" ]
getter for queryBuilder @param string $table @return QueryBuilder $queryBuilder
[ "getter", "for", "queryBuilder" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AbstractDataHandler.php#L190-L201
TYPO3-extensions/gridelements
Classes/DataHandler/AbstractDataHandler.php
AbstractDataHandler.checkAndUpdateTranslatedElements
public function checkAndUpdateTranslatedElements($uid) { if ($uid <= 0) { return; } $queryBuilder = $this->getQueryBuilder(); $currentValues = $queryBuilder ->select( 'uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', 'l18n_parent' ) ->from('tt_content') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)) ) ->setMaxResults(1) ->execute() ->fetch(); if (!empty($currentValues['l18n_parent'])) { $originalUid = (int)$currentValues['uid']; $queryBuilder = $this->getQueryBuilder(); $currentValues = $queryBuilder ->select( 'uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', 'l18n_parent' ) ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'uid', $queryBuilder->createNamedParameter((int)$currentValues['l18n_parent'], \PDO::PARAM_INT) ) ) ->setMaxResults(1) ->execute() ->fetch(); $updateArray = $currentValues; unset($updateArray['uid']); unset($updateArray['sys_language_uid']); unset($updateArray['l18n_parent']); $this->getConnection()->update( 'tt_content', $updateArray, ['uid' => (int)$originalUid] ); } if (empty($currentValues['uid'])) { return; } $queryBuilder = $this->getQueryBuilder(); $translatedElementQuery = $queryBuilder ->select( 'uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', 'l18n_parent' ) ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'l18n_parent', $queryBuilder->createNamedParameter((int)$currentValues['uid'], \PDO::PARAM_INT) ) ) ->execute(); $translatedElements = []; while ($translatedElement = $translatedElementQuery->fetch()) { $translatedElements[$translatedElement['uid']] = $translatedElement; } if (empty($translatedElements)) { return; } $translatedContainers = []; if ($currentValues['tx_gridelements_container'] > 0) { $queryBuilder = $this->getQueryBuilder(); $translatedContainerQuery = $queryBuilder ->select('uid', 'sys_language_uid') ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'l18n_parent', $queryBuilder->createNamedParameter( (int)$currentValues['tx_gridelements_container'], \PDO::PARAM_INT ) ) ) ->execute(); while ($translatedContainer = $translatedContainerQuery->fetch()) { $translatedContainers[$translatedContainer['sys_language_uid']] = $translatedContainer; } } $containerUpdateArray = []; foreach ($translatedElements as $translatedUid => $translatedElement) { $updateArray = []; if (isset($translatedContainers[$translatedElement['sys_language_uid']])) { $updateArray['tx_gridelements_container'] = (int)$translatedContainers[$translatedElement['sys_language_uid']]['uid']; $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; } else { if ($translatedElement['tx_gridelements_container'] == $currentValues['tx_gridelements_container']) { $updateArray['tx_gridelements_container'] = (int)$currentValues['tx_gridelements_container']; $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; } else { $updateArray['tx_gridelements_container'] = 0; $updateArray['tx_gridelements_columns'] = 0; } } $updateArray['colPos'] = (int)$currentValues['colPos']; $this->getConnection()->update( 'tt_content', $updateArray, ['uid' => (int)$translatedUid] ); if (isset($updateArray['tx_gridelements_container']) && $translatedElement['tx_gridelements_container'] !== $updateArray['tx_gridelements_container']) { $containerUpdateArray[$translatedElement['tx_gridelements_container']] -= 1; $containerUpdateArray[$updateArray['tx_gridelements_container']] += 1; $this->getTceMain()->updateRefIndex('tt_content', (int)$translatedElement['tx_gridelements_container']); $this->getTceMain()->updateRefIndex('tt_content', (int)$updateArray['tx_gridelements_container']); } } if (!empty($containerUpdateArray)) { $this->doGridContainerUpdate($containerUpdateArray); } }
php
public function checkAndUpdateTranslatedElements($uid) { if ($uid <= 0) { return; } $queryBuilder = $this->getQueryBuilder(); $currentValues = $queryBuilder ->select( 'uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', 'l18n_parent' ) ->from('tt_content') ->where( $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter((int)$uid, \PDO::PARAM_INT)) ) ->setMaxResults(1) ->execute() ->fetch(); if (!empty($currentValues['l18n_parent'])) { $originalUid = (int)$currentValues['uid']; $queryBuilder = $this->getQueryBuilder(); $currentValues = $queryBuilder ->select( 'uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', 'l18n_parent' ) ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'uid', $queryBuilder->createNamedParameter((int)$currentValues['l18n_parent'], \PDO::PARAM_INT) ) ) ->setMaxResults(1) ->execute() ->fetch(); $updateArray = $currentValues; unset($updateArray['uid']); unset($updateArray['sys_language_uid']); unset($updateArray['l18n_parent']); $this->getConnection()->update( 'tt_content', $updateArray, ['uid' => (int)$originalUid] ); } if (empty($currentValues['uid'])) { return; } $queryBuilder = $this->getQueryBuilder(); $translatedElementQuery = $queryBuilder ->select( 'uid', 'tx_gridelements_container', 'tx_gridelements_columns', 'sys_language_uid', 'colPos', 'l18n_parent' ) ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'l18n_parent', $queryBuilder->createNamedParameter((int)$currentValues['uid'], \PDO::PARAM_INT) ) ) ->execute(); $translatedElements = []; while ($translatedElement = $translatedElementQuery->fetch()) { $translatedElements[$translatedElement['uid']] = $translatedElement; } if (empty($translatedElements)) { return; } $translatedContainers = []; if ($currentValues['tx_gridelements_container'] > 0) { $queryBuilder = $this->getQueryBuilder(); $translatedContainerQuery = $queryBuilder ->select('uid', 'sys_language_uid') ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'l18n_parent', $queryBuilder->createNamedParameter( (int)$currentValues['tx_gridelements_container'], \PDO::PARAM_INT ) ) ) ->execute(); while ($translatedContainer = $translatedContainerQuery->fetch()) { $translatedContainers[$translatedContainer['sys_language_uid']] = $translatedContainer; } } $containerUpdateArray = []; foreach ($translatedElements as $translatedUid => $translatedElement) { $updateArray = []; if (isset($translatedContainers[$translatedElement['sys_language_uid']])) { $updateArray['tx_gridelements_container'] = (int)$translatedContainers[$translatedElement['sys_language_uid']]['uid']; $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; } else { if ($translatedElement['tx_gridelements_container'] == $currentValues['tx_gridelements_container']) { $updateArray['tx_gridelements_container'] = (int)$currentValues['tx_gridelements_container']; $updateArray['tx_gridelements_columns'] = (int)$currentValues['tx_gridelements_columns']; } else { $updateArray['tx_gridelements_container'] = 0; $updateArray['tx_gridelements_columns'] = 0; } } $updateArray['colPos'] = (int)$currentValues['colPos']; $this->getConnection()->update( 'tt_content', $updateArray, ['uid' => (int)$translatedUid] ); if (isset($updateArray['tx_gridelements_container']) && $translatedElement['tx_gridelements_container'] !== $updateArray['tx_gridelements_container']) { $containerUpdateArray[$translatedElement['tx_gridelements_container']] -= 1; $containerUpdateArray[$updateArray['tx_gridelements_container']] += 1; $this->getTceMain()->updateRefIndex('tt_content', (int)$translatedElement['tx_gridelements_container']); $this->getTceMain()->updateRefIndex('tt_content', (int)$updateArray['tx_gridelements_container']); } } if (!empty($containerUpdateArray)) { $this->doGridContainerUpdate($containerUpdateArray); } }
[ "public", "function", "checkAndUpdateTranslatedElements", "(", "$", "uid", ")", "{", "if", "(", "$", "uid", "<=", "0", ")", "{", "return", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "currentValues", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ",", "'tx_gridelements_container'", ",", "'tx_gridelements_columns'", ",", "'sys_language_uid'", ",", "'colPos'", ",", "'l18n_parent'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "uid", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "setMaxResults", "(", "1", ")", "->", "execute", "(", ")", "->", "fetch", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "currentValues", "[", "'l18n_parent'", "]", ")", ")", "{", "$", "originalUid", "=", "(", "int", ")", "$", "currentValues", "[", "'uid'", "]", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "currentValues", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ",", "'tx_gridelements_container'", ",", "'tx_gridelements_columns'", ",", "'sys_language_uid'", ",", "'colPos'", ",", "'l18n_parent'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "currentValues", "[", "'l18n_parent'", "]", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "setMaxResults", "(", "1", ")", "->", "execute", "(", ")", "->", "fetch", "(", ")", ";", "$", "updateArray", "=", "$", "currentValues", ";", "unset", "(", "$", "updateArray", "[", "'uid'", "]", ")", ";", "unset", "(", "$", "updateArray", "[", "'sys_language_uid'", "]", ")", ";", "unset", "(", "$", "updateArray", "[", "'l18n_parent'", "]", ")", ";", "$", "this", "->", "getConnection", "(", ")", "->", "update", "(", "'tt_content'", ",", "$", "updateArray", ",", "[", "'uid'", "=>", "(", "int", ")", "$", "originalUid", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "currentValues", "[", "'uid'", "]", ")", ")", "{", "return", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "translatedElementQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ",", "'tx_gridelements_container'", ",", "'tx_gridelements_columns'", ",", "'sys_language_uid'", ",", "'colPos'", ",", "'l18n_parent'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'l18n_parent'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "currentValues", "[", "'uid'", "]", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "translatedElements", "=", "[", "]", ";", "while", "(", "$", "translatedElement", "=", "$", "translatedElementQuery", "->", "fetch", "(", ")", ")", "{", "$", "translatedElements", "[", "$", "translatedElement", "[", "'uid'", "]", "]", "=", "$", "translatedElement", ";", "}", "if", "(", "empty", "(", "$", "translatedElements", ")", ")", "{", "return", ";", "}", "$", "translatedContainers", "=", "[", "]", ";", "if", "(", "$", "currentValues", "[", "'tx_gridelements_container'", "]", ">", "0", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "translatedContainerQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ",", "'sys_language_uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'l18n_parent'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "currentValues", "[", "'tx_gridelements_container'", "]", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "execute", "(", ")", ";", "while", "(", "$", "translatedContainer", "=", "$", "translatedContainerQuery", "->", "fetch", "(", ")", ")", "{", "$", "translatedContainers", "[", "$", "translatedContainer", "[", "'sys_language_uid'", "]", "]", "=", "$", "translatedContainer", ";", "}", "}", "$", "containerUpdateArray", "=", "[", "]", ";", "foreach", "(", "$", "translatedElements", "as", "$", "translatedUid", "=>", "$", "translatedElement", ")", "{", "$", "updateArray", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "translatedContainers", "[", "$", "translatedElement", "[", "'sys_language_uid'", "]", "]", ")", ")", "{", "$", "updateArray", "[", "'tx_gridelements_container'", "]", "=", "(", "int", ")", "$", "translatedContainers", "[", "$", "translatedElement", "[", "'sys_language_uid'", "]", "]", "[", "'uid'", "]", ";", "$", "updateArray", "[", "'tx_gridelements_columns'", "]", "=", "(", "int", ")", "$", "currentValues", "[", "'tx_gridelements_columns'", "]", ";", "}", "else", "{", "if", "(", "$", "translatedElement", "[", "'tx_gridelements_container'", "]", "==", "$", "currentValues", "[", "'tx_gridelements_container'", "]", ")", "{", "$", "updateArray", "[", "'tx_gridelements_container'", "]", "=", "(", "int", ")", "$", "currentValues", "[", "'tx_gridelements_container'", "]", ";", "$", "updateArray", "[", "'tx_gridelements_columns'", "]", "=", "(", "int", ")", "$", "currentValues", "[", "'tx_gridelements_columns'", "]", ";", "}", "else", "{", "$", "updateArray", "[", "'tx_gridelements_container'", "]", "=", "0", ";", "$", "updateArray", "[", "'tx_gridelements_columns'", "]", "=", "0", ";", "}", "}", "$", "updateArray", "[", "'colPos'", "]", "=", "(", "int", ")", "$", "currentValues", "[", "'colPos'", "]", ";", "$", "this", "->", "getConnection", "(", ")", "->", "update", "(", "'tt_content'", ",", "$", "updateArray", ",", "[", "'uid'", "=>", "(", "int", ")", "$", "translatedUid", "]", ")", ";", "if", "(", "isset", "(", "$", "updateArray", "[", "'tx_gridelements_container'", "]", ")", "&&", "$", "translatedElement", "[", "'tx_gridelements_container'", "]", "!==", "$", "updateArray", "[", "'tx_gridelements_container'", "]", ")", "{", "$", "containerUpdateArray", "[", "$", "translatedElement", "[", "'tx_gridelements_container'", "]", "]", "-=", "1", ";", "$", "containerUpdateArray", "[", "$", "updateArray", "[", "'tx_gridelements_container'", "]", "]", "+=", "1", ";", "$", "this", "->", "getTceMain", "(", ")", "->", "updateRefIndex", "(", "'tt_content'", ",", "(", "int", ")", "$", "translatedElement", "[", "'tx_gridelements_container'", "]", ")", ";", "$", "this", "->", "getTceMain", "(", ")", "->", "updateRefIndex", "(", "'tt_content'", ",", "(", "int", ")", "$", "updateArray", "[", "'tx_gridelements_container'", "]", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "containerUpdateArray", ")", ")", "{", "$", "this", "->", "doGridContainerUpdate", "(", "$", "containerUpdateArray", ")", ";", "}", "}" ]
Function to handle record actions for current or former children of translated grid containers as well as translated references @param int $uid
[ "Function", "to", "handle", "record", "actions", "for", "current", "or", "former", "children", "of", "translated", "grid", "containers", "as", "well", "as", "translated", "references" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AbstractDataHandler.php#L209-L346
TYPO3-extensions/gridelements
Classes/DataHandler/AbstractDataHandler.php
AbstractDataHandler.doGridContainerUpdate
public function doGridContainerUpdate($containerUpdateArray = []) { if (is_array($containerUpdateArray) && !empty($containerUpdateArray)) { $queryBuilder = $this->getQueryBuilder(); $currentContainers = $queryBuilder ->select('uid', 'tx_gridelements_children') ->from('tt_content') ->where( $queryBuilder->expr()->in('uid', implode(',', array_keys($containerUpdateArray))) ) ->execute() ->fetchAll(); if (!empty($currentContainers)) { foreach ($currentContainers as $fieldArray) { $fieldArray['tx_gridelements_children'] = (int)$fieldArray['tx_gridelements_children'] + (int)$containerUpdateArray[$fieldArray['uid']]; $this->getConnection()->update( 'tt_content', $fieldArray, ['uid' => (int)$fieldArray['uid']] ); $this->getTceMain()->updateRefIndex('tt_content', (int)$fieldArray['uid']); } } } }
php
public function doGridContainerUpdate($containerUpdateArray = []) { if (is_array($containerUpdateArray) && !empty($containerUpdateArray)) { $queryBuilder = $this->getQueryBuilder(); $currentContainers = $queryBuilder ->select('uid', 'tx_gridelements_children') ->from('tt_content') ->where( $queryBuilder->expr()->in('uid', implode(',', array_keys($containerUpdateArray))) ) ->execute() ->fetchAll(); if (!empty($currentContainers)) { foreach ($currentContainers as $fieldArray) { $fieldArray['tx_gridelements_children'] = (int)$fieldArray['tx_gridelements_children'] + (int)$containerUpdateArray[$fieldArray['uid']]; $this->getConnection()->update( 'tt_content', $fieldArray, ['uid' => (int)$fieldArray['uid']] ); $this->getTceMain()->updateRefIndex('tt_content', (int)$fieldArray['uid']); } } } }
[ "public", "function", "doGridContainerUpdate", "(", "$", "containerUpdateArray", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "containerUpdateArray", ")", "&&", "!", "empty", "(", "$", "containerUpdateArray", ")", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "currentContainers", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ",", "'tx_gridelements_children'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "implode", "(", "','", ",", "array_keys", "(", "$", "containerUpdateArray", ")", ")", ")", ")", "->", "execute", "(", ")", "->", "fetchAll", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "currentContainers", ")", ")", "{", "foreach", "(", "$", "currentContainers", "as", "$", "fieldArray", ")", "{", "$", "fieldArray", "[", "'tx_gridelements_children'", "]", "=", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_children'", "]", "+", "(", "int", ")", "$", "containerUpdateArray", "[", "$", "fieldArray", "[", "'uid'", "]", "]", ";", "$", "this", "->", "getConnection", "(", ")", "->", "update", "(", "'tt_content'", ",", "$", "fieldArray", ",", "[", "'uid'", "=>", "(", "int", ")", "$", "fieldArray", "[", "'uid'", "]", "]", ")", ";", "$", "this", "->", "getTceMain", "(", ")", "->", "updateRefIndex", "(", "'tt_content'", ",", "(", "int", ")", "$", "fieldArray", "[", "'uid'", "]", ")", ";", "}", "}", "}", "}" ]
Function to handle record actions between different grid containers @param array $containerUpdateArray
[ "Function", "to", "handle", "record", "actions", "between", "different", "grid", "containers" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AbstractDataHandler.php#L374-L398
TYPO3-extensions/gridelements
Classes/Hooks/PageRenderer.php
PageRenderer.addJSCSS
public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer) { if (!empty($GLOBALS['SOBE']) && (get_class($GLOBALS['SOBE']) === RecordListController::class || is_subclass_of( $GLOBALS['SOBE'], RecordListController::class ))) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady'); return; } if (!empty($GLOBALS['SOBE']) && (get_class($GLOBALS['SOBE']) === PageLayoutController::class || is_subclass_of( $GLOBALS['SOBE'], PageLayoutController::class ))) { $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragDrop'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragInWizard'); /** @var Clipboard $clipObj */ $clipObj = GeneralUtility::makeInstance(Clipboard::class); // Start clipboard $clipObj->initializeClipboard(); $clipObj->lockToNormal(); $clipBoard = $clipObj->clipData['normal']; if (!$pageRenderer->getCharSet()) { $pageRenderer->setCharSet('utf-8'); } // pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys $pageRenderer->addInlineLanguageLabelFile( 'EXT:gridelements/Resources/Private/Language/locallang_db.xml', 'tx_gridelements_js' ); $pAddExtOnReadyCode = ' TYPO3.l10n = { localize: function(langKey){ return TYPO3.lang[langKey]; } } '; $id = (int)GeneralUtility::_GP('id'); $layout = GeneralUtility::callUserFunction( BackendLayoutView::class . '->getSelectedBackendLayout', $id, $this ); if (is_array($layout) && !empty($layout['__config']['backend_layout.']['rows.'])) { /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init(0); $layout = ['config' => $layout['__config']['backend_layout.']]; $columns = $layoutSetup->checkAvailableColumns($layout, true); if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) { $layout['columns'] = $columns; unset($layout['columns']['allowed']); $layout['allowed'] = $columns['allowed'] ?: []; $layout['disallowed'] = $columns['disallowed'] ?: []; $layout['maxitems'] = $columns['maxitems'] ?: []; } } // add Ext.onReady() code from file $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $pAddExtOnReadyCode .= ' top.pageColumnsAllowed = ' . json_encode($layout['allowed']) . '; top.pageColumnsDisallowed = ' . json_encode($layout['disallowed']) . '; top.pageColumnsMaxitems = ' . json_encode($layout['maxitems']) . '; top.pasteReferenceAllowed = ' . ($this->getBackendUser()->checkAuthMode( 'tt_content', 'CType', 'shortcut', $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] ) ? 'true' : 'false') . '; top.skipDraggableDetails = ' . ($this->getBackendUser()->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'true' : 'false') . "; top.backPath = '" . $GLOBALS['BACK_PATH'] . "'; top.browserUrl = '" . htmlspecialchars($uriBuilder->buildUriFromRoute('wizard_element_browser')) . "';"; if (!empty($clipBoard) && !empty($clipBoard['el'])) { $clipBoardElement = GeneralUtility::trimExplode('|', key($clipBoard['el'])); if ($clipBoardElement[0] === 'tt_content') { $clipBoardElementData = BackendUtility::getRecord('tt_content', (int)$clipBoardElement[1]); $pAddExtOnReadyCode .= " top.clipBoardElementCType = '" . $clipBoardElementData['CType'] . "'; top.clipBoardElementTxGridelementsBackendLayout = '" . (($clipBoardElementData['CType'] == 'gridelements_pi1') ? $clipBoardElementData['tx_gridelements_backend_layout'] : '') . "'; top.clipBoardElementListType = '" . $clipBoardElementData['list_type'] . "';"; } else { $pAddExtOnReadyCode .= " top.clipBoardElementCType = ''; top.clipBoardElementTxGridelementsBackendLayout = ''; top.clipBoardElementListType = '';"; } } $pAddExtOnReadyCode .= ' top.copyFromAnotherPageLinkTemplate = ' . json_encode('<a class="t3js-paste-new btn btn-default" title="' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_js.copyfrompage') . '">' . $iconFactory->getIcon( 'actions-insert-reference', Icon::SIZE_SMALL )->render() . '</a>') . ';'; $pageRenderer->addJsInlineCode('gridelementsExtOnReady', $pAddExtOnReadyCode); } }
php
public function addJSCSS(array $parameters, \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer) { if (!empty($GLOBALS['SOBE']) && (get_class($GLOBALS['SOBE']) === RecordListController::class || is_subclass_of( $GLOBALS['SOBE'], RecordListController::class ))) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady'); return; } if (!empty($GLOBALS['SOBE']) && (get_class($GLOBALS['SOBE']) === PageLayoutController::class || is_subclass_of( $GLOBALS['SOBE'], PageLayoutController::class ))) { $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsOnReady'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragDrop'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Gridelements/GridElementsDragInWizard'); /** @var Clipboard $clipObj */ $clipObj = GeneralUtility::makeInstance(Clipboard::class); // Start clipboard $clipObj->initializeClipboard(); $clipObj->lockToNormal(); $clipBoard = $clipObj->clipData['normal']; if (!$pageRenderer->getCharSet()) { $pageRenderer->setCharSet('utf-8'); } // pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys $pageRenderer->addInlineLanguageLabelFile( 'EXT:gridelements/Resources/Private/Language/locallang_db.xml', 'tx_gridelements_js' ); $pAddExtOnReadyCode = ' TYPO3.l10n = { localize: function(langKey){ return TYPO3.lang[langKey]; } } '; $id = (int)GeneralUtility::_GP('id'); $layout = GeneralUtility::callUserFunction( BackendLayoutView::class . '->getSelectedBackendLayout', $id, $this ); if (is_array($layout) && !empty($layout['__config']['backend_layout.']['rows.'])) { /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init(0); $layout = ['config' => $layout['__config']['backend_layout.']]; $columns = $layoutSetup->checkAvailableColumns($layout, true); if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) { $layout['columns'] = $columns; unset($layout['columns']['allowed']); $layout['allowed'] = $columns['allowed'] ?: []; $layout['disallowed'] = $columns['disallowed'] ?: []; $layout['maxitems'] = $columns['maxitems'] ?: []; } } // add Ext.onReady() code from file $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $pAddExtOnReadyCode .= ' top.pageColumnsAllowed = ' . json_encode($layout['allowed']) . '; top.pageColumnsDisallowed = ' . json_encode($layout['disallowed']) . '; top.pageColumnsMaxitems = ' . json_encode($layout['maxitems']) . '; top.pasteReferenceAllowed = ' . ($this->getBackendUser()->checkAuthMode( 'tt_content', 'CType', 'shortcut', $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] ) ? 'true' : 'false') . '; top.skipDraggableDetails = ' . ($this->getBackendUser()->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'true' : 'false') . "; top.backPath = '" . $GLOBALS['BACK_PATH'] . "'; top.browserUrl = '" . htmlspecialchars($uriBuilder->buildUriFromRoute('wizard_element_browser')) . "';"; if (!empty($clipBoard) && !empty($clipBoard['el'])) { $clipBoardElement = GeneralUtility::trimExplode('|', key($clipBoard['el'])); if ($clipBoardElement[0] === 'tt_content') { $clipBoardElementData = BackendUtility::getRecord('tt_content', (int)$clipBoardElement[1]); $pAddExtOnReadyCode .= " top.clipBoardElementCType = '" . $clipBoardElementData['CType'] . "'; top.clipBoardElementTxGridelementsBackendLayout = '" . (($clipBoardElementData['CType'] == 'gridelements_pi1') ? $clipBoardElementData['tx_gridelements_backend_layout'] : '') . "'; top.clipBoardElementListType = '" . $clipBoardElementData['list_type'] . "';"; } else { $pAddExtOnReadyCode .= " top.clipBoardElementCType = ''; top.clipBoardElementTxGridelementsBackendLayout = ''; top.clipBoardElementListType = '';"; } } $pAddExtOnReadyCode .= ' top.copyFromAnotherPageLinkTemplate = ' . json_encode('<a class="t3js-paste-new btn btn-default" title="' . $this->getLanguageService()->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_js.copyfrompage') . '">' . $iconFactory->getIcon( 'actions-insert-reference', Icon::SIZE_SMALL )->render() . '</a>') . ';'; $pageRenderer->addJsInlineCode('gridelementsExtOnReady', $pAddExtOnReadyCode); } }
[ "public", "function", "addJSCSS", "(", "array", "$", "parameters", ",", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Page", "\\", "PageRenderer", "$", "pageRenderer", ")", "{", "if", "(", "!", "empty", "(", "$", "GLOBALS", "[", "'SOBE'", "]", ")", "&&", "(", "get_class", "(", "$", "GLOBALS", "[", "'SOBE'", "]", ")", "===", "RecordListController", "::", "class", "||", "is_subclass_of", "(", "$", "GLOBALS", "[", "'SOBE'", "]", ",", "RecordListController", "::", "class", ")", ")", ")", "{", "$", "pageRenderer", "->", "loadRequireJsModule", "(", "'TYPO3/CMS/Gridelements/GridElementsOnReady'", ")", ";", "return", ";", "}", "if", "(", "!", "empty", "(", "$", "GLOBALS", "[", "'SOBE'", "]", ")", "&&", "(", "get_class", "(", "$", "GLOBALS", "[", "'SOBE'", "]", ")", "===", "PageLayoutController", "::", "class", "||", "is_subclass_of", "(", "$", "GLOBALS", "[", "'SOBE'", "]", ",", "PageLayoutController", "::", "class", ")", ")", ")", "{", "$", "iconFactory", "=", "GeneralUtility", "::", "makeInstance", "(", "IconFactory", "::", "class", ")", ";", "$", "pageRenderer", "->", "loadRequireJsModule", "(", "'TYPO3/CMS/Gridelements/GridElementsOnReady'", ")", ";", "$", "pageRenderer", "->", "loadRequireJsModule", "(", "'TYPO3/CMS/Gridelements/GridElementsDragDrop'", ")", ";", "$", "pageRenderer", "->", "loadRequireJsModule", "(", "'TYPO3/CMS/Gridelements/GridElementsDragInWizard'", ")", ";", "/** @var Clipboard $clipObj */", "$", "clipObj", "=", "GeneralUtility", "::", "makeInstance", "(", "Clipboard", "::", "class", ")", ";", "// Start clipboard", "$", "clipObj", "->", "initializeClipboard", "(", ")", ";", "$", "clipObj", "->", "lockToNormal", "(", ")", ";", "$", "clipBoard", "=", "$", "clipObj", "->", "clipData", "[", "'normal'", "]", ";", "if", "(", "!", "$", "pageRenderer", "->", "getCharSet", "(", ")", ")", "{", "$", "pageRenderer", "->", "setCharSet", "(", "'utf-8'", ")", ";", "}", "// pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys", "$", "pageRenderer", "->", "addInlineLanguageLabelFile", "(", "'EXT:gridelements/Resources/Private/Language/locallang_db.xml'", ",", "'tx_gridelements_js'", ")", ";", "$", "pAddExtOnReadyCode", "=", "'\n TYPO3.l10n = {\n localize: function(langKey){\n return TYPO3.lang[langKey];\n }\n }\n '", ";", "$", "id", "=", "(", "int", ")", "GeneralUtility", "::", "_GP", "(", "'id'", ")", ";", "$", "layout", "=", "GeneralUtility", "::", "callUserFunction", "(", "BackendLayoutView", "::", "class", ".", "'->getSelectedBackendLayout'", ",", "$", "id", ",", "$", "this", ")", ";", "if", "(", "is_array", "(", "$", "layout", ")", "&&", "!", "empty", "(", "$", "layout", "[", "'__config'", "]", "[", "'backend_layout.'", "]", "[", "'rows.'", "]", ")", ")", "{", "/** @var LayoutSetup $layoutSetup */", "$", "layoutSetup", "=", "GeneralUtility", "::", "makeInstance", "(", "LayoutSetup", "::", "class", ")", "->", "init", "(", "0", ")", ";", "$", "layout", "=", "[", "'config'", "=>", "$", "layout", "[", "'__config'", "]", "[", "'backend_layout.'", "]", "]", ";", "$", "columns", "=", "$", "layoutSetup", "->", "checkAvailableColumns", "(", "$", "layout", ",", "true", ")", ";", "if", "(", "$", "columns", "[", "'allowed'", "]", "||", "$", "columns", "[", "'disallowed'", "]", "||", "$", "columns", "[", "'maxitems'", "]", ")", "{", "$", "layout", "[", "'columns'", "]", "=", "$", "columns", ";", "unset", "(", "$", "layout", "[", "'columns'", "]", "[", "'allowed'", "]", ")", ";", "$", "layout", "[", "'allowed'", "]", "=", "$", "columns", "[", "'allowed'", "]", "?", ":", "[", "]", ";", "$", "layout", "[", "'disallowed'", "]", "=", "$", "columns", "[", "'disallowed'", "]", "?", ":", "[", "]", ";", "$", "layout", "[", "'maxitems'", "]", "=", "$", "columns", "[", "'maxitems'", "]", "?", ":", "[", "]", ";", "}", "}", "// add Ext.onReady() code from file", "$", "uriBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "UriBuilder", "::", "class", ")", ";", "$", "pAddExtOnReadyCode", ".=", "'\n top.pageColumnsAllowed = '", ".", "json_encode", "(", "$", "layout", "[", "'allowed'", "]", ")", ".", "';\n top.pageColumnsDisallowed = '", ".", "json_encode", "(", "$", "layout", "[", "'disallowed'", "]", ")", ".", "';\n top.pageColumnsMaxitems = '", ".", "json_encode", "(", "$", "layout", "[", "'maxitems'", "]", ")", ".", "';\n top.pasteReferenceAllowed = '", ".", "(", "$", "this", "->", "getBackendUser", "(", ")", "->", "checkAuthMode", "(", "'tt_content'", ",", "'CType'", ",", "'shortcut'", ",", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'BE'", "]", "[", "'explicitADmode'", "]", ")", "?", "'true'", ":", "'false'", ")", ".", "';\n top.skipDraggableDetails = '", ".", "(", "$", "this", "->", "getBackendUser", "(", ")", "->", "uc", "[", "'dragAndDropHideNewElementWizardInfoOverlay'", "]", "?", "'true'", ":", "'false'", ")", ".", "\";\n top.backPath = '\"", ".", "$", "GLOBALS", "[", "'BACK_PATH'", "]", ".", "\"';\n top.browserUrl = '\"", ".", "htmlspecialchars", "(", "$", "uriBuilder", "->", "buildUriFromRoute", "(", "'wizard_element_browser'", ")", ")", ".", "\"';\"", ";", "if", "(", "!", "empty", "(", "$", "clipBoard", ")", "&&", "!", "empty", "(", "$", "clipBoard", "[", "'el'", "]", ")", ")", "{", "$", "clipBoardElement", "=", "GeneralUtility", "::", "trimExplode", "(", "'|'", ",", "key", "(", "$", "clipBoard", "[", "'el'", "]", ")", ")", ";", "if", "(", "$", "clipBoardElement", "[", "0", "]", "===", "'tt_content'", ")", "{", "$", "clipBoardElementData", "=", "BackendUtility", "::", "getRecord", "(", "'tt_content'", ",", "(", "int", ")", "$", "clipBoardElement", "[", "1", "]", ")", ";", "$", "pAddExtOnReadyCode", ".=", "\"\n top.clipBoardElementCType = '\"", ".", "$", "clipBoardElementData", "[", "'CType'", "]", ".", "\"';\n top.clipBoardElementTxGridelementsBackendLayout = '\"", ".", "(", "(", "$", "clipBoardElementData", "[", "'CType'", "]", "==", "'gridelements_pi1'", ")", "?", "$", "clipBoardElementData", "[", "'tx_gridelements_backend_layout'", "]", ":", "''", ")", ".", "\"';\n top.clipBoardElementListType = '\"", ".", "$", "clipBoardElementData", "[", "'list_type'", "]", ".", "\"';\"", ";", "}", "else", "{", "$", "pAddExtOnReadyCode", ".=", "\"\n top.clipBoardElementCType = '';\n top.clipBoardElementTxGridelementsBackendLayout = '';\n top.clipBoardElementListType = '';\"", ";", "}", "}", "$", "pAddExtOnReadyCode", ".=", "'\n top.copyFromAnotherPageLinkTemplate = '", ".", "json_encode", "(", "'<a class=\"t3js-paste-new btn btn-default\" title=\"'", ".", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_js.copyfrompage'", ")", ".", "'\">'", ".", "$", "iconFactory", "->", "getIcon", "(", "'actions-insert-reference'", ",", "Icon", "::", "SIZE_SMALL", ")", "->", "render", "(", ")", ".", "'</a>'", ")", ".", "';'", ";", "$", "pageRenderer", "->", "addJsInlineCode", "(", "'gridelementsExtOnReady'", ",", "$", "pAddExtOnReadyCode", ")", ";", "}", "}" ]
wrapper function called by hook (\TYPO3\CMS\Core\Page\PageRenderer->render-preProcess) @param array $parameters An array of available parameters @param \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer The parent object that triggered this hook
[ "wrapper", "function", "called", "by", "hook", "(", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Page", "\\", "PageRenderer", "-", ">", "render", "-", "preProcess", ")" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/PageRenderer.php#L48-L149
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.execute_preProcessFieldArray
public function execute_preProcessFieldArray(array &$fieldArray, $table, $id, DataHandler $parentObj) { if ($table === 'tt_content') { $this->init($table, $id, $parentObj); if (!$this->getTceMain()->isImporting) { $cmdId = ''; if (is_array($parentObj->cmdmap['tt_content'])) { $cmdId = (int)key($parentObj->cmdmap['tt_content']); } $new = !MathUtility::canBeInterpretedAsInteger(key($parentObj->datamap['tt_content'])) || !empty($parentObj->cmdmap['tt_content'][$cmdId]['copy']) || !empty($parentObj->cmdmap['tt_content'][$cmdId]['move']); $this->processFieldArrayForTtContent($fieldArray, $id, $new); } } }
php
public function execute_preProcessFieldArray(array &$fieldArray, $table, $id, DataHandler $parentObj) { if ($table === 'tt_content') { $this->init($table, $id, $parentObj); if (!$this->getTceMain()->isImporting) { $cmdId = ''; if (is_array($parentObj->cmdmap['tt_content'])) { $cmdId = (int)key($parentObj->cmdmap['tt_content']); } $new = !MathUtility::canBeInterpretedAsInteger(key($parentObj->datamap['tt_content'])) || !empty($parentObj->cmdmap['tt_content'][$cmdId]['copy']) || !empty($parentObj->cmdmap['tt_content'][$cmdId]['move']); $this->processFieldArrayForTtContent($fieldArray, $id, $new); } } }
[ "public", "function", "execute_preProcessFieldArray", "(", "array", "&", "$", "fieldArray", ",", "$", "table", ",", "$", "id", ",", "DataHandler", "$", "parentObj", ")", "{", "if", "(", "$", "table", "===", "'tt_content'", ")", "{", "$", "this", "->", "init", "(", "$", "table", ",", "$", "id", ",", "$", "parentObj", ")", ";", "if", "(", "!", "$", "this", "->", "getTceMain", "(", ")", "->", "isImporting", ")", "{", "$", "cmdId", "=", "''", ";", "if", "(", "is_array", "(", "$", "parentObj", "->", "cmdmap", "[", "'tt_content'", "]", ")", ")", "{", "$", "cmdId", "=", "(", "int", ")", "key", "(", "$", "parentObj", "->", "cmdmap", "[", "'tt_content'", "]", ")", ";", "}", "$", "new", "=", "!", "MathUtility", "::", "canBeInterpretedAsInteger", "(", "key", "(", "$", "parentObj", "->", "datamap", "[", "'tt_content'", "]", ")", ")", "||", "!", "empty", "(", "$", "parentObj", "->", "cmdmap", "[", "'tt_content'", "]", "[", "$", "cmdId", "]", "[", "'copy'", "]", ")", "||", "!", "empty", "(", "$", "parentObj", "->", "cmdmap", "[", "'tt_content'", "]", "[", "$", "cmdId", "]", "[", "'move'", "]", ")", ";", "$", "this", "->", "processFieldArrayForTtContent", "(", "$", "fieldArray", ",", "$", "id", ",", "$", "new", ")", ";", "}", "}", "}" ]
Function to set the colPos of an element depending on whether it is a child of a parent container or not will set colPos according to availability of the current grid column of an element 0 = no column at all -1 = grid element column -2 = non used elements column changes are applied to the field array of the parent object by reference @param array $fieldArray The array of fields and values that have been saved to the datamap @param string $table The name of the table the data should be saved to @param int $id The parent uid of either the page or the container we are currently working on @param DataHandler $parentObj The parent object that triggered this hook
[ "Function", "to", "set", "the", "colPos", "of", "an", "element", "depending", "on", "whether", "it", "is", "a", "child", "of", "a", "parent", "container", "or", "not", "will", "set", "colPos", "according", "to", "availability", "of", "the", "current", "grid", "column", "of", "an", "element", "0", "=", "no", "column", "at", "all", "-", "1", "=", "grid", "element", "column", "-", "2", "=", "non", "used", "elements", "column", "changes", "are", "applied", "to", "the", "field", "array", "of", "the", "parent", "object", "by", "reference" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L61-L76
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.processFieldArrayForTtContent
public function processFieldArrayForTtContent(array &$fieldArray, $id = 0, $new = false) { $pid = (int)GeneralUtility::_GET('DDinsertNew'); if (abs($pid) > 0) { $this->setDefaultFieldValues($fieldArray, $pid); $this->getDefaultFlexformValues($fieldArray); } $this->setFieldEntries($fieldArray, $id, $new); }
php
public function processFieldArrayForTtContent(array &$fieldArray, $id = 0, $new = false) { $pid = (int)GeneralUtility::_GET('DDinsertNew'); if (abs($pid) > 0) { $this->setDefaultFieldValues($fieldArray, $pid); $this->getDefaultFlexformValues($fieldArray); } $this->setFieldEntries($fieldArray, $id, $new); }
[ "public", "function", "processFieldArrayForTtContent", "(", "array", "&", "$", "fieldArray", ",", "$", "id", "=", "0", ",", "$", "new", "=", "false", ")", "{", "$", "pid", "=", "(", "int", ")", "GeneralUtility", "::", "_GET", "(", "'DDinsertNew'", ")", ";", "if", "(", "abs", "(", "$", "pid", ")", ">", "0", ")", "{", "$", "this", "->", "setDefaultFieldValues", "(", "$", "fieldArray", ",", "$", "pid", ")", ";", "$", "this", "->", "getDefaultFlexformValues", "(", "$", "fieldArray", ")", ";", "}", "$", "this", "->", "setFieldEntries", "(", "$", "fieldArray", ",", "$", "id", ",", "$", "new", ")", ";", "}" ]
process field array for table tt_content @param array $fieldArray @param int $id @param bool $new
[ "process", "field", "array", "for", "table", "tt_content" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L85-L95
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.setDefaultFieldValues
public function setDefaultFieldValues(array &$fieldArray, $uidPid = 0) { // Default values: $newRow = []; // Used to store default values as found here: // Default values as set in userTS: $TCAdefaultOverride = (array)($this->getBackendUser()->getTSConfig()['TCAdefaults'] ?? []); if (is_array($TCAdefaultOverride['tt_content.'])) { foreach ($TCAdefaultOverride['tt_content.'] as $field => $value) { if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $value; } } } if ($uidPid < 0) { $record = BackendUtility::getRecord('tt_content', abs($uidPid), 'pid'); $pageId = $record['pid']; } else { $pageId = (int)$uidPid; } $pageTS = BackendUtility::getPagesTSconfig($pageId); if (isset($pageTS['TCAdefaults.'])) { $TCAPageTSOverride = $pageTS['TCAdefaults.']; if (is_array($TCAPageTSOverride['tt_content.'])) { foreach ($TCAPageTSOverride['tt_content.'] as $field => $value) { if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $value; } } } } // Default values as submitted: $this->definitionValues = GeneralUtility::_GP('defVals'); $this->overrideValues = GeneralUtility::_GP('overrideVals'); if (!is_array($this->definitionValues) && is_array($this->overrideValues)) { $this->definitionValues = $this->overrideValues; } if (is_array($this->definitionValues['tt_content'])) { foreach ($this->definitionValues['tt_content'] as $field => $value) { if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $value; } } } // Fetch default values if a previous record exists if ($uidPid < 0 && !empty($record) && $GLOBALS['TCA']['tt_content']['ctrl']['useColumnsForDefaultValues']) { // Gets the list of fields to copy from the previous record. $fieldArray = explode(',', $GLOBALS['TCA']['tt_content']['ctrl']['useColumnsForDefaultValues']); foreach ($fieldArray as $field) { $field = trim($field); if ($field === '') { continue; } if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $record[$field]; } } } $fieldArray = array_merge($newRow, $fieldArray); }
php
public function setDefaultFieldValues(array &$fieldArray, $uidPid = 0) { // Default values: $newRow = []; // Used to store default values as found here: // Default values as set in userTS: $TCAdefaultOverride = (array)($this->getBackendUser()->getTSConfig()['TCAdefaults'] ?? []); if (is_array($TCAdefaultOverride['tt_content.'])) { foreach ($TCAdefaultOverride['tt_content.'] as $field => $value) { if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $value; } } } if ($uidPid < 0) { $record = BackendUtility::getRecord('tt_content', abs($uidPid), 'pid'); $pageId = $record['pid']; } else { $pageId = (int)$uidPid; } $pageTS = BackendUtility::getPagesTSconfig($pageId); if (isset($pageTS['TCAdefaults.'])) { $TCAPageTSOverride = $pageTS['TCAdefaults.']; if (is_array($TCAPageTSOverride['tt_content.'])) { foreach ($TCAPageTSOverride['tt_content.'] as $field => $value) { if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $value; } } } } // Default values as submitted: $this->definitionValues = GeneralUtility::_GP('defVals'); $this->overrideValues = GeneralUtility::_GP('overrideVals'); if (!is_array($this->definitionValues) && is_array($this->overrideValues)) { $this->definitionValues = $this->overrideValues; } if (is_array($this->definitionValues['tt_content'])) { foreach ($this->definitionValues['tt_content'] as $field => $value) { if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $value; } } } // Fetch default values if a previous record exists if ($uidPid < 0 && !empty($record) && $GLOBALS['TCA']['tt_content']['ctrl']['useColumnsForDefaultValues']) { // Gets the list of fields to copy from the previous record. $fieldArray = explode(',', $GLOBALS['TCA']['tt_content']['ctrl']['useColumnsForDefaultValues']); foreach ($fieldArray as $field) { $field = trim($field); if ($field === '') { continue; } if (isset($GLOBALS['TCA']['tt_content']['columns'][$field])) { $newRow[$field] = $record[$field]; } } } $fieldArray = array_merge($newRow, $fieldArray); }
[ "public", "function", "setDefaultFieldValues", "(", "array", "&", "$", "fieldArray", ",", "$", "uidPid", "=", "0", ")", "{", "// Default values:", "$", "newRow", "=", "[", "]", ";", "// Used to store default values as found here:", "// Default values as set in userTS:", "$", "TCAdefaultOverride", "=", "(", "array", ")", "(", "$", "this", "->", "getBackendUser", "(", ")", "->", "getTSConfig", "(", ")", "[", "'TCAdefaults'", "]", "??", "[", "]", ")", ";", "if", "(", "is_array", "(", "$", "TCAdefaultOverride", "[", "'tt_content.'", "]", ")", ")", "{", "foreach", "(", "$", "TCAdefaultOverride", "[", "'tt_content.'", "]", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'columns'", "]", "[", "$", "field", "]", ")", ")", "{", "$", "newRow", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "}", "if", "(", "$", "uidPid", "<", "0", ")", "{", "$", "record", "=", "BackendUtility", "::", "getRecord", "(", "'tt_content'", ",", "abs", "(", "$", "uidPid", ")", ",", "'pid'", ")", ";", "$", "pageId", "=", "$", "record", "[", "'pid'", "]", ";", "}", "else", "{", "$", "pageId", "=", "(", "int", ")", "$", "uidPid", ";", "}", "$", "pageTS", "=", "BackendUtility", "::", "getPagesTSconfig", "(", "$", "pageId", ")", ";", "if", "(", "isset", "(", "$", "pageTS", "[", "'TCAdefaults.'", "]", ")", ")", "{", "$", "TCAPageTSOverride", "=", "$", "pageTS", "[", "'TCAdefaults.'", "]", ";", "if", "(", "is_array", "(", "$", "TCAPageTSOverride", "[", "'tt_content.'", "]", ")", ")", "{", "foreach", "(", "$", "TCAPageTSOverride", "[", "'tt_content.'", "]", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'columns'", "]", "[", "$", "field", "]", ")", ")", "{", "$", "newRow", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "}", "}", "// Default values as submitted:", "$", "this", "->", "definitionValues", "=", "GeneralUtility", "::", "_GP", "(", "'defVals'", ")", ";", "$", "this", "->", "overrideValues", "=", "GeneralUtility", "::", "_GP", "(", "'overrideVals'", ")", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "definitionValues", ")", "&&", "is_array", "(", "$", "this", "->", "overrideValues", ")", ")", "{", "$", "this", "->", "definitionValues", "=", "$", "this", "->", "overrideValues", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "definitionValues", "[", "'tt_content'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "definitionValues", "[", "'tt_content'", "]", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'columns'", "]", "[", "$", "field", "]", ")", ")", "{", "$", "newRow", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "}", "// Fetch default values if a previous record exists", "if", "(", "$", "uidPid", "<", "0", "&&", "!", "empty", "(", "$", "record", ")", "&&", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'ctrl'", "]", "[", "'useColumnsForDefaultValues'", "]", ")", "{", "// Gets the list of fields to copy from the previous record.", "$", "fieldArray", "=", "explode", "(", "','", ",", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'ctrl'", "]", "[", "'useColumnsForDefaultValues'", "]", ")", ";", "foreach", "(", "$", "fieldArray", "as", "$", "field", ")", "{", "$", "field", "=", "trim", "(", "$", "field", ")", ";", "if", "(", "$", "field", "===", "''", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'columns'", "]", "[", "$", "field", "]", ")", ")", "{", "$", "newRow", "[", "$", "field", "]", "=", "$", "record", "[", "$", "field", "]", ";", "}", "}", "}", "$", "fieldArray", "=", "array_merge", "(", "$", "newRow", ",", "$", "fieldArray", ")", ";", "}" ]
set default field values for new records @param array $fieldArray @param int $uidPid
[ "set", "default", "field", "values", "for", "new", "records" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L103-L167
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.getDefaultFlexformValues
public function getDefaultFlexformValues(array &$fieldArray) { foreach ($GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'] as $key => $dataStructure) { $types = GeneralUtility::trimExplode(',', $key); if (($types[0] === $fieldArray['list_type'] || $types[0] === '*') && ($types[1] === $fieldArray['CType'] || $types[1] === '*')) { $fieldArray['pi_flexform'] = $this->extractDefaultDataFromDataStructure($dataStructure); } } }
php
public function getDefaultFlexformValues(array &$fieldArray) { foreach ($GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'] as $key => $dataStructure) { $types = GeneralUtility::trimExplode(',', $key); if (($types[0] === $fieldArray['list_type'] || $types[0] === '*') && ($types[1] === $fieldArray['CType'] || $types[1] === '*')) { $fieldArray['pi_flexform'] = $this->extractDefaultDataFromDataStructure($dataStructure); } } }
[ "public", "function", "getDefaultFlexformValues", "(", "array", "&", "$", "fieldArray", ")", "{", "foreach", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'columns'", "]", "[", "'pi_flexform'", "]", "[", "'config'", "]", "[", "'ds'", "]", "as", "$", "key", "=>", "$", "dataStructure", ")", "{", "$", "types", "=", "GeneralUtility", "::", "trimExplode", "(", "','", ",", "$", "key", ")", ";", "if", "(", "(", "$", "types", "[", "0", "]", "===", "$", "fieldArray", "[", "'list_type'", "]", "||", "$", "types", "[", "0", "]", "===", "'*'", ")", "&&", "(", "$", "types", "[", "1", "]", "===", "$", "fieldArray", "[", "'CType'", "]", "||", "$", "types", "[", "1", "]", "===", "'*'", ")", ")", "{", "$", "fieldArray", "[", "'pi_flexform'", "]", "=", "$", "this", "->", "extractDefaultDataFromDataStructure", "(", "$", "dataStructure", ")", ";", "}", "}", "}" ]
checks for default flexform values for new records and sets them accordingly @param array $fieldArray
[ "checks", "for", "default", "flexform", "values", "for", "new", "records", "and", "sets", "them", "accordingly" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L182-L190
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.extractDefaultDataFromDataStructure
public function extractDefaultDataFromDataStructure($dataStructure) { $returnXML = ''; $sheetArray = []; if ($dataStructure) { $structureArray = GeneralUtility::xml2array($dataStructure); if (!isset($structureArray['sheets']) && isset($structureArray['ROOT'])) { $structureArray['sheets']['sDEF']['ROOT'] = $structureArray['ROOT']; unset($structureArray['ROOT']); } if (isset($structureArray['sheets']) && !empty($structureArray['sheets'])) { foreach ($structureArray['sheets'] as $sheetName => $sheet) { if (is_array($sheet['ROOT']['el']) && !empty($sheet['ROOT']['el'])) { $elArray = []; foreach ($sheet['ROOT']['el'] as $elName => $elConf) { $config = $elConf['TCEforms']['config']; $elArray[$elName]['vDEF'] = $config['default']; if (!$elArray[$elName]['vDEF'] && $config['type'] === 'select' && !empty($config['items'])) { $elArray[$elName]['vDEF'] = $config['items'][0][1]; } } $sheetArray['data'][$sheetName]['lDEF'] = $elArray; } } } if (!empty($sheetArray)) { $flexformTools = GeneralUtility::makeInstance(FlexFormTools::class); $returnXML = $flexformTools->flexArray2Xml($sheetArray, true); } } return $returnXML; }
php
public function extractDefaultDataFromDataStructure($dataStructure) { $returnXML = ''; $sheetArray = []; if ($dataStructure) { $structureArray = GeneralUtility::xml2array($dataStructure); if (!isset($structureArray['sheets']) && isset($structureArray['ROOT'])) { $structureArray['sheets']['sDEF']['ROOT'] = $structureArray['ROOT']; unset($structureArray['ROOT']); } if (isset($structureArray['sheets']) && !empty($structureArray['sheets'])) { foreach ($structureArray['sheets'] as $sheetName => $sheet) { if (is_array($sheet['ROOT']['el']) && !empty($sheet['ROOT']['el'])) { $elArray = []; foreach ($sheet['ROOT']['el'] as $elName => $elConf) { $config = $elConf['TCEforms']['config']; $elArray[$elName]['vDEF'] = $config['default']; if (!$elArray[$elName]['vDEF'] && $config['type'] === 'select' && !empty($config['items'])) { $elArray[$elName]['vDEF'] = $config['items'][0][1]; } } $sheetArray['data'][$sheetName]['lDEF'] = $elArray; } } } if (!empty($sheetArray)) { $flexformTools = GeneralUtility::makeInstance(FlexFormTools::class); $returnXML = $flexformTools->flexArray2Xml($sheetArray, true); } } return $returnXML; }
[ "public", "function", "extractDefaultDataFromDataStructure", "(", "$", "dataStructure", ")", "{", "$", "returnXML", "=", "''", ";", "$", "sheetArray", "=", "[", "]", ";", "if", "(", "$", "dataStructure", ")", "{", "$", "structureArray", "=", "GeneralUtility", "::", "xml2array", "(", "$", "dataStructure", ")", ";", "if", "(", "!", "isset", "(", "$", "structureArray", "[", "'sheets'", "]", ")", "&&", "isset", "(", "$", "structureArray", "[", "'ROOT'", "]", ")", ")", "{", "$", "structureArray", "[", "'sheets'", "]", "[", "'sDEF'", "]", "[", "'ROOT'", "]", "=", "$", "structureArray", "[", "'ROOT'", "]", ";", "unset", "(", "$", "structureArray", "[", "'ROOT'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "structureArray", "[", "'sheets'", "]", ")", "&&", "!", "empty", "(", "$", "structureArray", "[", "'sheets'", "]", ")", ")", "{", "foreach", "(", "$", "structureArray", "[", "'sheets'", "]", "as", "$", "sheetName", "=>", "$", "sheet", ")", "{", "if", "(", "is_array", "(", "$", "sheet", "[", "'ROOT'", "]", "[", "'el'", "]", ")", "&&", "!", "empty", "(", "$", "sheet", "[", "'ROOT'", "]", "[", "'el'", "]", ")", ")", "{", "$", "elArray", "=", "[", "]", ";", "foreach", "(", "$", "sheet", "[", "'ROOT'", "]", "[", "'el'", "]", "as", "$", "elName", "=>", "$", "elConf", ")", "{", "$", "config", "=", "$", "elConf", "[", "'TCEforms'", "]", "[", "'config'", "]", ";", "$", "elArray", "[", "$", "elName", "]", "[", "'vDEF'", "]", "=", "$", "config", "[", "'default'", "]", ";", "if", "(", "!", "$", "elArray", "[", "$", "elName", "]", "[", "'vDEF'", "]", "&&", "$", "config", "[", "'type'", "]", "===", "'select'", "&&", "!", "empty", "(", "$", "config", "[", "'items'", "]", ")", ")", "{", "$", "elArray", "[", "$", "elName", "]", "[", "'vDEF'", "]", "=", "$", "config", "[", "'items'", "]", "[", "0", "]", "[", "1", "]", ";", "}", "}", "$", "sheetArray", "[", "'data'", "]", "[", "$", "sheetName", "]", "[", "'lDEF'", "]", "=", "$", "elArray", ";", "}", "}", "}", "if", "(", "!", "empty", "(", "$", "sheetArray", ")", ")", "{", "$", "flexformTools", "=", "GeneralUtility", "::", "makeInstance", "(", "FlexFormTools", "::", "class", ")", ";", "$", "returnXML", "=", "$", "flexformTools", "->", "flexArray2Xml", "(", "$", "sheetArray", ",", "true", ")", ";", "}", "}", "return", "$", "returnXML", ";", "}" ]
extracts the default data out of a given XML data structure @param string $dataStructure @return string $defaultData
[ "extracts", "the", "default", "data", "out", "of", "a", "given", "XML", "data", "structure" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L199-L231
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.setFieldEntries
public function setFieldEntries(array &$fieldArray, $contentId = 0, $new = false) { $containerUpdateArray = []; if (isset($fieldArray['tx_gridelements_container'])) { if ((int)$fieldArray['tx_gridelements_container'] > 0 && $new) { $containerUpdateArray[(int)$fieldArray['tx_gridelements_container']] = 1; } if ((int)$fieldArray['tx_gridelements_container'] === 0) { $originalContainer = BackendUtility::getRecord( 'tt_content', (int)$contentId, 'tx_gridelements_container,sys_language_uid' ); if (!empty($originalContainer)) { $containerUpdateArray[(int)$originalContainer['tx_gridelements_container']] = -1; } } } if (!empty($containerUpdateArray)) { $this->doGridContainerUpdate($containerUpdateArray); } $this->setFieldEntriesForGridContainers($fieldArray); }
php
public function setFieldEntries(array &$fieldArray, $contentId = 0, $new = false) { $containerUpdateArray = []; if (isset($fieldArray['tx_gridelements_container'])) { if ((int)$fieldArray['tx_gridelements_container'] > 0 && $new) { $containerUpdateArray[(int)$fieldArray['tx_gridelements_container']] = 1; } if ((int)$fieldArray['tx_gridelements_container'] === 0) { $originalContainer = BackendUtility::getRecord( 'tt_content', (int)$contentId, 'tx_gridelements_container,sys_language_uid' ); if (!empty($originalContainer)) { $containerUpdateArray[(int)$originalContainer['tx_gridelements_container']] = -1; } } } if (!empty($containerUpdateArray)) { $this->doGridContainerUpdate($containerUpdateArray); } $this->setFieldEntriesForGridContainers($fieldArray); }
[ "public", "function", "setFieldEntries", "(", "array", "&", "$", "fieldArray", ",", "$", "contentId", "=", "0", ",", "$", "new", "=", "false", ")", "{", "$", "containerUpdateArray", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ")", ")", "{", "if", "(", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ">", "0", "&&", "$", "new", ")", "{", "$", "containerUpdateArray", "[", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", "]", "=", "1", ";", "}", "if", "(", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", "===", "0", ")", "{", "$", "originalContainer", "=", "BackendUtility", "::", "getRecord", "(", "'tt_content'", ",", "(", "int", ")", "$", "contentId", ",", "'tx_gridelements_container,sys_language_uid'", ")", ";", "if", "(", "!", "empty", "(", "$", "originalContainer", ")", ")", "{", "$", "containerUpdateArray", "[", "(", "int", ")", "$", "originalContainer", "[", "'tx_gridelements_container'", "]", "]", "=", "-", "1", ";", "}", "}", "}", "if", "(", "!", "empty", "(", "$", "containerUpdateArray", ")", ")", "{", "$", "this", "->", "doGridContainerUpdate", "(", "$", "containerUpdateArray", ")", ";", "}", "$", "this", "->", "setFieldEntriesForGridContainers", "(", "$", "fieldArray", ")", ";", "}" ]
set initial entries to field array @param array $fieldArray @param int $contentId @param bool $new
[ "set", "initial", "entries", "to", "field", "array" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L240-L262
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.setFieldEntriesForGridContainers
public function setFieldEntriesForGridContainers(array &$fieldArray) { if ((int)$fieldArray['tx_gridelements_container'] > 0 && isset($fieldArray['colPos']) && (int)$fieldArray['colPos'] !== -1) { $fieldArray['colPos'] = -1; $fieldArray['tx_gridelements_columns'] = 0; $targetContainer = BackendUtility::getRecord( 'tt_content', (int)$fieldArray['tx_gridelements_container'], 'sys_language_uid' ); if ((int)$targetContainer['sys_language_uid'] > -1) { $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid']; } } else { if (isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] === 0 && (int)$fieldArray['colPos'] === -1) { $fieldArray['colPos'] = $this->checkForRootColumn((int)$this->getContentUid()); $fieldArray['tx_gridelements_columns'] = 0; $fieldArray['tx_gridelements_container'] = 0; } else { if (!isset($fieldArray['sys_language_uid']) && isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] > 0 && (int)$fieldArray['colPos'] === -1) { $targetContainer = BackendUtility::getRecord( 'tt_content', (int)$fieldArray['tx_gridelements_container'], 'sys_language_uid' ); if ((int)$targetContainer['sys_language_uid'] > -1) { $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid']; } } } } if (isset($targetContainer) && (int)$targetContainer['sys_language_uid'] === -1) { $list = array_flip(GeneralUtility::trimExplode( ',', $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'], true )); unset($list['sys_language_uid']); $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'] = implode(',', array_flip($list)); } }
php
public function setFieldEntriesForGridContainers(array &$fieldArray) { if ((int)$fieldArray['tx_gridelements_container'] > 0 && isset($fieldArray['colPos']) && (int)$fieldArray['colPos'] !== -1) { $fieldArray['colPos'] = -1; $fieldArray['tx_gridelements_columns'] = 0; $targetContainer = BackendUtility::getRecord( 'tt_content', (int)$fieldArray['tx_gridelements_container'], 'sys_language_uid' ); if ((int)$targetContainer['sys_language_uid'] > -1) { $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid']; } } else { if (isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] === 0 && (int)$fieldArray['colPos'] === -1) { $fieldArray['colPos'] = $this->checkForRootColumn((int)$this->getContentUid()); $fieldArray['tx_gridelements_columns'] = 0; $fieldArray['tx_gridelements_container'] = 0; } else { if (!isset($fieldArray['sys_language_uid']) && isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] > 0 && (int)$fieldArray['colPos'] === -1) { $targetContainer = BackendUtility::getRecord( 'tt_content', (int)$fieldArray['tx_gridelements_container'], 'sys_language_uid' ); if ((int)$targetContainer['sys_language_uid'] > -1) { $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid']; } } } } if (isset($targetContainer) && (int)$targetContainer['sys_language_uid'] === -1) { $list = array_flip(GeneralUtility::trimExplode( ',', $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'], true )); unset($list['sys_language_uid']); $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'] = implode(',', array_flip($list)); } }
[ "public", "function", "setFieldEntriesForGridContainers", "(", "array", "&", "$", "fieldArray", ")", "{", "if", "(", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ">", "0", "&&", "isset", "(", "$", "fieldArray", "[", "'colPos'", "]", ")", "&&", "(", "int", ")", "$", "fieldArray", "[", "'colPos'", "]", "!==", "-", "1", ")", "{", "$", "fieldArray", "[", "'colPos'", "]", "=", "-", "1", ";", "$", "fieldArray", "[", "'tx_gridelements_columns'", "]", "=", "0", ";", "$", "targetContainer", "=", "BackendUtility", "::", "getRecord", "(", "'tt_content'", ",", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ",", "'sys_language_uid'", ")", ";", "if", "(", "(", "int", ")", "$", "targetContainer", "[", "'sys_language_uid'", "]", ">", "-", "1", ")", "{", "$", "fieldArray", "[", "'sys_language_uid'", "]", "=", "(", "int", ")", "$", "targetContainer", "[", "'sys_language_uid'", "]", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ")", "&&", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", "===", "0", "&&", "(", "int", ")", "$", "fieldArray", "[", "'colPos'", "]", "===", "-", "1", ")", "{", "$", "fieldArray", "[", "'colPos'", "]", "=", "$", "this", "->", "checkForRootColumn", "(", "(", "int", ")", "$", "this", "->", "getContentUid", "(", ")", ")", ";", "$", "fieldArray", "[", "'tx_gridelements_columns'", "]", "=", "0", ";", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", "=", "0", ";", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "fieldArray", "[", "'sys_language_uid'", "]", ")", "&&", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ")", "&&", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ">", "0", "&&", "(", "int", ")", "$", "fieldArray", "[", "'colPos'", "]", "===", "-", "1", ")", "{", "$", "targetContainer", "=", "BackendUtility", "::", "getRecord", "(", "'tt_content'", ",", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ",", "'sys_language_uid'", ")", ";", "if", "(", "(", "int", ")", "$", "targetContainer", "[", "'sys_language_uid'", "]", ">", "-", "1", ")", "{", "$", "fieldArray", "[", "'sys_language_uid'", "]", "=", "(", "int", ")", "$", "targetContainer", "[", "'sys_language_uid'", "]", ";", "}", "}", "}", "}", "if", "(", "isset", "(", "$", "targetContainer", ")", "&&", "(", "int", ")", "$", "targetContainer", "[", "'sys_language_uid'", "]", "===", "-", "1", ")", "{", "$", "list", "=", "array_flip", "(", "GeneralUtility", "::", "trimExplode", "(", "','", ",", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'ctrl'", "]", "[", "'copyAfterDuplFields'", "]", ",", "true", ")", ")", ";", "unset", "(", "$", "list", "[", "'sys_language_uid'", "]", ")", ";", "$", "GLOBALS", "[", "'TCA'", "]", "[", "'tt_content'", "]", "[", "'ctrl'", "]", "[", "'copyAfterDuplFields'", "]", "=", "implode", "(", "','", ",", "array_flip", "(", "$", "list", ")", ")", ";", "}", "}" ]
set/override entries to gridelements container @param array $fieldArray
[ "set", "/", "override", "entries", "to", "gridelements", "container" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L269-L309
TYPO3-extensions/gridelements
Classes/DataHandler/PreProcessFieldArray.php
PreProcessFieldArray.checkForRootColumn
public function checkForRootColumn($contentId) { $queryBuilder = $this->getQueryBuilder(); $queryBuilder ->getRestrictions() ->removeAll(); $parent = $queryBuilder ->select('t1.colPos', 't1.tx_gridelements_container') ->from('tt_content', 't1') ->join( 't1', 'tt_content', 't2', $queryBuilder->expr()->eq('t1.uid', $queryBuilder->quoteIdentifier('t2.tx_gridelements_container')) ) ->where( $queryBuilder->expr()->eq( 't2.uid', $queryBuilder->createNamedParameter((int)$contentId, \PDO::PARAM_INT) ) ) ->execute() ->fetch(); if (!empty($parent) && $parent['tx_gridelements_container'] > 0) { $colPos = $this->checkForRootColumn($parent['tx_gridelements_container']); } else { $colPos = (int)$parent['colPos']; } return $colPos; }
php
public function checkForRootColumn($contentId) { $queryBuilder = $this->getQueryBuilder(); $queryBuilder ->getRestrictions() ->removeAll(); $parent = $queryBuilder ->select('t1.colPos', 't1.tx_gridelements_container') ->from('tt_content', 't1') ->join( 't1', 'tt_content', 't2', $queryBuilder->expr()->eq('t1.uid', $queryBuilder->quoteIdentifier('t2.tx_gridelements_container')) ) ->where( $queryBuilder->expr()->eq( 't2.uid', $queryBuilder->createNamedParameter((int)$contentId, \PDO::PARAM_INT) ) ) ->execute() ->fetch(); if (!empty($parent) && $parent['tx_gridelements_container'] > 0) { $colPos = $this->checkForRootColumn($parent['tx_gridelements_container']); } else { $colPos = (int)$parent['colPos']; } return $colPos; }
[ "public", "function", "checkForRootColumn", "(", "$", "contentId", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "getRestrictions", "(", ")", "->", "removeAll", "(", ")", ";", "$", "parent", "=", "$", "queryBuilder", "->", "select", "(", "'t1.colPos'", ",", "'t1.tx_gridelements_container'", ")", "->", "from", "(", "'tt_content'", ",", "'t1'", ")", "->", "join", "(", "'t1'", ",", "'tt_content'", ",", "'t2'", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'t1.uid'", ",", "$", "queryBuilder", "->", "quoteIdentifier", "(", "'t2.tx_gridelements_container'", ")", ")", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'t2.uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "contentId", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "execute", "(", ")", "->", "fetch", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "parent", ")", "&&", "$", "parent", "[", "'tx_gridelements_container'", "]", ">", "0", ")", "{", "$", "colPos", "=", "$", "this", "->", "checkForRootColumn", "(", "$", "parent", "[", "'tx_gridelements_container'", "]", ")", ";", "}", "else", "{", "$", "colPos", "=", "(", "int", ")", "$", "parent", "[", "'colPos'", "]", ";", "}", "return", "$", "colPos", ";", "}" ]
Function to recursively determine the colPos of the root container so that an element that has been removed from any container will still remain in the same major page column @param int $contentId The uid of the current content element @return int The new column of this content element
[ "Function", "to", "recursively", "determine", "the", "colPos", "of", "the", "root", "container", "so", "that", "an", "element", "that", "has", "been", "removed", "from", "any", "container", "will", "still", "remain", "in", "the", "same", "major", "page", "column" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/PreProcessFieldArray.php#L320-L350
TYPO3-extensions/gridelements
Classes/DataHandler/ProcessCmdmap.php
ProcessCmdmap.execute_processCmdmap
public function execute_processCmdmap( $command, $table, $id, $value, &$commandIsProcessed, DataHandler $parentObj = null, $pasteUpdate = false ) { $this->init($table, $id, $parentObj); $reference = (int)GeneralUtility::_GET('reference'); if ($command === 'copy' && $reference === 1 && !$commandIsProcessed && $table === 'tt_content' && !$this->getTceMain()->isImporting) { $dataArray = [ 'pid' => $value, 'CType' => 'shortcut', 'records' => $id, 'header' => 'Reference', ]; // used for overriding container and column with real target values if (is_array($pasteUpdate) && !empty($pasteUpdate)) { $dataArray = array_merge($dataArray, $pasteUpdate); } $clipBoard = GeneralUtility::_GET('CB'); if (!empty($clipBoard)) { $updateArray = $clipBoard['update']; if (!empty($updateArray)) { $dataArray = array_merge($dataArray, $updateArray); } } $data = []; $data['tt_content']['NEW234134'] = $dataArray; $this->getTceMain()->start($data, []); $this->getTceMain()->process_datamap(); $parentObj->registerDBList = null; $parentObj->remapStack = null; $commandIsProcessed = true; } if ($command === 'delete' && $table === 'tt_content') { $containerUpdateArray = []; $queryBuilder = $this->getQueryBuilder(); $originalContainer = $queryBuilder ->select('tx_gridelements_container', 'sys_language_uid') ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'uid', $queryBuilder->createNamedParameter((int)$id, \PDO::PARAM_INT) ) ) ->execute() ->fetch(); if (!empty($originalContainer)) { $containerUpdateArray[$originalContainer['tx_gridelements_container']] = -1; $this->doGridContainerUpdate($containerUpdateArray); } } if ($table === 'tt_content') { $this->cleanupWorkspacesAfterFinalizing(); } }
php
public function execute_processCmdmap( $command, $table, $id, $value, &$commandIsProcessed, DataHandler $parentObj = null, $pasteUpdate = false ) { $this->init($table, $id, $parentObj); $reference = (int)GeneralUtility::_GET('reference'); if ($command === 'copy' && $reference === 1 && !$commandIsProcessed && $table === 'tt_content' && !$this->getTceMain()->isImporting) { $dataArray = [ 'pid' => $value, 'CType' => 'shortcut', 'records' => $id, 'header' => 'Reference', ]; // used for overriding container and column with real target values if (is_array($pasteUpdate) && !empty($pasteUpdate)) { $dataArray = array_merge($dataArray, $pasteUpdate); } $clipBoard = GeneralUtility::_GET('CB'); if (!empty($clipBoard)) { $updateArray = $clipBoard['update']; if (!empty($updateArray)) { $dataArray = array_merge($dataArray, $updateArray); } } $data = []; $data['tt_content']['NEW234134'] = $dataArray; $this->getTceMain()->start($data, []); $this->getTceMain()->process_datamap(); $parentObj->registerDBList = null; $parentObj->remapStack = null; $commandIsProcessed = true; } if ($command === 'delete' && $table === 'tt_content') { $containerUpdateArray = []; $queryBuilder = $this->getQueryBuilder(); $originalContainer = $queryBuilder ->select('tx_gridelements_container', 'sys_language_uid') ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'uid', $queryBuilder->createNamedParameter((int)$id, \PDO::PARAM_INT) ) ) ->execute() ->fetch(); if (!empty($originalContainer)) { $containerUpdateArray[$originalContainer['tx_gridelements_container']] = -1; $this->doGridContainerUpdate($containerUpdateArray); } } if ($table === 'tt_content') { $this->cleanupWorkspacesAfterFinalizing(); } }
[ "public", "function", "execute_processCmdmap", "(", "$", "command", ",", "$", "table", ",", "$", "id", ",", "$", "value", ",", "&", "$", "commandIsProcessed", ",", "DataHandler", "$", "parentObj", "=", "null", ",", "$", "pasteUpdate", "=", "false", ")", "{", "$", "this", "->", "init", "(", "$", "table", ",", "$", "id", ",", "$", "parentObj", ")", ";", "$", "reference", "=", "(", "int", ")", "GeneralUtility", "::", "_GET", "(", "'reference'", ")", ";", "if", "(", "$", "command", "===", "'copy'", "&&", "$", "reference", "===", "1", "&&", "!", "$", "commandIsProcessed", "&&", "$", "table", "===", "'tt_content'", "&&", "!", "$", "this", "->", "getTceMain", "(", ")", "->", "isImporting", ")", "{", "$", "dataArray", "=", "[", "'pid'", "=>", "$", "value", ",", "'CType'", "=>", "'shortcut'", ",", "'records'", "=>", "$", "id", ",", "'header'", "=>", "'Reference'", ",", "]", ";", "// used for overriding container and column with real target values", "if", "(", "is_array", "(", "$", "pasteUpdate", ")", "&&", "!", "empty", "(", "$", "pasteUpdate", ")", ")", "{", "$", "dataArray", "=", "array_merge", "(", "$", "dataArray", ",", "$", "pasteUpdate", ")", ";", "}", "$", "clipBoard", "=", "GeneralUtility", "::", "_GET", "(", "'CB'", ")", ";", "if", "(", "!", "empty", "(", "$", "clipBoard", ")", ")", "{", "$", "updateArray", "=", "$", "clipBoard", "[", "'update'", "]", ";", "if", "(", "!", "empty", "(", "$", "updateArray", ")", ")", "{", "$", "dataArray", "=", "array_merge", "(", "$", "dataArray", ",", "$", "updateArray", ")", ";", "}", "}", "$", "data", "=", "[", "]", ";", "$", "data", "[", "'tt_content'", "]", "[", "'NEW234134'", "]", "=", "$", "dataArray", ";", "$", "this", "->", "getTceMain", "(", ")", "->", "start", "(", "$", "data", ",", "[", "]", ")", ";", "$", "this", "->", "getTceMain", "(", ")", "->", "process_datamap", "(", ")", ";", "$", "parentObj", "->", "registerDBList", "=", "null", ";", "$", "parentObj", "->", "remapStack", "=", "null", ";", "$", "commandIsProcessed", "=", "true", ";", "}", "if", "(", "$", "command", "===", "'delete'", "&&", "$", "table", "===", "'tt_content'", ")", "{", "$", "containerUpdateArray", "=", "[", "]", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "originalContainer", "=", "$", "queryBuilder", "->", "select", "(", "'tx_gridelements_container'", ",", "'sys_language_uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "id", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "execute", "(", ")", "->", "fetch", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "originalContainer", ")", ")", "{", "$", "containerUpdateArray", "[", "$", "originalContainer", "[", "'tx_gridelements_container'", "]", "]", "=", "-", "1", ";", "$", "this", "->", "doGridContainerUpdate", "(", "$", "containerUpdateArray", ")", ";", "}", "}", "if", "(", "$", "table", "===", "'tt_content'", ")", "{", "$", "this", "->", "cleanupWorkspacesAfterFinalizing", "(", ")", ";", "}", "}" ]
Function to process the drag & drop copy action @param string $command The command to be handled by the command map @param string $table The name of the table we are working on @param int $id The id of the record that is going to be copied @param string $value The value that has been sent with the copy command @param bool $commandIsProcessed A switch to tell the parent object, if the record has been copied @param DataHandler $parentObj The parent object that triggered this hook @param array|bool $pasteUpdate Values to be updated after the record is pasted
[ "Function", "to", "process", "the", "drag", "&", "drop", "copy", "action" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/ProcessCmdmap.php#L45-L112
TYPO3-extensions/gridelements
Classes/Backend/ItemsProcFuncs/CTypeList.php
CTypeList.itemsProcFunc
public function itemsProcFunc(array &$params) { if ((int)$params['row']['pid'] > 0) { $colPos = is_array($params['row']['colPos']) ? $params['row']['colPos'][0] : $params['row']['colPos']; $this->checkForAllowedCTypes( $params['items'], $params['row']['pid'], $colPos, $params['row']['tx_gridelements_container'], $params['row']['tx_gridelements_columns'] ); } else { $this->init((int)$params['row']['pid']); // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first $existingElement = BackendUtility::getRecordWSOL('tt_content', -((int)$params['row']['pid']), 'pid,CType,colPos,tx_gridelements_container,tx_gridelements_columns'); if ((int)$existingElement['pid'] > 0) { $this->checkForAllowedCTypes( $params['items'], $existingElement['pid'], $existingElement['colPos'], $existingElement['tx_gridelements_container'], $existingElement['tx_gridelements_columns'] ); } } }
php
public function itemsProcFunc(array &$params) { if ((int)$params['row']['pid'] > 0) { $colPos = is_array($params['row']['colPos']) ? $params['row']['colPos'][0] : $params['row']['colPos']; $this->checkForAllowedCTypes( $params['items'], $params['row']['pid'], $colPos, $params['row']['tx_gridelements_container'], $params['row']['tx_gridelements_columns'] ); } else { $this->init((int)$params['row']['pid']); // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first $existingElement = BackendUtility::getRecordWSOL('tt_content', -((int)$params['row']['pid']), 'pid,CType,colPos,tx_gridelements_container,tx_gridelements_columns'); if ((int)$existingElement['pid'] > 0) { $this->checkForAllowedCTypes( $params['items'], $existingElement['pid'], $existingElement['colPos'], $existingElement['tx_gridelements_container'], $existingElement['tx_gridelements_columns'] ); } } }
[ "public", "function", "itemsProcFunc", "(", "array", "&", "$", "params", ")", "{", "if", "(", "(", "int", ")", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ">", "0", ")", "{", "$", "colPos", "=", "is_array", "(", "$", "params", "[", "'row'", "]", "[", "'colPos'", "]", ")", "?", "$", "params", "[", "'row'", "]", "[", "'colPos'", "]", "[", "0", "]", ":", "$", "params", "[", "'row'", "]", "[", "'colPos'", "]", ";", "$", "this", "->", "checkForAllowedCTypes", "(", "$", "params", "[", "'items'", "]", ",", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ",", "$", "colPos", ",", "$", "params", "[", "'row'", "]", "[", "'tx_gridelements_container'", "]", ",", "$", "params", "[", "'row'", "]", "[", "'tx_gridelements_columns'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "init", "(", "(", "int", ")", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ")", ";", "// negative uid_pid values indicate that the element has been inserted after an existing element", "// so there is no pid to get the backendLayout for and we have to get that first", "$", "existingElement", "=", "BackendUtility", "::", "getRecordWSOL", "(", "'tt_content'", ",", "-", "(", "(", "int", ")", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ")", ",", "'pid,CType,colPos,tx_gridelements_container,tx_gridelements_columns'", ")", ";", "if", "(", "(", "int", ")", "$", "existingElement", "[", "'pid'", "]", ">", "0", ")", "{", "$", "this", "->", "checkForAllowedCTypes", "(", "$", "params", "[", "'items'", "]", ",", "$", "existingElement", "[", "'pid'", "]", ",", "$", "existingElement", "[", "'colPos'", "]", ",", "$", "existingElement", "[", "'tx_gridelements_container'", "]", ",", "$", "existingElement", "[", "'tx_gridelements_columns'", "]", ")", ";", "}", "}", "}" ]
ItemProcFunc for CType items @param array $params The array of parameters that is used to render the item list
[ "ItemProcFunc", "for", "CType", "items" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/ItemsProcFuncs/CTypeList.php#L45-L71
TYPO3-extensions/gridelements
Classes/Backend/ItemsProcFuncs/CTypeList.php
CTypeList.checkForAllowedCTypes
public function checkForAllowedCTypes(array &$items, $pageId, $pageColumn, $gridContainerId, $gridColumn) { $allowed = []; $disallowed = []; if ((int)$pageColumn >= 0 || (int)$pageColumn === -2) { $column = $pageColumn ? $pageColumn : 0; $layout = $this->getSelectedBackendLayout($pageId); } else { $this->init($pageId); $column = $gridColumn ? (int)$gridColumn : 0; $gridElement = $this->layoutSetup->cacheCurrentParent($gridContainerId, true); $layout = $this->layoutSetup->getLayoutSetup($gridElement['tx_gridelements_backend_layout']); } if (!empty($layout)) { if (is_array($layout['allowed']) && is_array($layout['allowed'][$column]) && !empty($layout['allowed'][$column]['CType'])) { $allowed = $layout['allowed'][$column]['CType']; } if (is_array($layout['disallowed']) && is_array($layout['disallowed'][$column]) && !empty($layout['disallowed'][$column]['CType'])) { $disallowed = $layout['disallowed'][$column]['CType']; } } if (isset($layout) && (!empty($allowed) || !empty($disallowed))) { foreach ($items as $key => $item) { if (( !empty($allowed) && !isset($allowed['*']) && !isset($allowed[$item[1]]) ) || ( !empty($disallowed) && ( isset($disallowed['*']) || isset($disallowed[$item[1]]) ) )) { unset($items[$key]); } } } }
php
public function checkForAllowedCTypes(array &$items, $pageId, $pageColumn, $gridContainerId, $gridColumn) { $allowed = []; $disallowed = []; if ((int)$pageColumn >= 0 || (int)$pageColumn === -2) { $column = $pageColumn ? $pageColumn : 0; $layout = $this->getSelectedBackendLayout($pageId); } else { $this->init($pageId); $column = $gridColumn ? (int)$gridColumn : 0; $gridElement = $this->layoutSetup->cacheCurrentParent($gridContainerId, true); $layout = $this->layoutSetup->getLayoutSetup($gridElement['tx_gridelements_backend_layout']); } if (!empty($layout)) { if (is_array($layout['allowed']) && is_array($layout['allowed'][$column]) && !empty($layout['allowed'][$column]['CType'])) { $allowed = $layout['allowed'][$column]['CType']; } if (is_array($layout['disallowed']) && is_array($layout['disallowed'][$column]) && !empty($layout['disallowed'][$column]['CType'])) { $disallowed = $layout['disallowed'][$column]['CType']; } } if (isset($layout) && (!empty($allowed) || !empty($disallowed))) { foreach ($items as $key => $item) { if (( !empty($allowed) && !isset($allowed['*']) && !isset($allowed[$item[1]]) ) || ( !empty($disallowed) && ( isset($disallowed['*']) || isset($disallowed[$item[1]]) ) )) { unset($items[$key]); } } } }
[ "public", "function", "checkForAllowedCTypes", "(", "array", "&", "$", "items", ",", "$", "pageId", ",", "$", "pageColumn", ",", "$", "gridContainerId", ",", "$", "gridColumn", ")", "{", "$", "allowed", "=", "[", "]", ";", "$", "disallowed", "=", "[", "]", ";", "if", "(", "(", "int", ")", "$", "pageColumn", ">=", "0", "||", "(", "int", ")", "$", "pageColumn", "===", "-", "2", ")", "{", "$", "column", "=", "$", "pageColumn", "?", "$", "pageColumn", ":", "0", ";", "$", "layout", "=", "$", "this", "->", "getSelectedBackendLayout", "(", "$", "pageId", ")", ";", "}", "else", "{", "$", "this", "->", "init", "(", "$", "pageId", ")", ";", "$", "column", "=", "$", "gridColumn", "?", "(", "int", ")", "$", "gridColumn", ":", "0", ";", "$", "gridElement", "=", "$", "this", "->", "layoutSetup", "->", "cacheCurrentParent", "(", "$", "gridContainerId", ",", "true", ")", ";", "$", "layout", "=", "$", "this", "->", "layoutSetup", "->", "getLayoutSetup", "(", "$", "gridElement", "[", "'tx_gridelements_backend_layout'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "layout", ")", ")", "{", "if", "(", "is_array", "(", "$", "layout", "[", "'allowed'", "]", ")", "&&", "is_array", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", ")", "&&", "!", "empty", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", ")", ")", "{", "$", "allowed", "=", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", ";", "}", "if", "(", "is_array", "(", "$", "layout", "[", "'disallowed'", "]", ")", "&&", "is_array", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", ")", "&&", "!", "empty", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", ")", ")", "{", "$", "disallowed", "=", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", ";", "}", "}", "if", "(", "isset", "(", "$", "layout", ")", "&&", "(", "!", "empty", "(", "$", "allowed", ")", "||", "!", "empty", "(", "$", "disallowed", ")", ")", ")", "{", "foreach", "(", "$", "items", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "(", "!", "empty", "(", "$", "allowed", ")", "&&", "!", "isset", "(", "$", "allowed", "[", "'*'", "]", ")", "&&", "!", "isset", "(", "$", "allowed", "[", "$", "item", "[", "1", "]", "]", ")", ")", "||", "(", "!", "empty", "(", "$", "disallowed", ")", "&&", "(", "isset", "(", "$", "disallowed", "[", "'*'", "]", ")", "||", "isset", "(", "$", "disallowed", "[", "$", "item", "[", "1", "]", "]", ")", ")", ")", ")", "{", "unset", "(", "$", "items", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
Checks if a CType is allowed in this particular page or grid column - only this one column defines the allowed CTypes regardless of any parent column @param array $items The items of the current CType list @param int $pageId The id of the page we are currently working on @param int $pageColumn The page column the element is a child of @param int $gridContainerId The ID of the current container @param int $gridColumn The grid column the element is a child of
[ "Checks", "if", "a", "CType", "is", "allowed", "in", "this", "particular", "page", "or", "grid", "column", "-", "only", "this", "one", "column", "defines", "the", "allowed", "CTypes", "regardless", "of", "any", "parent", "column" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/ItemsProcFuncs/CTypeList.php#L82-L121
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.main
public function main($content = '', $conf = []) { // first we have to take care of possible flexform values containing additional information // that is not available via DB relations. It will be added as "virtual" key to the existing data Array // so that you can easily get the values with TypoScript $this->initPluginFlexForm(); $this->getPluginFlexFormData(); $this->languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); // now we have to find the children of this grid container regardless of their column // so we can get them within a single DB query instead of doing a query per column // but we will only fetch those columns that are used by the current grid layout if ($this->languageAspect->getLegacyOverlayType() && $this->cObj->data['l18n_parent']) { $element = $this->cObj->data['l18n_parent']; } else { $element = $this->cObj->data['uid']; } $pid = $this->cObj->data['pid']; $layout = $this->cObj->data['tx_gridelements_backend_layout']; /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class); $layoutSetup->init($this->cObj->data['pid'], $conf); $availableColumns = $layoutSetup->getLayoutColumns($layout); $csvColumns = ltrim(str_replace('-2,-1', '', $availableColumns['CSV']), ','); $this->getChildren($element, $pid, $csvColumns); // and we have to determine the frontend setup related to the backend layout record which is assigned to this container $typoScriptSetup = $layoutSetup->getTypoScriptSetup($layout); // we need a sorting columns array to make sure that the columns are rendered in the order // that they have been created in the grid wizard but still be able to get all children // within just one SELECT query $sortColumns = explode(',', $csvColumns); $this->renderChildrenIntoParentColumns($typoScriptSetup, $sortColumns); unset($children); unset($sortColumns); // if there are any columns available, we can go on with the render process if (!empty($this->cObj->data['tx_gridelements_view_columns'])) { $content = $this->renderColumnsIntoParentGrid($typoScriptSetup); } unset($availableColumns); unset($csvColumns); if (isset($typoScriptSetup['jsFooterInline']) || isset($typoScriptSetup['jsFooterInline.'])) { $jsFooterInline = isset($typoScriptSetup['jsFooterInline.']) ? $this->cObj->stdWrap( $typoScriptSetup['jsFooterInline'], $typoScriptSetup['jsFooterInline.'] ) : $typoScriptSetup['jsFooterInline']; $this->getPageRenderer()->addJsFooterInlineCode('gridelements' . $element, $jsFooterInline); unset($typoScriptSetup['jsFooterInline']); unset($typoScriptSetup['jsFooterInline.']); } // finally we can unset the columns setup as well and apply stdWrap operations to the overall result // before returning the content unset($typoScriptSetup['columns.']); return !empty($typoScriptSetup) ? $this->cObj->stdWrap($content, $typoScriptSetup) : $content; }
php
public function main($content = '', $conf = []) { // first we have to take care of possible flexform values containing additional information // that is not available via DB relations. It will be added as "virtual" key to the existing data Array // so that you can easily get the values with TypoScript $this->initPluginFlexForm(); $this->getPluginFlexFormData(); $this->languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); // now we have to find the children of this grid container regardless of their column // so we can get them within a single DB query instead of doing a query per column // but we will only fetch those columns that are used by the current grid layout if ($this->languageAspect->getLegacyOverlayType() && $this->cObj->data['l18n_parent']) { $element = $this->cObj->data['l18n_parent']; } else { $element = $this->cObj->data['uid']; } $pid = $this->cObj->data['pid']; $layout = $this->cObj->data['tx_gridelements_backend_layout']; /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class); $layoutSetup->init($this->cObj->data['pid'], $conf); $availableColumns = $layoutSetup->getLayoutColumns($layout); $csvColumns = ltrim(str_replace('-2,-1', '', $availableColumns['CSV']), ','); $this->getChildren($element, $pid, $csvColumns); // and we have to determine the frontend setup related to the backend layout record which is assigned to this container $typoScriptSetup = $layoutSetup->getTypoScriptSetup($layout); // we need a sorting columns array to make sure that the columns are rendered in the order // that they have been created in the grid wizard but still be able to get all children // within just one SELECT query $sortColumns = explode(',', $csvColumns); $this->renderChildrenIntoParentColumns($typoScriptSetup, $sortColumns); unset($children); unset($sortColumns); // if there are any columns available, we can go on with the render process if (!empty($this->cObj->data['tx_gridelements_view_columns'])) { $content = $this->renderColumnsIntoParentGrid($typoScriptSetup); } unset($availableColumns); unset($csvColumns); if (isset($typoScriptSetup['jsFooterInline']) || isset($typoScriptSetup['jsFooterInline.'])) { $jsFooterInline = isset($typoScriptSetup['jsFooterInline.']) ? $this->cObj->stdWrap( $typoScriptSetup['jsFooterInline'], $typoScriptSetup['jsFooterInline.'] ) : $typoScriptSetup['jsFooterInline']; $this->getPageRenderer()->addJsFooterInlineCode('gridelements' . $element, $jsFooterInline); unset($typoScriptSetup['jsFooterInline']); unset($typoScriptSetup['jsFooterInline.']); } // finally we can unset the columns setup as well and apply stdWrap operations to the overall result // before returning the content unset($typoScriptSetup['columns.']); return !empty($typoScriptSetup) ? $this->cObj->stdWrap($content, $typoScriptSetup) : $content; }
[ "public", "function", "main", "(", "$", "content", "=", "''", ",", "$", "conf", "=", "[", "]", ")", "{", "// first we have to take care of possible flexform values containing additional information", "// that is not available via DB relations. It will be added as \"virtual\" key to the existing data Array", "// so that you can easily get the values with TypoScript", "$", "this", "->", "initPluginFlexForm", "(", ")", ";", "$", "this", "->", "getPluginFlexFormData", "(", ")", ";", "$", "this", "->", "languageAspect", "=", "GeneralUtility", "::", "makeInstance", "(", "Context", "::", "class", ")", "->", "getAspect", "(", "'language'", ")", ";", "// now we have to find the children of this grid container regardless of their column", "// so we can get them within a single DB query instead of doing a query per column", "// but we will only fetch those columns that are used by the current grid layout", "if", "(", "$", "this", "->", "languageAspect", "->", "getLegacyOverlayType", "(", ")", "&&", "$", "this", "->", "cObj", "->", "data", "[", "'l18n_parent'", "]", ")", "{", "$", "element", "=", "$", "this", "->", "cObj", "->", "data", "[", "'l18n_parent'", "]", ";", "}", "else", "{", "$", "element", "=", "$", "this", "->", "cObj", "->", "data", "[", "'uid'", "]", ";", "}", "$", "pid", "=", "$", "this", "->", "cObj", "->", "data", "[", "'pid'", "]", ";", "$", "layout", "=", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_backend_layout'", "]", ";", "/** @var LayoutSetup $layoutSetup */", "$", "layoutSetup", "=", "GeneralUtility", "::", "makeInstance", "(", "LayoutSetup", "::", "class", ")", ";", "$", "layoutSetup", "->", "init", "(", "$", "this", "->", "cObj", "->", "data", "[", "'pid'", "]", ",", "$", "conf", ")", ";", "$", "availableColumns", "=", "$", "layoutSetup", "->", "getLayoutColumns", "(", "$", "layout", ")", ";", "$", "csvColumns", "=", "ltrim", "(", "str_replace", "(", "'-2,-1'", ",", "''", ",", "$", "availableColumns", "[", "'CSV'", "]", ")", ",", "','", ")", ";", "$", "this", "->", "getChildren", "(", "$", "element", ",", "$", "pid", ",", "$", "csvColumns", ")", ";", "// and we have to determine the frontend setup related to the backend layout record which is assigned to this container", "$", "typoScriptSetup", "=", "$", "layoutSetup", "->", "getTypoScriptSetup", "(", "$", "layout", ")", ";", "// we need a sorting columns array to make sure that the columns are rendered in the order", "// that they have been created in the grid wizard but still be able to get all children", "// within just one SELECT query", "$", "sortColumns", "=", "explode", "(", "','", ",", "$", "csvColumns", ")", ";", "$", "this", "->", "renderChildrenIntoParentColumns", "(", "$", "typoScriptSetup", ",", "$", "sortColumns", ")", ";", "unset", "(", "$", "children", ")", ";", "unset", "(", "$", "sortColumns", ")", ";", "// if there are any columns available, we can go on with the render process", "if", "(", "!", "empty", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_columns'", "]", ")", ")", "{", "$", "content", "=", "$", "this", "->", "renderColumnsIntoParentGrid", "(", "$", "typoScriptSetup", ")", ";", "}", "unset", "(", "$", "availableColumns", ")", ";", "unset", "(", "$", "csvColumns", ")", ";", "if", "(", "isset", "(", "$", "typoScriptSetup", "[", "'jsFooterInline'", "]", ")", "||", "isset", "(", "$", "typoScriptSetup", "[", "'jsFooterInline.'", "]", ")", ")", "{", "$", "jsFooterInline", "=", "isset", "(", "$", "typoScriptSetup", "[", "'jsFooterInline.'", "]", ")", "?", "$", "this", "->", "cObj", "->", "stdWrap", "(", "$", "typoScriptSetup", "[", "'jsFooterInline'", "]", ",", "$", "typoScriptSetup", "[", "'jsFooterInline.'", "]", ")", ":", "$", "typoScriptSetup", "[", "'jsFooterInline'", "]", ";", "$", "this", "->", "getPageRenderer", "(", ")", "->", "addJsFooterInlineCode", "(", "'gridelements'", ".", "$", "element", ",", "$", "jsFooterInline", ")", ";", "unset", "(", "$", "typoScriptSetup", "[", "'jsFooterInline'", "]", ")", ";", "unset", "(", "$", "typoScriptSetup", "[", "'jsFooterInline.'", "]", ")", ";", "}", "// finally we can unset the columns setup as well and apply stdWrap operations to the overall result", "// before returning the content", "unset", "(", "$", "typoScriptSetup", "[", "'columns.'", "]", ")", ";", "return", "!", "empty", "(", "$", "typoScriptSetup", ")", "?", "$", "this", "->", "cObj", "->", "stdWrap", "(", "$", "content", ",", "$", "typoScriptSetup", ")", ":", "$", "content", ";", "}" ]
The main method of the PlugIn @param string $content The PlugIn content @param array $conf The PlugIn configuration @return string The content that is displayed on the website
[ "The", "main", "method", "of", "the", "PlugIn" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L83-L148
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.initPluginFlexForm
public function initPluginFlexForm($field = 'pi_flexform', &$child = null) { // Converting flexform data into array: if (!empty($child)) { if (!is_array($child[$field]) && $child[$field]) { $child[$field] = GeneralUtility::xml2array($child[$field]); if (!is_array($child[$field])) { $child[$field] = []; } } } elseif (!is_array($this->cObj->data[$field]) && $this->cObj->data[$field]) { $this->cObj->data[$field] = GeneralUtility::xml2array($this->cObj->data[$field]); if (!is_array($this->cObj->data[$field])) { $this->cObj->data[$field] = []; } } }
php
public function initPluginFlexForm($field = 'pi_flexform', &$child = null) { // Converting flexform data into array: if (!empty($child)) { if (!is_array($child[$field]) && $child[$field]) { $child[$field] = GeneralUtility::xml2array($child[$field]); if (!is_array($child[$field])) { $child[$field] = []; } } } elseif (!is_array($this->cObj->data[$field]) && $this->cObj->data[$field]) { $this->cObj->data[$field] = GeneralUtility::xml2array($this->cObj->data[$field]); if (!is_array($this->cObj->data[$field])) { $this->cObj->data[$field] = []; } } }
[ "public", "function", "initPluginFlexForm", "(", "$", "field", "=", "'pi_flexform'", ",", "&", "$", "child", "=", "null", ")", "{", "// Converting flexform data into array:", "if", "(", "!", "empty", "(", "$", "child", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "child", "[", "$", "field", "]", ")", "&&", "$", "child", "[", "$", "field", "]", ")", "{", "$", "child", "[", "$", "field", "]", "=", "GeneralUtility", "::", "xml2array", "(", "$", "child", "[", "$", "field", "]", ")", ";", "if", "(", "!", "is_array", "(", "$", "child", "[", "$", "field", "]", ")", ")", "{", "$", "child", "[", "$", "field", "]", "=", "[", "]", ";", "}", "}", "}", "elseif", "(", "!", "is_array", "(", "$", "this", "->", "cObj", "->", "data", "[", "$", "field", "]", ")", "&&", "$", "this", "->", "cObj", "->", "data", "[", "$", "field", "]", ")", "{", "$", "this", "->", "cObj", "->", "data", "[", "$", "field", "]", "=", "GeneralUtility", "::", "xml2array", "(", "$", "this", "->", "cObj", "->", "data", "[", "$", "field", "]", ")", ";", "if", "(", "!", "is_array", "(", "$", "this", "->", "cObj", "->", "data", "[", "$", "field", "]", ")", ")", "{", "$", "this", "->", "cObj", "->", "data", "[", "$", "field", "]", "=", "[", "]", ";", "}", "}", "}" ]
Converts $this->cObj->data['pi_flexform'] from XML string to flexForm array. @param string $field Field name to convert @param array $child
[ "Converts", "$this", "-", ">", "cObj", "-", ">", "data", "[", "pi_flexform", "]", "from", "XML", "string", "to", "flexForm", "array", "." ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L156-L172
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getPluginFlexFormData
public function getPluginFlexFormData(&$child = []) { if (!empty($child)) { $cObjData = $child; } else { $cObjData = $this->cObj->data; } $pluginFlexForm = $cObjData['pi_flexform']; if (is_array($pluginFlexForm) && is_array($pluginFlexForm['data'])) { foreach ($pluginFlexForm['data'] as $sheet => $data) { if (is_array($data)) { foreach ((array)$data as $language => $value) { if (is_array($value)) { foreach ((array)$value as $key => $val) { $cObjData['flexform_' . $key] = $this->getFlexFormValue( $pluginFlexForm, $key, $sheet ); } } } } } } unset($pluginFlexForm); if (!empty($child)) { $child = $cObjData; } else { $this->cObj->data = $cObjData; } unset($cObjData); }
php
public function getPluginFlexFormData(&$child = []) { if (!empty($child)) { $cObjData = $child; } else { $cObjData = $this->cObj->data; } $pluginFlexForm = $cObjData['pi_flexform']; if (is_array($pluginFlexForm) && is_array($pluginFlexForm['data'])) { foreach ($pluginFlexForm['data'] as $sheet => $data) { if (is_array($data)) { foreach ((array)$data as $language => $value) { if (is_array($value)) { foreach ((array)$value as $key => $val) { $cObjData['flexform_' . $key] = $this->getFlexFormValue( $pluginFlexForm, $key, $sheet ); } } } } } } unset($pluginFlexForm); if (!empty($child)) { $child = $cObjData; } else { $this->cObj->data = $cObjData; } unset($cObjData); }
[ "public", "function", "getPluginFlexFormData", "(", "&", "$", "child", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "child", ")", ")", "{", "$", "cObjData", "=", "$", "child", ";", "}", "else", "{", "$", "cObjData", "=", "$", "this", "->", "cObj", "->", "data", ";", "}", "$", "pluginFlexForm", "=", "$", "cObjData", "[", "'pi_flexform'", "]", ";", "if", "(", "is_array", "(", "$", "pluginFlexForm", ")", "&&", "is_array", "(", "$", "pluginFlexForm", "[", "'data'", "]", ")", ")", "{", "foreach", "(", "$", "pluginFlexForm", "[", "'data'", "]", "as", "$", "sheet", "=>", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "data", "as", "$", "language", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "cObjData", "[", "'flexform_'", ".", "$", "key", "]", "=", "$", "this", "->", "getFlexFormValue", "(", "$", "pluginFlexForm", ",", "$", "key", ",", "$", "sheet", ")", ";", "}", "}", "}", "}", "}", "}", "unset", "(", "$", "pluginFlexForm", ")", ";", "if", "(", "!", "empty", "(", "$", "child", ")", ")", "{", "$", "child", "=", "$", "cObjData", ";", "}", "else", "{", "$", "this", "->", "cObj", "->", "data", "=", "$", "cObjData", ";", "}", "unset", "(", "$", "cObjData", ")", ";", "}" ]
fetches values from the grid flexform and assigns them to virtual fields in the data array @param array $child
[ "fetches", "values", "from", "the", "grid", "flexform", "and", "assigns", "them", "to", "virtual", "fields", "in", "the", "data", "array" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L178-L215
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getFlexFormValue
public function getFlexFormValue( $T3FlexForm_array, $fieldName, $sheet = 'sDEF', $language = 'lDEF', $value = 'vDEF' ) { $sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array['data'][$sheet][$language] : ''; if (is_array($sheetArray)) { return $this->getFlexFormValueFromSheetArray($sheetArray, explode('/', $fieldName), $value); } return ''; }
php
public function getFlexFormValue( $T3FlexForm_array, $fieldName, $sheet = 'sDEF', $language = 'lDEF', $value = 'vDEF' ) { $sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array['data'][$sheet][$language] : ''; if (is_array($sheetArray)) { return $this->getFlexFormValueFromSheetArray($sheetArray, explode('/', $fieldName), $value); } return ''; }
[ "public", "function", "getFlexFormValue", "(", "$", "T3FlexForm_array", ",", "$", "fieldName", ",", "$", "sheet", "=", "'sDEF'", ",", "$", "language", "=", "'lDEF'", ",", "$", "value", "=", "'vDEF'", ")", "{", "$", "sheetArray", "=", "is_array", "(", "$", "T3FlexForm_array", ")", "?", "$", "T3FlexForm_array", "[", "'data'", "]", "[", "$", "sheet", "]", "[", "$", "language", "]", ":", "''", ";", "if", "(", "is_array", "(", "$", "sheetArray", ")", ")", "{", "return", "$", "this", "->", "getFlexFormValueFromSheetArray", "(", "$", "sheetArray", ",", "explode", "(", "'/'", ",", "$", "fieldName", ")", ",", "$", "value", ")", ";", "}", "return", "''", ";", "}" ]
Return value from somewhere inside a FlexForm structure @param array $T3FlexForm_array FlexForm data @param string $fieldName Field name to extract. Can be given like "test/el/2/test/el/field_templateObject" where each part will dig a level deeper in the FlexForm data. @param string $sheet Sheet pointer, eg. "sDEF" @param string $language Language pointer, eg. "lDEF" @param string $value Value pointer, eg. "vDEF" @return string The content.
[ "Return", "value", "from", "somewhere", "inside", "a", "FlexForm", "structure" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L228-L240
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getFlexFormValueFromSheetArray
public function getFlexFormValueFromSheetArray($sheetArray, $fieldNameArr, $value) { $tempArr = $sheetArray; foreach ($fieldNameArr as $k => $v) { $checkedValue = MathUtility::canBeInterpretedAsInteger($v); if ($checkedValue) { if (is_array($tempArr)) { $c = 0; foreach ($tempArr as $values) { if ($c == $v) { $tempArr = $values; break; } $c++; } } } else { $tempArr = $tempArr[$v]; } } if (is_array($tempArr)) { if (is_array($tempArr['el'])) { $out = $this->getFlexformSectionsRecursively($tempArr['el'], $value); } else { $out = $tempArr[$value]; } } else { $out = $tempArr; } return $out; }
php
public function getFlexFormValueFromSheetArray($sheetArray, $fieldNameArr, $value) { $tempArr = $sheetArray; foreach ($fieldNameArr as $k => $v) { $checkedValue = MathUtility::canBeInterpretedAsInteger($v); if ($checkedValue) { if (is_array($tempArr)) { $c = 0; foreach ($tempArr as $values) { if ($c == $v) { $tempArr = $values; break; } $c++; } } } else { $tempArr = $tempArr[$v]; } } if (is_array($tempArr)) { if (is_array($tempArr['el'])) { $out = $this->getFlexformSectionsRecursively($tempArr['el'], $value); } else { $out = $tempArr[$value]; } } else { $out = $tempArr; } return $out; }
[ "public", "function", "getFlexFormValueFromSheetArray", "(", "$", "sheetArray", ",", "$", "fieldNameArr", ",", "$", "value", ")", "{", "$", "tempArr", "=", "$", "sheetArray", ";", "foreach", "(", "$", "fieldNameArr", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "checkedValue", "=", "MathUtility", "::", "canBeInterpretedAsInteger", "(", "$", "v", ")", ";", "if", "(", "$", "checkedValue", ")", "{", "if", "(", "is_array", "(", "$", "tempArr", ")", ")", "{", "$", "c", "=", "0", ";", "foreach", "(", "$", "tempArr", "as", "$", "values", ")", "{", "if", "(", "$", "c", "==", "$", "v", ")", "{", "$", "tempArr", "=", "$", "values", ";", "break", ";", "}", "$", "c", "++", ";", "}", "}", "}", "else", "{", "$", "tempArr", "=", "$", "tempArr", "[", "$", "v", "]", ";", "}", "}", "if", "(", "is_array", "(", "$", "tempArr", ")", ")", "{", "if", "(", "is_array", "(", "$", "tempArr", "[", "'el'", "]", ")", ")", "{", "$", "out", "=", "$", "this", "->", "getFlexformSectionsRecursively", "(", "$", "tempArr", "[", "'el'", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "out", "=", "$", "tempArr", "[", "$", "value", "]", ";", "}", "}", "else", "{", "$", "out", "=", "$", "tempArr", ";", "}", "return", "$", "out", ";", "}" ]
Returns part of $sheetArray pointed to by the keys in $fieldNameArray @param array $sheetArray Multidimensional array, typically FlexForm contents @param array $fieldNameArr Array where each value points to a key in the FlexForms content - the input array will have the value returned pointed to by these keys. All integer keys will not take their integer counterparts, but rather traverse the current position in the array an return element number X (whether this is right behavior is not settled yet...) @param string $value Value for outermost key, typ. "vDEF" depending on language. @return mixed The value, typ. string. @see pi_getFlexFormValue()
[ "Returns", "part", "of", "$sheetArray", "pointed", "to", "by", "the", "keys", "in", "$fieldNameArray" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L252-L283
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getFlexformSectionsRecursively
public function getFlexformSectionsRecursively($dataArr, $valueKey = 'vDEF') { $out = []; foreach ($dataArr as $k => $el) { if (is_array($el) && is_array($el['el'])) { $out[$k] = $this->getFlexformSectionsRecursively($el['el']); } elseif (is_array($el) && is_array($el['data']['el'])) { $out[] = $this->getFlexformSectionsRecursively($el['data']['el']); } elseif (isset($el[$valueKey])) { $out[$k] = $el[$valueKey]; } } return $out; }
php
public function getFlexformSectionsRecursively($dataArr, $valueKey = 'vDEF') { $out = []; foreach ($dataArr as $k => $el) { if (is_array($el) && is_array($el['el'])) { $out[$k] = $this->getFlexformSectionsRecursively($el['el']); } elseif (is_array($el) && is_array($el['data']['el'])) { $out[] = $this->getFlexformSectionsRecursively($el['data']['el']); } elseif (isset($el[$valueKey])) { $out[$k] = $el[$valueKey]; } } return $out; }
[ "public", "function", "getFlexformSectionsRecursively", "(", "$", "dataArr", ",", "$", "valueKey", "=", "'vDEF'", ")", "{", "$", "out", "=", "[", "]", ";", "foreach", "(", "$", "dataArr", "as", "$", "k", "=>", "$", "el", ")", "{", "if", "(", "is_array", "(", "$", "el", ")", "&&", "is_array", "(", "$", "el", "[", "'el'", "]", ")", ")", "{", "$", "out", "[", "$", "k", "]", "=", "$", "this", "->", "getFlexformSectionsRecursively", "(", "$", "el", "[", "'el'", "]", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "el", ")", "&&", "is_array", "(", "$", "el", "[", "'data'", "]", "[", "'el'", "]", ")", ")", "{", "$", "out", "[", "]", "=", "$", "this", "->", "getFlexformSectionsRecursively", "(", "$", "el", "[", "'data'", "]", "[", "'el'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "el", "[", "$", "valueKey", "]", ")", ")", "{", "$", "out", "[", "$", "k", "]", "=", "$", "el", "[", "$", "valueKey", "]", ";", "}", "}", "return", "$", "out", ";", "}" ]
@param $dataArr @param string $valueKey @return array
[ "@param", "$dataArr", "@param", "string", "$valueKey" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L291-L305
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getChildren
public function getChildren($element = 0, $pid = 0, $csvColumns = '') { if (!$element || $csvColumns === '') { return; } $csvColumns = GeneralUtility::intExplode(',', $csvColumns); $queryBuilder = $this->getQueryBuilder(); $where = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT) ), $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) ), $queryBuilder->expr()->in( 'sys_language_uid', $queryBuilder->createNamedParameter([-1, 0], Connection::PARAM_INT_ARRAY) ) ); $translationOverlay = []; $translationNoOverlay = []; if ($this->languageAspect->getContentId() > 0) { if ($this->languageAspect->getLegacyOverlayType()) { if (isset($this->cObj->data['_LOCALIZED_UID']) && $this->cObj->data['_LOCALIZED_UID'] !== 0) { $element = (int)$this->cObj->data['_LOCALIZED_UID']; } if ($element) { $translationOverlay = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq('tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT)), $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) ), $queryBuilder->expr()->in( 'sys_language_uid', $queryBuilder->createNamedParameter( [-1, $this->languageAspect->getContentId()], Connection::PARAM_INT_ARRAY ) ), $queryBuilder->expr()->eq( 'l18n_parent', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ) ); } } else { if ($element) { $translationNoOverlay = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT) ), $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) ), $queryBuilder->expr()->in( 'sys_language_uid', $queryBuilder->createNamedParameter( [-1, $this->languageAspect->getContentId()], Connection::PARAM_INT_ARRAY ) ) ); } } } $children = $queryBuilder ->select('*') ->from('tt_content') ->where( $queryBuilder->expr()->orX( $where, $translationOverlay, $translationNoOverlay ) ) ->orderBy('sorting', 'ASC') ->execute(); $this->cObj->data['tx_gridelements_view_children'] = []; while ($child = $children->fetch()) { // Versioning preview: $sorting = $child['sorting']; $this->getTSFE()->sys_page->versionOL('tt_content', $child, true); // Language overlay: if (is_array($child)) { $child['sorting'] = $sorting; if ($this->languageAspect->getLegacyOverlayType()) { $child = $this->getTSFE()->sys_page->getRecordOverlay( 'tt_content', $child, $this->languageAspect->getContentId(), $this->languageAspect->getLegacyOverlayType() ); } if (!empty($child)) { if ($child['CType'] === 'gridelements_pi1') { $this->initPluginFlexForm('pi_flexform', $child); $this->getPluginFlexFormData($child); } $this->cObj->data['tx_gridelements_view_children'][] = $child; unset($child); } } } $compareFunction = function ($child_a, $child_b) { if ($child_a['sorting'] > $child_b['sorting']) { return 1; } if ($child_a['sorting'] === $child_b['sorting']) { return 0; } return -1; }; usort($this->cObj->data['tx_gridelements_view_children'], $compareFunction); }
php
public function getChildren($element = 0, $pid = 0, $csvColumns = '') { if (!$element || $csvColumns === '') { return; } $csvColumns = GeneralUtility::intExplode(',', $csvColumns); $queryBuilder = $this->getQueryBuilder(); $where = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT) ), $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) ), $queryBuilder->expr()->in( 'sys_language_uid', $queryBuilder->createNamedParameter([-1, 0], Connection::PARAM_INT_ARRAY) ) ); $translationOverlay = []; $translationNoOverlay = []; if ($this->languageAspect->getContentId() > 0) { if ($this->languageAspect->getLegacyOverlayType()) { if (isset($this->cObj->data['_LOCALIZED_UID']) && $this->cObj->data['_LOCALIZED_UID'] !== 0) { $element = (int)$this->cObj->data['_LOCALIZED_UID']; } if ($element) { $translationOverlay = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq('tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT)), $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) ), $queryBuilder->expr()->in( 'sys_language_uid', $queryBuilder->createNamedParameter( [-1, $this->languageAspect->getContentId()], Connection::PARAM_INT_ARRAY ) ), $queryBuilder->expr()->eq( 'l18n_parent', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) ) ); } } else { if ($element) { $translationNoOverlay = $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$element, \PDO::PARAM_INT) ), $queryBuilder->expr()->neq('colPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT)), $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pid, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($csvColumns, Connection::PARAM_INT_ARRAY) ), $queryBuilder->expr()->in( 'sys_language_uid', $queryBuilder->createNamedParameter( [-1, $this->languageAspect->getContentId()], Connection::PARAM_INT_ARRAY ) ) ); } } } $children = $queryBuilder ->select('*') ->from('tt_content') ->where( $queryBuilder->expr()->orX( $where, $translationOverlay, $translationNoOverlay ) ) ->orderBy('sorting', 'ASC') ->execute(); $this->cObj->data['tx_gridelements_view_children'] = []; while ($child = $children->fetch()) { // Versioning preview: $sorting = $child['sorting']; $this->getTSFE()->sys_page->versionOL('tt_content', $child, true); // Language overlay: if (is_array($child)) { $child['sorting'] = $sorting; if ($this->languageAspect->getLegacyOverlayType()) { $child = $this->getTSFE()->sys_page->getRecordOverlay( 'tt_content', $child, $this->languageAspect->getContentId(), $this->languageAspect->getLegacyOverlayType() ); } if (!empty($child)) { if ($child['CType'] === 'gridelements_pi1') { $this->initPluginFlexForm('pi_flexform', $child); $this->getPluginFlexFormData($child); } $this->cObj->data['tx_gridelements_view_children'][] = $child; unset($child); } } } $compareFunction = function ($child_a, $child_b) { if ($child_a['sorting'] > $child_b['sorting']) { return 1; } if ($child_a['sorting'] === $child_b['sorting']) { return 0; } return -1; }; usort($this->cObj->data['tx_gridelements_view_children'], $compareFunction); }
[ "public", "function", "getChildren", "(", "$", "element", "=", "0", ",", "$", "pid", "=", "0", ",", "$", "csvColumns", "=", "''", ")", "{", "if", "(", "!", "$", "element", "||", "$", "csvColumns", "===", "''", ")", "{", "return", ";", "}", "$", "csvColumns", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "csvColumns", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "where", "=", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'tx_gridelements_container'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "element", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "neq", "(", "'colPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "-", "2", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "pid", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'tx_gridelements_columns'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "csvColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'sys_language_uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "[", "-", "1", ",", "0", "]", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ";", "$", "translationOverlay", "=", "[", "]", ";", "$", "translationNoOverlay", "=", "[", "]", ";", "if", "(", "$", "this", "->", "languageAspect", "->", "getContentId", "(", ")", ">", "0", ")", "{", "if", "(", "$", "this", "->", "languageAspect", "->", "getLegacyOverlayType", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cObj", "->", "data", "[", "'_LOCALIZED_UID'", "]", ")", "&&", "$", "this", "->", "cObj", "->", "data", "[", "'_LOCALIZED_UID'", "]", "!==", "0", ")", "{", "$", "element", "=", "(", "int", ")", "$", "this", "->", "cObj", "->", "data", "[", "'_LOCALIZED_UID'", "]", ";", "}", "if", "(", "$", "element", ")", "{", "$", "translationOverlay", "=", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'tx_gridelements_container'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "element", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "neq", "(", "'colPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "-", "2", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "pid", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'tx_gridelements_columns'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "csvColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'sys_language_uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "[", "-", "1", ",", "$", "this", "->", "languageAspect", "->", "getContentId", "(", ")", "]", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'l18n_parent'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "0", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", ";", "}", "}", "else", "{", "if", "(", "$", "element", ")", "{", "$", "translationNoOverlay", "=", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'tx_gridelements_container'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "element", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "neq", "(", "'colPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "-", "2", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "pid", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'tx_gridelements_columns'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "csvColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'sys_language_uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "[", "-", "1", ",", "$", "this", "->", "languageAspect", "->", "getContentId", "(", ")", "]", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ";", "}", "}", "}", "$", "children", "=", "$", "queryBuilder", "->", "select", "(", "'*'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "orX", "(", "$", "where", ",", "$", "translationOverlay", ",", "$", "translationNoOverlay", ")", ")", "->", "orderBy", "(", "'sorting'", ",", "'ASC'", ")", "->", "execute", "(", ")", ";", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_children'", "]", "=", "[", "]", ";", "while", "(", "$", "child", "=", "$", "children", "->", "fetch", "(", ")", ")", "{", "// Versioning preview:", "$", "sorting", "=", "$", "child", "[", "'sorting'", "]", ";", "$", "this", "->", "getTSFE", "(", ")", "->", "sys_page", "->", "versionOL", "(", "'tt_content'", ",", "$", "child", ",", "true", ")", ";", "// Language overlay:", "if", "(", "is_array", "(", "$", "child", ")", ")", "{", "$", "child", "[", "'sorting'", "]", "=", "$", "sorting", ";", "if", "(", "$", "this", "->", "languageAspect", "->", "getLegacyOverlayType", "(", ")", ")", "{", "$", "child", "=", "$", "this", "->", "getTSFE", "(", ")", "->", "sys_page", "->", "getRecordOverlay", "(", "'tt_content'", ",", "$", "child", ",", "$", "this", "->", "languageAspect", "->", "getContentId", "(", ")", ",", "$", "this", "->", "languageAspect", "->", "getLegacyOverlayType", "(", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "child", ")", ")", "{", "if", "(", "$", "child", "[", "'CType'", "]", "===", "'gridelements_pi1'", ")", "{", "$", "this", "->", "initPluginFlexForm", "(", "'pi_flexform'", ",", "$", "child", ")", ";", "$", "this", "->", "getPluginFlexFormData", "(", "$", "child", ")", ";", "}", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_children'", "]", "[", "]", "=", "$", "child", ";", "unset", "(", "$", "child", ")", ";", "}", "}", "}", "$", "compareFunction", "=", "function", "(", "$", "child_a", ",", "$", "child_b", ")", "{", "if", "(", "$", "child_a", "[", "'sorting'", "]", ">", "$", "child_b", "[", "'sorting'", "]", ")", "{", "return", "1", ";", "}", "if", "(", "$", "child_a", "[", "'sorting'", "]", "===", "$", "child_b", "[", "'sorting'", "]", ")", "{", "return", "0", ";", "}", "return", "-", "1", ";", "}", ";", "usort", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_children'", "]", ",", "$", "compareFunction", ")", ";", "}" ]
fetches all available children for a certain grid container @param int $element The uid of the grid container @param int $pid @param string $csvColumns A list of available column IDs
[ "fetches", "all", "available", "children", "for", "a", "certain", "grid", "container" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L322-L461
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getQueryBuilder
public function getQueryBuilder() { /** @var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tt_content'); $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); return $queryBuilder; }
php
public function getQueryBuilder() { /** @var $queryBuilder QueryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tt_content'); $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class)); return $queryBuilder; }
[ "public", "function", "getQueryBuilder", "(", ")", "{", "/** @var $queryBuilder QueryBuilder */", "$", "queryBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getQueryBuilderForTable", "(", "'tt_content'", ")", ";", "$", "queryBuilder", "->", "setRestrictions", "(", "GeneralUtility", "::", "makeInstance", "(", "FrontendRestrictionContainer", "::", "class", ")", ")", ";", "return", "$", "queryBuilder", ";", "}" ]
getter for queryBuilder @return QueryBuilder queryBuilder
[ "getter", "for", "queryBuilder" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L468-L475
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.renderChildrenIntoParentColumns
public function renderChildrenIntoParentColumns($typoScriptSetup = [], $sortColumns = []) { // first we have to make a backup copy of the original data array // and we have to modify the depth counter to avoid stopping too early $currentParentGrid = $this->copyCurrentParentGrid(); $columns = $this->getUsedColumns($sortColumns); $parentGridData = $this->getParentGridData($currentParentGrid['data']); $parentGridData['tx_gridelements_view_columns'] = $columns; $counter = !empty($this->cObj->data['tx_gridelements_view_children']); $parentRecordNumbers = []; $this->getTSFE()->cObjectDepthCounter += $counter; // each of the children will now be rendered separately and the output will be added to it's particular column $rawColumns = []; if (!empty($this->cObj->data['tx_gridelements_view_children'])) { foreach ($this->cObj->data['tx_gridelements_view_children'] as $child) { $rawColumns[$child['tx_gridelements_columns']][] = $child; $renderedChild = $child; $this->renderChildIntoParentColumn( $columns, $renderedChild, $parentGridData, $parentRecordNumbers, $typoScriptSetup ); $currentParentGrid['data']['tx_gridelements_view_child_' . $child['uid']] = $renderedChild; unset($renderedChild); } $currentParentGrid['data']['tx_gridelements_view_raw_columns'] = $rawColumns; } // now we can reset the depth counter and the data array so that the element will behave just as usual // it will just contain the additional tx_gridelements_view section with the prerendered elements // it is important to do this before any stdWrap functions are applied to the grid container // since they will depend on the original data $this->getTSFE()->cObjectDepthCounter -= $counter; $this->cObj->currentRecord = $currentParentGrid['record']; $this->cObj->data = $currentParentGrid['data']; $this->cObj->parentRecordNumber = $currentParentGrid['parentRecordNumber']; if (!empty($sortColumns)) { $this->cObj->data['tx_gridelements_view_columns'] = []; foreach ($sortColumns as $sortKey) { $sortKey = trim($sortKey); if (isset($parentGridData['tx_gridelements_view_columns'][$sortKey])) { $this->cObj->data['tx_gridelements_view_columns'][$sortKey] = $parentGridData['tx_gridelements_view_columns'][$sortKey]; } } } unset($parentGridData); unset($currentParentGrid); }
php
public function renderChildrenIntoParentColumns($typoScriptSetup = [], $sortColumns = []) { // first we have to make a backup copy of the original data array // and we have to modify the depth counter to avoid stopping too early $currentParentGrid = $this->copyCurrentParentGrid(); $columns = $this->getUsedColumns($sortColumns); $parentGridData = $this->getParentGridData($currentParentGrid['data']); $parentGridData['tx_gridelements_view_columns'] = $columns; $counter = !empty($this->cObj->data['tx_gridelements_view_children']); $parentRecordNumbers = []; $this->getTSFE()->cObjectDepthCounter += $counter; // each of the children will now be rendered separately and the output will be added to it's particular column $rawColumns = []; if (!empty($this->cObj->data['tx_gridelements_view_children'])) { foreach ($this->cObj->data['tx_gridelements_view_children'] as $child) { $rawColumns[$child['tx_gridelements_columns']][] = $child; $renderedChild = $child; $this->renderChildIntoParentColumn( $columns, $renderedChild, $parentGridData, $parentRecordNumbers, $typoScriptSetup ); $currentParentGrid['data']['tx_gridelements_view_child_' . $child['uid']] = $renderedChild; unset($renderedChild); } $currentParentGrid['data']['tx_gridelements_view_raw_columns'] = $rawColumns; } // now we can reset the depth counter and the data array so that the element will behave just as usual // it will just contain the additional tx_gridelements_view section with the prerendered elements // it is important to do this before any stdWrap functions are applied to the grid container // since they will depend on the original data $this->getTSFE()->cObjectDepthCounter -= $counter; $this->cObj->currentRecord = $currentParentGrid['record']; $this->cObj->data = $currentParentGrid['data']; $this->cObj->parentRecordNumber = $currentParentGrid['parentRecordNumber']; if (!empty($sortColumns)) { $this->cObj->data['tx_gridelements_view_columns'] = []; foreach ($sortColumns as $sortKey) { $sortKey = trim($sortKey); if (isset($parentGridData['tx_gridelements_view_columns'][$sortKey])) { $this->cObj->data['tx_gridelements_view_columns'][$sortKey] = $parentGridData['tx_gridelements_view_columns'][$sortKey]; } } } unset($parentGridData); unset($currentParentGrid); }
[ "public", "function", "renderChildrenIntoParentColumns", "(", "$", "typoScriptSetup", "=", "[", "]", ",", "$", "sortColumns", "=", "[", "]", ")", "{", "// first we have to make a backup copy of the original data array", "// and we have to modify the depth counter to avoid stopping too early", "$", "currentParentGrid", "=", "$", "this", "->", "copyCurrentParentGrid", "(", ")", ";", "$", "columns", "=", "$", "this", "->", "getUsedColumns", "(", "$", "sortColumns", ")", ";", "$", "parentGridData", "=", "$", "this", "->", "getParentGridData", "(", "$", "currentParentGrid", "[", "'data'", "]", ")", ";", "$", "parentGridData", "[", "'tx_gridelements_view_columns'", "]", "=", "$", "columns", ";", "$", "counter", "=", "!", "empty", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_children'", "]", ")", ";", "$", "parentRecordNumbers", "=", "[", "]", ";", "$", "this", "->", "getTSFE", "(", ")", "->", "cObjectDepthCounter", "+=", "$", "counter", ";", "// each of the children will now be rendered separately and the output will be added to it's particular column", "$", "rawColumns", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_children'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_children'", "]", "as", "$", "child", ")", "{", "$", "rawColumns", "[", "$", "child", "[", "'tx_gridelements_columns'", "]", "]", "[", "]", "=", "$", "child", ";", "$", "renderedChild", "=", "$", "child", ";", "$", "this", "->", "renderChildIntoParentColumn", "(", "$", "columns", ",", "$", "renderedChild", ",", "$", "parentGridData", ",", "$", "parentRecordNumbers", ",", "$", "typoScriptSetup", ")", ";", "$", "currentParentGrid", "[", "'data'", "]", "[", "'tx_gridelements_view_child_'", ".", "$", "child", "[", "'uid'", "]", "]", "=", "$", "renderedChild", ";", "unset", "(", "$", "renderedChild", ")", ";", "}", "$", "currentParentGrid", "[", "'data'", "]", "[", "'tx_gridelements_view_raw_columns'", "]", "=", "$", "rawColumns", ";", "}", "// now we can reset the depth counter and the data array so that the element will behave just as usual", "// it will just contain the additional tx_gridelements_view section with the prerendered elements", "// it is important to do this before any stdWrap functions are applied to the grid container", "// since they will depend on the original data", "$", "this", "->", "getTSFE", "(", ")", "->", "cObjectDepthCounter", "-=", "$", "counter", ";", "$", "this", "->", "cObj", "->", "currentRecord", "=", "$", "currentParentGrid", "[", "'record'", "]", ";", "$", "this", "->", "cObj", "->", "data", "=", "$", "currentParentGrid", "[", "'data'", "]", ";", "$", "this", "->", "cObj", "->", "parentRecordNumber", "=", "$", "currentParentGrid", "[", "'parentRecordNumber'", "]", ";", "if", "(", "!", "empty", "(", "$", "sortColumns", ")", ")", "{", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_columns'", "]", "=", "[", "]", ";", "foreach", "(", "$", "sortColumns", "as", "$", "sortKey", ")", "{", "$", "sortKey", "=", "trim", "(", "$", "sortKey", ")", ";", "if", "(", "isset", "(", "$", "parentGridData", "[", "'tx_gridelements_view_columns'", "]", "[", "$", "sortKey", "]", ")", ")", "{", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_columns'", "]", "[", "$", "sortKey", "]", "=", "$", "parentGridData", "[", "'tx_gridelements_view_columns'", "]", "[", "$", "sortKey", "]", ";", "}", "}", "}", "unset", "(", "$", "parentGridData", ")", ";", "unset", "(", "$", "currentParentGrid", ")", ";", "}" ]
renders the children of the grid container and puts them into their respective columns @param array $typoScriptSetup @param array $sortColumns An Array of column positions within the grid container in the order they got in the grid setup
[ "renders", "the", "children", "of", "the", "grid", "container", "and", "puts", "them", "into", "their", "respective", "columns" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L484-L539
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getUsedColumns
public function getUsedColumns($sortColumns = []) { $columns = []; // we need the array values as keys if (!empty($sortColumns)) { foreach ($sortColumns as $column_number) { $columns[$column_number] = ''; } } return $columns; }
php
public function getUsedColumns($sortColumns = []) { $columns = []; // we need the array values as keys if (!empty($sortColumns)) { foreach ($sortColumns as $column_number) { $columns[$column_number] = ''; } } return $columns; }
[ "public", "function", "getUsedColumns", "(", "$", "sortColumns", "=", "[", "]", ")", "{", "$", "columns", "=", "[", "]", ";", "// we need the array values as keys", "if", "(", "!", "empty", "(", "$", "sortColumns", ")", ")", "{", "foreach", "(", "$", "sortColumns", "as", "$", "column_number", ")", "{", "$", "columns", "[", "$", "column_number", "]", "=", "''", ";", "}", "}", "return", "$", "columns", ";", "}" ]
@param array $sortColumns @return array
[ "@param", "array", "$sortColumns" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L558-L568
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.getParentGridData
public function getParentGridData($data = []) { // filter out existing superfluous keys to reduce memory load // String comparisons are way too expensive, so we go for unset within some loops if (!empty($data['tx_gridelements_view_children'])) { foreach ($data['tx_gridelements_view_children'] as $child) { unset($data['tx_gridelements_view_child_' . $child['uid']]); } } if (!empty($data['tx_gridelements_view_columns'])) { foreach ($data['tx_gridelements_view_columns'] as $column => $content) { unset($data['tx_gridelements_view_column_' . $column]); } } unset($data['tx_gridelements_view_children']); unset($data['tx_gridelements_view_columns']); // Set parent grid data for the first time $parentGridData = $this->setParentGridData($data); // Now we can remove any parentgrid_parentgrid_ keys if (!empty($parentGridData)) { foreach ($parentGridData as $key => $value) { unset($data[$key]); } } // Set parentgrid data for the first time return $this->setParentGridData($data); }
php
public function getParentGridData($data = []) { // filter out existing superfluous keys to reduce memory load // String comparisons are way too expensive, so we go for unset within some loops if (!empty($data['tx_gridelements_view_children'])) { foreach ($data['tx_gridelements_view_children'] as $child) { unset($data['tx_gridelements_view_child_' . $child['uid']]); } } if (!empty($data['tx_gridelements_view_columns'])) { foreach ($data['tx_gridelements_view_columns'] as $column => $content) { unset($data['tx_gridelements_view_column_' . $column]); } } unset($data['tx_gridelements_view_children']); unset($data['tx_gridelements_view_columns']); // Set parent grid data for the first time $parentGridData = $this->setParentGridData($data); // Now we can remove any parentgrid_parentgrid_ keys if (!empty($parentGridData)) { foreach ($parentGridData as $key => $value) { unset($data[$key]); } } // Set parentgrid data for the first time return $this->setParentGridData($data); }
[ "public", "function", "getParentGridData", "(", "$", "data", "=", "[", "]", ")", "{", "// filter out existing superfluous keys to reduce memory load", "// String comparisons are way too expensive, so we go for unset within some loops", "if", "(", "!", "empty", "(", "$", "data", "[", "'tx_gridelements_view_children'", "]", ")", ")", "{", "foreach", "(", "$", "data", "[", "'tx_gridelements_view_children'", "]", "as", "$", "child", ")", "{", "unset", "(", "$", "data", "[", "'tx_gridelements_view_child_'", ".", "$", "child", "[", "'uid'", "]", "]", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "data", "[", "'tx_gridelements_view_columns'", "]", ")", ")", "{", "foreach", "(", "$", "data", "[", "'tx_gridelements_view_columns'", "]", "as", "$", "column", "=>", "$", "content", ")", "{", "unset", "(", "$", "data", "[", "'tx_gridelements_view_column_'", ".", "$", "column", "]", ")", ";", "}", "}", "unset", "(", "$", "data", "[", "'tx_gridelements_view_children'", "]", ")", ";", "unset", "(", "$", "data", "[", "'tx_gridelements_view_columns'", "]", ")", ";", "// Set parent grid data for the first time", "$", "parentGridData", "=", "$", "this", "->", "setParentGridData", "(", "$", "data", ")", ";", "// Now we can remove any parentgrid_parentgrid_ keys", "if", "(", "!", "empty", "(", "$", "parentGridData", ")", ")", "{", "foreach", "(", "$", "parentGridData", "as", "$", "key", "=>", "$", "value", ")", "{", "unset", "(", "$", "data", "[", "$", "key", "]", ")", ";", "}", "}", "// Set parentgrid data for the first time", "return", "$", "this", "->", "setParentGridData", "(", "$", "data", ")", ";", "}" ]
@param $data @return array
[ "@param", "$data" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L575-L605
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.setParentGridData
public function setParentGridData($data = []) { $parentGridData = []; foreach ($data as $key => $value) { $parentGridData['parentgrid_' . $key] = $value; } return $parentGridData; }
php
public function setParentGridData($data = []) { $parentGridData = []; foreach ($data as $key => $value) { $parentGridData['parentgrid_' . $key] = $value; } return $parentGridData; }
[ "public", "function", "setParentGridData", "(", "$", "data", "=", "[", "]", ")", "{", "$", "parentGridData", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "parentGridData", "[", "'parentgrid_'", ".", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "parentGridData", ";", "}" ]
@param array $data @return array
[ "@param", "array", "$data" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L612-L619
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.renderChildIntoParentColumn
public function renderChildIntoParentColumn( $columns, &$child, &$parentGridData, &$parentRecordNumbers, $typoScriptSetup = [] ) { $column_number = (int)$child['tx_gridelements_columns']; $columnKey = $column_number . '.'; $columnSetupKey = isset($typoScriptSetup['columns.'][$columnKey]) ? $columnKey : 'default.'; if ($child['uid'] <= 0) { return; } // update SYS_LASTCHANGED if necessary $this->cObj->lastChanged($child['tstamp']); $this->cObj->start(array_merge($child, $parentGridData), 'tt_content'); $parentRecordNumbers[$columnKey]++; $this->cObj->parentRecordNumber = $parentRecordNumbers[$columnKey]; // we render each child into the children key to provide them prerendered for usage with your own templating $child = $this->cObj->cObjGetSingle( $typoScriptSetup['columns.'][$columnSetupKey]['renderObj'], $typoScriptSetup['columns.'][$columnSetupKey]['renderObj.'] ); // then we assign the prerendered child to the appropriate column if (isset($columns[$column_number])) { $parentGridData['tx_gridelements_view_columns'][$column_number] .= $child; } }
php
public function renderChildIntoParentColumn( $columns, &$child, &$parentGridData, &$parentRecordNumbers, $typoScriptSetup = [] ) { $column_number = (int)$child['tx_gridelements_columns']; $columnKey = $column_number . '.'; $columnSetupKey = isset($typoScriptSetup['columns.'][$columnKey]) ? $columnKey : 'default.'; if ($child['uid'] <= 0) { return; } // update SYS_LASTCHANGED if necessary $this->cObj->lastChanged($child['tstamp']); $this->cObj->start(array_merge($child, $parentGridData), 'tt_content'); $parentRecordNumbers[$columnKey]++; $this->cObj->parentRecordNumber = $parentRecordNumbers[$columnKey]; // we render each child into the children key to provide them prerendered for usage with your own templating $child = $this->cObj->cObjGetSingle( $typoScriptSetup['columns.'][$columnSetupKey]['renderObj'], $typoScriptSetup['columns.'][$columnSetupKey]['renderObj.'] ); // then we assign the prerendered child to the appropriate column if (isset($columns[$column_number])) { $parentGridData['tx_gridelements_view_columns'][$column_number] .= $child; } }
[ "public", "function", "renderChildIntoParentColumn", "(", "$", "columns", ",", "&", "$", "child", ",", "&", "$", "parentGridData", ",", "&", "$", "parentRecordNumbers", ",", "$", "typoScriptSetup", "=", "[", "]", ")", "{", "$", "column_number", "=", "(", "int", ")", "$", "child", "[", "'tx_gridelements_columns'", "]", ";", "$", "columnKey", "=", "$", "column_number", ".", "'.'", ";", "$", "columnSetupKey", "=", "isset", "(", "$", "typoScriptSetup", "[", "'columns.'", "]", "[", "$", "columnKey", "]", ")", "?", "$", "columnKey", ":", "'default.'", ";", "if", "(", "$", "child", "[", "'uid'", "]", "<=", "0", ")", "{", "return", ";", "}", "// update SYS_LASTCHANGED if necessary", "$", "this", "->", "cObj", "->", "lastChanged", "(", "$", "child", "[", "'tstamp'", "]", ")", ";", "$", "this", "->", "cObj", "->", "start", "(", "array_merge", "(", "$", "child", ",", "$", "parentGridData", ")", ",", "'tt_content'", ")", ";", "$", "parentRecordNumbers", "[", "$", "columnKey", "]", "++", ";", "$", "this", "->", "cObj", "->", "parentRecordNumber", "=", "$", "parentRecordNumbers", "[", "$", "columnKey", "]", ";", "// we render each child into the children key to provide them prerendered for usage with your own templating", "$", "child", "=", "$", "this", "->", "cObj", "->", "cObjGetSingle", "(", "$", "typoScriptSetup", "[", "'columns.'", "]", "[", "$", "columnSetupKey", "]", "[", "'renderObj'", "]", ",", "$", "typoScriptSetup", "[", "'columns.'", "]", "[", "$", "columnSetupKey", "]", "[", "'renderObj.'", "]", ")", ";", "// then we assign the prerendered child to the appropriate column", "if", "(", "isset", "(", "$", "columns", "[", "$", "column_number", "]", ")", ")", "{", "$", "parentGridData", "[", "'tx_gridelements_view_columns'", "]", "[", "$", "column_number", "]", ".=", "$", "child", ";", "}", "}" ]
renders the columns of the grid container and returns the actual content @param array $columns @param array $child @param array $parentGridData @param array $parentRecordNumbers @param array $typoScriptSetup
[ "renders", "the", "columns", "of", "the", "grid", "container", "and", "returns", "the", "actual", "content" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L630-L660
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.renderColumnsIntoParentGrid
public function renderColumnsIntoParentGrid($setup = []) { if (empty($this->cObj->data['tx_gridelements_view_columns'])) { return ''; } $content = ''; foreach ($this->cObj->data['tx_gridelements_view_columns'] as $column => $columnContent) { // if there are any columns available, we have to determine the corresponding TS setup // and if there is none we are going to use the default setup $tempSetup = isset($setup['columns.'][$column . '.']) ? $setup['columns.'][$column . '.'] : $setup['columns.']['default.']; // now we just have to unset the renderObj // before applying the rest of the keys via the usual stdWrap operations unset($tempSetup['renderObj']); unset($tempSetup['renderObj.']); // we render each column into the column key to provide them prerendered for usage with your own templating $this->cObj->data['tx_gridelements_view_column_' . $column] = empty($tempSetup) ? $columnContent : $this->cObj->stdWrap($columnContent, $tempSetup); $content .= $this->cObj->data['tx_gridelements_view_column_' . $column]; } return $content; }
php
public function renderColumnsIntoParentGrid($setup = []) { if (empty($this->cObj->data['tx_gridelements_view_columns'])) { return ''; } $content = ''; foreach ($this->cObj->data['tx_gridelements_view_columns'] as $column => $columnContent) { // if there are any columns available, we have to determine the corresponding TS setup // and if there is none we are going to use the default setup $tempSetup = isset($setup['columns.'][$column . '.']) ? $setup['columns.'][$column . '.'] : $setup['columns.']['default.']; // now we just have to unset the renderObj // before applying the rest of the keys via the usual stdWrap operations unset($tempSetup['renderObj']); unset($tempSetup['renderObj.']); // we render each column into the column key to provide them prerendered for usage with your own templating $this->cObj->data['tx_gridelements_view_column_' . $column] = empty($tempSetup) ? $columnContent : $this->cObj->stdWrap($columnContent, $tempSetup); $content .= $this->cObj->data['tx_gridelements_view_column_' . $column]; } return $content; }
[ "public", "function", "renderColumnsIntoParentGrid", "(", "$", "setup", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_columns'", "]", ")", ")", "{", "return", "''", ";", "}", "$", "content", "=", "''", ";", "foreach", "(", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_columns'", "]", "as", "$", "column", "=>", "$", "columnContent", ")", "{", "// if there are any columns available, we have to determine the corresponding TS setup", "// and if there is none we are going to use the default setup", "$", "tempSetup", "=", "isset", "(", "$", "setup", "[", "'columns.'", "]", "[", "$", "column", ".", "'.'", "]", ")", "?", "$", "setup", "[", "'columns.'", "]", "[", "$", "column", ".", "'.'", "]", ":", "$", "setup", "[", "'columns.'", "]", "[", "'default.'", "]", ";", "// now we just have to unset the renderObj", "// before applying the rest of the keys via the usual stdWrap operations", "unset", "(", "$", "tempSetup", "[", "'renderObj'", "]", ")", ";", "unset", "(", "$", "tempSetup", "[", "'renderObj.'", "]", ")", ";", "// we render each column into the column key to provide them prerendered for usage with your own templating", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_column_'", ".", "$", "column", "]", "=", "empty", "(", "$", "tempSetup", ")", "?", "$", "columnContent", ":", "$", "this", "->", "cObj", "->", "stdWrap", "(", "$", "columnContent", ",", "$", "tempSetup", ")", ";", "$", "content", ".=", "$", "this", "->", "cObj", "->", "data", "[", "'tx_gridelements_view_column_'", ".", "$", "column", "]", ";", "}", "return", "$", "content", ";", "}" ]
renders the columns of the grid container and returns the actual content @param array $setup The adjusted setup of the grid container @return string $content The raw HTML output of the grid container before stdWrap functions will be applied to it
[ "renders", "the", "columns", "of", "the", "grid", "container", "and", "returns", "the", "actual", "content" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L669-L691
TYPO3-extensions/gridelements
Classes/Plugin/Gridelements.php
Gridelements.user_getTreeList
public function user_getTreeList() { $pidList = $this->getTSFE()->register['tt_content_shortcut_recursive'] ? $this->cObj->getTreeList( $this->cObj->data['uid'], $this->getTSFE()->register['tt_content_shortcut_recursive'] ) : ''; $this->getTSFE()->register['pidInList'] = trim($this->cObj->data['uid'] . ',' . $pidList, ','); }
php
public function user_getTreeList() { $pidList = $this->getTSFE()->register['tt_content_shortcut_recursive'] ? $this->cObj->getTreeList( $this->cObj->data['uid'], $this->getTSFE()->register['tt_content_shortcut_recursive'] ) : ''; $this->getTSFE()->register['pidInList'] = trim($this->cObj->data['uid'] . ',' . $pidList, ','); }
[ "public", "function", "user_getTreeList", "(", ")", "{", "$", "pidList", "=", "$", "this", "->", "getTSFE", "(", ")", "->", "register", "[", "'tt_content_shortcut_recursive'", "]", "?", "$", "this", "->", "cObj", "->", "getTreeList", "(", "$", "this", "->", "cObj", "->", "data", "[", "'uid'", "]", ",", "$", "this", "->", "getTSFE", "(", ")", "->", "register", "[", "'tt_content_shortcut_recursive'", "]", ")", ":", "''", ";", "$", "this", "->", "getTSFE", "(", ")", "->", "register", "[", "'pidInList'", "]", "=", "trim", "(", "$", "this", "->", "cObj", "->", "data", "[", "'uid'", "]", ".", "','", ".", "$", "pidList", ",", "','", ")", ";", "}" ]
renders a recursive pidList to reference content from a list of pages
[ "renders", "a", "recursive", "pidList", "to", "reference", "content", "from", "a", "list", "of", "pages" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Plugin/Gridelements.php#L707-L716
TYPO3-extensions/gridelements
Classes/Backend/ItemsProcFuncs/ColPosList.php
ColPosList.itemsProcFunc
public function itemsProcFunc(array &$params) { $this->init(); if ($params['row']['pid'] > 0) { $contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType']; $listType = is_array($params['row']['list_type']) ? $params['row']['list_type'][0] : $params['row']['list_type']; $gridType = is_array($params['row']['tx_gridelements_backend_layout']) ? $params['row']['tx_gridelements_backend_layout'][0] : $params['row']['tx_gridelements_backend_layout']; $params['items'] = $this->addColPosListLayoutItems( $params['row']['pid'], $params['items'], $contentType, $listType, $gridType, $params['row']['tx_gridelements_container'] ); } else { // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first $existingElement = BackendUtility::getRecordWSOL( 'tt_content', -((int)$params['row']['pid']), 'pid,CType,tx_gridelements_container' ); if ($existingElement['pid'] > 0) { $params['items'] = $this->addColPosListLayoutItems( $existingElement['pid'], $params['items'], $existingElement['CType'], $existingElement['list_type'], $existingElement['tx_gridelements_backend_layout'], $existingElement['tx_gridelements_container'] ); } } }
php
public function itemsProcFunc(array &$params) { $this->init(); if ($params['row']['pid'] > 0) { $contentType = is_array($params['row']['CType']) ? $params['row']['CType'][0] : $params['row']['CType']; $listType = is_array($params['row']['list_type']) ? $params['row']['list_type'][0] : $params['row']['list_type']; $gridType = is_array($params['row']['tx_gridelements_backend_layout']) ? $params['row']['tx_gridelements_backend_layout'][0] : $params['row']['tx_gridelements_backend_layout']; $params['items'] = $this->addColPosListLayoutItems( $params['row']['pid'], $params['items'], $contentType, $listType, $gridType, $params['row']['tx_gridelements_container'] ); } else { // negative uid_pid values indicate that the element has been inserted after an existing element // so there is no pid to get the backendLayout for and we have to get that first $existingElement = BackendUtility::getRecordWSOL( 'tt_content', -((int)$params['row']['pid']), 'pid,CType,tx_gridelements_container' ); if ($existingElement['pid'] > 0) { $params['items'] = $this->addColPosListLayoutItems( $existingElement['pid'], $params['items'], $existingElement['CType'], $existingElement['list_type'], $existingElement['tx_gridelements_backend_layout'], $existingElement['tx_gridelements_container'] ); } } }
[ "public", "function", "itemsProcFunc", "(", "array", "&", "$", "params", ")", "{", "$", "this", "->", "init", "(", ")", ";", "if", "(", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ">", "0", ")", "{", "$", "contentType", "=", "is_array", "(", "$", "params", "[", "'row'", "]", "[", "'CType'", "]", ")", "?", "$", "params", "[", "'row'", "]", "[", "'CType'", "]", "[", "0", "]", ":", "$", "params", "[", "'row'", "]", "[", "'CType'", "]", ";", "$", "listType", "=", "is_array", "(", "$", "params", "[", "'row'", "]", "[", "'list_type'", "]", ")", "?", "$", "params", "[", "'row'", "]", "[", "'list_type'", "]", "[", "0", "]", ":", "$", "params", "[", "'row'", "]", "[", "'list_type'", "]", ";", "$", "gridType", "=", "is_array", "(", "$", "params", "[", "'row'", "]", "[", "'tx_gridelements_backend_layout'", "]", ")", "?", "$", "params", "[", "'row'", "]", "[", "'tx_gridelements_backend_layout'", "]", "[", "0", "]", ":", "$", "params", "[", "'row'", "]", "[", "'tx_gridelements_backend_layout'", "]", ";", "$", "params", "[", "'items'", "]", "=", "$", "this", "->", "addColPosListLayoutItems", "(", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ",", "$", "params", "[", "'items'", "]", ",", "$", "contentType", ",", "$", "listType", ",", "$", "gridType", ",", "$", "params", "[", "'row'", "]", "[", "'tx_gridelements_container'", "]", ")", ";", "}", "else", "{", "// negative uid_pid values indicate that the element has been inserted after an existing element", "// so there is no pid to get the backendLayout for and we have to get that first", "$", "existingElement", "=", "BackendUtility", "::", "getRecordWSOL", "(", "'tt_content'", ",", "-", "(", "(", "int", ")", "$", "params", "[", "'row'", "]", "[", "'pid'", "]", ")", ",", "'pid,CType,tx_gridelements_container'", ")", ";", "if", "(", "$", "existingElement", "[", "'pid'", "]", ">", "0", ")", "{", "$", "params", "[", "'items'", "]", "=", "$", "this", "->", "addColPosListLayoutItems", "(", "$", "existingElement", "[", "'pid'", "]", ",", "$", "params", "[", "'items'", "]", ",", "$", "existingElement", "[", "'CType'", "]", ",", "$", "existingElement", "[", "'list_type'", "]", ",", "$", "existingElement", "[", "'tx_gridelements_backend_layout'", "]", ",", "$", "existingElement", "[", "'tx_gridelements_container'", "]", ")", ";", "}", "}", "}" ]
ItemProcFunc for colpos items @param array $params The array of parameters that is used to render the item list
[ "ItemProcFunc", "for", "colpos", "items" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/ItemsProcFuncs/ColPosList.php#L37-L71
TYPO3-extensions/gridelements
Classes/Backend/ItemsProcFuncs/ColPosList.php
ColPosList.addColPosListLayoutItems
protected function addColPosListLayoutItems( $pageId, array $items, $contentType = '', $listType = '', $gridType = '', $container = 0 ) { if (empty($container)) { $layout = $this->getSelectedBackendLayout($pageId); if ($layout) { if ($contentType !== '' && !empty($layout['__items'])) { foreach ($layout['__items'] as $itemKey => $itemArray) { $column = $itemArray[1]; if ( ( isset($layout['allowed'][$column]) && !isset($layout['allowed'][$column]['CType'][$contentType]) && !isset($layout['allowed'][$column]['CType']['*']) ) || ( !empty($listType) && isset($layout['allowed'][$column]) && isset($layout['allowed'][$column]['list_type']) && !isset($layout['allowed'][$column]['list_type'][$listType]) && !isset($layout['allowed'][$column]['list_type']['*']) ) || ( !empty($gridType) && isset($layout['allowed'][$column]) && isset($layout['allowed'][$column]['tx_gridelements_backend_layout']) && !isset($layout['allowed'][$column]['tx_gridelements_backend_layout'][$gridType]) && !isset($layout['allowed'][$column]['tx_gridelements_backend_layout']['*']) ) || ( isset($layout['disallowed'][$column]) && ( isset($layout['disallowed'][$column]['CType'][$contentType]) || isset($layout['disallowed'][$column]['CType']['*']) ) ) || ( !empty($listType) && isset($layout['disallowed'][$column]) && ( isset($layout['disallowed'][$column]['list_type'][$listType]) || isset($layout['disallowed'][$column]['list_type']['*']) ) ) || ( !empty($gridType) && isset($layout['disallowed'][$column]) && ( isset($layout['disallowed'][$column]['tx_gridelements_backend_layout'][$gridType]) || isset($layout['disallowed'][$column]['tx_gridelements_backend_layout']['*']) ) ) ) { unset($layout['__items'][$itemKey]); } } } if (!empty($layout['__items'])) { $items = $layout['__items']; } } } else { $items = []; $items[] = [ $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tt_content.tx_gridelements_container'), '-1', null, null, ]; } return $items; }
php
protected function addColPosListLayoutItems( $pageId, array $items, $contentType = '', $listType = '', $gridType = '', $container = 0 ) { if (empty($container)) { $layout = $this->getSelectedBackendLayout($pageId); if ($layout) { if ($contentType !== '' && !empty($layout['__items'])) { foreach ($layout['__items'] as $itemKey => $itemArray) { $column = $itemArray[1]; if ( ( isset($layout['allowed'][$column]) && !isset($layout['allowed'][$column]['CType'][$contentType]) && !isset($layout['allowed'][$column]['CType']['*']) ) || ( !empty($listType) && isset($layout['allowed'][$column]) && isset($layout['allowed'][$column]['list_type']) && !isset($layout['allowed'][$column]['list_type'][$listType]) && !isset($layout['allowed'][$column]['list_type']['*']) ) || ( !empty($gridType) && isset($layout['allowed'][$column]) && isset($layout['allowed'][$column]['tx_gridelements_backend_layout']) && !isset($layout['allowed'][$column]['tx_gridelements_backend_layout'][$gridType]) && !isset($layout['allowed'][$column]['tx_gridelements_backend_layout']['*']) ) || ( isset($layout['disallowed'][$column]) && ( isset($layout['disallowed'][$column]['CType'][$contentType]) || isset($layout['disallowed'][$column]['CType']['*']) ) ) || ( !empty($listType) && isset($layout['disallowed'][$column]) && ( isset($layout['disallowed'][$column]['list_type'][$listType]) || isset($layout['disallowed'][$column]['list_type']['*']) ) ) || ( !empty($gridType) && isset($layout['disallowed'][$column]) && ( isset($layout['disallowed'][$column]['tx_gridelements_backend_layout'][$gridType]) || isset($layout['disallowed'][$column]['tx_gridelements_backend_layout']['*']) ) ) ) { unset($layout['__items'][$itemKey]); } } } if (!empty($layout['__items'])) { $items = $layout['__items']; } } } else { $items = []; $items[] = [ $this->languageService->sL('LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tt_content.tx_gridelements_container'), '-1', null, null, ]; } return $items; }
[ "protected", "function", "addColPosListLayoutItems", "(", "$", "pageId", ",", "array", "$", "items", ",", "$", "contentType", "=", "''", ",", "$", "listType", "=", "''", ",", "$", "gridType", "=", "''", ",", "$", "container", "=", "0", ")", "{", "if", "(", "empty", "(", "$", "container", ")", ")", "{", "$", "layout", "=", "$", "this", "->", "getSelectedBackendLayout", "(", "$", "pageId", ")", ";", "if", "(", "$", "layout", ")", "{", "if", "(", "$", "contentType", "!==", "''", "&&", "!", "empty", "(", "$", "layout", "[", "'__items'", "]", ")", ")", "{", "foreach", "(", "$", "layout", "[", "'__items'", "]", "as", "$", "itemKey", "=>", "$", "itemArray", ")", "{", "$", "column", "=", "$", "itemArray", "[", "1", "]", ";", "if", "(", "(", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", ")", "&&", "!", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", "[", "$", "contentType", "]", ")", "&&", "!", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", "[", "'*'", "]", ")", ")", "||", "(", "!", "empty", "(", "$", "listType", ")", "&&", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", ")", "&&", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'list_type'", "]", ")", "&&", "!", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'list_type'", "]", "[", "$", "listType", "]", ")", "&&", "!", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'list_type'", "]", "[", "'*'", "]", ")", ")", "||", "(", "!", "empty", "(", "$", "gridType", ")", "&&", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", ")", "&&", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'tx_gridelements_backend_layout'", "]", ")", "&&", "!", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'tx_gridelements_backend_layout'", "]", "[", "$", "gridType", "]", ")", "&&", "!", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "column", "]", "[", "'tx_gridelements_backend_layout'", "]", "[", "'*'", "]", ")", ")", "||", "(", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", ")", "&&", "(", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", "[", "$", "contentType", "]", ")", "||", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'CType'", "]", "[", "'*'", "]", ")", ")", ")", "||", "(", "!", "empty", "(", "$", "listType", ")", "&&", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", ")", "&&", "(", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'list_type'", "]", "[", "$", "listType", "]", ")", "||", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'list_type'", "]", "[", "'*'", "]", ")", ")", ")", "||", "(", "!", "empty", "(", "$", "gridType", ")", "&&", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", ")", "&&", "(", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'tx_gridelements_backend_layout'", "]", "[", "$", "gridType", "]", ")", "||", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "column", "]", "[", "'tx_gridelements_backend_layout'", "]", "[", "'*'", "]", ")", ")", ")", ")", "{", "unset", "(", "$", "layout", "[", "'__items'", "]", "[", "$", "itemKey", "]", ")", ";", "}", "}", "}", "if", "(", "!", "empty", "(", "$", "layout", "[", "'__items'", "]", ")", ")", "{", "$", "items", "=", "$", "layout", "[", "'__items'", "]", ";", "}", "}", "}", "else", "{", "$", "items", "=", "[", "]", ";", "$", "items", "[", "]", "=", "[", "$", "this", "->", "languageService", "->", "sL", "(", "'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tt_content.tx_gridelements_container'", ")", ",", "'-1'", ",", "null", ",", "null", ",", "]", ";", "}", "return", "$", "items", ";", "}" ]
Adds items to a colpos list @param int $pageId The uid of the page we are currently working on @param array $items The array of items before the action @param string $contentType The content type of the item holding the colPosList @param string $listType The list type of the item holding the colPosList @param string $gridType The grid type of the item holding the colPosList @param int $container @return array $items The ready made array of items
[ "Adds", "items", "to", "a", "colpos", "list" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Backend/ItemsProcFuncs/ColPosList.php#L85-L161
TYPO3-extensions/gridelements
Classes/Helper/Helper.php
Helper.getPidFromUid
public function getPidFromUid($uid = 0) { $queryBuilder = self::getQueryBuilder(); $triggerElement = $queryBuilder ->select('pid') ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'uid', $queryBuilder->createNamedParameter(abs($uid), \PDO::PARAM_INT) ) ) ->execute() ->fetch(); $pid = (int)$triggerElement['pid']; return is_array($triggerElement) && $pid ? $pid : 0; }
php
public function getPidFromUid($uid = 0) { $queryBuilder = self::getQueryBuilder(); $triggerElement = $queryBuilder ->select('pid') ->from('tt_content') ->where( $queryBuilder->expr()->eq( 'uid', $queryBuilder->createNamedParameter(abs($uid), \PDO::PARAM_INT) ) ) ->execute() ->fetch(); $pid = (int)$triggerElement['pid']; return is_array($triggerElement) && $pid ? $pid : 0; }
[ "public", "function", "getPidFromUid", "(", "$", "uid", "=", "0", ")", "{", "$", "queryBuilder", "=", "self", "::", "getQueryBuilder", "(", ")", ";", "$", "triggerElement", "=", "$", "queryBuilder", "->", "select", "(", "'pid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "abs", "(", "$", "uid", ")", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "execute", "(", ")", "->", "fetch", "(", ")", ";", "$", "pid", "=", "(", "int", ")", "$", "triggerElement", "[", "'pid'", "]", ";", "return", "is_array", "(", "$", "triggerElement", ")", "&&", "$", "pid", "?", "$", "pid", ":", "0", ";", "}" ]
converts tt_content uid into a pid @param int $uid the uid value of a tt_content record @return int
[ "converts", "tt_content", "uid", "into", "a", "pid" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Helper/Helper.php#L172-L188
TYPO3-extensions/gridelements
Classes/Helper/Helper.php
Helper.getSpecificIds
public function getSpecificIds(array $record) { $specificIds = []; $specificIds['uid'] = (int)$record['uid']; $specificIds['pid'] = (int)$record['pid']; if (self::getBackendUser()->workspace > 0 && !empty($record['t3ver_oid'])) { $specificIds['uid'] = (int)$record['t3ver_oid']; $specificIds['pid'] = -1; } return $specificIds; }
php
public function getSpecificIds(array $record) { $specificIds = []; $specificIds['uid'] = (int)$record['uid']; $specificIds['pid'] = (int)$record['pid']; if (self::getBackendUser()->workspace > 0 && !empty($record['t3ver_oid'])) { $specificIds['uid'] = (int)$record['t3ver_oid']; $specificIds['pid'] = -1; } return $specificIds; }
[ "public", "function", "getSpecificIds", "(", "array", "$", "record", ")", "{", "$", "specificIds", "=", "[", "]", ";", "$", "specificIds", "[", "'uid'", "]", "=", "(", "int", ")", "$", "record", "[", "'uid'", "]", ";", "$", "specificIds", "[", "'pid'", "]", "=", "(", "int", ")", "$", "record", "[", "'pid'", "]", ";", "if", "(", "self", "::", "getBackendUser", "(", ")", "->", "workspace", ">", "0", "&&", "!", "empty", "(", "$", "record", "[", "'t3ver_oid'", "]", ")", ")", "{", "$", "specificIds", "[", "'uid'", "]", "=", "(", "int", ")", "$", "record", "[", "'t3ver_oid'", "]", ";", "$", "specificIds", "[", "'pid'", "]", "=", "-", "1", ";", "}", "return", "$", "specificIds", ";", "}" ]
Gets the uid of a record depending on the current context. If in workspace mode, the overlay uid is used (if available), otherwise the regular uid is used. @param array $record Overlaid record data @return int[]
[ "Gets", "the", "uid", "of", "a", "record", "depending", "on", "the", "current", "context", ".", "If", "in", "workspace", "mode", "the", "overlay", "uid", "is", "used", "(", "if", "available", ")", "otherwise", "the", "regular", "uid", "is", "used", "." ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Helper/Helper.php#L216-L228
TYPO3-extensions/gridelements
Classes/DataProcessing/GridChildrenProcessor.php
GridChildrenProcessor.process
public function process( ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData ) { if ( $processedData['data']['CType'] !== 'gridelements_pi1' || empty($processorConfiguration) ) { return $processedData; } $this->containerProcessorConfiguration = $processorConfiguration[$processedData['data']['tx_gridelements_backend_layout'] . '.']; if (empty($this->containerProcessorConfiguration)) { $this->containerProcessorConfiguration = $processorConfiguration['default.']; if (empty($this->containerProcessorConfiguration)) { return $processedData; } } $this->contentObjectConfiguration = $contentObjectConfiguration; $this->processorConfiguration = $processorConfiguration; unset($processorConfiguration); $this->processedData = $processedData; unset($processedData); $targetVariableName = $cObj->stdWrapValue('as', $this->containerProcessorConfiguration, 'children'); $options = $this->containerProcessorConfiguration['options.'] ? $this->containerProcessorConfiguration['options.'] : []; $this->options = array_merge( $this->registeredOptions, array_intersect_key($options, $this->registeredOptions) ); unset($options); foreach ($this->options as $key => &$option) { $option = $cObj->stdWrapValue($key, $this->options, $option); } $this->checkOptions($this->processedData['data']); if (isset($this->processorConfiguration['recursive'])) { $this->options['recursive'] = $this->processorConfiguration['recursive']; } $queryConfiguration = [ 'pidInList' => (int)$cObj->data['pid'], 'orderBy' => ( $this->options['sortingField'] ? htmlspecialchars($this->options['sortingField']) : 'sorting' ) . ' ' . ( strtolower($this->options['sortingDirection']) === 'desc' ? 'DESC' : 'ASC' ), 'where' => 'tx_gridelements_container = ' . (int)$cObj->data['uid'], ]; $records = $cObj->getRecords('tt_content', $queryConfiguration); foreach ($records as $record) { $this->processChildRecord($record); } if ( $this->options['respectColumns'] || $this->options['respectRows'] ) { $this->processedData[$targetVariableName] = $this->sortRecordsIntoMatrix(); } else { $this->processedData[$targetVariableName] = $this->processedRecordVariables; } unset($this->processedRecordVariables); foreach ($this->options as $key => $option) { unset($this->options[$key . '.']); } $this->processedData['options'] = $this->options; unset($this->options); return $this->processedData; }
php
public function process( ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData ) { if ( $processedData['data']['CType'] !== 'gridelements_pi1' || empty($processorConfiguration) ) { return $processedData; } $this->containerProcessorConfiguration = $processorConfiguration[$processedData['data']['tx_gridelements_backend_layout'] . '.']; if (empty($this->containerProcessorConfiguration)) { $this->containerProcessorConfiguration = $processorConfiguration['default.']; if (empty($this->containerProcessorConfiguration)) { return $processedData; } } $this->contentObjectConfiguration = $contentObjectConfiguration; $this->processorConfiguration = $processorConfiguration; unset($processorConfiguration); $this->processedData = $processedData; unset($processedData); $targetVariableName = $cObj->stdWrapValue('as', $this->containerProcessorConfiguration, 'children'); $options = $this->containerProcessorConfiguration['options.'] ? $this->containerProcessorConfiguration['options.'] : []; $this->options = array_merge( $this->registeredOptions, array_intersect_key($options, $this->registeredOptions) ); unset($options); foreach ($this->options as $key => &$option) { $option = $cObj->stdWrapValue($key, $this->options, $option); } $this->checkOptions($this->processedData['data']); if (isset($this->processorConfiguration['recursive'])) { $this->options['recursive'] = $this->processorConfiguration['recursive']; } $queryConfiguration = [ 'pidInList' => (int)$cObj->data['pid'], 'orderBy' => ( $this->options['sortingField'] ? htmlspecialchars($this->options['sortingField']) : 'sorting' ) . ' ' . ( strtolower($this->options['sortingDirection']) === 'desc' ? 'DESC' : 'ASC' ), 'where' => 'tx_gridelements_container = ' . (int)$cObj->data['uid'], ]; $records = $cObj->getRecords('tt_content', $queryConfiguration); foreach ($records as $record) { $this->processChildRecord($record); } if ( $this->options['respectColumns'] || $this->options['respectRows'] ) { $this->processedData[$targetVariableName] = $this->sortRecordsIntoMatrix(); } else { $this->processedData[$targetVariableName] = $this->processedRecordVariables; } unset($this->processedRecordVariables); foreach ($this->options as $key => $option) { unset($this->options[$key . '.']); } $this->processedData['options'] = $this->options; unset($this->options); return $this->processedData; }
[ "public", "function", "process", "(", "ContentObjectRenderer", "$", "cObj", ",", "array", "$", "contentObjectConfiguration", ",", "array", "$", "processorConfiguration", ",", "array", "$", "processedData", ")", "{", "if", "(", "$", "processedData", "[", "'data'", "]", "[", "'CType'", "]", "!==", "'gridelements_pi1'", "||", "empty", "(", "$", "processorConfiguration", ")", ")", "{", "return", "$", "processedData", ";", "}", "$", "this", "->", "containerProcessorConfiguration", "=", "$", "processorConfiguration", "[", "$", "processedData", "[", "'data'", "]", "[", "'tx_gridelements_backend_layout'", "]", ".", "'.'", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "containerProcessorConfiguration", ")", ")", "{", "$", "this", "->", "containerProcessorConfiguration", "=", "$", "processorConfiguration", "[", "'default.'", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "containerProcessorConfiguration", ")", ")", "{", "return", "$", "processedData", ";", "}", "}", "$", "this", "->", "contentObjectConfiguration", "=", "$", "contentObjectConfiguration", ";", "$", "this", "->", "processorConfiguration", "=", "$", "processorConfiguration", ";", "unset", "(", "$", "processorConfiguration", ")", ";", "$", "this", "->", "processedData", "=", "$", "processedData", ";", "unset", "(", "$", "processedData", ")", ";", "$", "targetVariableName", "=", "$", "cObj", "->", "stdWrapValue", "(", "'as'", ",", "$", "this", "->", "containerProcessorConfiguration", ",", "'children'", ")", ";", "$", "options", "=", "$", "this", "->", "containerProcessorConfiguration", "[", "'options.'", "]", "?", "$", "this", "->", "containerProcessorConfiguration", "[", "'options.'", "]", ":", "[", "]", ";", "$", "this", "->", "options", "=", "array_merge", "(", "$", "this", "->", "registeredOptions", ",", "array_intersect_key", "(", "$", "options", ",", "$", "this", "->", "registeredOptions", ")", ")", ";", "unset", "(", "$", "options", ")", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "key", "=>", "&", "$", "option", ")", "{", "$", "option", "=", "$", "cObj", "->", "stdWrapValue", "(", "$", "key", ",", "$", "this", "->", "options", ",", "$", "option", ")", ";", "}", "$", "this", "->", "checkOptions", "(", "$", "this", "->", "processedData", "[", "'data'", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "processorConfiguration", "[", "'recursive'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'recursive'", "]", "=", "$", "this", "->", "processorConfiguration", "[", "'recursive'", "]", ";", "}", "$", "queryConfiguration", "=", "[", "'pidInList'", "=>", "(", "int", ")", "$", "cObj", "->", "data", "[", "'pid'", "]", ",", "'orderBy'", "=>", "(", "$", "this", "->", "options", "[", "'sortingField'", "]", "?", "htmlspecialchars", "(", "$", "this", "->", "options", "[", "'sortingField'", "]", ")", ":", "'sorting'", ")", ".", "' '", ".", "(", "strtolower", "(", "$", "this", "->", "options", "[", "'sortingDirection'", "]", ")", "===", "'desc'", "?", "'DESC'", ":", "'ASC'", ")", ",", "'where'", "=>", "'tx_gridelements_container = '", ".", "(", "int", ")", "$", "cObj", "->", "data", "[", "'uid'", "]", ",", "]", ";", "$", "records", "=", "$", "cObj", "->", "getRecords", "(", "'tt_content'", ",", "$", "queryConfiguration", ")", ";", "foreach", "(", "$", "records", "as", "$", "record", ")", "{", "$", "this", "->", "processChildRecord", "(", "$", "record", ")", ";", "}", "if", "(", "$", "this", "->", "options", "[", "'respectColumns'", "]", "||", "$", "this", "->", "options", "[", "'respectRows'", "]", ")", "{", "$", "this", "->", "processedData", "[", "$", "targetVariableName", "]", "=", "$", "this", "->", "sortRecordsIntoMatrix", "(", ")", ";", "}", "else", "{", "$", "this", "->", "processedData", "[", "$", "targetVariableName", "]", "=", "$", "this", "->", "processedRecordVariables", ";", "}", "unset", "(", "$", "this", "->", "processedRecordVariables", ")", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "key", "=>", "$", "option", ")", "{", "unset", "(", "$", "this", "->", "options", "[", "$", "key", ".", "'.'", "]", ")", ";", "}", "$", "this", "->", "processedData", "[", "'options'", "]", "=", "$", "this", "->", "options", ";", "unset", "(", "$", "this", "->", "options", ")", ";", "return", "$", "this", "->", "processedData", ";", "}" ]
Fetches records from the database as an array @param ContentObjectRenderer $cObj The data of the content element or page @param array $contentObjectConfiguration The configuration of Content Object @param array $processorConfiguration The configuration of this processor @param array $processedData Key/value store of processed data (e.g. to be passed to a Fluid View) @return array the processed data as key/value store
[ "Fetches", "records", "from", "the", "database", "as", "an", "array" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataProcessing/GridChildrenProcessor.php#L115-L189
TYPO3-extensions/gridelements
Classes/DataProcessing/GridChildrenProcessor.php
GridChildrenProcessor.processChildRecord
protected function processChildRecord($record) { $id = (int)$record['uid']; $this->checkOptions($record); /* @var $recordContentObjectRenderer ContentObjectRenderer */ $recordContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); $recordContentObjectRenderer->start($record, 'tt_content'); $this->processedRecordVariables[$id] = ['data' => $record]; if ( (int)$this->options['recursive'] > 0 && $record['CType'] === 'gridelements_pi1' && !empty($record['tx_gridelements_backend_layout']) ) { $childProcessorConfiguration = $this->containerProcessorConfiguration; $childProcessorConfiguration['dataProcessing.']['0.'] = $this->processorConfiguration; $childProcessorConfiguration['dataProcessing.']['0.']['recursive'] = (int)$this->options['recursive'] - 1; $childProcessorConfiguration['dataProcessing.']['0'] = 'GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor'; $this->processedRecordVariables[$id] = $this->contentDataProcessor->process( $recordContentObjectRenderer, $childProcessorConfiguration, $this->processedRecordVariables[$id] ); } else { $this->processedRecordVariables[$id] = $this->contentDataProcessor->process( $recordContentObjectRenderer, $this->containerProcessorConfiguration, $this->processedRecordVariables[$id] ); } }
php
protected function processChildRecord($record) { $id = (int)$record['uid']; $this->checkOptions($record); /* @var $recordContentObjectRenderer ContentObjectRenderer */ $recordContentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class); $recordContentObjectRenderer->start($record, 'tt_content'); $this->processedRecordVariables[$id] = ['data' => $record]; if ( (int)$this->options['recursive'] > 0 && $record['CType'] === 'gridelements_pi1' && !empty($record['tx_gridelements_backend_layout']) ) { $childProcessorConfiguration = $this->containerProcessorConfiguration; $childProcessorConfiguration['dataProcessing.']['0.'] = $this->processorConfiguration; $childProcessorConfiguration['dataProcessing.']['0.']['recursive'] = (int)$this->options['recursive'] - 1; $childProcessorConfiguration['dataProcessing.']['0'] = 'GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor'; $this->processedRecordVariables[$id] = $this->contentDataProcessor->process( $recordContentObjectRenderer, $childProcessorConfiguration, $this->processedRecordVariables[$id] ); } else { $this->processedRecordVariables[$id] = $this->contentDataProcessor->process( $recordContentObjectRenderer, $this->containerProcessorConfiguration, $this->processedRecordVariables[$id] ); } }
[ "protected", "function", "processChildRecord", "(", "$", "record", ")", "{", "$", "id", "=", "(", "int", ")", "$", "record", "[", "'uid'", "]", ";", "$", "this", "->", "checkOptions", "(", "$", "record", ")", ";", "/* @var $recordContentObjectRenderer ContentObjectRenderer */", "$", "recordContentObjectRenderer", "=", "GeneralUtility", "::", "makeInstance", "(", "ContentObjectRenderer", "::", "class", ")", ";", "$", "recordContentObjectRenderer", "->", "start", "(", "$", "record", ",", "'tt_content'", ")", ";", "$", "this", "->", "processedRecordVariables", "[", "$", "id", "]", "=", "[", "'data'", "=>", "$", "record", "]", ";", "if", "(", "(", "int", ")", "$", "this", "->", "options", "[", "'recursive'", "]", ">", "0", "&&", "$", "record", "[", "'CType'", "]", "===", "'gridelements_pi1'", "&&", "!", "empty", "(", "$", "record", "[", "'tx_gridelements_backend_layout'", "]", ")", ")", "{", "$", "childProcessorConfiguration", "=", "$", "this", "->", "containerProcessorConfiguration", ";", "$", "childProcessorConfiguration", "[", "'dataProcessing.'", "]", "[", "'0.'", "]", "=", "$", "this", "->", "processorConfiguration", ";", "$", "childProcessorConfiguration", "[", "'dataProcessing.'", "]", "[", "'0.'", "]", "[", "'recursive'", "]", "=", "(", "int", ")", "$", "this", "->", "options", "[", "'recursive'", "]", "-", "1", ";", "$", "childProcessorConfiguration", "[", "'dataProcessing.'", "]", "[", "'0'", "]", "=", "'GridElementsTeam\\Gridelements\\DataProcessing\\GridChildrenProcessor'", ";", "$", "this", "->", "processedRecordVariables", "[", "$", "id", "]", "=", "$", "this", "->", "contentDataProcessor", "->", "process", "(", "$", "recordContentObjectRenderer", ",", "$", "childProcessorConfiguration", ",", "$", "this", "->", "processedRecordVariables", "[", "$", "id", "]", ")", ";", "}", "else", "{", "$", "this", "->", "processedRecordVariables", "[", "$", "id", "]", "=", "$", "this", "->", "contentDataProcessor", "->", "process", "(", "$", "recordContentObjectRenderer", ",", "$", "this", "->", "containerProcessorConfiguration", ",", "$", "this", "->", "processedRecordVariables", "[", "$", "id", "]", ")", ";", "}", "}" ]
Processes child records recursively to get other children into the same array @param $record
[ "Processes", "child", "records", "recursively", "to", "get", "other", "children", "into", "the", "same", "array" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataProcessing/GridChildrenProcessor.php#L223-L252
TYPO3-extensions/gridelements
Classes/Wizard/GridelementsBackendLayoutWizardElement.php
GridelementsBackendLayoutWizardElement.init
protected function init() { if (empty($this->data['databaseRow']['config'])) { $rows = [[['colspan' => 1, 'rowspan' => 1, 'spanned' => 0, 'name' => '0x0']]]; $colCount = 1; $rowCount = 1; } else { /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init(0); if ($this->data['tableName'] === 'tx-gridelements_backend_layout') { $layoutId = $this->data['databaseRow']['alias'] ?: (int)$this->data['databaseRow']['uid']; $layout = $layoutSetup->getLayoutSetup($layoutId); } else { $parser = GeneralUtility::makeInstance(TypoScriptParser::class); $parser->parse($this->data['databaseRow']['config']); $layout = ['config' => $parser->setup['backend_layout.']]; if (!empty($layout['config']['rows.'])) { $columns = $layoutSetup->checkAvailableColumns($layout); if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) { $layout['columns'] = $columns; unset($layout['columns']['allowed']); $layout['allowed'] = $columns['allowed'] ?: []; $layout['disallowed'] = $columns['disallowed'] ?: []; $layout['maxitems'] = $columns['maxitems'] ?: []; } } } $rows = []; $colCount = $layout['config']['colCount']; $rowCount = $layout['config']['rowCount']; $dataRows = $layout['config']['rows.']; $spannedMatrix = []; for ($i = 1; $i <= $rowCount; $i++) { $cells = []; $row = array_shift($dataRows); $columns = $row['columns.']; for ($j = 1; $j <= $colCount; $j++) { $cellData = []; if (!$spannedMatrix[$i][$j]) { if (is_array($columns) && !empty($columns)) { $column = array_shift($columns); if (isset($column['colspan'])) { $cellData['colspan'] = (int)$column['colspan']; $columnColSpan = (int)$column['colspan']; if (isset($column['rowspan'])) { $columnRowSpan = (int)$column['rowspan']; for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) { for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) { $spannedMatrix[$i + $spanRow][$j + $spanColumn] = 1; } } } else { for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) { $spannedMatrix[$i][$j + $spanColumn] = 1; } } } else { $cellData['colspan'] = 1; if (isset($column['rowspan'])) { $columnRowSpan = (int)$column['rowspan']; for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) { $spannedMatrix[$i + $spanRow][$j] = 1; } } } if (isset($column['rowspan'])) { $cellData['rowspan'] = (int)$column['rowspan']; } else { $cellData['rowspan'] = 1; } if (isset($column['name'])) { $cellData['name'] = $column['name']; } if (isset($column['colPos'])) { $colPos = (int)$column['colPos']; $cellData['column'] = $colPos; $cellData['allowed'] = []; if (isset($layout['allowed'][$colPos])) { foreach ($layout['allowed'][$colPos] as $key => $valueArray) { $cellData['allowed'][$key] = implode(',', array_keys($valueArray)); } } $cellData['disallowed'] = []; if (isset($layout['disallowed'][$colPos])) { foreach ($layout['disallowed'][$colPos] as $key => $valueArray) { $cellData['disallowed'][$key] = implode(',', array_keys($valueArray)); } } $cellData['maxitems'] = (int)$layout['maxitems'][$colPos]; } } } else { $cellData = ['colspan' => 1, 'rowspan' => 1, 'spanned' => 1]; } $cells[] = $cellData; } $rows[] = $cells; if (!empty($spannedMatrix[$i]) && is_array($spannedMatrix[$i])) { ksort($spannedMatrix[$i]); } } } $this->rows = $rows; $this->colCount = (int)$colCount; $this->rowCount = (int)$rowCount; }
php
protected function init() { if (empty($this->data['databaseRow']['config'])) { $rows = [[['colspan' => 1, 'rowspan' => 1, 'spanned' => 0, 'name' => '0x0']]]; $colCount = 1; $rowCount = 1; } else { /** @var LayoutSetup $layoutSetup */ $layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init(0); if ($this->data['tableName'] === 'tx-gridelements_backend_layout') { $layoutId = $this->data['databaseRow']['alias'] ?: (int)$this->data['databaseRow']['uid']; $layout = $layoutSetup->getLayoutSetup($layoutId); } else { $parser = GeneralUtility::makeInstance(TypoScriptParser::class); $parser->parse($this->data['databaseRow']['config']); $layout = ['config' => $parser->setup['backend_layout.']]; if (!empty($layout['config']['rows.'])) { $columns = $layoutSetup->checkAvailableColumns($layout); if ($columns['allowed'] || $columns['disallowed'] || $columns['maxitems']) { $layout['columns'] = $columns; unset($layout['columns']['allowed']); $layout['allowed'] = $columns['allowed'] ?: []; $layout['disallowed'] = $columns['disallowed'] ?: []; $layout['maxitems'] = $columns['maxitems'] ?: []; } } } $rows = []; $colCount = $layout['config']['colCount']; $rowCount = $layout['config']['rowCount']; $dataRows = $layout['config']['rows.']; $spannedMatrix = []; for ($i = 1; $i <= $rowCount; $i++) { $cells = []; $row = array_shift($dataRows); $columns = $row['columns.']; for ($j = 1; $j <= $colCount; $j++) { $cellData = []; if (!$spannedMatrix[$i][$j]) { if (is_array($columns) && !empty($columns)) { $column = array_shift($columns); if (isset($column['colspan'])) { $cellData['colspan'] = (int)$column['colspan']; $columnColSpan = (int)$column['colspan']; if (isset($column['rowspan'])) { $columnRowSpan = (int)$column['rowspan']; for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) { for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) { $spannedMatrix[$i + $spanRow][$j + $spanColumn] = 1; } } } else { for ($spanColumn = 0; $spanColumn < $columnColSpan; $spanColumn++) { $spannedMatrix[$i][$j + $spanColumn] = 1; } } } else { $cellData['colspan'] = 1; if (isset($column['rowspan'])) { $columnRowSpan = (int)$column['rowspan']; for ($spanRow = 0; $spanRow < $columnRowSpan; $spanRow++) { $spannedMatrix[$i + $spanRow][$j] = 1; } } } if (isset($column['rowspan'])) { $cellData['rowspan'] = (int)$column['rowspan']; } else { $cellData['rowspan'] = 1; } if (isset($column['name'])) { $cellData['name'] = $column['name']; } if (isset($column['colPos'])) { $colPos = (int)$column['colPos']; $cellData['column'] = $colPos; $cellData['allowed'] = []; if (isset($layout['allowed'][$colPos])) { foreach ($layout['allowed'][$colPos] as $key => $valueArray) { $cellData['allowed'][$key] = implode(',', array_keys($valueArray)); } } $cellData['disallowed'] = []; if (isset($layout['disallowed'][$colPos])) { foreach ($layout['disallowed'][$colPos] as $key => $valueArray) { $cellData['disallowed'][$key] = implode(',', array_keys($valueArray)); } } $cellData['maxitems'] = (int)$layout['maxitems'][$colPos]; } } } else { $cellData = ['colspan' => 1, 'rowspan' => 1, 'spanned' => 1]; } $cells[] = $cellData; } $rows[] = $cells; if (!empty($spannedMatrix[$i]) && is_array($spannedMatrix[$i])) { ksort($spannedMatrix[$i]); } } } $this->rows = $rows; $this->colCount = (int)$colCount; $this->rowCount = (int)$rowCount; }
[ "protected", "function", "init", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "data", "[", "'databaseRow'", "]", "[", "'config'", "]", ")", ")", "{", "$", "rows", "=", "[", "[", "[", "'colspan'", "=>", "1", ",", "'rowspan'", "=>", "1", ",", "'spanned'", "=>", "0", ",", "'name'", "=>", "'0x0'", "]", "]", "]", ";", "$", "colCount", "=", "1", ";", "$", "rowCount", "=", "1", ";", "}", "else", "{", "/** @var LayoutSetup $layoutSetup */", "$", "layoutSetup", "=", "GeneralUtility", "::", "makeInstance", "(", "LayoutSetup", "::", "class", ")", "->", "init", "(", "0", ")", ";", "if", "(", "$", "this", "->", "data", "[", "'tableName'", "]", "===", "'tx-gridelements_backend_layout'", ")", "{", "$", "layoutId", "=", "$", "this", "->", "data", "[", "'databaseRow'", "]", "[", "'alias'", "]", "?", ":", "(", "int", ")", "$", "this", "->", "data", "[", "'databaseRow'", "]", "[", "'uid'", "]", ";", "$", "layout", "=", "$", "layoutSetup", "->", "getLayoutSetup", "(", "$", "layoutId", ")", ";", "}", "else", "{", "$", "parser", "=", "GeneralUtility", "::", "makeInstance", "(", "TypoScriptParser", "::", "class", ")", ";", "$", "parser", "->", "parse", "(", "$", "this", "->", "data", "[", "'databaseRow'", "]", "[", "'config'", "]", ")", ";", "$", "layout", "=", "[", "'config'", "=>", "$", "parser", "->", "setup", "[", "'backend_layout.'", "]", "]", ";", "if", "(", "!", "empty", "(", "$", "layout", "[", "'config'", "]", "[", "'rows.'", "]", ")", ")", "{", "$", "columns", "=", "$", "layoutSetup", "->", "checkAvailableColumns", "(", "$", "layout", ")", ";", "if", "(", "$", "columns", "[", "'allowed'", "]", "||", "$", "columns", "[", "'disallowed'", "]", "||", "$", "columns", "[", "'maxitems'", "]", ")", "{", "$", "layout", "[", "'columns'", "]", "=", "$", "columns", ";", "unset", "(", "$", "layout", "[", "'columns'", "]", "[", "'allowed'", "]", ")", ";", "$", "layout", "[", "'allowed'", "]", "=", "$", "columns", "[", "'allowed'", "]", "?", ":", "[", "]", ";", "$", "layout", "[", "'disallowed'", "]", "=", "$", "columns", "[", "'disallowed'", "]", "?", ":", "[", "]", ";", "$", "layout", "[", "'maxitems'", "]", "=", "$", "columns", "[", "'maxitems'", "]", "?", ":", "[", "]", ";", "}", "}", "}", "$", "rows", "=", "[", "]", ";", "$", "colCount", "=", "$", "layout", "[", "'config'", "]", "[", "'colCount'", "]", ";", "$", "rowCount", "=", "$", "layout", "[", "'config'", "]", "[", "'rowCount'", "]", ";", "$", "dataRows", "=", "$", "layout", "[", "'config'", "]", "[", "'rows.'", "]", ";", "$", "spannedMatrix", "=", "[", "]", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "rowCount", ";", "$", "i", "++", ")", "{", "$", "cells", "=", "[", "]", ";", "$", "row", "=", "array_shift", "(", "$", "dataRows", ")", ";", "$", "columns", "=", "$", "row", "[", "'columns.'", "]", ";", "for", "(", "$", "j", "=", "1", ";", "$", "j", "<=", "$", "colCount", ";", "$", "j", "++", ")", "{", "$", "cellData", "=", "[", "]", ";", "if", "(", "!", "$", "spannedMatrix", "[", "$", "i", "]", "[", "$", "j", "]", ")", "{", "if", "(", "is_array", "(", "$", "columns", ")", "&&", "!", "empty", "(", "$", "columns", ")", ")", "{", "$", "column", "=", "array_shift", "(", "$", "columns", ")", ";", "if", "(", "isset", "(", "$", "column", "[", "'colspan'", "]", ")", ")", "{", "$", "cellData", "[", "'colspan'", "]", "=", "(", "int", ")", "$", "column", "[", "'colspan'", "]", ";", "$", "columnColSpan", "=", "(", "int", ")", "$", "column", "[", "'colspan'", "]", ";", "if", "(", "isset", "(", "$", "column", "[", "'rowspan'", "]", ")", ")", "{", "$", "columnRowSpan", "=", "(", "int", ")", "$", "column", "[", "'rowspan'", "]", ";", "for", "(", "$", "spanRow", "=", "0", ";", "$", "spanRow", "<", "$", "columnRowSpan", ";", "$", "spanRow", "++", ")", "{", "for", "(", "$", "spanColumn", "=", "0", ";", "$", "spanColumn", "<", "$", "columnColSpan", ";", "$", "spanColumn", "++", ")", "{", "$", "spannedMatrix", "[", "$", "i", "+", "$", "spanRow", "]", "[", "$", "j", "+", "$", "spanColumn", "]", "=", "1", ";", "}", "}", "}", "else", "{", "for", "(", "$", "spanColumn", "=", "0", ";", "$", "spanColumn", "<", "$", "columnColSpan", ";", "$", "spanColumn", "++", ")", "{", "$", "spannedMatrix", "[", "$", "i", "]", "[", "$", "j", "+", "$", "spanColumn", "]", "=", "1", ";", "}", "}", "}", "else", "{", "$", "cellData", "[", "'colspan'", "]", "=", "1", ";", "if", "(", "isset", "(", "$", "column", "[", "'rowspan'", "]", ")", ")", "{", "$", "columnRowSpan", "=", "(", "int", ")", "$", "column", "[", "'rowspan'", "]", ";", "for", "(", "$", "spanRow", "=", "0", ";", "$", "spanRow", "<", "$", "columnRowSpan", ";", "$", "spanRow", "++", ")", "{", "$", "spannedMatrix", "[", "$", "i", "+", "$", "spanRow", "]", "[", "$", "j", "]", "=", "1", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "column", "[", "'rowspan'", "]", ")", ")", "{", "$", "cellData", "[", "'rowspan'", "]", "=", "(", "int", ")", "$", "column", "[", "'rowspan'", "]", ";", "}", "else", "{", "$", "cellData", "[", "'rowspan'", "]", "=", "1", ";", "}", "if", "(", "isset", "(", "$", "column", "[", "'name'", "]", ")", ")", "{", "$", "cellData", "[", "'name'", "]", "=", "$", "column", "[", "'name'", "]", ";", "}", "if", "(", "isset", "(", "$", "column", "[", "'colPos'", "]", ")", ")", "{", "$", "colPos", "=", "(", "int", ")", "$", "column", "[", "'colPos'", "]", ";", "$", "cellData", "[", "'column'", "]", "=", "$", "colPos", ";", "$", "cellData", "[", "'allowed'", "]", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "colPos", "]", ")", ")", "{", "foreach", "(", "$", "layout", "[", "'allowed'", "]", "[", "$", "colPos", "]", "as", "$", "key", "=>", "$", "valueArray", ")", "{", "$", "cellData", "[", "'allowed'", "]", "[", "$", "key", "]", "=", "implode", "(", "','", ",", "array_keys", "(", "$", "valueArray", ")", ")", ";", "}", "}", "$", "cellData", "[", "'disallowed'", "]", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "colPos", "]", ")", ")", "{", "foreach", "(", "$", "layout", "[", "'disallowed'", "]", "[", "$", "colPos", "]", "as", "$", "key", "=>", "$", "valueArray", ")", "{", "$", "cellData", "[", "'disallowed'", "]", "[", "$", "key", "]", "=", "implode", "(", "','", ",", "array_keys", "(", "$", "valueArray", ")", ")", ";", "}", "}", "$", "cellData", "[", "'maxitems'", "]", "=", "(", "int", ")", "$", "layout", "[", "'maxitems'", "]", "[", "$", "colPos", "]", ";", "}", "}", "}", "else", "{", "$", "cellData", "=", "[", "'colspan'", "=>", "1", ",", "'rowspan'", "=>", "1", ",", "'spanned'", "=>", "1", "]", ";", "}", "$", "cells", "[", "]", "=", "$", "cellData", ";", "}", "$", "rows", "[", "]", "=", "$", "cells", ";", "if", "(", "!", "empty", "(", "$", "spannedMatrix", "[", "$", "i", "]", ")", "&&", "is_array", "(", "$", "spannedMatrix", "[", "$", "i", "]", ")", ")", "{", "ksort", "(", "$", "spannedMatrix", "[", "$", "i", "]", ")", ";", "}", "}", "}", "$", "this", "->", "rows", "=", "$", "rows", ";", "$", "this", "->", "colCount", "=", "(", "int", ")", "$", "colCount", ";", "$", "this", "->", "rowCount", "=", "(", "int", ")", "$", "rowCount", ";", "}" ]
Initialize wizard
[ "Initialize", "wizard" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Wizard/GridelementsBackendLayoutWizardElement.php#L232-L337
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.manipulateWizardItems
public function manipulateWizardItems(&$wizardItems, &$parentObject) { if (!$this->getBackendUser()->checkAuthMode( 'tt_content', 'CType', 'gridelements_pi1', $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] )) { return; } $pageID = $parentObject->id; $this->init($pageID); $container = (int)GeneralUtility::_GP('tx_gridelements_container'); $column = (int)GeneralUtility::_GP('tx_gridelements_columns'); $allowed_GP = GeneralUtility::_GP('tx_gridelements_allowed'); $disallowed_GP = GeneralUtility::_GP('tx_gridelements_disallowed'); if (!empty($allowed_GP) || !empty($disallowed_GP)) { $allowed = json_decode(base64_decode($allowed_GP), true) ?: []; if (!empty($allowed)) { foreach ($allowed as &$item) { if (!is_array($item)) { $item = array_flip(GeneralUtility::trimExplode(',', $item)); } } } $disallowed = json_decode(base64_decode($disallowed_GP), true) ?: []; if (!empty($disallowed)) { foreach ($disallowed as &$item) { if (!is_array($item)) { $item = array_flip(GeneralUtility::trimExplode(',', $item)); } } } $this->removeDisallowedWizardItems($allowed, $disallowed, $wizardItems); } else { $allowed = null; $disallowed = null; } if (( empty($allowed['CType']) || isset($allowed['CType']['gridelements_pi1']) || isset($allowed['CType']['*']) ) && !isset($disallowed['tx_gridelements_backend_layout']['*']) ) { $allowedGridTypes = $allowed['tx_gridelements_backend_layout'] ?: []; $disallowedGridTypes = $disallowed['tx_gridelements_backend_layout'] ?: []; $excludeLayouts = $this->getExcludeLayouts($container, $parentObject); $gridItems = $this->layoutSetup->getLayoutWizardItems( $parentObject->colPos, $excludeLayouts, $allowedGridTypes, $disallowedGridTypes ); $this->addGridItemsToWizard($gridItems, $wizardItems); } $this->addGridValuesToWizardItems($wizardItems, $container, $column); $this->removeEmptyHeadersFromWizard($wizardItems); }
php
public function manipulateWizardItems(&$wizardItems, &$parentObject) { if (!$this->getBackendUser()->checkAuthMode( 'tt_content', 'CType', 'gridelements_pi1', $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'] )) { return; } $pageID = $parentObject->id; $this->init($pageID); $container = (int)GeneralUtility::_GP('tx_gridelements_container'); $column = (int)GeneralUtility::_GP('tx_gridelements_columns'); $allowed_GP = GeneralUtility::_GP('tx_gridelements_allowed'); $disallowed_GP = GeneralUtility::_GP('tx_gridelements_disallowed'); if (!empty($allowed_GP) || !empty($disallowed_GP)) { $allowed = json_decode(base64_decode($allowed_GP), true) ?: []; if (!empty($allowed)) { foreach ($allowed as &$item) { if (!is_array($item)) { $item = array_flip(GeneralUtility::trimExplode(',', $item)); } } } $disallowed = json_decode(base64_decode($disallowed_GP), true) ?: []; if (!empty($disallowed)) { foreach ($disallowed as &$item) { if (!is_array($item)) { $item = array_flip(GeneralUtility::trimExplode(',', $item)); } } } $this->removeDisallowedWizardItems($allowed, $disallowed, $wizardItems); } else { $allowed = null; $disallowed = null; } if (( empty($allowed['CType']) || isset($allowed['CType']['gridelements_pi1']) || isset($allowed['CType']['*']) ) && !isset($disallowed['tx_gridelements_backend_layout']['*']) ) { $allowedGridTypes = $allowed['tx_gridelements_backend_layout'] ?: []; $disallowedGridTypes = $disallowed['tx_gridelements_backend_layout'] ?: []; $excludeLayouts = $this->getExcludeLayouts($container, $parentObject); $gridItems = $this->layoutSetup->getLayoutWizardItems( $parentObject->colPos, $excludeLayouts, $allowedGridTypes, $disallowedGridTypes ); $this->addGridItemsToWizard($gridItems, $wizardItems); } $this->addGridValuesToWizardItems($wizardItems, $container, $column); $this->removeEmptyHeadersFromWizard($wizardItems); }
[ "public", "function", "manipulateWizardItems", "(", "&", "$", "wizardItems", ",", "&", "$", "parentObject", ")", "{", "if", "(", "!", "$", "this", "->", "getBackendUser", "(", ")", "->", "checkAuthMode", "(", "'tt_content'", ",", "'CType'", ",", "'gridelements_pi1'", ",", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'BE'", "]", "[", "'explicitADmode'", "]", ")", ")", "{", "return", ";", "}", "$", "pageID", "=", "$", "parentObject", "->", "id", ";", "$", "this", "->", "init", "(", "$", "pageID", ")", ";", "$", "container", "=", "(", "int", ")", "GeneralUtility", "::", "_GP", "(", "'tx_gridelements_container'", ")", ";", "$", "column", "=", "(", "int", ")", "GeneralUtility", "::", "_GP", "(", "'tx_gridelements_columns'", ")", ";", "$", "allowed_GP", "=", "GeneralUtility", "::", "_GP", "(", "'tx_gridelements_allowed'", ")", ";", "$", "disallowed_GP", "=", "GeneralUtility", "::", "_GP", "(", "'tx_gridelements_disallowed'", ")", ";", "if", "(", "!", "empty", "(", "$", "allowed_GP", ")", "||", "!", "empty", "(", "$", "disallowed_GP", ")", ")", "{", "$", "allowed", "=", "json_decode", "(", "base64_decode", "(", "$", "allowed_GP", ")", ",", "true", ")", "?", ":", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "allowed", ")", ")", "{", "foreach", "(", "$", "allowed", "as", "&", "$", "item", ")", "{", "if", "(", "!", "is_array", "(", "$", "item", ")", ")", "{", "$", "item", "=", "array_flip", "(", "GeneralUtility", "::", "trimExplode", "(", "','", ",", "$", "item", ")", ")", ";", "}", "}", "}", "$", "disallowed", "=", "json_decode", "(", "base64_decode", "(", "$", "disallowed_GP", ")", ",", "true", ")", "?", ":", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "disallowed", ")", ")", "{", "foreach", "(", "$", "disallowed", "as", "&", "$", "item", ")", "{", "if", "(", "!", "is_array", "(", "$", "item", ")", ")", "{", "$", "item", "=", "array_flip", "(", "GeneralUtility", "::", "trimExplode", "(", "','", ",", "$", "item", ")", ")", ";", "}", "}", "}", "$", "this", "->", "removeDisallowedWizardItems", "(", "$", "allowed", ",", "$", "disallowed", ",", "$", "wizardItems", ")", ";", "}", "else", "{", "$", "allowed", "=", "null", ";", "$", "disallowed", "=", "null", ";", "}", "if", "(", "(", "empty", "(", "$", "allowed", "[", "'CType'", "]", ")", "||", "isset", "(", "$", "allowed", "[", "'CType'", "]", "[", "'gridelements_pi1'", "]", ")", "||", "isset", "(", "$", "allowed", "[", "'CType'", "]", "[", "'*'", "]", ")", ")", "&&", "!", "isset", "(", "$", "disallowed", "[", "'tx_gridelements_backend_layout'", "]", "[", "'*'", "]", ")", ")", "{", "$", "allowedGridTypes", "=", "$", "allowed", "[", "'tx_gridelements_backend_layout'", "]", "?", ":", "[", "]", ";", "$", "disallowedGridTypes", "=", "$", "disallowed", "[", "'tx_gridelements_backend_layout'", "]", "?", ":", "[", "]", ";", "$", "excludeLayouts", "=", "$", "this", "->", "getExcludeLayouts", "(", "$", "container", ",", "$", "parentObject", ")", ";", "$", "gridItems", "=", "$", "this", "->", "layoutSetup", "->", "getLayoutWizardItems", "(", "$", "parentObject", "->", "colPos", ",", "$", "excludeLayouts", ",", "$", "allowedGridTypes", ",", "$", "disallowedGridTypes", ")", ";", "$", "this", "->", "addGridItemsToWizard", "(", "$", "gridItems", ",", "$", "wizardItems", ")", ";", "}", "$", "this", "->", "addGridValuesToWizardItems", "(", "$", "wizardItems", ",", "$", "container", ",", "$", "column", ")", ";", "$", "this", "->", "removeEmptyHeadersFromWizard", "(", "$", "wizardItems", ")", ";", "}" ]
Processes the items of the new content element wizard and inserts necessary default values for items created within a grid @param array $wizardItems The array containing the current status of the wizard item list before rendering @param NewContentElementController $parentObject The parent object that triggered this hook
[ "Processes", "the", "items", "of", "the", "new", "content", "element", "wizard", "and", "inserts", "necessary", "default", "values", "for", "items", "created", "within", "a", "grid" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L64-L126
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.init
public function init($pageUid) { if (!$this->layoutSetup instanceof LayoutSetup) { $this->layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid); } }
php
public function init($pageUid) { if (!$this->layoutSetup instanceof LayoutSetup) { $this->layoutSetup = GeneralUtility::makeInstance(LayoutSetup::class)->init($pageUid); } }
[ "public", "function", "init", "(", "$", "pageUid", ")", "{", "if", "(", "!", "$", "this", "->", "layoutSetup", "instanceof", "LayoutSetup", ")", "{", "$", "this", "->", "layoutSetup", "=", "GeneralUtility", "::", "makeInstance", "(", "LayoutSetup", "::", "class", ")", "->", "init", "(", "$", "pageUid", ")", ";", "}", "}" ]
initializes this class @param int $pageUid
[ "initializes", "this", "class" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L133-L138
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.removeDisallowedWizardItems
public function removeDisallowedWizardItems(array $allowed, array $disallowed, array &$wizardItems) { foreach ($wizardItems as $key => $wizardItem) { if (!$wizardItems[$key]['header']) { if ( ( !empty($allowed['CType']) && !isset($allowed['CType'][$wizardItems[$key]['tt_content_defValues']['CType']]) && !isset($allowed['CType']['*']) ) || ( !empty($disallowed) && ( isset($disallowed['CType'][$wizardItems[$key]['tt_content_defValues']['CType']]) || isset($disallowed['CType']['*']) ) ) || ( isset($wizardItems[$key]['tt_content_defValues']['list_type']) && !empty($allowed['list_type']) && !isset($allowed['list_type'][$wizardItems[$key]['tt_content_defValues']['list_type']]) && !isset($allowed['list_type']['*']) ) || ( isset($wizardItems[$key]['tt_content_defValues']['list_type']) && !empty($disallowed) && ( isset($disallowed['list_type'][$wizardItems[$key]['tt_content_defValues']['list_type']]) || isset($disallowed['list_type']['*']) ) ) ) { unset($wizardItems[$key]); } } } }
php
public function removeDisallowedWizardItems(array $allowed, array $disallowed, array &$wizardItems) { foreach ($wizardItems as $key => $wizardItem) { if (!$wizardItems[$key]['header']) { if ( ( !empty($allowed['CType']) && !isset($allowed['CType'][$wizardItems[$key]['tt_content_defValues']['CType']]) && !isset($allowed['CType']['*']) ) || ( !empty($disallowed) && ( isset($disallowed['CType'][$wizardItems[$key]['tt_content_defValues']['CType']]) || isset($disallowed['CType']['*']) ) ) || ( isset($wizardItems[$key]['tt_content_defValues']['list_type']) && !empty($allowed['list_type']) && !isset($allowed['list_type'][$wizardItems[$key]['tt_content_defValues']['list_type']]) && !isset($allowed['list_type']['*']) ) || ( isset($wizardItems[$key]['tt_content_defValues']['list_type']) && !empty($disallowed) && ( isset($disallowed['list_type'][$wizardItems[$key]['tt_content_defValues']['list_type']]) || isset($disallowed['list_type']['*']) ) ) ) { unset($wizardItems[$key]); } } } }
[ "public", "function", "removeDisallowedWizardItems", "(", "array", "$", "allowed", ",", "array", "$", "disallowed", ",", "array", "&", "$", "wizardItems", ")", "{", "foreach", "(", "$", "wizardItems", "as", "$", "key", "=>", "$", "wizardItem", ")", "{", "if", "(", "!", "$", "wizardItems", "[", "$", "key", "]", "[", "'header'", "]", ")", "{", "if", "(", "(", "!", "empty", "(", "$", "allowed", "[", "'CType'", "]", ")", "&&", "!", "isset", "(", "$", "allowed", "[", "'CType'", "]", "[", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'CType'", "]", "]", ")", "&&", "!", "isset", "(", "$", "allowed", "[", "'CType'", "]", "[", "'*'", "]", ")", ")", "||", "(", "!", "empty", "(", "$", "disallowed", ")", "&&", "(", "isset", "(", "$", "disallowed", "[", "'CType'", "]", "[", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'CType'", "]", "]", ")", "||", "isset", "(", "$", "disallowed", "[", "'CType'", "]", "[", "'*'", "]", ")", ")", ")", "||", "(", "isset", "(", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'list_type'", "]", ")", "&&", "!", "empty", "(", "$", "allowed", "[", "'list_type'", "]", ")", "&&", "!", "isset", "(", "$", "allowed", "[", "'list_type'", "]", "[", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'list_type'", "]", "]", ")", "&&", "!", "isset", "(", "$", "allowed", "[", "'list_type'", "]", "[", "'*'", "]", ")", ")", "||", "(", "isset", "(", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'list_type'", "]", ")", "&&", "!", "empty", "(", "$", "disallowed", ")", "&&", "(", "isset", "(", "$", "disallowed", "[", "'list_type'", "]", "[", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'list_type'", "]", "]", ")", "||", "isset", "(", "$", "disallowed", "[", "'list_type'", "]", "[", "'*'", "]", ")", ")", ")", ")", "{", "unset", "(", "$", "wizardItems", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
remove disallowed content elements from wizard items @param array $allowed @param array $disallowed @param array $wizardItems
[ "remove", "disallowed", "content", "elements", "from", "wizard", "items" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L147-L181
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.getExcludeLayouts
public function getExcludeLayouts($container, NewContentElementController $parentObject) { $excludeLayouts = 0; $excludeArray = []; $pageID = $parentObject->id; $TSconfig = BackendUtility::getPagesTSconfig($pageID); if ($container && $TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['topLevelLayouts']) { $excludeArray[] = trim($TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['topLevelLayouts']); } $excludeLayoutsTS = $TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['excludeLayouts']; if ($excludeLayoutsTS) { $excludeArray[] = trim($excludeLayoutsTS); } $userExcludeLayoutsTS = $TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['userExcludeLayouts']; if ($userExcludeLayoutsTS) { $excludeArray[] = trim($userExcludeLayoutsTS); } if (!empty($excludeArray)) { $excludeLayouts = implode(',', $excludeArray); } return $excludeLayouts; }
php
public function getExcludeLayouts($container, NewContentElementController $parentObject) { $excludeLayouts = 0; $excludeArray = []; $pageID = $parentObject->id; $TSconfig = BackendUtility::getPagesTSconfig($pageID); if ($container && $TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['topLevelLayouts']) { $excludeArray[] = trim($TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['topLevelLayouts']); } $excludeLayoutsTS = $TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['excludeLayouts']; if ($excludeLayoutsTS) { $excludeArray[] = trim($excludeLayoutsTS); } $userExcludeLayoutsTS = $TSconfig['TCEFORM.']['tt_content.']['tx_gridelements_backend_layout.']['itemsProcFunc.']['userExcludeLayouts']; if ($userExcludeLayoutsTS) { $excludeArray[] = trim($userExcludeLayoutsTS); } if (!empty($excludeArray)) { $excludeLayouts = implode(',', $excludeArray); } return $excludeLayouts; }
[ "public", "function", "getExcludeLayouts", "(", "$", "container", ",", "NewContentElementController", "$", "parentObject", ")", "{", "$", "excludeLayouts", "=", "0", ";", "$", "excludeArray", "=", "[", "]", ";", "$", "pageID", "=", "$", "parentObject", "->", "id", ";", "$", "TSconfig", "=", "BackendUtility", "::", "getPagesTSconfig", "(", "$", "pageID", ")", ";", "if", "(", "$", "container", "&&", "$", "TSconfig", "[", "'TCEFORM.'", "]", "[", "'tt_content.'", "]", "[", "'tx_gridelements_backend_layout.'", "]", "[", "'itemsProcFunc.'", "]", "[", "'topLevelLayouts'", "]", ")", "{", "$", "excludeArray", "[", "]", "=", "trim", "(", "$", "TSconfig", "[", "'TCEFORM.'", "]", "[", "'tt_content.'", "]", "[", "'tx_gridelements_backend_layout.'", "]", "[", "'itemsProcFunc.'", "]", "[", "'topLevelLayouts'", "]", ")", ";", "}", "$", "excludeLayoutsTS", "=", "$", "TSconfig", "[", "'TCEFORM.'", "]", "[", "'tt_content.'", "]", "[", "'tx_gridelements_backend_layout.'", "]", "[", "'itemsProcFunc.'", "]", "[", "'excludeLayouts'", "]", ";", "if", "(", "$", "excludeLayoutsTS", ")", "{", "$", "excludeArray", "[", "]", "=", "trim", "(", "$", "excludeLayoutsTS", ")", ";", "}", "$", "userExcludeLayoutsTS", "=", "$", "TSconfig", "[", "'TCEFORM.'", "]", "[", "'tt_content.'", "]", "[", "'tx_gridelements_backend_layout.'", "]", "[", "'itemsProcFunc.'", "]", "[", "'userExcludeLayouts'", "]", ";", "if", "(", "$", "userExcludeLayoutsTS", ")", "{", "$", "excludeArray", "[", "]", "=", "trim", "(", "$", "userExcludeLayoutsTS", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "excludeArray", ")", ")", "{", "$", "excludeLayouts", "=", "implode", "(", "','", ",", "$", "excludeArray", ")", ";", "}", "return", "$", "excludeLayouts", ";", "}" ]
retrieve layouts to exclude from pageTSconfig @param int $container @param NewContentElementController $parentObject The parent object that triggered this hook @return array
[ "retrieve", "layouts", "to", "exclude", "from", "pageTSconfig" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L191-L221
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.addGridItemsToWizard
public function addGridItemsToWizard(array &$gridItems, array &$wizardItems) { if (empty($gridItems)) { return; } // create gridelements node $wizardItems['gridelements'] = []; // set header label $wizardItems['gridelements']['header'] = $this->getLanguageService()->sL( 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_backend_layout_wizard_label' ); $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); // traverse the gridelements and create wizard item for each gridelement foreach ($gridItems as $key => $item) { $largeIcon = ''; if (empty($item['iconIdentifierLarge'])) { if (is_array($item['icon']) && isset($item['icon'][1])) { $item['iconIdentifierLarge'] = 'gridelements-large-' . $key; $largeIcon = $item['icon'][1]; if (StringUtility::beginsWith($largeIcon, '../typo3conf/ext/')) { $largeIcon = str_replace('../typo3conf/ext/', 'EXT:', $largeIcon); } if (StringUtility::beginsWith($largeIcon, '../uploads/tx_gridelements/')) { $largeIcon = str_replace('../', '', $largeIcon); } else { if (!StringUtility::beginsWith($largeIcon, 'EXT:') && strpos( $largeIcon, '/' ) === false ) { $largeIcon = GeneralUtility::resolveBackPath($item['icon'][1]); } } if (!empty($largeIcon)) { if (StringUtility::endsWith($largeIcon, '.svg')) { $iconRegistry->registerIcon($item['iconIdentifierLarge'], SvgIconProvider::class, [ 'source' => $largeIcon, ]); } else { $iconRegistry->registerIcon( $item['iconIdentifierLarge'], BitmapIconProvider::class, [ 'source' => $largeIcon, ] ); } } } else { $item['iconIdentifierLarge'] = 'gridelements-large-' . $key; $iconRegistry->registerIcon($item['iconIdentifierLarge'], SvgIconProvider::class, [ 'source' => 'EXT:gridelements/Resources/Public/Icons/gridelements.svg', ]); } } $itemIdentifier = $item['alias'] ? $item['alias'] : $item['uid']; $wizardItems['gridelements_' . $itemIdentifier] = [ 'title' => $item['title'], 'description' => $item['description'], 'params' => ($largeIcon ? '&largeIconImage=' . $largeIcon : '') . '&defVals[tt_content][CType]=gridelements_pi1&defVals[tt_content][tx_gridelements_backend_layout]=' . $item['uid'] . ($item['tll'] ? '&isTopLevelLayout' : ''), 'tt_content_defValues' => [ 'CType' => 'gridelements_pi1', 'tx_gridelements_backend_layout' => $item['uid'], ], ]; $icon = ''; if ($item['iconIdentifier']) { $wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'] = $item['iconIdentifier']; } elseif (is_array($item['icon']) && isset($item['icon'][0])) { $item['iconIdentifier'] = 'gridelements-' . $key; $icon = $item['icon'][0]; if (StringUtility::beginsWith($icon, '../typo3conf/ext/')) { $icon = str_replace('../typo3conf/ext/', 'EXT:', $icon); } if (StringUtility::beginsWith($icon, '../uploads/tx_gridelements/')) { $icon = str_replace('../', '', $icon); } else { if (!StringUtility::beginsWith($icon, 'EXT:') && strpos($icon, '/') !== false) { $icon = GeneralUtility::resolveBackPath($item['icon'][0]); } } if (StringUtility::endsWith($icon, '.svg')) { $iconRegistry->registerIcon($item['iconIdentifier'], SvgIconProvider::class, [ 'source' => $icon, ]); } else { $iconRegistry->registerIcon($item['iconIdentifier'], BitmapIconProvider::class, [ 'source' => $icon, ]); } } else { $item['iconIdentifier'] = 'gridelements-' . $key; $iconRegistry->registerIcon($item['iconIdentifier'], SvgIconProvider::class, [ 'source' => 'EXT:gridelements/Resources/Public/Icons/gridelements.svg', ]); } if ($icon && !isset($wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'])) { $wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'] = 'gridelements-' . $key; } else { if (!isset($wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'])) { $wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'] = 'gridelements-default'; } } } }
php
public function addGridItemsToWizard(array &$gridItems, array &$wizardItems) { if (empty($gridItems)) { return; } // create gridelements node $wizardItems['gridelements'] = []; // set header label $wizardItems['gridelements']['header'] = $this->getLanguageService()->sL( 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_backend_layout_wizard_label' ); $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); // traverse the gridelements and create wizard item for each gridelement foreach ($gridItems as $key => $item) { $largeIcon = ''; if (empty($item['iconIdentifierLarge'])) { if (is_array($item['icon']) && isset($item['icon'][1])) { $item['iconIdentifierLarge'] = 'gridelements-large-' . $key; $largeIcon = $item['icon'][1]; if (StringUtility::beginsWith($largeIcon, '../typo3conf/ext/')) { $largeIcon = str_replace('../typo3conf/ext/', 'EXT:', $largeIcon); } if (StringUtility::beginsWith($largeIcon, '../uploads/tx_gridelements/')) { $largeIcon = str_replace('../', '', $largeIcon); } else { if (!StringUtility::beginsWith($largeIcon, 'EXT:') && strpos( $largeIcon, '/' ) === false ) { $largeIcon = GeneralUtility::resolveBackPath($item['icon'][1]); } } if (!empty($largeIcon)) { if (StringUtility::endsWith($largeIcon, '.svg')) { $iconRegistry->registerIcon($item['iconIdentifierLarge'], SvgIconProvider::class, [ 'source' => $largeIcon, ]); } else { $iconRegistry->registerIcon( $item['iconIdentifierLarge'], BitmapIconProvider::class, [ 'source' => $largeIcon, ] ); } } } else { $item['iconIdentifierLarge'] = 'gridelements-large-' . $key; $iconRegistry->registerIcon($item['iconIdentifierLarge'], SvgIconProvider::class, [ 'source' => 'EXT:gridelements/Resources/Public/Icons/gridelements.svg', ]); } } $itemIdentifier = $item['alias'] ? $item['alias'] : $item['uid']; $wizardItems['gridelements_' . $itemIdentifier] = [ 'title' => $item['title'], 'description' => $item['description'], 'params' => ($largeIcon ? '&largeIconImage=' . $largeIcon : '') . '&defVals[tt_content][CType]=gridelements_pi1&defVals[tt_content][tx_gridelements_backend_layout]=' . $item['uid'] . ($item['tll'] ? '&isTopLevelLayout' : ''), 'tt_content_defValues' => [ 'CType' => 'gridelements_pi1', 'tx_gridelements_backend_layout' => $item['uid'], ], ]; $icon = ''; if ($item['iconIdentifier']) { $wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'] = $item['iconIdentifier']; } elseif (is_array($item['icon']) && isset($item['icon'][0])) { $item['iconIdentifier'] = 'gridelements-' . $key; $icon = $item['icon'][0]; if (StringUtility::beginsWith($icon, '../typo3conf/ext/')) { $icon = str_replace('../typo3conf/ext/', 'EXT:', $icon); } if (StringUtility::beginsWith($icon, '../uploads/tx_gridelements/')) { $icon = str_replace('../', '', $icon); } else { if (!StringUtility::beginsWith($icon, 'EXT:') && strpos($icon, '/') !== false) { $icon = GeneralUtility::resolveBackPath($item['icon'][0]); } } if (StringUtility::endsWith($icon, '.svg')) { $iconRegistry->registerIcon($item['iconIdentifier'], SvgIconProvider::class, [ 'source' => $icon, ]); } else { $iconRegistry->registerIcon($item['iconIdentifier'], BitmapIconProvider::class, [ 'source' => $icon, ]); } } else { $item['iconIdentifier'] = 'gridelements-' . $key; $iconRegistry->registerIcon($item['iconIdentifier'], SvgIconProvider::class, [ 'source' => 'EXT:gridelements/Resources/Public/Icons/gridelements.svg', ]); } if ($icon && !isset($wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'])) { $wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'] = 'gridelements-' . $key; } else { if (!isset($wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'])) { $wizardItems['gridelements_' . $itemIdentifier]['iconIdentifier'] = 'gridelements-default'; } } } }
[ "public", "function", "addGridItemsToWizard", "(", "array", "&", "$", "gridItems", ",", "array", "&", "$", "wizardItems", ")", "{", "if", "(", "empty", "(", "$", "gridItems", ")", ")", "{", "return", ";", "}", "// create gridelements node", "$", "wizardItems", "[", "'gridelements'", "]", "=", "[", "]", ";", "// set header label", "$", "wizardItems", "[", "'gridelements'", "]", "[", "'header'", "]", "=", "$", "this", "->", "getLanguageService", "(", ")", "->", "sL", "(", "'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xml:tx_gridelements_backend_layout_wizard_label'", ")", ";", "$", "iconRegistry", "=", "GeneralUtility", "::", "makeInstance", "(", "IconRegistry", "::", "class", ")", ";", "// traverse the gridelements and create wizard item for each gridelement", "foreach", "(", "$", "gridItems", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "largeIcon", "=", "''", ";", "if", "(", "empty", "(", "$", "item", "[", "'iconIdentifierLarge'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "item", "[", "'icon'", "]", ")", "&&", "isset", "(", "$", "item", "[", "'icon'", "]", "[", "1", "]", ")", ")", "{", "$", "item", "[", "'iconIdentifierLarge'", "]", "=", "'gridelements-large-'", ".", "$", "key", ";", "$", "largeIcon", "=", "$", "item", "[", "'icon'", "]", "[", "1", "]", ";", "if", "(", "StringUtility", "::", "beginsWith", "(", "$", "largeIcon", ",", "'../typo3conf/ext/'", ")", ")", "{", "$", "largeIcon", "=", "str_replace", "(", "'../typo3conf/ext/'", ",", "'EXT:'", ",", "$", "largeIcon", ")", ";", "}", "if", "(", "StringUtility", "::", "beginsWith", "(", "$", "largeIcon", ",", "'../uploads/tx_gridelements/'", ")", ")", "{", "$", "largeIcon", "=", "str_replace", "(", "'../'", ",", "''", ",", "$", "largeIcon", ")", ";", "}", "else", "{", "if", "(", "!", "StringUtility", "::", "beginsWith", "(", "$", "largeIcon", ",", "'EXT:'", ")", "&&", "strpos", "(", "$", "largeIcon", ",", "'/'", ")", "===", "false", ")", "{", "$", "largeIcon", "=", "GeneralUtility", "::", "resolveBackPath", "(", "$", "item", "[", "'icon'", "]", "[", "1", "]", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "largeIcon", ")", ")", "{", "if", "(", "StringUtility", "::", "endsWith", "(", "$", "largeIcon", ",", "'.svg'", ")", ")", "{", "$", "iconRegistry", "->", "registerIcon", "(", "$", "item", "[", "'iconIdentifierLarge'", "]", ",", "SvgIconProvider", "::", "class", ",", "[", "'source'", "=>", "$", "largeIcon", ",", "]", ")", ";", "}", "else", "{", "$", "iconRegistry", "->", "registerIcon", "(", "$", "item", "[", "'iconIdentifierLarge'", "]", ",", "BitmapIconProvider", "::", "class", ",", "[", "'source'", "=>", "$", "largeIcon", ",", "]", ")", ";", "}", "}", "}", "else", "{", "$", "item", "[", "'iconIdentifierLarge'", "]", "=", "'gridelements-large-'", ".", "$", "key", ";", "$", "iconRegistry", "->", "registerIcon", "(", "$", "item", "[", "'iconIdentifierLarge'", "]", ",", "SvgIconProvider", "::", "class", ",", "[", "'source'", "=>", "'EXT:gridelements/Resources/Public/Icons/gridelements.svg'", ",", "]", ")", ";", "}", "}", "$", "itemIdentifier", "=", "$", "item", "[", "'alias'", "]", "?", "$", "item", "[", "'alias'", "]", ":", "$", "item", "[", "'uid'", "]", ";", "$", "wizardItems", "[", "'gridelements_'", ".", "$", "itemIdentifier", "]", "=", "[", "'title'", "=>", "$", "item", "[", "'title'", "]", ",", "'description'", "=>", "$", "item", "[", "'description'", "]", ",", "'params'", "=>", "(", "$", "largeIcon", "?", "'&largeIconImage='", ".", "$", "largeIcon", ":", "''", ")", ".", "'&defVals[tt_content][CType]=gridelements_pi1&defVals[tt_content][tx_gridelements_backend_layout]='", ".", "$", "item", "[", "'uid'", "]", ".", "(", "$", "item", "[", "'tll'", "]", "?", "'&isTopLevelLayout'", ":", "''", ")", ",", "'tt_content_defValues'", "=>", "[", "'CType'", "=>", "'gridelements_pi1'", ",", "'tx_gridelements_backend_layout'", "=>", "$", "item", "[", "'uid'", "]", ",", "]", ",", "]", ";", "$", "icon", "=", "''", ";", "if", "(", "$", "item", "[", "'iconIdentifier'", "]", ")", "{", "$", "wizardItems", "[", "'gridelements_'", ".", "$", "itemIdentifier", "]", "[", "'iconIdentifier'", "]", "=", "$", "item", "[", "'iconIdentifier'", "]", ";", "}", "elseif", "(", "is_array", "(", "$", "item", "[", "'icon'", "]", ")", "&&", "isset", "(", "$", "item", "[", "'icon'", "]", "[", "0", "]", ")", ")", "{", "$", "item", "[", "'iconIdentifier'", "]", "=", "'gridelements-'", ".", "$", "key", ";", "$", "icon", "=", "$", "item", "[", "'icon'", "]", "[", "0", "]", ";", "if", "(", "StringUtility", "::", "beginsWith", "(", "$", "icon", ",", "'../typo3conf/ext/'", ")", ")", "{", "$", "icon", "=", "str_replace", "(", "'../typo3conf/ext/'", ",", "'EXT:'", ",", "$", "icon", ")", ";", "}", "if", "(", "StringUtility", "::", "beginsWith", "(", "$", "icon", ",", "'../uploads/tx_gridelements/'", ")", ")", "{", "$", "icon", "=", "str_replace", "(", "'../'", ",", "''", ",", "$", "icon", ")", ";", "}", "else", "{", "if", "(", "!", "StringUtility", "::", "beginsWith", "(", "$", "icon", ",", "'EXT:'", ")", "&&", "strpos", "(", "$", "icon", ",", "'/'", ")", "!==", "false", ")", "{", "$", "icon", "=", "GeneralUtility", "::", "resolveBackPath", "(", "$", "item", "[", "'icon'", "]", "[", "0", "]", ")", ";", "}", "}", "if", "(", "StringUtility", "::", "endsWith", "(", "$", "icon", ",", "'.svg'", ")", ")", "{", "$", "iconRegistry", "->", "registerIcon", "(", "$", "item", "[", "'iconIdentifier'", "]", ",", "SvgIconProvider", "::", "class", ",", "[", "'source'", "=>", "$", "icon", ",", "]", ")", ";", "}", "else", "{", "$", "iconRegistry", "->", "registerIcon", "(", "$", "item", "[", "'iconIdentifier'", "]", ",", "BitmapIconProvider", "::", "class", ",", "[", "'source'", "=>", "$", "icon", ",", "]", ")", ";", "}", "}", "else", "{", "$", "item", "[", "'iconIdentifier'", "]", "=", "'gridelements-'", ".", "$", "key", ";", "$", "iconRegistry", "->", "registerIcon", "(", "$", "item", "[", "'iconIdentifier'", "]", ",", "SvgIconProvider", "::", "class", ",", "[", "'source'", "=>", "'EXT:gridelements/Resources/Public/Icons/gridelements.svg'", ",", "]", ")", ";", "}", "if", "(", "$", "icon", "&&", "!", "isset", "(", "$", "wizardItems", "[", "'gridelements_'", ".", "$", "itemIdentifier", "]", "[", "'iconIdentifier'", "]", ")", ")", "{", "$", "wizardItems", "[", "'gridelements_'", ".", "$", "itemIdentifier", "]", "[", "'iconIdentifier'", "]", "=", "'gridelements-'", ".", "$", "key", ";", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "wizardItems", "[", "'gridelements_'", ".", "$", "itemIdentifier", "]", "[", "'iconIdentifier'", "]", ")", ")", "{", "$", "wizardItems", "[", "'gridelements_'", ".", "$", "itemIdentifier", "]", "[", "'iconIdentifier'", "]", "=", "'gridelements-default'", ";", "}", "}", "}", "}" ]
add gridelements to wizard items @param array $gridItems @param array $wizardItems
[ "add", "gridelements", "to", "wizard", "items" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L229-L338
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.addGridValuesToWizardItems
public function addGridValuesToWizardItems(array &$wizardItems, $container, $column) { foreach ($wizardItems as $key => $wizardItem) { if (!$wizardItems[$key]['header']) { if ($container !== 0) { $wizardItems[$key]['tt_content_defValues']['tx_gridelements_container'] = (int)$container; $wizardItems[$key]['params'] .= '&defVals[tt_content][tx_gridelements_container]=' . (int)$container; } $wizardItems[$key]['tt_content_defValues']['tx_gridelements_columns'] = (int)$column; $wizardItems[$key]['params'] .= '&defVals[tt_content][tx_gridelements_columns]=' . (int)$column; } } }
php
public function addGridValuesToWizardItems(array &$wizardItems, $container, $column) { foreach ($wizardItems as $key => $wizardItem) { if (!$wizardItems[$key]['header']) { if ($container !== 0) { $wizardItems[$key]['tt_content_defValues']['tx_gridelements_container'] = (int)$container; $wizardItems[$key]['params'] .= '&defVals[tt_content][tx_gridelements_container]=' . (int)$container; } $wizardItems[$key]['tt_content_defValues']['tx_gridelements_columns'] = (int)$column; $wizardItems[$key]['params'] .= '&defVals[tt_content][tx_gridelements_columns]=' . (int)$column; } } }
[ "public", "function", "addGridValuesToWizardItems", "(", "array", "&", "$", "wizardItems", ",", "$", "container", ",", "$", "column", ")", "{", "foreach", "(", "$", "wizardItems", "as", "$", "key", "=>", "$", "wizardItem", ")", "{", "if", "(", "!", "$", "wizardItems", "[", "$", "key", "]", "[", "'header'", "]", ")", "{", "if", "(", "$", "container", "!==", "0", ")", "{", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'tx_gridelements_container'", "]", "=", "(", "int", ")", "$", "container", ";", "$", "wizardItems", "[", "$", "key", "]", "[", "'params'", "]", ".=", "'&defVals[tt_content][tx_gridelements_container]='", ".", "(", "int", ")", "$", "container", ";", "}", "$", "wizardItems", "[", "$", "key", "]", "[", "'tt_content_defValues'", "]", "[", "'tx_gridelements_columns'", "]", "=", "(", "int", ")", "$", "column", ";", "$", "wizardItems", "[", "$", "key", "]", "[", "'params'", "]", ".=", "'&defVals[tt_content][tx_gridelements_columns]='", ".", "(", "int", ")", "$", "column", ";", "}", "}", "}" ]
initializes wizard items @param array $wizardItems @param int $container @param int $column
[ "initializes", "wizard", "items" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L355-L367
TYPO3-extensions/gridelements
Classes/Hooks/WizardItems.php
WizardItems.removeEmptyHeadersFromWizard
public function removeEmptyHeadersFromWizard(array &$wizardItems) { $headersWithElements = []; foreach ($wizardItems as $key => $wizardItem) { $isElement = strpos($key, '_', 1); if ($isElement) { $headersWithElements[substr($key, 0, $isElement)] = true; } } foreach ($wizardItems as $key => $wizardItem) { if ($wizardItems[$key]['header']) { if (!isset($headersWithElements[$key])) { unset($wizardItems[$key]); } } } }
php
public function removeEmptyHeadersFromWizard(array &$wizardItems) { $headersWithElements = []; foreach ($wizardItems as $key => $wizardItem) { $isElement = strpos($key, '_', 1); if ($isElement) { $headersWithElements[substr($key, 0, $isElement)] = true; } } foreach ($wizardItems as $key => $wizardItem) { if ($wizardItems[$key]['header']) { if (!isset($headersWithElements[$key])) { unset($wizardItems[$key]); } } } }
[ "public", "function", "removeEmptyHeadersFromWizard", "(", "array", "&", "$", "wizardItems", ")", "{", "$", "headersWithElements", "=", "[", "]", ";", "foreach", "(", "$", "wizardItems", "as", "$", "key", "=>", "$", "wizardItem", ")", "{", "$", "isElement", "=", "strpos", "(", "$", "key", ",", "'_'", ",", "1", ")", ";", "if", "(", "$", "isElement", ")", "{", "$", "headersWithElements", "[", "substr", "(", "$", "key", ",", "0", ",", "$", "isElement", ")", "]", "=", "true", ";", "}", "}", "foreach", "(", "$", "wizardItems", "as", "$", "key", "=>", "$", "wizardItem", ")", "{", "if", "(", "$", "wizardItems", "[", "$", "key", "]", "[", "'header'", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "headersWithElements", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "wizardItems", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
remove unnecessary headers from wizard items @param array $wizardItems
[ "remove", "unnecessary", "headers", "from", "wizard", "items" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/Hooks/WizardItems.php#L374-L390
TYPO3-extensions/gridelements
Classes/DataHandler/AfterDatabaseOperations.php
AfterDatabaseOperations.adjustValuesAfterWorkspaceOperations
public function adjustValuesAfterWorkspaceOperations(array $fieldArray, $uid, DataHandler $parentObj) { $workspace = $this->getBackendUser()->workspace; if ($workspace && (isset($fieldArray['colPos']) || isset($fieldArray['tx_gridelements_container']) || isset($fieldArray['tx_gridelements_columns']))) { $originalRecord = $parentObj->recordInfo('tt_content', (int)$uid, '*'); if ($originalRecord['t3ver_state'] === 4) { $updateArray = []; $movePlaceholder = BackendUtility::getMovePlaceholder('tt_content', (int)$uid, 'uid', $workspace); if (isset($fieldArray['colPos'])) { $updateArray['colPos'] = (int)$fieldArray['colPos']; } if (isset($fieldArray['tx_gridelements_container'])) { $updateArray['tx_gridelements_container'] = (int)$fieldArray['tx_gridelements_container']; } if (isset($fieldArray['tx_gridelements_columns'])) { $updateArray['tx_gridelements_columns'] = (int)$fieldArray['tx_gridelements_columns']; } $parentObj->updateDB('tt_content', (int)$movePlaceholder['uid'], $updateArray); } } }
php
public function adjustValuesAfterWorkspaceOperations(array $fieldArray, $uid, DataHandler $parentObj) { $workspace = $this->getBackendUser()->workspace; if ($workspace && (isset($fieldArray['colPos']) || isset($fieldArray['tx_gridelements_container']) || isset($fieldArray['tx_gridelements_columns']))) { $originalRecord = $parentObj->recordInfo('tt_content', (int)$uid, '*'); if ($originalRecord['t3ver_state'] === 4) { $updateArray = []; $movePlaceholder = BackendUtility::getMovePlaceholder('tt_content', (int)$uid, 'uid', $workspace); if (isset($fieldArray['colPos'])) { $updateArray['colPos'] = (int)$fieldArray['colPos']; } if (isset($fieldArray['tx_gridelements_container'])) { $updateArray['tx_gridelements_container'] = (int)$fieldArray['tx_gridelements_container']; } if (isset($fieldArray['tx_gridelements_columns'])) { $updateArray['tx_gridelements_columns'] = (int)$fieldArray['tx_gridelements_columns']; } $parentObj->updateDB('tt_content', (int)$movePlaceholder['uid'], $updateArray); } } }
[ "public", "function", "adjustValuesAfterWorkspaceOperations", "(", "array", "$", "fieldArray", ",", "$", "uid", ",", "DataHandler", "$", "parentObj", ")", "{", "$", "workspace", "=", "$", "this", "->", "getBackendUser", "(", ")", "->", "workspace", ";", "if", "(", "$", "workspace", "&&", "(", "isset", "(", "$", "fieldArray", "[", "'colPos'", "]", ")", "||", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ")", "||", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_columns'", "]", ")", ")", ")", "{", "$", "originalRecord", "=", "$", "parentObj", "->", "recordInfo", "(", "'tt_content'", ",", "(", "int", ")", "$", "uid", ",", "'*'", ")", ";", "if", "(", "$", "originalRecord", "[", "'t3ver_state'", "]", "===", "4", ")", "{", "$", "updateArray", "=", "[", "]", ";", "$", "movePlaceholder", "=", "BackendUtility", "::", "getMovePlaceholder", "(", "'tt_content'", ",", "(", "int", ")", "$", "uid", ",", "'uid'", ",", "$", "workspace", ")", ";", "if", "(", "isset", "(", "$", "fieldArray", "[", "'colPos'", "]", ")", ")", "{", "$", "updateArray", "[", "'colPos'", "]", "=", "(", "int", ")", "$", "fieldArray", "[", "'colPos'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ")", ")", "{", "$", "updateArray", "[", "'tx_gridelements_container'", "]", "=", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_container'", "]", ";", "}", "if", "(", "isset", "(", "$", "fieldArray", "[", "'tx_gridelements_columns'", "]", ")", ")", "{", "$", "updateArray", "[", "'tx_gridelements_columns'", "]", "=", "(", "int", ")", "$", "fieldArray", "[", "'tx_gridelements_columns'", "]", ";", "}", "$", "parentObj", "->", "updateDB", "(", "'tt_content'", ",", "(", "int", ")", "$", "movePlaceholder", "[", "'uid'", "]", ",", "$", "updateArray", ")", ";", "}", "}", "}" ]
Function to adjust colPos, container and grid column of an element after it has been moved out of or into a container during a workspace operation @param array $fieldArray The array of fields and values that have been saved to the datamap @param int $uid the ID of the record @param DataHandler $parentObj The parent object that triggered this hook
[ "Function", "to", "adjust", "colPos", "container", "and", "grid", "column", "of", "an", "element", "after", "it", "has", "been", "moved", "out", "of", "or", "into", "a", "container", "during", "a", "workspace", "operation" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AfterDatabaseOperations.php#L44-L64
TYPO3-extensions/gridelements
Classes/DataHandler/AfterDatabaseOperations.php
AfterDatabaseOperations.execute_afterDatabaseOperations
public function execute_afterDatabaseOperations(array &$fieldArray, $table, $uid, DataHandler $parentObj) { if ($table === 'tt_content' || $table === 'pages') { $this->init($table, $uid, $parentObj); if (!$this->getTceMain()->isImporting) { $this->saveCleanedUpFieldArray($fieldArray); if ($table === 'tt_content' && (int)$uid > 0) { $this->checkAndUpdateTranslatedElements($uid); } } } }
php
public function execute_afterDatabaseOperations(array &$fieldArray, $table, $uid, DataHandler $parentObj) { if ($table === 'tt_content' || $table === 'pages') { $this->init($table, $uid, $parentObj); if (!$this->getTceMain()->isImporting) { $this->saveCleanedUpFieldArray($fieldArray); if ($table === 'tt_content' && (int)$uid > 0) { $this->checkAndUpdateTranslatedElements($uid); } } } }
[ "public", "function", "execute_afterDatabaseOperations", "(", "array", "&", "$", "fieldArray", ",", "$", "table", ",", "$", "uid", ",", "DataHandler", "$", "parentObj", ")", "{", "if", "(", "$", "table", "===", "'tt_content'", "||", "$", "table", "===", "'pages'", ")", "{", "$", "this", "->", "init", "(", "$", "table", ",", "$", "uid", ",", "$", "parentObj", ")", ";", "if", "(", "!", "$", "this", "->", "getTceMain", "(", ")", "->", "isImporting", ")", "{", "$", "this", "->", "saveCleanedUpFieldArray", "(", "$", "fieldArray", ")", ";", "if", "(", "$", "table", "===", "'tt_content'", "&&", "(", "int", ")", "$", "uid", ">", "0", ")", "{", "$", "this", "->", "checkAndUpdateTranslatedElements", "(", "$", "uid", ")", ";", "}", "}", "}", "}" ]
Function to set the colPos of an element depending on whether it is a child of a parent container or not will set colPos according to availability of the current grid column of an element 0 = no column at all -1 = grid element column -2 = non used elements column changes are applied to the field array of the parent object by reference @param array $fieldArray The array of fields and values that have been saved to the datamap @param string $table The name of the table the data should be saved to @param int $uid the ID of the record @param DataHandler $parentObj The parent object that triggered this hook
[ "Function", "to", "set", "the", "colPos", "of", "an", "element", "depending", "on", "whether", "it", "is", "a", "child", "of", "a", "parent", "container", "or", "not", "will", "set", "colPos", "according", "to", "availability", "of", "the", "current", "grid", "column", "of", "an", "element", "0", "=", "no", "column", "at", "all", "-", "1", "=", "grid", "element", "column", "-", "2", "=", "non", "used", "elements", "column", "changes", "are", "applied", "to", "the", "field", "array", "of", "the", "parent", "object", "by", "reference" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AfterDatabaseOperations.php#L90-L101
TYPO3-extensions/gridelements
Classes/DataHandler/AfterDatabaseOperations.php
AfterDatabaseOperations.saveCleanedUpFieldArray
public function saveCleanedUpFieldArray(array $changedFieldArray) { unset($changedFieldArray['pi_flexform']); if (isset($changedFieldArray['tx_gridelements_backend_layout']) && $this->getTable() === 'tt_content' || isset($changedFieldArray['backend_layout']) && $this->getTable() === 'pages' || isset($changedFieldArray['backend_layout_next_level']) && $this->getTable() === 'pages' ) { $this->setUnusedElements($changedFieldArray); } }
php
public function saveCleanedUpFieldArray(array $changedFieldArray) { unset($changedFieldArray['pi_flexform']); if (isset($changedFieldArray['tx_gridelements_backend_layout']) && $this->getTable() === 'tt_content' || isset($changedFieldArray['backend_layout']) && $this->getTable() === 'pages' || isset($changedFieldArray['backend_layout_next_level']) && $this->getTable() === 'pages' ) { $this->setUnusedElements($changedFieldArray); } }
[ "public", "function", "saveCleanedUpFieldArray", "(", "array", "$", "changedFieldArray", ")", "{", "unset", "(", "$", "changedFieldArray", "[", "'pi_flexform'", "]", ")", ";", "if", "(", "isset", "(", "$", "changedFieldArray", "[", "'tx_gridelements_backend_layout'", "]", ")", "&&", "$", "this", "->", "getTable", "(", ")", "===", "'tt_content'", "||", "isset", "(", "$", "changedFieldArray", "[", "'backend_layout'", "]", ")", "&&", "$", "this", "->", "getTable", "(", ")", "===", "'pages'", "||", "isset", "(", "$", "changedFieldArray", "[", "'backend_layout_next_level'", "]", ")", "&&", "$", "this", "->", "getTable", "(", ")", "===", "'pages'", ")", "{", "$", "this", "->", "setUnusedElements", "(", "$", "changedFieldArray", ")", ";", "}", "}" ]
save cleaned up field array @param array $changedFieldArray
[ "save", "cleaned", "up", "field", "array" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AfterDatabaseOperations.php#L108-L117
TYPO3-extensions/gridelements
Classes/DataHandler/AfterDatabaseOperations.php
AfterDatabaseOperations.setUnusedElements
public function setUnusedElements(array &$fieldArray) { $changedGridElements = []; $changedElements = []; $changedSubPageElements = []; if ($this->getTable() === 'tt_content') { $changedGridElements[$this->getContentUid()] = true; $childElementsInUnavailableColumns = []; $childElementsInAvailableColumns = []; $availableColumns = $this->getAvailableColumns($fieldArray['tx_gridelements_backend_layout'], 'tt_content'); if (!empty($availableColumns) || $availableColumns === '0') { $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); $childElementsInUnavailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->gt('tx_gridelements_container', 0), $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$this->getContentUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->notIn( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $childElementsInUnavailableColumns = []; while ($childElementInUnavailableColumns = $childElementsInUnavailableColumnsQuery->fetch()) { $childElementsInUnavailableColumns[] = $childElementInUnavailableColumns['uid']; } if (!empty($childElementsInUnavailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $childElementsInUnavailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', -2) ->set('backupColPos', -1) ->execute(); array_flip($childElementsInUnavailableColumns); } $queryBuilder = $this->getQueryBuilder(); $childElementsInAvailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->gt('tx_gridelements_container', 0), $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$this->getContentUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $childElementsInAvailableColumns = []; while ($childElementInAvailableColumns = $childElementsInAvailableColumnsQuery->fetch()) { $childElementsInAvailableColumns[] = $childElementInAvailableColumns['uid']; } if (!empty($childElementsInAvailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $childElementsInAvailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', -1) ->set('backupColPos', -2) ->execute(); array_flip($childElementsInAvailableColumns); } } $changedGridElements = $changedGridElements + $childElementsInUnavailableColumns + $childElementsInAvailableColumns; } if ($this->getTable() === 'pages') { $backendLayoutUid = 0; $backendLayoutNextLevelUid = 0; $rootline = BackendUtility::BEgetRootLine($this->getPageUid()); for ($i = count($rootline); $i > 0; $i--) { $page = BackendUtility::getRecord( 'pages', (int)$rootline[$i]['uid'], 'uid,backend_layout,backend_layout_next_level' ); $selectedBackendLayoutNextLevel = (int)$page['backend_layout_next_level']; if ($page['uid'] === $this->getPageUid()) { if ($fieldArray['backend_layout_next_level'] !== 0) { // Backend layout for sub pages of the current page is set $backendLayoutNextLevelUid = (int)$fieldArray['backend_layout_next_level']; } if ($fieldArray['backend_layout'] !== 0) { // Backend layout for current page is set $backendLayoutUid = $fieldArray['backend_layout']; break; } } else { if ($selectedBackendLayoutNextLevel === -1 && $page['uid'] !== $this->getPageUid()) { // Some previous page in our rootline sets layout_next to "None" break; } if ($selectedBackendLayoutNextLevel > 0 && $page['uid'] !== $this->getPageUid()) { // Some previous page in our rootline sets some backend_layout, use it $backendLayoutUid = $selectedBackendLayoutNextLevel; break; } } } if (isset($fieldArray['backend_layout'])) { $availableColumns = $this->getAvailableColumns($backendLayoutUid, 'pages', $this->getPageUid()); $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); $elementsInUnavailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->notIn( 'colPos', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $elementsInUnavailableColumns = []; while ($elementInUnavailableColumns = $elementsInUnavailableColumnsQuery->fetch()) { $elementsInUnavailableColumns[] = $elementInUnavailableColumns['uid']; } if (!empty($elementsInUnavailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $elementsInUnavailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos'), false) ->set('colPos', -2) ->execute(); array_flip($elementsInUnavailableColumns); } $queryBuilder = $this->getQueryBuilder(); $elementsInAvailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->neq( 'backupColPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'backupColPos', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $elementsInAvailableColumns = []; while ($elementInAvailableColumns = $elementsInAvailableColumnsQuery->fetch()) { $elementsInAvailableColumns[] = $elementInAvailableColumns['uid']; } if (!empty($elementsInAvailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $elementsInAvailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos'), false) ->set('backupColPos', -2) ->execute(); array_flip($elementsInAvailableColumns); } $changedElements = $elementsInUnavailableColumns + $elementsInAvailableColumns; } if (isset($fieldArray['backend_layout_next_level'])) { $backendLayoutUid = $backendLayoutNextLevelUid ? $backendLayoutNextLevelUid : $backendLayoutUid; $subPages = []; $this->getSubPagesRecursively($this->getPageUid(), $subPages); if (!empty($subPages)) { $changedSubPageElements = []; foreach ($subPages as $page) { $availableColumns = $this->getAvailableColumns($backendLayoutUid, 'pages', $page['uid']); $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); $subPageElementsInUnavailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT) ), $queryBuilder->expr()->notIn( 'colPos', $queryBuilder->createNamedParameter( $availableColumns, Connection::PARAM_INT_ARRAY ) ) ) ) ->execute(); $subPageElementsInUnavailableColumns = []; while ($subPageElementInUnavailableColumns = $subPageElementsInUnavailableColumnsQuery->fetch()) { $subPageElementsInUnavailableColumns[] = $subPageElementInUnavailableColumns['uid']; } if (!empty($subPageElementsInUnavailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $subPageElementsInUnavailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos'), false) ->set('colPos', -2) ->execute(); array_flip($subPageElementsInUnavailableColumns); } $queryBuilder = $this->getQueryBuilder(); $subPageElementsInAvailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT) ), $queryBuilder->expr()->neq( 'backupColPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'backupColPos', $queryBuilder->createNamedParameter( $availableColumns, Connection::PARAM_INT_ARRAY ) ) ) ) ->execute(); $subPageElementsInAvailableColumns = []; while ($subPageElementInAvailableColumns = $subPageElementsInAvailableColumnsQuery->fetch()) { $subPageElementsInAvailableColumns[] = $subPageElementInAvailableColumns['uid']; } if (!empty($subPageElementsInAvailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $subPageElementsInAvailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos'), false) ->set('backupColPos', -2) ->execute(); array_flip($subPageElementsInAvailableColumns); } $changedPageElements = $subPageElementsInUnavailableColumns + $subPageElementsInAvailableColumns; $changedSubPageElements = $changedSubPageElements + $changedPageElements; } } } } $changedElementUids = $changedGridElements + $changedElements + $changedSubPageElements; if (!empty($changedElementUids)) { foreach ($changedElementUids as $uid => $value) { $this->dataHandler->updateRefIndex('tt_content', $uid); } } }
php
public function setUnusedElements(array &$fieldArray) { $changedGridElements = []; $changedElements = []; $changedSubPageElements = []; if ($this->getTable() === 'tt_content') { $changedGridElements[$this->getContentUid()] = true; $childElementsInUnavailableColumns = []; $childElementsInAvailableColumns = []; $availableColumns = $this->getAvailableColumns($fieldArray['tx_gridelements_backend_layout'], 'tt_content'); if (!empty($availableColumns) || $availableColumns === '0') { $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); $childElementsInUnavailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->gt('tx_gridelements_container', 0), $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$this->getContentUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->notIn( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $childElementsInUnavailableColumns = []; while ($childElementInUnavailableColumns = $childElementsInUnavailableColumnsQuery->fetch()) { $childElementsInUnavailableColumns[] = $childElementInUnavailableColumns['uid']; } if (!empty($childElementsInUnavailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $childElementsInUnavailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', -2) ->set('backupColPos', -1) ->execute(); array_flip($childElementsInUnavailableColumns); } $queryBuilder = $this->getQueryBuilder(); $childElementsInAvailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->gt('tx_gridelements_container', 0), $queryBuilder->expr()->eq( 'tx_gridelements_container', $queryBuilder->createNamedParameter((int)$this->getContentUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'tx_gridelements_columns', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $childElementsInAvailableColumns = []; while ($childElementInAvailableColumns = $childElementsInAvailableColumnsQuery->fetch()) { $childElementsInAvailableColumns[] = $childElementInAvailableColumns['uid']; } if (!empty($childElementsInAvailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $childElementsInAvailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', -1) ->set('backupColPos', -2) ->execute(); array_flip($childElementsInAvailableColumns); } } $changedGridElements = $changedGridElements + $childElementsInUnavailableColumns + $childElementsInAvailableColumns; } if ($this->getTable() === 'pages') { $backendLayoutUid = 0; $backendLayoutNextLevelUid = 0; $rootline = BackendUtility::BEgetRootLine($this->getPageUid()); for ($i = count($rootline); $i > 0; $i--) { $page = BackendUtility::getRecord( 'pages', (int)$rootline[$i]['uid'], 'uid,backend_layout,backend_layout_next_level' ); $selectedBackendLayoutNextLevel = (int)$page['backend_layout_next_level']; if ($page['uid'] === $this->getPageUid()) { if ($fieldArray['backend_layout_next_level'] !== 0) { // Backend layout for sub pages of the current page is set $backendLayoutNextLevelUid = (int)$fieldArray['backend_layout_next_level']; } if ($fieldArray['backend_layout'] !== 0) { // Backend layout for current page is set $backendLayoutUid = $fieldArray['backend_layout']; break; } } else { if ($selectedBackendLayoutNextLevel === -1 && $page['uid'] !== $this->getPageUid()) { // Some previous page in our rootline sets layout_next to "None" break; } if ($selectedBackendLayoutNextLevel > 0 && $page['uid'] !== $this->getPageUid()) { // Some previous page in our rootline sets some backend_layout, use it $backendLayoutUid = $selectedBackendLayoutNextLevel; break; } } } if (isset($fieldArray['backend_layout'])) { $availableColumns = $this->getAvailableColumns($backendLayoutUid, 'pages', $this->getPageUid()); $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); $elementsInUnavailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->notIn( 'colPos', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $elementsInUnavailableColumns = []; while ($elementInUnavailableColumns = $elementsInUnavailableColumnsQuery->fetch()) { $elementsInUnavailableColumns[] = $elementInUnavailableColumns['uid']; } if (!empty($elementsInUnavailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $elementsInUnavailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos'), false) ->set('colPos', -2) ->execute(); array_flip($elementsInUnavailableColumns); } $queryBuilder = $this->getQueryBuilder(); $elementsInAvailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$this->getPageUid(), \PDO::PARAM_INT) ), $queryBuilder->expr()->neq( 'backupColPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'backupColPos', $queryBuilder->createNamedParameter($availableColumns, Connection::PARAM_INT_ARRAY) ) ) ) ->execute(); $elementsInAvailableColumns = []; while ($elementInAvailableColumns = $elementsInAvailableColumnsQuery->fetch()) { $elementsInAvailableColumns[] = $elementInAvailableColumns['uid']; } if (!empty($elementsInAvailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $elementsInAvailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos'), false) ->set('backupColPos', -2) ->execute(); array_flip($elementsInAvailableColumns); } $changedElements = $elementsInUnavailableColumns + $elementsInAvailableColumns; } if (isset($fieldArray['backend_layout_next_level'])) { $backendLayoutUid = $backendLayoutNextLevelUid ? $backendLayoutNextLevelUid : $backendLayoutUid; $subPages = []; $this->getSubPagesRecursively($this->getPageUid(), $subPages); if (!empty($subPages)) { $changedSubPageElements = []; foreach ($subPages as $page) { $availableColumns = $this->getAvailableColumns($backendLayoutUid, 'pages', $page['uid']); $availableColumns = GeneralUtility::intExplode(',', $availableColumns); $queryBuilder = $this->getQueryBuilder(); $subPageElementsInUnavailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT) ), $queryBuilder->expr()->notIn( 'colPos', $queryBuilder->createNamedParameter( $availableColumns, Connection::PARAM_INT_ARRAY ) ) ) ) ->execute(); $subPageElementsInUnavailableColumns = []; while ($subPageElementInUnavailableColumns = $subPageElementsInUnavailableColumnsQuery->fetch()) { $subPageElementsInUnavailableColumns[] = $subPageElementInUnavailableColumns['uid']; } if (!empty($subPageElementsInUnavailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $subPageElementsInUnavailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('backupColPos', $queryBuilder->quoteIdentifier('colPos'), false) ->set('colPos', -2) ->execute(); array_flip($subPageElementsInUnavailableColumns); } $queryBuilder = $this->getQueryBuilder(); $subPageElementsInAvailableColumnsQuery = $queryBuilder ->select('uid') ->from('tt_content') ->where( $queryBuilder->expr()->andX( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$page['uid'], \PDO::PARAM_INT) ), $queryBuilder->expr()->neq( 'backupColPos', $queryBuilder->createNamedParameter(-2, \PDO::PARAM_INT) ), $queryBuilder->expr()->in( 'backupColPos', $queryBuilder->createNamedParameter( $availableColumns, Connection::PARAM_INT_ARRAY ) ) ) ) ->execute(); $subPageElementsInAvailableColumns = []; while ($subPageElementInAvailableColumns = $subPageElementsInAvailableColumnsQuery->fetch()) { $subPageElementsInAvailableColumns[] = $subPageElementInAvailableColumns['uid']; } if (!empty($subPageElementsInAvailableColumns)) { $queryBuilder ->update('tt_content') ->where( $queryBuilder->expr()->in( 'uid', $queryBuilder->createNamedParameter( $subPageElementsInAvailableColumns, Connection::PARAM_INT_ARRAY ) ) ) ->set('colPos', $queryBuilder->quoteIdentifier('backupColPos'), false) ->set('backupColPos', -2) ->execute(); array_flip($subPageElementsInAvailableColumns); } $changedPageElements = $subPageElementsInUnavailableColumns + $subPageElementsInAvailableColumns; $changedSubPageElements = $changedSubPageElements + $changedPageElements; } } } } $changedElementUids = $changedGridElements + $changedElements + $changedSubPageElements; if (!empty($changedElementUids)) { foreach ($changedElementUids as $uid => $value) { $this->dataHandler->updateRefIndex('tt_content', $uid); } } }
[ "public", "function", "setUnusedElements", "(", "array", "&", "$", "fieldArray", ")", "{", "$", "changedGridElements", "=", "[", "]", ";", "$", "changedElements", "=", "[", "]", ";", "$", "changedSubPageElements", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getTable", "(", ")", "===", "'tt_content'", ")", "{", "$", "changedGridElements", "[", "$", "this", "->", "getContentUid", "(", ")", "]", "=", "true", ";", "$", "childElementsInUnavailableColumns", "=", "[", "]", ";", "$", "childElementsInAvailableColumns", "=", "[", "]", ";", "$", "availableColumns", "=", "$", "this", "->", "getAvailableColumns", "(", "$", "fieldArray", "[", "'tx_gridelements_backend_layout'", "]", ",", "'tt_content'", ")", ";", "if", "(", "!", "empty", "(", "$", "availableColumns", ")", "||", "$", "availableColumns", "===", "'0'", ")", "{", "$", "availableColumns", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "availableColumns", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "childElementsInUnavailableColumnsQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "gt", "(", "'tx_gridelements_container'", ",", "0", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'tx_gridelements_container'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "this", "->", "getContentUid", "(", ")", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "notIn", "(", "'tx_gridelements_columns'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "availableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "childElementsInUnavailableColumns", "=", "[", "]", ";", "while", "(", "$", "childElementInUnavailableColumns", "=", "$", "childElementsInUnavailableColumnsQuery", "->", "fetch", "(", ")", ")", "{", "$", "childElementsInUnavailableColumns", "[", "]", "=", "$", "childElementInUnavailableColumns", "[", "'uid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "childElementsInUnavailableColumns", ")", ")", "{", "$", "queryBuilder", "->", "update", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "childElementsInUnavailableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", "->", "set", "(", "'colPos'", ",", "-", "2", ")", "->", "set", "(", "'backupColPos'", ",", "-", "1", ")", "->", "execute", "(", ")", ";", "array_flip", "(", "$", "childElementsInUnavailableColumns", ")", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "childElementsInAvailableColumnsQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "gt", "(", "'tx_gridelements_container'", ",", "0", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'tx_gridelements_container'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "this", "->", "getContentUid", "(", ")", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'tx_gridelements_columns'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "availableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "childElementsInAvailableColumns", "=", "[", "]", ";", "while", "(", "$", "childElementInAvailableColumns", "=", "$", "childElementsInAvailableColumnsQuery", "->", "fetch", "(", ")", ")", "{", "$", "childElementsInAvailableColumns", "[", "]", "=", "$", "childElementInAvailableColumns", "[", "'uid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "childElementsInAvailableColumns", ")", ")", "{", "$", "queryBuilder", "->", "update", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "childElementsInAvailableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", "->", "set", "(", "'colPos'", ",", "-", "1", ")", "->", "set", "(", "'backupColPos'", ",", "-", "2", ")", "->", "execute", "(", ")", ";", "array_flip", "(", "$", "childElementsInAvailableColumns", ")", ";", "}", "}", "$", "changedGridElements", "=", "$", "changedGridElements", "+", "$", "childElementsInUnavailableColumns", "+", "$", "childElementsInAvailableColumns", ";", "}", "if", "(", "$", "this", "->", "getTable", "(", ")", "===", "'pages'", ")", "{", "$", "backendLayoutUid", "=", "0", ";", "$", "backendLayoutNextLevelUid", "=", "0", ";", "$", "rootline", "=", "BackendUtility", "::", "BEgetRootLine", "(", "$", "this", "->", "getPageUid", "(", ")", ")", ";", "for", "(", "$", "i", "=", "count", "(", "$", "rootline", ")", ";", "$", "i", ">", "0", ";", "$", "i", "--", ")", "{", "$", "page", "=", "BackendUtility", "::", "getRecord", "(", "'pages'", ",", "(", "int", ")", "$", "rootline", "[", "$", "i", "]", "[", "'uid'", "]", ",", "'uid,backend_layout,backend_layout_next_level'", ")", ";", "$", "selectedBackendLayoutNextLevel", "=", "(", "int", ")", "$", "page", "[", "'backend_layout_next_level'", "]", ";", "if", "(", "$", "page", "[", "'uid'", "]", "===", "$", "this", "->", "getPageUid", "(", ")", ")", "{", "if", "(", "$", "fieldArray", "[", "'backend_layout_next_level'", "]", "!==", "0", ")", "{", "// Backend layout for sub pages of the current page is set", "$", "backendLayoutNextLevelUid", "=", "(", "int", ")", "$", "fieldArray", "[", "'backend_layout_next_level'", "]", ";", "}", "if", "(", "$", "fieldArray", "[", "'backend_layout'", "]", "!==", "0", ")", "{", "// Backend layout for current page is set", "$", "backendLayoutUid", "=", "$", "fieldArray", "[", "'backend_layout'", "]", ";", "break", ";", "}", "}", "else", "{", "if", "(", "$", "selectedBackendLayoutNextLevel", "===", "-", "1", "&&", "$", "page", "[", "'uid'", "]", "!==", "$", "this", "->", "getPageUid", "(", ")", ")", "{", "// Some previous page in our rootline sets layout_next to \"None\"", "break", ";", "}", "if", "(", "$", "selectedBackendLayoutNextLevel", ">", "0", "&&", "$", "page", "[", "'uid'", "]", "!==", "$", "this", "->", "getPageUid", "(", ")", ")", "{", "// Some previous page in our rootline sets some backend_layout, use it", "$", "backendLayoutUid", "=", "$", "selectedBackendLayoutNextLevel", ";", "break", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "fieldArray", "[", "'backend_layout'", "]", ")", ")", "{", "$", "availableColumns", "=", "$", "this", "->", "getAvailableColumns", "(", "$", "backendLayoutUid", ",", "'pages'", ",", "$", "this", "->", "getPageUid", "(", ")", ")", ";", "$", "availableColumns", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "availableColumns", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "elementsInUnavailableColumnsQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "this", "->", "getPageUid", "(", ")", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "notIn", "(", "'colPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "availableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "elementsInUnavailableColumns", "=", "[", "]", ";", "while", "(", "$", "elementInUnavailableColumns", "=", "$", "elementsInUnavailableColumnsQuery", "->", "fetch", "(", ")", ")", "{", "$", "elementsInUnavailableColumns", "[", "]", "=", "$", "elementInUnavailableColumns", "[", "'uid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "elementsInUnavailableColumns", ")", ")", "{", "$", "queryBuilder", "->", "update", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "elementsInUnavailableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", "->", "set", "(", "'backupColPos'", ",", "$", "queryBuilder", "->", "quoteIdentifier", "(", "'colPos'", ")", ",", "false", ")", "->", "set", "(", "'colPos'", ",", "-", "2", ")", "->", "execute", "(", ")", ";", "array_flip", "(", "$", "elementsInUnavailableColumns", ")", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "elementsInAvailableColumnsQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "this", "->", "getPageUid", "(", ")", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "neq", "(", "'backupColPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "-", "2", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'backupColPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "availableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "elementsInAvailableColumns", "=", "[", "]", ";", "while", "(", "$", "elementInAvailableColumns", "=", "$", "elementsInAvailableColumnsQuery", "->", "fetch", "(", ")", ")", "{", "$", "elementsInAvailableColumns", "[", "]", "=", "$", "elementInAvailableColumns", "[", "'uid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "elementsInAvailableColumns", ")", ")", "{", "$", "queryBuilder", "->", "update", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "elementsInAvailableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", "->", "set", "(", "'colPos'", ",", "$", "queryBuilder", "->", "quoteIdentifier", "(", "'backupColPos'", ")", ",", "false", ")", "->", "set", "(", "'backupColPos'", ",", "-", "2", ")", "->", "execute", "(", ")", ";", "array_flip", "(", "$", "elementsInAvailableColumns", ")", ";", "}", "$", "changedElements", "=", "$", "elementsInUnavailableColumns", "+", "$", "elementsInAvailableColumns", ";", "}", "if", "(", "isset", "(", "$", "fieldArray", "[", "'backend_layout_next_level'", "]", ")", ")", "{", "$", "backendLayoutUid", "=", "$", "backendLayoutNextLevelUid", "?", "$", "backendLayoutNextLevelUid", ":", "$", "backendLayoutUid", ";", "$", "subPages", "=", "[", "]", ";", "$", "this", "->", "getSubPagesRecursively", "(", "$", "this", "->", "getPageUid", "(", ")", ",", "$", "subPages", ")", ";", "if", "(", "!", "empty", "(", "$", "subPages", ")", ")", "{", "$", "changedSubPageElements", "=", "[", "]", ";", "foreach", "(", "$", "subPages", "as", "$", "page", ")", "{", "$", "availableColumns", "=", "$", "this", "->", "getAvailableColumns", "(", "$", "backendLayoutUid", ",", "'pages'", ",", "$", "page", "[", "'uid'", "]", ")", ";", "$", "availableColumns", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "availableColumns", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "subPageElementsInUnavailableColumnsQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "page", "[", "'uid'", "]", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "notIn", "(", "'colPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "availableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "subPageElementsInUnavailableColumns", "=", "[", "]", ";", "while", "(", "$", "subPageElementInUnavailableColumns", "=", "$", "subPageElementsInUnavailableColumnsQuery", "->", "fetch", "(", ")", ")", "{", "$", "subPageElementsInUnavailableColumns", "[", "]", "=", "$", "subPageElementInUnavailableColumns", "[", "'uid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "subPageElementsInUnavailableColumns", ")", ")", "{", "$", "queryBuilder", "->", "update", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "subPageElementsInUnavailableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", "->", "set", "(", "'backupColPos'", ",", "$", "queryBuilder", "->", "quoteIdentifier", "(", "'colPos'", ")", ",", "false", ")", "->", "set", "(", "'colPos'", ",", "-", "2", ")", "->", "execute", "(", ")", ";", "array_flip", "(", "$", "subPageElementsInUnavailableColumns", ")", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "subPageElementsInAvailableColumnsQuery", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ")", "->", "from", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "andX", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "page", "[", "'uid'", "]", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "neq", "(", "'backupColPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "-", "2", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ",", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'backupColPos'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "availableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", ")", "->", "execute", "(", ")", ";", "$", "subPageElementsInAvailableColumns", "=", "[", "]", ";", "while", "(", "$", "subPageElementInAvailableColumns", "=", "$", "subPageElementsInAvailableColumnsQuery", "->", "fetch", "(", ")", ")", "{", "$", "subPageElementsInAvailableColumns", "[", "]", "=", "$", "subPageElementInAvailableColumns", "[", "'uid'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "subPageElementsInAvailableColumns", ")", ")", "{", "$", "queryBuilder", "->", "update", "(", "'tt_content'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "in", "(", "'uid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "$", "subPageElementsInAvailableColumns", ",", "Connection", "::", "PARAM_INT_ARRAY", ")", ")", ")", "->", "set", "(", "'colPos'", ",", "$", "queryBuilder", "->", "quoteIdentifier", "(", "'backupColPos'", ")", ",", "false", ")", "->", "set", "(", "'backupColPos'", ",", "-", "2", ")", "->", "execute", "(", ")", ";", "array_flip", "(", "$", "subPageElementsInAvailableColumns", ")", ";", "}", "$", "changedPageElements", "=", "$", "subPageElementsInUnavailableColumns", "+", "$", "subPageElementsInAvailableColumns", ";", "$", "changedSubPageElements", "=", "$", "changedSubPageElements", "+", "$", "changedPageElements", ";", "}", "}", "}", "}", "$", "changedElementUids", "=", "$", "changedGridElements", "+", "$", "changedElements", "+", "$", "changedSubPageElements", ";", "if", "(", "!", "empty", "(", "$", "changedElementUids", ")", ")", "{", "foreach", "(", "$", "changedElementUids", "as", "$", "uid", "=>", "$", "value", ")", "{", "$", "this", "->", "dataHandler", "->", "updateRefIndex", "(", "'tt_content'", ",", "$", "uid", ")", ";", "}", "}", "}" ]
Function to move elements to/from the unused elements column while changing the layout of a page or a grid element @param array $fieldArray The array of fields and values that have been saved to the datamap
[ "Function", "to", "move", "elements", "to", "/", "from", "the", "unused", "elements", "column", "while", "changing", "the", "layout", "of", "a", "page", "or", "a", "grid", "element" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AfterDatabaseOperations.php#L124-L451
TYPO3-extensions/gridelements
Classes/DataHandler/AfterDatabaseOperations.php
AfterDatabaseOperations.getAvailableColumns
public function getAvailableColumns($layout = '', $table = '', $id = 0) { $tcaColumns = ''; if ($layout && $table === 'tt_content') { $tcaColumns = $this->layoutSetup->getLayoutColumns($layout); $tcaColumns = '-2,-1,' . $tcaColumns['CSV']; } elseif ($table === 'pages') { $tcaColumns = GeneralUtility::callUserFunction( BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this ); $temp = []; foreach ($tcaColumns as $item) { if (trim($item[1]) !== '') { $temp[] = (int)$item[1]; } } // Implode into a CSV string as BackendLayoutView->getColPosListItemsParsed returns an array $tcaColumns = rtrim('-2,-1,' . implode(',', $temp), ','); } return $tcaColumns; }
php
public function getAvailableColumns($layout = '', $table = '', $id = 0) { $tcaColumns = ''; if ($layout && $table === 'tt_content') { $tcaColumns = $this->layoutSetup->getLayoutColumns($layout); $tcaColumns = '-2,-1,' . $tcaColumns['CSV']; } elseif ($table === 'pages') { $tcaColumns = GeneralUtility::callUserFunction( BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this ); $temp = []; foreach ($tcaColumns as $item) { if (trim($item[1]) !== '') { $temp[] = (int)$item[1]; } } // Implode into a CSV string as BackendLayoutView->getColPosListItemsParsed returns an array $tcaColumns = rtrim('-2,-1,' . implode(',', $temp), ','); } return $tcaColumns; }
[ "public", "function", "getAvailableColumns", "(", "$", "layout", "=", "''", ",", "$", "table", "=", "''", ",", "$", "id", "=", "0", ")", "{", "$", "tcaColumns", "=", "''", ";", "if", "(", "$", "layout", "&&", "$", "table", "===", "'tt_content'", ")", "{", "$", "tcaColumns", "=", "$", "this", "->", "layoutSetup", "->", "getLayoutColumns", "(", "$", "layout", ")", ";", "$", "tcaColumns", "=", "'-2,-1,'", ".", "$", "tcaColumns", "[", "'CSV'", "]", ";", "}", "elseif", "(", "$", "table", "===", "'pages'", ")", "{", "$", "tcaColumns", "=", "GeneralUtility", "::", "callUserFunction", "(", "BackendLayoutView", "::", "class", ".", "'->getColPosListItemsParsed'", ",", "$", "id", ",", "$", "this", ")", ";", "$", "temp", "=", "[", "]", ";", "foreach", "(", "$", "tcaColumns", "as", "$", "item", ")", "{", "if", "(", "trim", "(", "$", "item", "[", "1", "]", ")", "!==", "''", ")", "{", "$", "temp", "[", "]", "=", "(", "int", ")", "$", "item", "[", "1", "]", ";", "}", "}", "// Implode into a CSV string as BackendLayoutView->getColPosListItemsParsed returns an array", "$", "tcaColumns", "=", "rtrim", "(", "'-2,-1,'", ".", "implode", "(", "','", ",", "$", "temp", ")", ",", "','", ")", ";", "}", "return", "$", "tcaColumns", ";", "}" ]
fetches all available columns for a certain grid container based on TCA settings and layout records @param string $layout The selected backend layout of the grid container or the page @param string $table The name of the table to get the layout for @param int $id he uid of the parent container - being the page id for the table "pages" @return string The columns available for the selected layout as CSV list
[ "fetches", "all", "available", "columns", "for", "a", "certain", "grid", "container", "based", "on", "TCA", "settings", "and", "layout", "records" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AfterDatabaseOperations.php#L462-L485
TYPO3-extensions/gridelements
Classes/DataHandler/AfterDatabaseOperations.php
AfterDatabaseOperations.getSubPagesRecursively
public function getSubPagesRecursively($pageUid, array &$subPages) { $queryBuilder = $this->getQueryBuilder('pages'); $childPages = $queryBuilder ->select('uid', 'backend_layout', 'backend_layout_next_level') ->from('pages') ->where( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pageUid, \PDO::PARAM_INT) ) ) ->execute() ->fetchAll(); if (!empty($childPages)) { foreach ($childPages as $page) { if (empty($page['backend_layout'])) { $subPages[] = $page; } if (empty($page['backend_layout_next_level'])) { $this->getSubPagesRecursively($page['uid'], $subPages); } } } }
php
public function getSubPagesRecursively($pageUid, array &$subPages) { $queryBuilder = $this->getQueryBuilder('pages'); $childPages = $queryBuilder ->select('uid', 'backend_layout', 'backend_layout_next_level') ->from('pages') ->where( $queryBuilder->expr()->eq( 'pid', $queryBuilder->createNamedParameter((int)$pageUid, \PDO::PARAM_INT) ) ) ->execute() ->fetchAll(); if (!empty($childPages)) { foreach ($childPages as $page) { if (empty($page['backend_layout'])) { $subPages[] = $page; } if (empty($page['backend_layout_next_level'])) { $this->getSubPagesRecursively($page['uid'], $subPages); } } } }
[ "public", "function", "getSubPagesRecursively", "(", "$", "pageUid", ",", "array", "&", "$", "subPages", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", "'pages'", ")", ";", "$", "childPages", "=", "$", "queryBuilder", "->", "select", "(", "'uid'", ",", "'backend_layout'", ",", "'backend_layout_next_level'", ")", "->", "from", "(", "'pages'", ")", "->", "where", "(", "$", "queryBuilder", "->", "expr", "(", ")", "->", "eq", "(", "'pid'", ",", "$", "queryBuilder", "->", "createNamedParameter", "(", "(", "int", ")", "$", "pageUid", ",", "\\", "PDO", "::", "PARAM_INT", ")", ")", ")", "->", "execute", "(", ")", "->", "fetchAll", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "childPages", ")", ")", "{", "foreach", "(", "$", "childPages", "as", "$", "page", ")", "{", "if", "(", "empty", "(", "$", "page", "[", "'backend_layout'", "]", ")", ")", "{", "$", "subPages", "[", "]", "=", "$", "page", ";", "}", "if", "(", "empty", "(", "$", "page", "[", "'backend_layout_next_level'", "]", ")", ")", "{", "$", "this", "->", "getSubPagesRecursively", "(", "$", "page", "[", "'uid'", "]", ",", "$", "subPages", ")", ";", "}", "}", "}", "}" ]
gets all subpages of the current page and traverses recursively unless backend_layout_next_level is set or unset (!= 0) @param int $pageUid @param array $subPages
[ "gets", "all", "subpages", "of", "the", "current", "page", "and", "traverses", "recursively", "unless", "backend_layout_next_level", "is", "set", "or", "unset", "(", "!", "=", "0", ")" ]
train
https://github.com/TYPO3-extensions/gridelements/blob/50a1ee6965445938726ca33c423d30a29adaf0a6/Classes/DataHandler/AfterDatabaseOperations.php#L493-L518
felixfbecker/php-advanced-json-rpc
lib/Request.php
Request.isRequest
public static function isRequest($msg): bool { return is_object($msg) && property_exists($msg, 'id') && isset($msg->method); }
php
public static function isRequest($msg): bool { return is_object($msg) && property_exists($msg, 'id') && isset($msg->method); }
[ "public", "static", "function", "isRequest", "(", "$", "msg", ")", ":", "bool", "{", "return", "is_object", "(", "$", "msg", ")", "&&", "property_exists", "(", "$", "msg", ",", "'id'", ")", "&&", "isset", "(", "$", "msg", "->", "method", ")", ";", "}" ]
A message is considered a Request if it has an ID and a method. @param object $msg A decoded message body @return bool
[ "A", "message", "is", "considered", "a", "Request", "if", "it", "has", "an", "ID", "and", "a", "method", "." ]
train
https://github.com/felixfbecker/php-advanced-json-rpc/blob/aaaf9b6088b9149ece1bf0e5f690976506bbdadf/lib/Request.php#L47-L50
felixfbecker/php-advanced-json-rpc
lib/Message.php
Message.parse
public static function parse(string $msg): Message { $decoded = json_decode($msg); if (json_last_error() !== JSON_ERROR_NONE) { throw new Error(json_last_error_msg(), ErrorCode::PARSE_ERROR); } if (Notification::isNotification($decoded)) { $obj = new Notification($decoded->method, $decoded->params ?? null); } else if (Request::isRequest($decoded)) { $obj = new Request($decoded->id, $decoded->method, $decoded->params ?? null); } else if (SuccessResponse::isSuccessResponse($decoded)) { $obj = new SuccessResponse($decoded->id, $decoded->result); } else if (ErrorResponse::isErrorResponse($decoded)) { $obj = new ErrorResponse($decoded->id, new Error($decoded->error->message, $decoded->error->code, $decoded->error->data ?? null)); } else { throw new Error('Invalid message', ErrorCode::INVALID_REQUEST); } return $obj; }
php
public static function parse(string $msg): Message { $decoded = json_decode($msg); if (json_last_error() !== JSON_ERROR_NONE) { throw new Error(json_last_error_msg(), ErrorCode::PARSE_ERROR); } if (Notification::isNotification($decoded)) { $obj = new Notification($decoded->method, $decoded->params ?? null); } else if (Request::isRequest($decoded)) { $obj = new Request($decoded->id, $decoded->method, $decoded->params ?? null); } else if (SuccessResponse::isSuccessResponse($decoded)) { $obj = new SuccessResponse($decoded->id, $decoded->result); } else if (ErrorResponse::isErrorResponse($decoded)) { $obj = new ErrorResponse($decoded->id, new Error($decoded->error->message, $decoded->error->code, $decoded->error->data ?? null)); } else { throw new Error('Invalid message', ErrorCode::INVALID_REQUEST); } return $obj; }
[ "public", "static", "function", "parse", "(", "string", "$", "msg", ")", ":", "Message", "{", "$", "decoded", "=", "json_decode", "(", "$", "msg", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "Error", "(", "json_last_error_msg", "(", ")", ",", "ErrorCode", "::", "PARSE_ERROR", ")", ";", "}", "if", "(", "Notification", "::", "isNotification", "(", "$", "decoded", ")", ")", "{", "$", "obj", "=", "new", "Notification", "(", "$", "decoded", "->", "method", ",", "$", "decoded", "->", "params", "??", "null", ")", ";", "}", "else", "if", "(", "Request", "::", "isRequest", "(", "$", "decoded", ")", ")", "{", "$", "obj", "=", "new", "Request", "(", "$", "decoded", "->", "id", ",", "$", "decoded", "->", "method", ",", "$", "decoded", "->", "params", "??", "null", ")", ";", "}", "else", "if", "(", "SuccessResponse", "::", "isSuccessResponse", "(", "$", "decoded", ")", ")", "{", "$", "obj", "=", "new", "SuccessResponse", "(", "$", "decoded", "->", "id", ",", "$", "decoded", "->", "result", ")", ";", "}", "else", "if", "(", "ErrorResponse", "::", "isErrorResponse", "(", "$", "decoded", ")", ")", "{", "$", "obj", "=", "new", "ErrorResponse", "(", "$", "decoded", "->", "id", ",", "new", "Error", "(", "$", "decoded", "->", "error", "->", "message", ",", "$", "decoded", "->", "error", "->", "code", ",", "$", "decoded", "->", "error", "->", "data", "??", "null", ")", ")", ";", "}", "else", "{", "throw", "new", "Error", "(", "'Invalid message'", ",", "ErrorCode", "::", "INVALID_REQUEST", ")", ";", "}", "return", "$", "obj", ";", "}" ]
Returns the appropriate Message subclass @param string $msg @return Message
[ "Returns", "the", "appropriate", "Message", "subclass" ]
train
https://github.com/felixfbecker/php-advanced-json-rpc/blob/aaaf9b6088b9149ece1bf0e5f690976506bbdadf/lib/Message.php#L24-L42
felixfbecker/php-advanced-json-rpc
lib/ErrorResponse.php
ErrorResponse.isErrorResponse
public static function isErrorResponse($msg): bool { return is_object($msg) && isset($msg->id) && isset($msg->error); }
php
public static function isErrorResponse($msg): bool { return is_object($msg) && isset($msg->id) && isset($msg->error); }
[ "public", "static", "function", "isErrorResponse", "(", "$", "msg", ")", ":", "bool", "{", "return", "is_object", "(", "$", "msg", ")", "&&", "isset", "(", "$", "msg", "->", "id", ")", "&&", "isset", "(", "$", "msg", "->", "error", ")", ";", "}" ]
A message is considered a Response if it has an ID and either a result or an error @param object $msg A decoded message body @return bool
[ "A", "message", "is", "considered", "a", "Response", "if", "it", "has", "an", "ID", "and", "either", "a", "result", "or", "an", "error" ]
train
https://github.com/felixfbecker/php-advanced-json-rpc/blob/aaaf9b6088b9149ece1bf0e5f690976506bbdadf/lib/ErrorResponse.php#L26-L29
felixfbecker/php-advanced-json-rpc
lib/Dispatcher.php
Dispatcher.dispatch
public function dispatch($msg) { if (is_string($msg)) { $msg = json_decode($msg); if (json_last_error() !== JSON_ERROR_NONE) { throw new Error(json_last_error_msg(), ErrorCode::PARSE_ERROR); } } // Find out the object and function that should be called $obj = $this->target; $parts = explode($this->delimiter, $msg->method); // The function to call is always the last part of the method $fn = array_pop($parts); // For namespaced methods like textDocument/didOpen, call the didOpen method on the $textDocument property // For simple methods like initialize, shutdown, exit, this loop will simply not be entered and $obj will be // the target foreach ($parts as $part) { if (!isset($obj->$part)) { throw new Error("Method {$msg->method} is not implemented", ErrorCode::METHOD_NOT_FOUND); } $obj = $obj->$part; } if (!isset($this->methods[$msg->method])) { try { $method = new ReflectionMethod($obj, $fn); $this->methods[$msg->method] = $method; } catch (ReflectionException $e) { throw new Error($e->getMessage(), ErrorCode::METHOD_NOT_FOUND, null, $e); } } $method = $this->methods[$msg->method]; $parameters = $method->getParameters(); if ($method->getDocComment()) { $docBlock = $this->docBlockFactory->create( $method->getDocComment(), $this->contextFactory->createFromReflector($method->getDeclaringClass()) ); $paramTags = $docBlock->getTagsByName('param'); } $args = []; if (isset($msg->params)) { // Find out the position if (is_array($msg->params)) { $args = $msg->params; } else if (is_object($msg->params)) { foreach ($parameters as $pos => $parameter) { $value = null; foreach(get_object_vars($msg->params) as $key => $val) { if ($parameter->name === $key) { $value = $val; break; } } $args[$pos] = $value; } } else { throw new Error('Params must be structured or omitted', ErrorCode::INVALID_REQUEST); } foreach ($args as $position => $value) { try { // If the type is structured (array or object), map it with JsonMapper if (is_object($value)) { // Does the parameter have a type hint? $param = $parameters[$position]; if ($param->hasType()) { $class = (string)$param->getType(); $value = $this->mapper->map($value, new $class()); } } else if (is_array($value) && isset($docBlock)) { // Get the array type from the DocBlock $type = $paramTags[$position]->getType(); // For union types, use the first one that is a class array (often it is SomeClass[]|null) if ($type instanceof Types\Compound) { for ($i = 0; $t = $type->get($i); $i++) { if ( $t instanceof Types\Array_ && $t->getValueType() instanceof Types\Object_ && (string)$t->getValueType() !== 'object' ) { $class = (string)$t->getValueType()->getFqsen(); $value = $this->mapper->mapArray($value, [], $class); break; } } } else if ($type instanceof Types\Array_) { $class = (string)$type->getValueType()->getFqsen(); $value = $this->mapper->mapArray($value, [], $class); } else { throw new Error('Type is not matching @param tag', ErrorCode::INVALID_PARAMS); } } } catch (JsonMapper_Exception $e) { throw new Error($e->getMessage(), ErrorCode::INVALID_PARAMS, null, $e); } $args[$position] = $value; } } ksort($args); $result = $obj->$fn(...$args); return $result; }
php
public function dispatch($msg) { if (is_string($msg)) { $msg = json_decode($msg); if (json_last_error() !== JSON_ERROR_NONE) { throw new Error(json_last_error_msg(), ErrorCode::PARSE_ERROR); } } // Find out the object and function that should be called $obj = $this->target; $parts = explode($this->delimiter, $msg->method); // The function to call is always the last part of the method $fn = array_pop($parts); // For namespaced methods like textDocument/didOpen, call the didOpen method on the $textDocument property // For simple methods like initialize, shutdown, exit, this loop will simply not be entered and $obj will be // the target foreach ($parts as $part) { if (!isset($obj->$part)) { throw new Error("Method {$msg->method} is not implemented", ErrorCode::METHOD_NOT_FOUND); } $obj = $obj->$part; } if (!isset($this->methods[$msg->method])) { try { $method = new ReflectionMethod($obj, $fn); $this->methods[$msg->method] = $method; } catch (ReflectionException $e) { throw new Error($e->getMessage(), ErrorCode::METHOD_NOT_FOUND, null, $e); } } $method = $this->methods[$msg->method]; $parameters = $method->getParameters(); if ($method->getDocComment()) { $docBlock = $this->docBlockFactory->create( $method->getDocComment(), $this->contextFactory->createFromReflector($method->getDeclaringClass()) ); $paramTags = $docBlock->getTagsByName('param'); } $args = []; if (isset($msg->params)) { // Find out the position if (is_array($msg->params)) { $args = $msg->params; } else if (is_object($msg->params)) { foreach ($parameters as $pos => $parameter) { $value = null; foreach(get_object_vars($msg->params) as $key => $val) { if ($parameter->name === $key) { $value = $val; break; } } $args[$pos] = $value; } } else { throw new Error('Params must be structured or omitted', ErrorCode::INVALID_REQUEST); } foreach ($args as $position => $value) { try { // If the type is structured (array or object), map it with JsonMapper if (is_object($value)) { // Does the parameter have a type hint? $param = $parameters[$position]; if ($param->hasType()) { $class = (string)$param->getType(); $value = $this->mapper->map($value, new $class()); } } else if (is_array($value) && isset($docBlock)) { // Get the array type from the DocBlock $type = $paramTags[$position]->getType(); // For union types, use the first one that is a class array (often it is SomeClass[]|null) if ($type instanceof Types\Compound) { for ($i = 0; $t = $type->get($i); $i++) { if ( $t instanceof Types\Array_ && $t->getValueType() instanceof Types\Object_ && (string)$t->getValueType() !== 'object' ) { $class = (string)$t->getValueType()->getFqsen(); $value = $this->mapper->mapArray($value, [], $class); break; } } } else if ($type instanceof Types\Array_) { $class = (string)$type->getValueType()->getFqsen(); $value = $this->mapper->mapArray($value, [], $class); } else { throw new Error('Type is not matching @param tag', ErrorCode::INVALID_PARAMS); } } } catch (JsonMapper_Exception $e) { throw new Error($e->getMessage(), ErrorCode::INVALID_PARAMS, null, $e); } $args[$position] = $value; } } ksort($args); $result = $obj->$fn(...$args); return $result; }
[ "public", "function", "dispatch", "(", "$", "msg", ")", "{", "if", "(", "is_string", "(", "$", "msg", ")", ")", "{", "$", "msg", "=", "json_decode", "(", "$", "msg", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "Error", "(", "json_last_error_msg", "(", ")", ",", "ErrorCode", "::", "PARSE_ERROR", ")", ";", "}", "}", "// Find out the object and function that should be called", "$", "obj", "=", "$", "this", "->", "target", ";", "$", "parts", "=", "explode", "(", "$", "this", "->", "delimiter", ",", "$", "msg", "->", "method", ")", ";", "// The function to call is always the last part of the method", "$", "fn", "=", "array_pop", "(", "$", "parts", ")", ";", "// For namespaced methods like textDocument/didOpen, call the didOpen method on the $textDocument property", "// For simple methods like initialize, shutdown, exit, this loop will simply not be entered and $obj will be", "// the target", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "if", "(", "!", "isset", "(", "$", "obj", "->", "$", "part", ")", ")", "{", "throw", "new", "Error", "(", "\"Method {$msg->method} is not implemented\"", ",", "ErrorCode", "::", "METHOD_NOT_FOUND", ")", ";", "}", "$", "obj", "=", "$", "obj", "->", "$", "part", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "methods", "[", "$", "msg", "->", "method", "]", ")", ")", "{", "try", "{", "$", "method", "=", "new", "ReflectionMethod", "(", "$", "obj", ",", "$", "fn", ")", ";", "$", "this", "->", "methods", "[", "$", "msg", "->", "method", "]", "=", "$", "method", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "Error", "(", "$", "e", "->", "getMessage", "(", ")", ",", "ErrorCode", "::", "METHOD_NOT_FOUND", ",", "null", ",", "$", "e", ")", ";", "}", "}", "$", "method", "=", "$", "this", "->", "methods", "[", "$", "msg", "->", "method", "]", ";", "$", "parameters", "=", "$", "method", "->", "getParameters", "(", ")", ";", "if", "(", "$", "method", "->", "getDocComment", "(", ")", ")", "{", "$", "docBlock", "=", "$", "this", "->", "docBlockFactory", "->", "create", "(", "$", "method", "->", "getDocComment", "(", ")", ",", "$", "this", "->", "contextFactory", "->", "createFromReflector", "(", "$", "method", "->", "getDeclaringClass", "(", ")", ")", ")", ";", "$", "paramTags", "=", "$", "docBlock", "->", "getTagsByName", "(", "'param'", ")", ";", "}", "$", "args", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "msg", "->", "params", ")", ")", "{", "// Find out the position", "if", "(", "is_array", "(", "$", "msg", "->", "params", ")", ")", "{", "$", "args", "=", "$", "msg", "->", "params", ";", "}", "else", "if", "(", "is_object", "(", "$", "msg", "->", "params", ")", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "pos", "=>", "$", "parameter", ")", "{", "$", "value", "=", "null", ";", "foreach", "(", "get_object_vars", "(", "$", "msg", "->", "params", ")", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "$", "parameter", "->", "name", "===", "$", "key", ")", "{", "$", "value", "=", "$", "val", ";", "break", ";", "}", "}", "$", "args", "[", "$", "pos", "]", "=", "$", "value", ";", "}", "}", "else", "{", "throw", "new", "Error", "(", "'Params must be structured or omitted'", ",", "ErrorCode", "::", "INVALID_REQUEST", ")", ";", "}", "foreach", "(", "$", "args", "as", "$", "position", "=>", "$", "value", ")", "{", "try", "{", "// If the type is structured (array or object), map it with JsonMapper", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "// Does the parameter have a type hint?", "$", "param", "=", "$", "parameters", "[", "$", "position", "]", ";", "if", "(", "$", "param", "->", "hasType", "(", ")", ")", "{", "$", "class", "=", "(", "string", ")", "$", "param", "->", "getType", "(", ")", ";", "$", "value", "=", "$", "this", "->", "mapper", "->", "map", "(", "$", "value", ",", "new", "$", "class", "(", ")", ")", ";", "}", "}", "else", "if", "(", "is_array", "(", "$", "value", ")", "&&", "isset", "(", "$", "docBlock", ")", ")", "{", "// Get the array type from the DocBlock", "$", "type", "=", "$", "paramTags", "[", "$", "position", "]", "->", "getType", "(", ")", ";", "// For union types, use the first one that is a class array (often it is SomeClass[]|null)", "if", "(", "$", "type", "instanceof", "Types", "\\", "Compound", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "t", "=", "$", "type", "->", "get", "(", "$", "i", ")", ";", "$", "i", "++", ")", "{", "if", "(", "$", "t", "instanceof", "Types", "\\", "Array_", "&&", "$", "t", "->", "getValueType", "(", ")", "instanceof", "Types", "\\", "Object_", "&&", "(", "string", ")", "$", "t", "->", "getValueType", "(", ")", "!==", "'object'", ")", "{", "$", "class", "=", "(", "string", ")", "$", "t", "->", "getValueType", "(", ")", "->", "getFqsen", "(", ")", ";", "$", "value", "=", "$", "this", "->", "mapper", "->", "mapArray", "(", "$", "value", ",", "[", "]", ",", "$", "class", ")", ";", "break", ";", "}", "}", "}", "else", "if", "(", "$", "type", "instanceof", "Types", "\\", "Array_", ")", "{", "$", "class", "=", "(", "string", ")", "$", "type", "->", "getValueType", "(", ")", "->", "getFqsen", "(", ")", ";", "$", "value", "=", "$", "this", "->", "mapper", "->", "mapArray", "(", "$", "value", ",", "[", "]", ",", "$", "class", ")", ";", "}", "else", "{", "throw", "new", "Error", "(", "'Type is not matching @param tag'", ",", "ErrorCode", "::", "INVALID_PARAMS", ")", ";", "}", "}", "}", "catch", "(", "JsonMapper_Exception", "$", "e", ")", "{", "throw", "new", "Error", "(", "$", "e", "->", "getMessage", "(", ")", ",", "ErrorCode", "::", "INVALID_PARAMS", ",", "null", ",", "$", "e", ")", ";", "}", "$", "args", "[", "$", "position", "]", "=", "$", "value", ";", "}", "}", "ksort", "(", "$", "args", ")", ";", "$", "result", "=", "$", "obj", "->", "$", "fn", "(", "...", "$", "args", ")", ";", "return", "$", "result", ";", "}" ]
Calls the appropriate method handler for an incoming Message @param string|object $msg The incoming message @return Result|void
[ "Calls", "the", "appropriate", "method", "handler", "for", "an", "incoming", "Message" ]
train
https://github.com/felixfbecker/php-advanced-json-rpc/blob/aaaf9b6088b9149ece1bf0e5f690976506bbdadf/lib/Dispatcher.php#L62-L162
felixfbecker/php-advanced-json-rpc
lib/Notification.php
Notification.isNotification
public static function isNotification($msg): bool { return is_object($msg) && !property_exists($msg, 'id') && isset($msg->method); }
php
public static function isNotification($msg): bool { return is_object($msg) && !property_exists($msg, 'id') && isset($msg->method); }
[ "public", "static", "function", "isNotification", "(", "$", "msg", ")", ":", "bool", "{", "return", "is_object", "(", "$", "msg", ")", "&&", "!", "property_exists", "(", "$", "msg", ",", "'id'", ")", "&&", "isset", "(", "$", "msg", "->", "method", ")", ";", "}" ]
A message is considered a Notification if it has a method but no ID. @param object $msg A decoded message body @return bool
[ "A", "message", "is", "considered", "a", "Notification", "if", "it", "has", "a", "method", "but", "no", "ID", "." ]
train
https://github.com/felixfbecker/php-advanced-json-rpc/blob/aaaf9b6088b9149ece1bf0e5f690976506bbdadf/lib/Notification.php#L42-L45
felixfbecker/php-advanced-json-rpc
lib/Response.php
Response.isResponse
public static function isResponse($msg): bool { return is_object($msg) && property_exists($msg, 'id') && (property_exists($msg, 'result') || isset($msg->error)); }
php
public static function isResponse($msg): bool { return is_object($msg) && property_exists($msg, 'id') && (property_exists($msg, 'result') || isset($msg->error)); }
[ "public", "static", "function", "isResponse", "(", "$", "msg", ")", ":", "bool", "{", "return", "is_object", "(", "$", "msg", ")", "&&", "property_exists", "(", "$", "msg", ",", "'id'", ")", "&&", "(", "property_exists", "(", "$", "msg", ",", "'result'", ")", "||", "isset", "(", "$", "msg", "->", "error", ")", ")", ";", "}" ]
A message is considered a Response if it has an ID and either a result or an error @param object $msg A decoded message body @return bool
[ "A", "message", "is", "considered", "a", "Response", "if", "it", "has", "an", "ID", "and", "either", "a", "result", "or", "an", "error" ]
train
https://github.com/felixfbecker/php-advanced-json-rpc/blob/aaaf9b6088b9149ece1bf0e5f690976506bbdadf/lib/Response.php#L26-L29
codacy/php-codacy-coverage
src/Codacy/Coverage/Command/Clover.php
Clover.getParser
protected function getParser($path = null) { $path = is_null($path) ? join(DIRECTORY_SEPARATOR, array('build', 'logs', 'clover.xml')) : $path; return new CloverParser($path); }
php
protected function getParser($path = null) { $path = is_null($path) ? join(DIRECTORY_SEPARATOR, array('build', 'logs', 'clover.xml')) : $path; return new CloverParser($path); }
[ "protected", "function", "getParser", "(", "$", "path", "=", "null", ")", "{", "$", "path", "=", "is_null", "(", "$", "path", ")", "?", "join", "(", "DIRECTORY_SEPARATOR", ",", "array", "(", "'build'", ",", "'logs'", ",", "'clover.xml'", ")", ")", ":", "$", "path", ";", "return", "new", "CloverParser", "(", "$", "path", ")", ";", "}" ]
Get parser of current format type. @param string $path Path to clover.xml @return CloverParser
[ "Get", "parser", "of", "current", "format", "type", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Command/Clover.php#L82-L88
codacy/php-codacy-coverage
src/Codacy/Coverage/Command/Clover.php
Clover.getCommitHash
protected function getCommitHash($hash = null) { if (!$hash) { $gClient = new GitClient(getcwd()); return $gClient->getHashOfLatestCommit(); } if (strlen($hash) != 40) { throw new \InvalidArgumentException( sprintf("Invalid git commit hash %s specified", $hash) ); } return urlencode($hash); }
php
protected function getCommitHash($hash = null) { if (!$hash) { $gClient = new GitClient(getcwd()); return $gClient->getHashOfLatestCommit(); } if (strlen($hash) != 40) { throw new \InvalidArgumentException( sprintf("Invalid git commit hash %s specified", $hash) ); } return urlencode($hash); }
[ "protected", "function", "getCommitHash", "(", "$", "hash", "=", "null", ")", "{", "if", "(", "!", "$", "hash", ")", "{", "$", "gClient", "=", "new", "GitClient", "(", "getcwd", "(", ")", ")", ";", "return", "$", "gClient", "->", "getHashOfLatestCommit", "(", ")", ";", "}", "if", "(", "strlen", "(", "$", "hash", ")", "!=", "40", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Invalid git commit hash %s specified\"", ",", "$", "hash", ")", ")", ";", "}", "return", "urlencode", "(", "$", "hash", ")", ";", "}" ]
Get Git commit hash of project @param string $hash Specified hash @return string Git commit hash @throws \InvalidArgumentException When bad hash specified, or can't get commit hash
[ "Get", "Git", "commit", "hash", "of", "project" ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Command/Clover.php#L119-L133
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/CloverParser.php
CloverParser.makeReport
public function makeReport() { $project = $this->element->project; $projectMetrics = $project->metrics; $coveredStatements = intval($projectMetrics['coveredstatements']); $statementsTotal = intval($projectMetrics['statements']); $reportTotal = round($this->safeDivision($coveredStatements, $statementsTotal) * 100); $fileReports = $this->makeFileReports($project); $report = new CoverageReport($reportTotal, $fileReports); return $report; }
php
public function makeReport() { $project = $this->element->project; $projectMetrics = $project->metrics; $coveredStatements = intval($projectMetrics['coveredstatements']); $statementsTotal = intval($projectMetrics['statements']); $reportTotal = round($this->safeDivision($coveredStatements, $statementsTotal) * 100); $fileReports = $this->makeFileReports($project); $report = new CoverageReport($reportTotal, $fileReports); return $report; }
[ "public", "function", "makeReport", "(", ")", "{", "$", "project", "=", "$", "this", "->", "element", "->", "project", ";", "$", "projectMetrics", "=", "$", "project", "->", "metrics", ";", "$", "coveredStatements", "=", "intval", "(", "$", "projectMetrics", "[", "'coveredstatements'", "]", ")", ";", "$", "statementsTotal", "=", "intval", "(", "$", "projectMetrics", "[", "'statements'", "]", ")", ";", "$", "reportTotal", "=", "round", "(", "$", "this", "->", "safeDivision", "(", "$", "coveredStatements", ",", "$", "statementsTotal", ")", "*", "100", ")", ";", "$", "fileReports", "=", "$", "this", "->", "makeFileReports", "(", "$", "project", ")", ";", "$", "report", "=", "new", "CoverageReport", "(", "$", "reportTotal", ",", "$", "fileReports", ")", ";", "return", "$", "report", ";", "}" ]
Extracts basic information about coverage report and delegates more detailed extraction work to _makeFileReports() method. @return CoverageReport $report The CoverageReport object
[ "Extracts", "basic", "information", "about", "coverage", "report", "and", "delegates", "more", "detailed", "extraction", "work", "to", "_makeFileReports", "()", "method", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/CloverParser.php#L22-L32
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/CloverParser.php
CloverParser.makeFileReports
private function makeFileReports(\SimpleXMLElement $node) { $fileReports = array(); /* * Most clover reports will have project/package/file/line xPath. * But there could be files that are not part of any package, i.e files that * that do not declare namespace. */ if ($node->file->count() > 0) { // so there is a file without package $fileReports = $this->makeFileReportsFromFiles($node->file, $fileReports); } if ($node->package->count() > 0) { $fileReports = $this->makeFileReportsFromPackages($node->package, $fileReports); } return $fileReports; }
php
private function makeFileReports(\SimpleXMLElement $node) { $fileReports = array(); /* * Most clover reports will have project/package/file/line xPath. * But there could be files that are not part of any package, i.e files that * that do not declare namespace. */ if ($node->file->count() > 0) { // so there is a file without package $fileReports = $this->makeFileReportsFromFiles($node->file, $fileReports); } if ($node->package->count() > 0) { $fileReports = $this->makeFileReportsFromPackages($node->package, $fileReports); } return $fileReports; }
[ "private", "function", "makeFileReports", "(", "\\", "SimpleXMLElement", "$", "node", ")", "{", "$", "fileReports", "=", "array", "(", ")", ";", "/*\n * Most clover reports will have project/package/file/line xPath.\n * But there could be files that are not part of any package, i.e files that \n * that do not declare namespace.\n */", "if", "(", "$", "node", "->", "file", "->", "count", "(", ")", ">", "0", ")", "{", "// so there is a file without package", "$", "fileReports", "=", "$", "this", "->", "makeFileReportsFromFiles", "(", "$", "node", "->", "file", ",", "$", "fileReports", ")", ";", "}", "if", "(", "$", "node", "->", "package", "->", "count", "(", ")", ">", "0", ")", "{", "$", "fileReports", "=", "$", "this", "->", "makeFileReportsFromPackages", "(", "$", "node", "->", "package", ",", "$", "fileReports", ")", ";", "}", "return", "$", "fileReports", ";", "}" ]
Takes the root \SimpleXMLElement object of the parsed file and decides on how to iterate it to extract information of all <file...>..</file> nodes. @param \SimpleXMLElement $node the root XML node. @return array holding FileReport objects
[ "Takes", "the", "root", "\\", "SimpleXMLElement", "object", "of", "the", "parsed", "file", "and", "decides", "on", "how", "to", "iterate", "it", "to", "extract", "information", "of", "all", "<file", "...", ">", "..", "<", "/", "file", ">", "nodes", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/CloverParser.php#L41-L57
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/CloverParser.php
CloverParser.makeFileReportsFromFiles
private function makeFileReportsFromFiles(\SimpleXMLElement $node, $fileReports) { foreach ($node as $file) { // iterate files in the package $countStatement = intval($file->metrics['statements']); $countCoveredStatements = intval($file->metrics['coveredstatements']); if ($countStatement == 0) { $fileTotal = 0; } else { $fileTotal = round($this->safeDivision($countCoveredStatements, $countStatement) * 100); } $fileName = $this->getRelativePath($file['name']); $lineCoverage = $this->getLineCoverage($file); $fileReport = new FileReport($fileTotal, $fileName, $lineCoverage); array_push($fileReports, $fileReport); } return $fileReports; }
php
private function makeFileReportsFromFiles(\SimpleXMLElement $node, $fileReports) { foreach ($node as $file) { // iterate files in the package $countStatement = intval($file->metrics['statements']); $countCoveredStatements = intval($file->metrics['coveredstatements']); if ($countStatement == 0) { $fileTotal = 0; } else { $fileTotal = round($this->safeDivision($countCoveredStatements, $countStatement) * 100); } $fileName = $this->getRelativePath($file['name']); $lineCoverage = $this->getLineCoverage($file); $fileReport = new FileReport($fileTotal, $fileName, $lineCoverage); array_push($fileReports, $fileReport); } return $fileReports; }
[ "private", "function", "makeFileReportsFromFiles", "(", "\\", "SimpleXMLElement", "$", "node", ",", "$", "fileReports", ")", "{", "foreach", "(", "$", "node", "as", "$", "file", ")", "{", "// iterate files in the package", "$", "countStatement", "=", "intval", "(", "$", "file", "->", "metrics", "[", "'statements'", "]", ")", ";", "$", "countCoveredStatements", "=", "intval", "(", "$", "file", "->", "metrics", "[", "'coveredstatements'", "]", ")", ";", "if", "(", "$", "countStatement", "==", "0", ")", "{", "$", "fileTotal", "=", "0", ";", "}", "else", "{", "$", "fileTotal", "=", "round", "(", "$", "this", "->", "safeDivision", "(", "$", "countCoveredStatements", ",", "$", "countStatement", ")", "*", "100", ")", ";", "}", "$", "fileName", "=", "$", "this", "->", "getRelativePath", "(", "$", "file", "[", "'name'", "]", ")", ";", "$", "lineCoverage", "=", "$", "this", "->", "getLineCoverage", "(", "$", "file", ")", ";", "$", "fileReport", "=", "new", "FileReport", "(", "$", "fileTotal", ",", "$", "fileName", ",", "$", "lineCoverage", ")", ";", "array_push", "(", "$", "fileReports", ",", "$", "fileReport", ")", ";", "}", "return", "$", "fileReports", ";", "}" ]
Iterates all over all <file...>..</file> nodes. @param \SimpleXMLElement $node The XML node holding the file nodes. @param array $fileReports array of FileReport objects @return array holding FileReport objects
[ "Iterates", "all", "over", "all", "<file", "...", ">", "..", "<", "/", "file", ">", "nodes", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/CloverParser.php#L65-L82
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/CloverParser.php
CloverParser.makeFileReportsFromPackages
private function makeFileReportsFromPackages(\SimpleXMLElement $node, $fileReports) { // iterate all packages foreach ($node as $package) { $fileReports = $this->makeFileReportsFromFiles($package->file, $fileReports); } return $fileReports; }
php
private function makeFileReportsFromPackages(\SimpleXMLElement $node, $fileReports) { // iterate all packages foreach ($node as $package) { $fileReports = $this->makeFileReportsFromFiles($package->file, $fileReports); } return $fileReports; }
[ "private", "function", "makeFileReportsFromPackages", "(", "\\", "SimpleXMLElement", "$", "node", ",", "$", "fileReports", ")", "{", "// iterate all packages", "foreach", "(", "$", "node", "as", "$", "package", ")", "{", "$", "fileReports", "=", "$", "this", "->", "makeFileReportsFromFiles", "(", "$", "package", "->", "file", ",", "$", "fileReports", ")", ";", "}", "return", "$", "fileReports", ";", "}" ]
Iterates over all <package..>...</package> nodes and calls _makeFileReportsFromFiles on them @param \SimpleXMLElement $node The XML node holding all <package..>...</package> nodes @param array $fileReports array of FileReport objects @return array holding FileReport objects
[ "Iterates", "over", "all", "<package", "..", ">", "...", "<", "/", "package", ">", "nodes", "and", "calls", "_makeFileReportsFromFiles", "on", "them" ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/CloverParser.php#L90-L97
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/CloverParser.php
CloverParser.getLineCoverage
private function getLineCoverage(\SimpleXMLElement $node) { $lineCoverage = (object)array(); foreach ($node as $line) { $count = intval($line['count']); // iterate all lines in that file if ($line['type'] == 'stmt') { $lineNr = (string)$line['num']; $hit = $count; $lineCoverage->$lineNr = $hit; } } return $lineCoverage; }
php
private function getLineCoverage(\SimpleXMLElement $node) { $lineCoverage = (object)array(); foreach ($node as $line) { $count = intval($line['count']); // iterate all lines in that file if ($line['type'] == 'stmt') { $lineNr = (string)$line['num']; $hit = $count; $lineCoverage->$lineNr = $hit; } } return $lineCoverage; }
[ "private", "function", "getLineCoverage", "(", "\\", "SimpleXMLElement", "$", "node", ")", "{", "$", "lineCoverage", "=", "(", "object", ")", "array", "(", ")", ";", "foreach", "(", "$", "node", "as", "$", "line", ")", "{", "$", "count", "=", "intval", "(", "$", "line", "[", "'count'", "]", ")", ";", "// iterate all lines in that file", "if", "(", "$", "line", "[", "'type'", "]", "==", "'stmt'", ")", "{", "$", "lineNr", "=", "(", "string", ")", "$", "line", "[", "'num'", "]", ";", "$", "hit", "=", "$", "count", ";", "$", "lineCoverage", "->", "$", "lineNr", "=", "$", "hit", ";", "}", "}", "return", "$", "lineCoverage", ";", "}" ]
Iterates all <line></line> nodes and produces an array holding line coverage information. Only adds lines of type "stmt" and with count greater than 0. @param \SimpleXMLElement $node The XML node holding the <line></line> nodes @return array: (lineNumber -> hits)
[ "Iterates", "all", "<line", ">", "<", "/", "line", ">", "nodes", "and", "produces", "an", "array", "holding", "line", "coverage", "information", ".", "Only", "adds", "lines", "of", "type", "stmt", "and", "with", "count", "greater", "than", "0", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/CloverParser.php#L105-L118
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/CloverParser.php
CloverParser.getRelativePath
private function getRelativePath(\SimpleXMLElement $fileName) { $prefix = $this->rootDir . DIRECTORY_SEPARATOR; $str = (string)$fileName; if (substr($str, 0, strlen($prefix)) == $prefix) { $str = substr($str, strlen($prefix)); } return $str; }
php
private function getRelativePath(\SimpleXMLElement $fileName) { $prefix = $this->rootDir . DIRECTORY_SEPARATOR; $str = (string)$fileName; if (substr($str, 0, strlen($prefix)) == $prefix) { $str = substr($str, strlen($prefix)); } return $str; }
[ "private", "function", "getRelativePath", "(", "\\", "SimpleXMLElement", "$", "fileName", ")", "{", "$", "prefix", "=", "$", "this", "->", "rootDir", ".", "DIRECTORY_SEPARATOR", ";", "$", "str", "=", "(", "string", ")", "$", "fileName", ";", "if", "(", "substr", "(", "$", "str", ",", "0", ",", "strlen", "(", "$", "prefix", ")", ")", "==", "$", "prefix", ")", "{", "$", "str", "=", "substr", "(", "$", "str", ",", "strlen", "(", "$", "prefix", ")", ")", ";", "}", "return", "$", "str", ";", "}" ]
Cuts the file name so we have relative path to projectRoot. In a clover file file names are saved from / on. We are only interested in relative filename @param \SimpleXMLElement $fileName The filename attribute @return string The relative path of that file
[ "Cuts", "the", "file", "name", "so", "we", "have", "relative", "path", "to", "projectRoot", ".", "In", "a", "clover", "file", "file", "names", "are", "saved", "from", "/", "on", ".", "We", "are", "only", "interested", "in", "relative", "filename" ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/CloverParser.php#L127-L137
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/PhpUnitXmlParser.php
PhpUnitXmlParser.getLineCoverage
private function getLineCoverage(\SimpleXMLElement $node) { $lineCoverage = (object)array(); if ($node->file->coverage) { foreach ($node->file->coverage->line as $line) { $count = $line->covered->count(); $nr = (string)$line["nr"]; $lineCoverage->$nr = $count; } } return $lineCoverage; }
php
private function getLineCoverage(\SimpleXMLElement $node) { $lineCoverage = (object)array(); if ($node->file->coverage) { foreach ($node->file->coverage->line as $line) { $count = $line->covered->count(); $nr = (string)$line["nr"]; $lineCoverage->$nr = $count; } } return $lineCoverage; }
[ "private", "function", "getLineCoverage", "(", "\\", "SimpleXMLElement", "$", "node", ")", "{", "$", "lineCoverage", "=", "(", "object", ")", "array", "(", ")", ";", "if", "(", "$", "node", "->", "file", "->", "coverage", ")", "{", "foreach", "(", "$", "node", "->", "file", "->", "coverage", "->", "line", "as", "$", "line", ")", "{", "$", "count", "=", "$", "line", "->", "covered", "->", "count", "(", ")", ";", "$", "nr", "=", "(", "string", ")", "$", "line", "[", "\"nr\"", "]", ";", "$", "lineCoverage", "->", "$", "nr", "=", "$", "count", ";", "}", "}", "return", "$", "lineCoverage", ";", "}" ]
Iterates all <line></line> nodes and produces an array holding line coverage information. @param \SimpleXMLElement $node The XML node holding the <line></line> nodes @return array: (lineNumber -> hits)
[ "Iterates", "all", "<line", ">", "<", "/", "line", ">", "nodes", "and", "produces", "an", "array", "holding", "line", "coverage", "information", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/PhpUnitXmlParser.php#L79-L90
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/PhpUnitXmlParser.php
PhpUnitXmlParser.getTotalFromPercent
private function getTotalFromPercent(\SimpleXMLElement $percent) { $percent = (string)$percent; $percent = substr($percent, 0, -1); return round($percent); }
php
private function getTotalFromPercent(\SimpleXMLElement $percent) { $percent = (string)$percent; $percent = substr($percent, 0, -1); return round($percent); }
[ "private", "function", "getTotalFromPercent", "(", "\\", "SimpleXMLElement", "$", "percent", ")", "{", "$", "percent", "=", "(", "string", ")", "$", "percent", ";", "$", "percent", "=", "substr", "(", "$", "percent", ",", "0", ",", "-", "1", ")", ";", "return", "round", "(", "$", "percent", ")", ";", "}" ]
Gets Integer from percent. Example: 95.00% -> 95 @param \SimpleXMLElement $percent The percent attribute of the node @return integer The according integer value
[ "Gets", "Integer", "from", "percent", ".", "Example", ":", "95", ".", "00%", "-", ">", "95" ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/PhpUnitXmlParser.php#L97-L102
codacy/php-codacy-coverage
src/Codacy/Coverage/Parser/PhpUnitXmlParser.php
PhpUnitXmlParser.getRelativePath
private function getRelativePath(\SimpleXMLElement $fileName) { $dirOfSrcFiles = $this->element->project->directory["name"]; $projectRoot = $this->rootDir; // Need to cut off everything lower than projectRoot $dirFromProjectRoot = substr($dirOfSrcFiles, strlen($projectRoot) + 1); // remove .xml and convert to string $relativeFilePath = substr((string)$fileName, 0, -4); return join(DIRECTORY_SEPARATOR, array($dirFromProjectRoot, $relativeFilePath)); }
php
private function getRelativePath(\SimpleXMLElement $fileName) { $dirOfSrcFiles = $this->element->project->directory["name"]; $projectRoot = $this->rootDir; // Need to cut off everything lower than projectRoot $dirFromProjectRoot = substr($dirOfSrcFiles, strlen($projectRoot) + 1); // remove .xml and convert to string $relativeFilePath = substr((string)$fileName, 0, -4); return join(DIRECTORY_SEPARATOR, array($dirFromProjectRoot, $relativeFilePath)); }
[ "private", "function", "getRelativePath", "(", "\\", "SimpleXMLElement", "$", "fileName", ")", "{", "$", "dirOfSrcFiles", "=", "$", "this", "->", "element", "->", "project", "->", "directory", "[", "\"name\"", "]", ";", "$", "projectRoot", "=", "$", "this", "->", "rootDir", ";", "// Need to cut off everything lower than projectRoot", "$", "dirFromProjectRoot", "=", "substr", "(", "$", "dirOfSrcFiles", ",", "strlen", "(", "$", "projectRoot", ")", "+", "1", ")", ";", "// remove .xml and convert to string", "$", "relativeFilePath", "=", "substr", "(", "(", "string", ")", "$", "fileName", ",", "0", ",", "-", "4", ")", ";", "return", "join", "(", "DIRECTORY_SEPARATOR", ",", "array", "(", "$", "dirFromProjectRoot", ",", "$", "relativeFilePath", ")", ")", ";", "}" ]
The PhpUnit XML Coverage format does not save the full path of the filename We can get the filename by combining the path of the first directory with the href attribute of each file. @param \SimpleXMLElement $fileName The href attribute of the <file></file> node. @return string The relative path of the file, that is, relative to project root.
[ "The", "PhpUnit", "XML", "Coverage", "format", "does", "not", "save", "the", "full", "path", "of", "the", "filename", "We", "can", "get", "the", "filename", "by", "combining", "the", "path", "of", "the", "first", "directory", "with", "the", "href", "attribute", "of", "each", "file", "." ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Parser/PhpUnitXmlParser.php#L111-L120
codacy/php-codacy-coverage
src/Codacy/Coverage/Util/CodacyApiClient.php
CodacyApiClient.sendCoverage
public function sendCoverage($commit, $data) { $tempCertFile = $this->dumpCertificateBundle(); $url = $this->baseUrl . "/2.0/coverage/" . $commit . "/php"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curl, CURLOPT_HTTPHEADER, array( "Content-type: application/json", "project_token: " . $this->projectToken ) ); curl_setopt($curl, CURLOPT_CAINFO, $tempCertFile); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); $json_response = curl_exec($curl); unlink($tempCertFile); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($status < 200 || $status > 201) { throw new \Exception( sprintf("Error: call to URL %s failed with status %s, response %s, curl_error %u", $url, $status, $json_response, curl_error($curl), curl_errno($curl) ) ); } curl_close($curl); $json = json_decode($json_response, true); if (isset($json['success']) || array_key_exists('success', $json)) { return $json['success']; } else { return $json['error']; } }
php
public function sendCoverage($commit, $data) { $tempCertFile = $this->dumpCertificateBundle(); $url = $this->baseUrl . "/2.0/coverage/" . $commit . "/php"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt( $curl, CURLOPT_HTTPHEADER, array( "Content-type: application/json", "project_token: " . $this->projectToken ) ); curl_setopt($curl, CURLOPT_CAINFO, $tempCertFile); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); $json_response = curl_exec($curl); unlink($tempCertFile); $status = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($status < 200 || $status > 201) { throw new \Exception( sprintf("Error: call to URL %s failed with status %s, response %s, curl_error %u", $url, $status, $json_response, curl_error($curl), curl_errno($curl) ) ); } curl_close($curl); $json = json_decode($json_response, true); if (isset($json['success']) || array_key_exists('success', $json)) { return $json['success']; } else { return $json['error']; } }
[ "public", "function", "sendCoverage", "(", "$", "commit", ",", "$", "data", ")", "{", "$", "tempCertFile", "=", "$", "this", "->", "dumpCertificateBundle", "(", ")", ";", "$", "url", "=", "$", "this", "->", "baseUrl", ".", "\"/2.0/coverage/\"", ".", "$", "commit", ".", "\"/php\"", ";", "$", "curl", "=", "curl_init", "(", "$", "url", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HEADER", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "\"Content-type: application/json\"", ",", "\"project_token: \"", ".", "$", "this", "->", "projectToken", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_CAINFO", ",", "$", "tempCertFile", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POSTFIELDS", ",", "$", "data", ")", ";", "$", "json_response", "=", "curl_exec", "(", "$", "curl", ")", ";", "unlink", "(", "$", "tempCertFile", ")", ";", "$", "status", "=", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HTTP_CODE", ")", ";", "if", "(", "$", "status", "<", "200", "||", "$", "status", ">", "201", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "\"Error: call to URL %s failed with status %s, response %s, curl_error %u\"", ",", "$", "url", ",", "$", "status", ",", "$", "json_response", ",", "curl_error", "(", "$", "curl", ")", ",", "curl_errno", "(", "$", "curl", ")", ")", ")", ";", "}", "curl_close", "(", "$", "curl", ")", ";", "$", "json", "=", "json_decode", "(", "$", "json_response", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "json", "[", "'success'", "]", ")", "||", "array_key_exists", "(", "'success'", ",", "$", "json", ")", ")", "{", "return", "$", "json", "[", "'success'", "]", ";", "}", "else", "{", "return", "$", "json", "[", "'error'", "]", ";", "}", "}" ]
@param string $commit commit uuid @param string $data the JSON data @return string success message @throws \Exception when remote server response
[ "@param", "string", "$commit", "commit", "uuid", "@param", "string", "$data", "the", "JSON", "data" ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Util/CodacyApiClient.php#L26-L70
codacy/php-codacy-coverage
src/Codacy/Coverage/Util/JsonProducer.php
JsonProducer.makeJson
public function makeJson() { $report = $this->makeReport(); $array = array(); $array['total'] = $report->getTotal(); $fileReportsArray = array(); $fileReports = $report->getFileReports(); foreach ($fileReports as $fr) { $fileArray = array(); $fileArray['filename'] = $fr->getFileName(); $fileArray['total'] = $fr->getTotal(); $fileArray['coverage'] = $fr->getLineCoverage(); array_push($fileReportsArray, $fileArray); } $array['fileReports'] = $fileReportsArray; if (version_compare(PHP_VERSION, '5.4.0', '>=')) { return json_encode($array, JSON_UNESCAPED_SLASHES); } else { return str_replace('\/', '/', json_encode($array)); } }
php
public function makeJson() { $report = $this->makeReport(); $array = array(); $array['total'] = $report->getTotal(); $fileReportsArray = array(); $fileReports = $report->getFileReports(); foreach ($fileReports as $fr) { $fileArray = array(); $fileArray['filename'] = $fr->getFileName(); $fileArray['total'] = $fr->getTotal(); $fileArray['coverage'] = $fr->getLineCoverage(); array_push($fileReportsArray, $fileArray); } $array['fileReports'] = $fileReportsArray; if (version_compare(PHP_VERSION, '5.4.0', '>=')) { return json_encode($array, JSON_UNESCAPED_SLASHES); } else { return str_replace('\/', '/', json_encode($array)); } }
[ "public", "function", "makeJson", "(", ")", "{", "$", "report", "=", "$", "this", "->", "makeReport", "(", ")", ";", "$", "array", "=", "array", "(", ")", ";", "$", "array", "[", "'total'", "]", "=", "$", "report", "->", "getTotal", "(", ")", ";", "$", "fileReportsArray", "=", "array", "(", ")", ";", "$", "fileReports", "=", "$", "report", "->", "getFileReports", "(", ")", ";", "foreach", "(", "$", "fileReports", "as", "$", "fr", ")", "{", "$", "fileArray", "=", "array", "(", ")", ";", "$", "fileArray", "[", "'filename'", "]", "=", "$", "fr", "->", "getFileName", "(", ")", ";", "$", "fileArray", "[", "'total'", "]", "=", "$", "fr", "->", "getTotal", "(", ")", ";", "$", "fileArray", "[", "'coverage'", "]", "=", "$", "fr", "->", "getLineCoverage", "(", ")", ";", "array_push", "(", "$", "fileReportsArray", ",", "$", "fileArray", ")", ";", "}", "$", "array", "[", "'fileReports'", "]", "=", "$", "fileReportsArray", ";", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4.0'", ",", "'>='", ")", ")", "{", "return", "json_encode", "(", "$", "array", ",", "JSON_UNESCAPED_SLASHES", ")", ";", "}", "else", "{", "return", "str_replace", "(", "'\\/'", ",", "'/'", ",", "json_encode", "(", "$", "array", ")", ")", ";", "}", "}" ]
Takes a CoverageReport object, the result of makeReport(), and outputs JSON. Example JSON format: { "total": 67, "fileReports": [ { "filename": "src/Codacy/Coverage/Api/Api.php", "total": 3, "coverage": { "12": 3, "13": 5, ......... ......... } }, ......... ....... ] } @return string the JSON string
[ "Takes", "a", "CoverageReport", "object", "the", "result", "of", "makeReport", "()", "and", "outputs", "JSON", ".", "Example", "JSON", "format", ":", "{", "total", ":", "67", "fileReports", ":", "[", "{", "filename", ":", "src", "/", "Codacy", "/", "Coverage", "/", "Api", "/", "Api", ".", "php", "total", ":", "3", "coverage", ":", "{", "12", ":", "3", "13", ":", "5", ".........", ".........", "}", "}", ".........", ".......", "]", "}" ]
train
https://github.com/codacy/php-codacy-coverage/blob/629d1fd597f91fb072bd822830059fd5145ce49a/src/Codacy/Coverage/Util/JsonProducer.php#L60-L86
oat-sa/extension-tao-delivery-rdf
view/form/DeliveryForm.php
DeliveryForm.setThemeNameSelectorOptions
protected function setThemeNameSelectorOptions() { $elementUri = tao_helpers_Uri::encode(DeliveryThemeDetailsProvider::DELIVERY_THEME_ID_URI); if (!$this->form->hasElement($elementUri)) { return false; } /** @var ThemeService $themeService */ $themeService = ServiceManager::getServiceManager()->get(ThemeService::SERVICE_ID); $allThemes = $themeService->getAllThemes(); $options = []; foreach ($allThemes as $currentThemeId => $currentTheme) { $options[$currentThemeId] = $currentThemeId; if (method_exists($currentTheme, 'getLabel')) { $options[$currentThemeId] = $currentTheme->getLabel(); } } $this->form->getElement($elementUri)->setOptions($options); return true; }
php
protected function setThemeNameSelectorOptions() { $elementUri = tao_helpers_Uri::encode(DeliveryThemeDetailsProvider::DELIVERY_THEME_ID_URI); if (!$this->form->hasElement($elementUri)) { return false; } /** @var ThemeService $themeService */ $themeService = ServiceManager::getServiceManager()->get(ThemeService::SERVICE_ID); $allThemes = $themeService->getAllThemes(); $options = []; foreach ($allThemes as $currentThemeId => $currentTheme) { $options[$currentThemeId] = $currentThemeId; if (method_exists($currentTheme, 'getLabel')) { $options[$currentThemeId] = $currentTheme->getLabel(); } } $this->form->getElement($elementUri)->setOptions($options); return true; }
[ "protected", "function", "setThemeNameSelectorOptions", "(", ")", "{", "$", "elementUri", "=", "tao_helpers_Uri", "::", "encode", "(", "DeliveryThemeDetailsProvider", "::", "DELIVERY_THEME_ID_URI", ")", ";", "if", "(", "!", "$", "this", "->", "form", "->", "hasElement", "(", "$", "elementUri", ")", ")", "{", "return", "false", ";", "}", "/** @var ThemeService $themeService */", "$", "themeService", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "ThemeService", "::", "SERVICE_ID", ")", ";", "$", "allThemes", "=", "$", "themeService", "->", "getAllThemes", "(", ")", ";", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "allThemes", "as", "$", "currentThemeId", "=>", "$", "currentTheme", ")", "{", "$", "options", "[", "$", "currentThemeId", "]", "=", "$", "currentThemeId", ";", "if", "(", "method_exists", "(", "$", "currentTheme", ",", "'getLabel'", ")", ")", "{", "$", "options", "[", "$", "currentThemeId", "]", "=", "$", "currentTheme", "->", "getLabel", "(", ")", ";", "}", "}", "$", "this", "->", "form", "->", "getElement", "(", "$", "elementUri", ")", "->", "setOptions", "(", "$", "options", ")", ";", "return", "true", ";", "}" ]
Sets the theme name selector options. @return bool
[ "Sets", "the", "theme", "name", "selector", "options", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/view/form/DeliveryForm.php#L91-L112
oat-sa/extension-tao-delivery-rdf
scripts/tools/jMeterCleaner.php
jMeterCleaner.usage
private function usage() { if (empty($this->params)) { $usageHelper = \common_report_Report::createInfo('USAGE: What you could do here:'); $usageHelper->add(\common_report_Report::createSuccess('Please, Note that sections must not intersect otherwise it will work according to priority')); $countDeliveriesForUsers = \common_report_Report::createInfo('1. Count how many deliveries has each of the user'); $countDeliveriesForUsers->add(\common_report_Report::createInfo('--count-deliveries-by-user')); $countDeliveriesForUsers->add(\common_report_Report::createInfo('--open-out `show all deliveries and executions id`')); $usageHelper->add($countDeliveriesForUsers); $openDeliveriesForUser = \common_report_Report::createInfo('2. Detailed report about deliveries for user'); $openDeliveriesForUser->add(\common_report_Report::createInfo('--detailed-report')); $openDeliveriesForUser->add(\common_report_Report::createInfo('--detailed-user=[userId]')); $openDeliveriesForUser->add(\common_report_Report::createInfo('--open-out `show all deliveries and executions id`')); $usageHelper->add($openDeliveriesForUser); $cleaner = \common_report_Report::createInfo('2. Clean test data that you want (The greater the force, the greater the responsibility)'); $cleaner->add(\common_report_Report::createFailure('Note: everything will be deleted even user')); $cleaner->add(\common_report_Report::createInfo('--run-cleaner')); $cleaner->add(\common_report_Report::createInfo('--clean-user=[userId] `will be deleted user, executions and states`')); $cleaner->add(\common_report_Report::createInfo('--clean-user-with-his-deliveries `will be deleted user, executions, states, DELIVERIES and RESULTS`')); $cleaner->add(\common_report_Report::createInfo('--clean-delivery=[deliveryId] `not required. If provided, then will be deleted only that delivery and results`')); $usageHelper->add($cleaner); $executionsCleaner = \common_report_Report::createInfo('3. Delete only executions and test results (The greater the force, the greater the responsibility)'); $executionsCleaner->add(\common_report_Report::createFailure('Note: will be deleted results, executions and services states')); $executionsCleaner->add(\common_report_Report::createInfo('--run-executions-cleaner')); $executionsCleaner->add(\common_report_Report::createInfo('--clean-user=[userId] `will be deleted executions, results and states`')); $executionsCleaner->add(\common_report_Report::createInfo('--clean-users-whose-label-begin-with=[string] `min length 3 symbols. Will be deleted executions, results and states only for the users whose labels begin with specified string.`')); $usageHelper->add($executionsCleaner); $this->report->add($usageHelper); } }
php
private function usage() { if (empty($this->params)) { $usageHelper = \common_report_Report::createInfo('USAGE: What you could do here:'); $usageHelper->add(\common_report_Report::createSuccess('Please, Note that sections must not intersect otherwise it will work according to priority')); $countDeliveriesForUsers = \common_report_Report::createInfo('1. Count how many deliveries has each of the user'); $countDeliveriesForUsers->add(\common_report_Report::createInfo('--count-deliveries-by-user')); $countDeliveriesForUsers->add(\common_report_Report::createInfo('--open-out `show all deliveries and executions id`')); $usageHelper->add($countDeliveriesForUsers); $openDeliveriesForUser = \common_report_Report::createInfo('2. Detailed report about deliveries for user'); $openDeliveriesForUser->add(\common_report_Report::createInfo('--detailed-report')); $openDeliveriesForUser->add(\common_report_Report::createInfo('--detailed-user=[userId]')); $openDeliveriesForUser->add(\common_report_Report::createInfo('--open-out `show all deliveries and executions id`')); $usageHelper->add($openDeliveriesForUser); $cleaner = \common_report_Report::createInfo('2. Clean test data that you want (The greater the force, the greater the responsibility)'); $cleaner->add(\common_report_Report::createFailure('Note: everything will be deleted even user')); $cleaner->add(\common_report_Report::createInfo('--run-cleaner')); $cleaner->add(\common_report_Report::createInfo('--clean-user=[userId] `will be deleted user, executions and states`')); $cleaner->add(\common_report_Report::createInfo('--clean-user-with-his-deliveries `will be deleted user, executions, states, DELIVERIES and RESULTS`')); $cleaner->add(\common_report_Report::createInfo('--clean-delivery=[deliveryId] `not required. If provided, then will be deleted only that delivery and results`')); $usageHelper->add($cleaner); $executionsCleaner = \common_report_Report::createInfo('3. Delete only executions and test results (The greater the force, the greater the responsibility)'); $executionsCleaner->add(\common_report_Report::createFailure('Note: will be deleted results, executions and services states')); $executionsCleaner->add(\common_report_Report::createInfo('--run-executions-cleaner')); $executionsCleaner->add(\common_report_Report::createInfo('--clean-user=[userId] `will be deleted executions, results and states`')); $executionsCleaner->add(\common_report_Report::createInfo('--clean-users-whose-label-begin-with=[string] `min length 3 symbols. Will be deleted executions, results and states only for the users whose labels begin with specified string.`')); $usageHelper->add($executionsCleaner); $this->report->add($usageHelper); } }
[ "private", "function", "usage", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "params", ")", ")", "{", "$", "usageHelper", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'USAGE: What you could do here:'", ")", ";", "$", "usageHelper", "->", "add", "(", "\\", "common_report_Report", "::", "createSuccess", "(", "'Please, Note that sections must not intersect otherwise it will work according to priority'", ")", ")", ";", "$", "countDeliveriesForUsers", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'1. Count how many deliveries has each of the user'", ")", ";", "$", "countDeliveriesForUsers", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--count-deliveries-by-user'", ")", ")", ";", "$", "countDeliveriesForUsers", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--open-out `show all deliveries and executions id`'", ")", ")", ";", "$", "usageHelper", "->", "add", "(", "$", "countDeliveriesForUsers", ")", ";", "$", "openDeliveriesForUser", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'2. Detailed report about deliveries for user'", ")", ";", "$", "openDeliveriesForUser", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--detailed-report'", ")", ")", ";", "$", "openDeliveriesForUser", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--detailed-user=[userId]'", ")", ")", ";", "$", "openDeliveriesForUser", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--open-out `show all deliveries and executions id`'", ")", ")", ";", "$", "usageHelper", "->", "add", "(", "$", "openDeliveriesForUser", ")", ";", "$", "cleaner", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'2. Clean test data that you want (The greater the force, the greater the responsibility)'", ")", ";", "$", "cleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createFailure", "(", "'Note: everything will be deleted even user'", ")", ")", ";", "$", "cleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--run-cleaner'", ")", ")", ";", "$", "cleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--clean-user=[userId] `will be deleted user, executions and states`'", ")", ")", ";", "$", "cleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--clean-user-with-his-deliveries `will be deleted user, executions, states, DELIVERIES and RESULTS`'", ")", ")", ";", "$", "cleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--clean-delivery=[deliveryId] `not required. If provided, then will be deleted only that delivery and results`'", ")", ")", ";", "$", "usageHelper", "->", "add", "(", "$", "cleaner", ")", ";", "$", "executionsCleaner", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'3. Delete only executions and test results (The greater the force, the greater the responsibility)'", ")", ";", "$", "executionsCleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createFailure", "(", "'Note: will be deleted results, executions and services states'", ")", ")", ";", "$", "executionsCleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--run-executions-cleaner'", ")", ")", ";", "$", "executionsCleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--clean-user=[userId] `will be deleted executions, results and states`'", ")", ")", ";", "$", "executionsCleaner", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'--clean-users-whose-label-begin-with=[string] `min length 3 symbols. Will be deleted executions, results and states only for the users whose labels begin with specified string.`'", ")", ")", ";", "$", "usageHelper", "->", "add", "(", "$", "executionsCleaner", ")", ";", "$", "this", "->", "report", "->", "add", "(", "$", "usageHelper", ")", ";", "}", "}" ]
how it works
[ "how", "it", "works" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/jMeterCleaner.php#L75-L109
oat-sa/extension-tao-delivery-rdf
scripts/tools/jMeterCleaner.php
jMeterCleaner.counter
private function counter() { if (!$this->done && in_array('--count-deliveries-by-user', $this->params)) { $this->done = true; $counterReport = \common_report_Report::createInfo('List of Users:'); $helper = new ConsoleTableHelper(); $helper->addHeader(['TestTaker', 'Deliveries', 'Executions']); $helper->addRows($this->getCountersByUsers(!in_array('--open-out', $this->params))); $counterReport->add($helper->generateReport()); $this->report->add($counterReport); } }
php
private function counter() { if (!$this->done && in_array('--count-deliveries-by-user', $this->params)) { $this->done = true; $counterReport = \common_report_Report::createInfo('List of Users:'); $helper = new ConsoleTableHelper(); $helper->addHeader(['TestTaker', 'Deliveries', 'Executions']); $helper->addRows($this->getCountersByUsers(!in_array('--open-out', $this->params))); $counterReport->add($helper->generateReport()); $this->report->add($counterReport); } }
[ "private", "function", "counter", "(", ")", "{", "if", "(", "!", "$", "this", "->", "done", "&&", "in_array", "(", "'--count-deliveries-by-user'", ",", "$", "this", "->", "params", ")", ")", "{", "$", "this", "->", "done", "=", "true", ";", "$", "counterReport", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'List of Users:'", ")", ";", "$", "helper", "=", "new", "ConsoleTableHelper", "(", ")", ";", "$", "helper", "->", "addHeader", "(", "[", "'TestTaker'", ",", "'Deliveries'", ",", "'Executions'", "]", ")", ";", "$", "helper", "->", "addRows", "(", "$", "this", "->", "getCountersByUsers", "(", "!", "in_array", "(", "'--open-out'", ",", "$", "this", "->", "params", ")", ")", ")", ";", "$", "counterReport", "->", "add", "(", "$", "helper", "->", "generateReport", "(", ")", ")", ";", "$", "this", "->", "report", "->", "add", "(", "$", "counterReport", ")", ";", "}", "}" ]
First section with general information about users
[ "First", "section", "with", "general", "information", "about", "users" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/jMeterCleaner.php#L123-L137
oat-sa/extension-tao-delivery-rdf
scripts/tools/jMeterCleaner.php
jMeterCleaner.detailed
private function detailed() { if (!$this->done && in_array('--detailed-report', $this->params)) { $this->done = true; $details = $this->getDetailsForUser(!in_array('--open-out', $this->params)); if ($details !== false) { $counterReport = \common_report_Report::createInfo('Detailed report for the user'); $helper = new ConsoleTableHelper(); $helper->addHeader(['TestTaker', 'Deliveries', 'Executions']); $helper->addRows($details); $counterReport->add($helper->generateReport()); $this->report->add($counterReport); } } }
php
private function detailed() { if (!$this->done && in_array('--detailed-report', $this->params)) { $this->done = true; $details = $this->getDetailsForUser(!in_array('--open-out', $this->params)); if ($details !== false) { $counterReport = \common_report_Report::createInfo('Detailed report for the user'); $helper = new ConsoleTableHelper(); $helper->addHeader(['TestTaker', 'Deliveries', 'Executions']); $helper->addRows($details); $counterReport->add($helper->generateReport()); $this->report->add($counterReport); } } }
[ "private", "function", "detailed", "(", ")", "{", "if", "(", "!", "$", "this", "->", "done", "&&", "in_array", "(", "'--detailed-report'", ",", "$", "this", "->", "params", ")", ")", "{", "$", "this", "->", "done", "=", "true", ";", "$", "details", "=", "$", "this", "->", "getDetailsForUser", "(", "!", "in_array", "(", "'--open-out'", ",", "$", "this", "->", "params", ")", ")", ";", "if", "(", "$", "details", "!==", "false", ")", "{", "$", "counterReport", "=", "\\", "common_report_Report", "::", "createInfo", "(", "'Detailed report for the user'", ")", ";", "$", "helper", "=", "new", "ConsoleTableHelper", "(", ")", ";", "$", "helper", "->", "addHeader", "(", "[", "'TestTaker'", ",", "'Deliveries'", ",", "'Executions'", "]", ")", ";", "$", "helper", "->", "addRows", "(", "$", "details", ")", ";", "$", "counterReport", "->", "add", "(", "$", "helper", "->", "generateReport", "(", ")", ")", ";", "$", "this", "->", "report", "->", "add", "(", "$", "counterReport", ")", ";", "}", "}", "}" ]
Second section with detailed information about the specified user
[ "Second", "section", "with", "detailed", "information", "about", "the", "specified", "user" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/jMeterCleaner.php#L203-L217
oat-sa/extension-tao-delivery-rdf
scripts/tools/jMeterCleaner.php
jMeterCleaner.getResourceFromParameter
private function getResourceFromParameter($prefix = '--unique-prefix') { $resource = null; $hasParameter = false; $val = $this->getParameterValue($prefix); if ($val) { $hasParameter = true; $resource = $this->getResource($val); if (!$resource->exists()) { $resource = null; } } return $hasParameter ? $resource : false; }
php
private function getResourceFromParameter($prefix = '--unique-prefix') { $resource = null; $hasParameter = false; $val = $this->getParameterValue($prefix); if ($val) { $hasParameter = true; $resource = $this->getResource($val); if (!$resource->exists()) { $resource = null; } } return $hasParameter ? $resource : false; }
[ "private", "function", "getResourceFromParameter", "(", "$", "prefix", "=", "'--unique-prefix'", ")", "{", "$", "resource", "=", "null", ";", "$", "hasParameter", "=", "false", ";", "$", "val", "=", "$", "this", "->", "getParameterValue", "(", "$", "prefix", ")", ";", "if", "(", "$", "val", ")", "{", "$", "hasParameter", "=", "true", ";", "$", "resource", "=", "$", "this", "->", "getResource", "(", "$", "val", ")", ";", "if", "(", "!", "$", "resource", "->", "exists", "(", ")", ")", "{", "$", "resource", "=", "null", ";", "}", "}", "return", "$", "hasParameter", "?", "$", "resource", ":", "false", ";", "}" ]
Get parameter from the list of parameters as Resource @param string $prefix @return bool|\core_kernel_classes_Resource
[ "Get", "parameter", "from", "the", "list", "of", "parameters", "as", "Resource" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/jMeterCleaner.php#L224-L239
oat-sa/extension-tao-delivery-rdf
scripts/tools/jMeterCleaner.php
jMeterCleaner.cleaner
private function cleaner() { if (!$this->done && in_array('--run-cleaner', $this->params)) { $this->done = true; $testTaker = $this->getResourceFromParameter('--clean-user='); if (!$testTaker) { $this->report->add(\common_report_Report::createFailure('--clean-user=[userId] is required and need to be a Resource')); return false; } $delivery = $this->getResourceFromParameter('--clean-delivery='); if ($delivery) { $this->report->add(\common_report_Report::createInfo('Deleting of the delivery data [' . $delivery->getUri() . ']')); } elseif ($delivery === null) { $this->report->add(\common_report_Report::createFailure('Delivery does not found')); return false; } else { $this->report->add(\common_report_Report::createInfo('Deleting of the TestTaker data [' . $testTaker->getUri() . ']')); } $ttData = $this->getDataByTestTaker($testTaker, false); if (!count($ttData)) { $this->report->add(\common_report_Report::createFailure('TestTaker with id [' . $testTaker->getUri() . '] has not been found')); return false; } elseif($delivery) { $hasDelivery = false; foreach ($ttData as $row) { if ($row[1] == $delivery->getUri()) { $hasDelivery = true; break; } } if (!$hasDelivery) { $this->report->add(\common_report_Report::createFailure('Delivery with id [' . $testTaker->getUri() . '] has not been found')); return false; } } if ($delivery) { $this->deleteDelivery($delivery); } else { $this->deleteTestTaker($testTaker, $ttData); } } return true; }
php
private function cleaner() { if (!$this->done && in_array('--run-cleaner', $this->params)) { $this->done = true; $testTaker = $this->getResourceFromParameter('--clean-user='); if (!$testTaker) { $this->report->add(\common_report_Report::createFailure('--clean-user=[userId] is required and need to be a Resource')); return false; } $delivery = $this->getResourceFromParameter('--clean-delivery='); if ($delivery) { $this->report->add(\common_report_Report::createInfo('Deleting of the delivery data [' . $delivery->getUri() . ']')); } elseif ($delivery === null) { $this->report->add(\common_report_Report::createFailure('Delivery does not found')); return false; } else { $this->report->add(\common_report_Report::createInfo('Deleting of the TestTaker data [' . $testTaker->getUri() . ']')); } $ttData = $this->getDataByTestTaker($testTaker, false); if (!count($ttData)) { $this->report->add(\common_report_Report::createFailure('TestTaker with id [' . $testTaker->getUri() . '] has not been found')); return false; } elseif($delivery) { $hasDelivery = false; foreach ($ttData as $row) { if ($row[1] == $delivery->getUri()) { $hasDelivery = true; break; } } if (!$hasDelivery) { $this->report->add(\common_report_Report::createFailure('Delivery with id [' . $testTaker->getUri() . '] has not been found')); return false; } } if ($delivery) { $this->deleteDelivery($delivery); } else { $this->deleteTestTaker($testTaker, $ttData); } } return true; }
[ "private", "function", "cleaner", "(", ")", "{", "if", "(", "!", "$", "this", "->", "done", "&&", "in_array", "(", "'--run-cleaner'", ",", "$", "this", "->", "params", ")", ")", "{", "$", "this", "->", "done", "=", "true", ";", "$", "testTaker", "=", "$", "this", "->", "getResourceFromParameter", "(", "'--clean-user='", ")", ";", "if", "(", "!", "$", "testTaker", ")", "{", "$", "this", "->", "report", "->", "add", "(", "\\", "common_report_Report", "::", "createFailure", "(", "'--clean-user=[userId] is required and need to be a Resource'", ")", ")", ";", "return", "false", ";", "}", "$", "delivery", "=", "$", "this", "->", "getResourceFromParameter", "(", "'--clean-delivery='", ")", ";", "if", "(", "$", "delivery", ")", "{", "$", "this", "->", "report", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'Deleting of the delivery data ['", ".", "$", "delivery", "->", "getUri", "(", ")", ".", "']'", ")", ")", ";", "}", "elseif", "(", "$", "delivery", "===", "null", ")", "{", "$", "this", "->", "report", "->", "add", "(", "\\", "common_report_Report", "::", "createFailure", "(", "'Delivery does not found'", ")", ")", ";", "return", "false", ";", "}", "else", "{", "$", "this", "->", "report", "->", "add", "(", "\\", "common_report_Report", "::", "createInfo", "(", "'Deleting of the TestTaker data ['", ".", "$", "testTaker", "->", "getUri", "(", ")", ".", "']'", ")", ")", ";", "}", "$", "ttData", "=", "$", "this", "->", "getDataByTestTaker", "(", "$", "testTaker", ",", "false", ")", ";", "if", "(", "!", "count", "(", "$", "ttData", ")", ")", "{", "$", "this", "->", "report", "->", "add", "(", "\\", "common_report_Report", "::", "createFailure", "(", "'TestTaker with id ['", ".", "$", "testTaker", "->", "getUri", "(", ")", ".", "'] has not been found'", ")", ")", ";", "return", "false", ";", "}", "elseif", "(", "$", "delivery", ")", "{", "$", "hasDelivery", "=", "false", ";", "foreach", "(", "$", "ttData", "as", "$", "row", ")", "{", "if", "(", "$", "row", "[", "1", "]", "==", "$", "delivery", "->", "getUri", "(", ")", ")", "{", "$", "hasDelivery", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "hasDelivery", ")", "{", "$", "this", "->", "report", "->", "add", "(", "\\", "common_report_Report", "::", "createFailure", "(", "'Delivery with id ['", ".", "$", "testTaker", "->", "getUri", "(", ")", ".", "'] has not been found'", ")", ")", ";", "return", "false", ";", "}", "}", "if", "(", "$", "delivery", ")", "{", "$", "this", "->", "deleteDelivery", "(", "$", "delivery", ")", ";", "}", "else", "{", "$", "this", "->", "deleteTestTaker", "(", "$", "testTaker", ",", "$", "ttData", ")", ";", "}", "}", "return", "true", ";", "}" ]
The most dangerous of the sections which will affect on the stored data
[ "The", "most", "dangerous", "of", "the", "sections", "which", "will", "affect", "on", "the", "stored", "data" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/jMeterCleaner.php#L281-L328
oat-sa/extension-tao-delivery-rdf
view/form/export/ExportForm.php
ExportForm.initElements
public function initElements() { $fileName = ''; $instances = array(); if (isset($this->data['instance'])){ $instance = $this->data['instance']; if ($instance instanceof \core_kernel_classes_Resource) { $instances[$instance->getUri()] = $instance->getLabel(); } } elseif (isset($this->data['class'])) { $class = $this->data['class']; if ($class instanceof \core_kernel_classes_Class) { foreach($class->getInstances() as $instance){ $instances[$instance->getUri()] = $instance->getLabel(); } } } else { throw new \common_Exception('No class nor instance specified for export'); } $instances = \tao_helpers_Uri::encodeArray($instances, \tao_helpers_Uri::ENCODE_ARRAY_KEYS); $descElt = \tao_helpers_form_FormFactory::getElement('desc', 'Label'); $descElt->setValue(__('Enables you to export a published delivery')); $this->form->addElement($descElt); $instanceElt = \tao_helpers_form_FormFactory::getElement('exportInstance', 'Radiobox'); $instanceElt->setDescription(__('Delivery')); $instanceElt->setAttribute('checkAll', true); $instanceElt->setOptions($instances); $instanceElt->setValue(current(array_keys($instances))); $this->form->addElement($instanceElt); $this->form->createGroup('options', __('Export Options'), array('desc', 'exportInstance')); }
php
public function initElements() { $fileName = ''; $instances = array(); if (isset($this->data['instance'])){ $instance = $this->data['instance']; if ($instance instanceof \core_kernel_classes_Resource) { $instances[$instance->getUri()] = $instance->getLabel(); } } elseif (isset($this->data['class'])) { $class = $this->data['class']; if ($class instanceof \core_kernel_classes_Class) { foreach($class->getInstances() as $instance){ $instances[$instance->getUri()] = $instance->getLabel(); } } } else { throw new \common_Exception('No class nor instance specified for export'); } $instances = \tao_helpers_Uri::encodeArray($instances, \tao_helpers_Uri::ENCODE_ARRAY_KEYS); $descElt = \tao_helpers_form_FormFactory::getElement('desc', 'Label'); $descElt->setValue(__('Enables you to export a published delivery')); $this->form->addElement($descElt); $instanceElt = \tao_helpers_form_FormFactory::getElement('exportInstance', 'Radiobox'); $instanceElt->setDescription(__('Delivery')); $instanceElt->setAttribute('checkAll', true); $instanceElt->setOptions($instances); $instanceElt->setValue(current(array_keys($instances))); $this->form->addElement($instanceElt); $this->form->createGroup('options', __('Export Options'), array('desc', 'exportInstance')); }
[ "public", "function", "initElements", "(", ")", "{", "$", "fileName", "=", "''", ";", "$", "instances", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'instance'", "]", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "data", "[", "'instance'", "]", ";", "if", "(", "$", "instance", "instanceof", "\\", "core_kernel_classes_Resource", ")", "{", "$", "instances", "[", "$", "instance", "->", "getUri", "(", ")", "]", "=", "$", "instance", "->", "getLabel", "(", ")", ";", "}", "}", "elseif", "(", "isset", "(", "$", "this", "->", "data", "[", "'class'", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "data", "[", "'class'", "]", ";", "if", "(", "$", "class", "instanceof", "\\", "core_kernel_classes_Class", ")", "{", "foreach", "(", "$", "class", "->", "getInstances", "(", ")", "as", "$", "instance", ")", "{", "$", "instances", "[", "$", "instance", "->", "getUri", "(", ")", "]", "=", "$", "instance", "->", "getLabel", "(", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "\\", "common_Exception", "(", "'No class nor instance specified for export'", ")", ";", "}", "$", "instances", "=", "\\", "tao_helpers_Uri", "::", "encodeArray", "(", "$", "instances", ",", "\\", "tao_helpers_Uri", "::", "ENCODE_ARRAY_KEYS", ")", ";", "$", "descElt", "=", "\\", "tao_helpers_form_FormFactory", "::", "getElement", "(", "'desc'", ",", "'Label'", ")", ";", "$", "descElt", "->", "setValue", "(", "__", "(", "'Enables you to export a published delivery'", ")", ")", ";", "$", "this", "->", "form", "->", "addElement", "(", "$", "descElt", ")", ";", "$", "instanceElt", "=", "\\", "tao_helpers_form_FormFactory", "::", "getElement", "(", "'exportInstance'", ",", "'Radiobox'", ")", ";", "$", "instanceElt", "->", "setDescription", "(", "__", "(", "'Delivery'", ")", ")", ";", "$", "instanceElt", "->", "setAttribute", "(", "'checkAll'", ",", "true", ")", ";", "$", "instanceElt", "->", "setOptions", "(", "$", "instances", ")", ";", "$", "instanceElt", "->", "setValue", "(", "current", "(", "array_keys", "(", "$", "instances", ")", ")", ")", ";", "$", "this", "->", "form", "->", "addElement", "(", "$", "instanceElt", ")", ";", "$", "this", "->", "form", "->", "createGroup", "(", "'options'", ",", "__", "(", "'Export Options'", ")", ",", "array", "(", "'desc'", ",", "'exportInstance'", ")", ")", ";", "}" ]
(non-PHPdoc) @see tao_helpers_form_FormContainer::initElements()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/view/form/export/ExportForm.php#L46-L83
oat-sa/extension-tao-delivery-rdf
view/form/WizardForm.php
WizardForm.initElements
public function initElements() { $class = $this->data['class']; if(!$class instanceof \core_kernel_classes_Class) { throw new \common_Exception('missing class in simple delivery creation form'); } $classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); /** @var \tao_helpers_form_elements_xhtml_Hidden $testElt */ $testElt = \tao_helpers_form_FormFactory::getElement('test', 'Hidden'); /** @var ComplexSearchService $search */ $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID); $queryBuilder = $search->query(); $query = $search->searchType($queryBuilder , TaoOntology::TEST_CLASS_URI, true); $queryBuilder->setCriteria($query); $count = $search->getGateway()->count($queryBuilder); if (0 === $count) { throw new NoTestsException(); } $selectElt = \tao_helpers_form_FormFactory::getElement('selectelt', 'Free'); $selectElt->setValue('<div class="test-select-container"></div>'); $this->form->addElement($selectElt); $testElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($testElt); $this->initCustomElements(); }
php
public function initElements() { $class = $this->data['class']; if(!$class instanceof \core_kernel_classes_Class) { throw new \common_Exception('missing class in simple delivery creation form'); } $classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); /** @var \tao_helpers_form_elements_xhtml_Hidden $testElt */ $testElt = \tao_helpers_form_FormFactory::getElement('test', 'Hidden'); /** @var ComplexSearchService $search */ $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID); $queryBuilder = $search->query(); $query = $search->searchType($queryBuilder , TaoOntology::TEST_CLASS_URI, true); $queryBuilder->setCriteria($query); $count = $search->getGateway()->count($queryBuilder); if (0 === $count) { throw new NoTestsException(); } $selectElt = \tao_helpers_form_FormFactory::getElement('selectelt', 'Free'); $selectElt->setValue('<div class="test-select-container"></div>'); $this->form->addElement($selectElt); $testElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($testElt); $this->initCustomElements(); }
[ "public", "function", "initElements", "(", ")", "{", "$", "class", "=", "$", "this", "->", "data", "[", "'class'", "]", ";", "if", "(", "!", "$", "class", "instanceof", "\\", "core_kernel_classes_Class", ")", "{", "throw", "new", "\\", "common_Exception", "(", "'missing class in simple delivery creation form'", ")", ";", "}", "$", "classUriElt", "=", "\\", "tao_helpers_form_FormFactory", "::", "getElement", "(", "'classUri'", ",", "'Hidden'", ")", ";", "$", "classUriElt", "->", "setValue", "(", "$", "class", "->", "getUri", "(", ")", ")", ";", "$", "this", "->", "form", "->", "addElement", "(", "$", "classUriElt", ")", ";", "/** @var \\tao_helpers_form_elements_xhtml_Hidden $testElt */", "$", "testElt", "=", "\\", "tao_helpers_form_FormFactory", "::", "getElement", "(", "'test'", ",", "'Hidden'", ")", ";", "/** @var ComplexSearchService $search */", "$", "search", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "ComplexSearchService", "::", "SERVICE_ID", ")", ";", "$", "queryBuilder", "=", "$", "search", "->", "query", "(", ")", ";", "$", "query", "=", "$", "search", "->", "searchType", "(", "$", "queryBuilder", ",", "TaoOntology", "::", "TEST_CLASS_URI", ",", "true", ")", ";", "$", "queryBuilder", "->", "setCriteria", "(", "$", "query", ")", ";", "$", "count", "=", "$", "search", "->", "getGateway", "(", ")", "->", "count", "(", "$", "queryBuilder", ")", ";", "if", "(", "0", "===", "$", "count", ")", "{", "throw", "new", "NoTestsException", "(", ")", ";", "}", "$", "selectElt", "=", "\\", "tao_helpers_form_FormFactory", "::", "getElement", "(", "'selectelt'", ",", "'Free'", ")", ";", "$", "selectElt", "->", "setValue", "(", "'<div class=\"test-select-container\"></div>'", ")", ";", "$", "this", "->", "form", "->", "addElement", "(", "$", "selectElt", ")", ";", "$", "testElt", "->", "addValidator", "(", "\\", "tao_helpers_form_FormFactory", "::", "getValidator", "(", "'NotEmpty'", ")", ")", ";", "$", "this", "->", "form", "->", "addElement", "(", "$", "testElt", ")", ";", "$", "this", "->", "initCustomElements", "(", ")", ";", "}" ]
/* Short description of method initElements @access public @author Joel Bout, <joel.bout@tudor.lu> @return mixed
[ "/", "*", "Short", "description", "of", "method", "initElements" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/view/form/WizardForm.php#L64-L97
oat-sa/extension-tao-delivery-rdf
controller/DeliveryMgmt.php
DeliveryMgmt.editDelivery
public function editDelivery() { $this->defaultData(); $class = $this->getCurrentClass(); $delivery = $this->getCurrentInstance(); //Removing Result Server form field if it is hardcoded in configuration //since property name (and possibly property itself) is deprecated then this lines will go away to //when "deprecation period" will be over /** @var ResultServerService $resultServerService */ $resultServerService = $this->getServiceManager()->get(ResultServerService::SERVICE_ID); if (!$resultServerService->isConfigurable()) { $options = []; } else { $options = [ 'excludedProperties' => [ OntologyService::PROPERTY_RESULT_SERVER ] ]; } $formContainer = new DeliveryForm($class, $delivery, $options); $myForm = $formContainer->getForm(); $deliveryUri = $delivery->getUri(); if ($myForm->isSubmited() && $myForm->isValid()) { $this->validateInstanceRoot($deliveryUri); $propertyValues = $myForm->getValues(); // then save the property values as usual $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($delivery); $delivery = $binder->bind($propertyValues); $this->getEventManager()->trigger(new DeliveryUpdatedEvent($deliveryUri, $propertyValues)); $this->setData('selectNode', \tao_helpers_Uri::encode($deliveryUri)); $this->setData('message', __('Delivery saved')); $this->setData('reload', true); } $this->setData('label', $delivery->getLabel()); // history $this->setData('date', $this->getClassService()->getCompilationDate($delivery)); $serviceProxy = $this->getServiceLocator()->get(ServiceProxy::SERVICE_ID); if ($serviceProxy instanceof Monitoring) { $execs = $serviceProxy->getExecutionsByDelivery($delivery); $this->setData('exec', count($execs)); } // define the groups related to the current delivery $property = $this->getProperty(GroupAssignment::PROPERTY_GROUP_DELIVERY); $tree = \tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property); $tree->setTitle(__('Assigned to')); $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl')); $this->setData('groupTree', $tree->render()); // testtaker brick $this->setData('assemblyUri', $deliveryUri); // define the subjects excluded from the current delivery $property = $this->getProperty(DeliveryContainerService::PROPERTY_EXCLUDED_SUBJECTS); $excluded = $delivery->getPropertyValues($property); $this->setData('ttexcluded', count($excluded)); $users = $this->getServiceLocator()->get(AssignmentService::SERVICE_ID)->getAssignedUsers($deliveryUri); $assigned = array_diff(array_unique($users), $excluded); $this->setData('ttassigned', count($assigned)); $updatedAt = $this->getServiceLocator()->get(ResourceWatcher::SERVICE_ID)->getUpdatedAt($delivery); $this->setData('updatedAt', $updatedAt); $this->setData('formTitle', __('Properties')); $this->setData('myForm', $myForm->render()); if ($this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID)->isEnabled('taoCampaign')) { $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery)); } $this->setView('DeliveryMgmt/editDelivery.tpl'); }
php
public function editDelivery() { $this->defaultData(); $class = $this->getCurrentClass(); $delivery = $this->getCurrentInstance(); //Removing Result Server form field if it is hardcoded in configuration //since property name (and possibly property itself) is deprecated then this lines will go away to //when "deprecation period" will be over /** @var ResultServerService $resultServerService */ $resultServerService = $this->getServiceManager()->get(ResultServerService::SERVICE_ID); if (!$resultServerService->isConfigurable()) { $options = []; } else { $options = [ 'excludedProperties' => [ OntologyService::PROPERTY_RESULT_SERVER ] ]; } $formContainer = new DeliveryForm($class, $delivery, $options); $myForm = $formContainer->getForm(); $deliveryUri = $delivery->getUri(); if ($myForm->isSubmited() && $myForm->isValid()) { $this->validateInstanceRoot($deliveryUri); $propertyValues = $myForm->getValues(); // then save the property values as usual $binder = new \tao_models_classes_dataBinding_GenerisFormDataBinder($delivery); $delivery = $binder->bind($propertyValues); $this->getEventManager()->trigger(new DeliveryUpdatedEvent($deliveryUri, $propertyValues)); $this->setData('selectNode', \tao_helpers_Uri::encode($deliveryUri)); $this->setData('message', __('Delivery saved')); $this->setData('reload', true); } $this->setData('label', $delivery->getLabel()); // history $this->setData('date', $this->getClassService()->getCompilationDate($delivery)); $serviceProxy = $this->getServiceLocator()->get(ServiceProxy::SERVICE_ID); if ($serviceProxy instanceof Monitoring) { $execs = $serviceProxy->getExecutionsByDelivery($delivery); $this->setData('exec', count($execs)); } // define the groups related to the current delivery $property = $this->getProperty(GroupAssignment::PROPERTY_GROUP_DELIVERY); $tree = \tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property); $tree->setTitle(__('Assigned to')); $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl')); $this->setData('groupTree', $tree->render()); // testtaker brick $this->setData('assemblyUri', $deliveryUri); // define the subjects excluded from the current delivery $property = $this->getProperty(DeliveryContainerService::PROPERTY_EXCLUDED_SUBJECTS); $excluded = $delivery->getPropertyValues($property); $this->setData('ttexcluded', count($excluded)); $users = $this->getServiceLocator()->get(AssignmentService::SERVICE_ID)->getAssignedUsers($deliveryUri); $assigned = array_diff(array_unique($users), $excluded); $this->setData('ttassigned', count($assigned)); $updatedAt = $this->getServiceLocator()->get(ResourceWatcher::SERVICE_ID)->getUpdatedAt($delivery); $this->setData('updatedAt', $updatedAt); $this->setData('formTitle', __('Properties')); $this->setData('myForm', $myForm->render()); if ($this->getServiceLocator()->get(\common_ext_ExtensionsManager::SERVICE_ID)->isEnabled('taoCampaign')) { $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery)); } $this->setView('DeliveryMgmt/editDelivery.tpl'); }
[ "public", "function", "editDelivery", "(", ")", "{", "$", "this", "->", "defaultData", "(", ")", ";", "$", "class", "=", "$", "this", "->", "getCurrentClass", "(", ")", ";", "$", "delivery", "=", "$", "this", "->", "getCurrentInstance", "(", ")", ";", "//Removing Result Server form field if it is hardcoded in configuration", "//since property name (and possibly property itself) is deprecated then this lines will go away to", "//when \"deprecation period\" will be over", "/** @var ResultServerService $resultServerService */", "$", "resultServerService", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "ResultServerService", "::", "SERVICE_ID", ")", ";", "if", "(", "!", "$", "resultServerService", "->", "isConfigurable", "(", ")", ")", "{", "$", "options", "=", "[", "]", ";", "}", "else", "{", "$", "options", "=", "[", "'excludedProperties'", "=>", "[", "OntologyService", "::", "PROPERTY_RESULT_SERVER", "]", "]", ";", "}", "$", "formContainer", "=", "new", "DeliveryForm", "(", "$", "class", ",", "$", "delivery", ",", "$", "options", ")", ";", "$", "myForm", "=", "$", "formContainer", "->", "getForm", "(", ")", ";", "$", "deliveryUri", "=", "$", "delivery", "->", "getUri", "(", ")", ";", "if", "(", "$", "myForm", "->", "isSubmited", "(", ")", "&&", "$", "myForm", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "validateInstanceRoot", "(", "$", "deliveryUri", ")", ";", "$", "propertyValues", "=", "$", "myForm", "->", "getValues", "(", ")", ";", "// then save the property values as usual", "$", "binder", "=", "new", "\\", "tao_models_classes_dataBinding_GenerisFormDataBinder", "(", "$", "delivery", ")", ";", "$", "delivery", "=", "$", "binder", "->", "bind", "(", "$", "propertyValues", ")", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "new", "DeliveryUpdatedEvent", "(", "$", "deliveryUri", ",", "$", "propertyValues", ")", ")", ";", "$", "this", "->", "setData", "(", "'selectNode'", ",", "\\", "tao_helpers_Uri", "::", "encode", "(", "$", "deliveryUri", ")", ")", ";", "$", "this", "->", "setData", "(", "'message'", ",", "__", "(", "'Delivery saved'", ")", ")", ";", "$", "this", "->", "setData", "(", "'reload'", ",", "true", ")", ";", "}", "$", "this", "->", "setData", "(", "'label'", ",", "$", "delivery", "->", "getLabel", "(", ")", ")", ";", "// history", "$", "this", "->", "setData", "(", "'date'", ",", "$", "this", "->", "getClassService", "(", ")", "->", "getCompilationDate", "(", "$", "delivery", ")", ")", ";", "$", "serviceProxy", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "ServiceProxy", "::", "SERVICE_ID", ")", ";", "if", "(", "$", "serviceProxy", "instanceof", "Monitoring", ")", "{", "$", "execs", "=", "$", "serviceProxy", "->", "getExecutionsByDelivery", "(", "$", "delivery", ")", ";", "$", "this", "->", "setData", "(", "'exec'", ",", "count", "(", "$", "execs", ")", ")", ";", "}", "// define the groups related to the current delivery", "$", "property", "=", "$", "this", "->", "getProperty", "(", "GroupAssignment", "::", "PROPERTY_GROUP_DELIVERY", ")", ";", "$", "tree", "=", "\\", "tao_helpers_form_GenerisTreeForm", "::", "buildReverseTree", "(", "$", "delivery", ",", "$", "property", ")", ";", "$", "tree", "->", "setTitle", "(", "__", "(", "'Assigned to'", ")", ")", ";", "$", "tree", "->", "setTemplate", "(", "Template", "::", "getTemplate", "(", "'widgets/assignGroup.tpl'", ")", ")", ";", "$", "this", "->", "setData", "(", "'groupTree'", ",", "$", "tree", "->", "render", "(", ")", ")", ";", "// testtaker brick", "$", "this", "->", "setData", "(", "'assemblyUri'", ",", "$", "deliveryUri", ")", ";", "// define the subjects excluded from the current delivery", "$", "property", "=", "$", "this", "->", "getProperty", "(", "DeliveryContainerService", "::", "PROPERTY_EXCLUDED_SUBJECTS", ")", ";", "$", "excluded", "=", "$", "delivery", "->", "getPropertyValues", "(", "$", "property", ")", ";", "$", "this", "->", "setData", "(", "'ttexcluded'", ",", "count", "(", "$", "excluded", ")", ")", ";", "$", "users", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "AssignmentService", "::", "SERVICE_ID", ")", "->", "getAssignedUsers", "(", "$", "deliveryUri", ")", ";", "$", "assigned", "=", "array_diff", "(", "array_unique", "(", "$", "users", ")", ",", "$", "excluded", ")", ";", "$", "this", "->", "setData", "(", "'ttassigned'", ",", "count", "(", "$", "assigned", ")", ")", ";", "$", "updatedAt", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "ResourceWatcher", "::", "SERVICE_ID", ")", "->", "getUpdatedAt", "(", "$", "delivery", ")", ";", "$", "this", "->", "setData", "(", "'updatedAt'", ",", "$", "updatedAt", ")", ";", "$", "this", "->", "setData", "(", "'formTitle'", ",", "__", "(", "'Properties'", ")", ")", ";", "$", "this", "->", "setData", "(", "'myForm'", ",", "$", "myForm", "->", "render", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "\\", "common_ext_ExtensionsManager", "::", "SERVICE_ID", ")", "->", "isEnabled", "(", "'taoCampaign'", ")", ")", "{", "$", "this", "->", "setData", "(", "'campaign'", ",", "taoCampaign_helpers_Campaign", "::", "renderCampaignTree", "(", "$", "delivery", ")", ")", ";", "}", "$", "this", "->", "setView", "(", "'DeliveryMgmt/editDelivery.tpl'", ")", ";", "}" ]
Edit a delivery instance @access public @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu} @return void @throws \common_exception_NoImplementation @throws \common_exception_Error @throws \oat\tao\model\security\SecurityException
[ "Edit", "a", "delivery", "instance" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/controller/DeliveryMgmt.php#L86-L164
oat-sa/extension-tao-delivery-rdf
scripts/tools/CleanFailedCompiledDeliveriesScript.php
CleanFailedCompiledDeliveriesScript.run
protected function run() { $report = common_report_Report::createInfo('Deleting Failing deliveries'); /** @var ComplexSearchService $search */ $search = $this->getModel()->getSearchInterface(); $deliveryAssemblyService = DeliveryAssemblyService::singleton(); $queryBuilder = $search->query(); $query = $search->searchType($queryBuilder, $deliveryAssemblyService->getRootClass()->getUri(),true); $queryBuilder->setCriteria($query); $searchResult = $search->getGateway()->search($queryBuilder); $failedDeliveries = []; /** @var \core_kernel_classes_Resource $instance */ foreach ($searchResult as $instance) { try { $value = DeliveryAssemblyService::singleton()->getRuntime($instance); if (is_null($value)) { $failedDeliveries[] = $instance; } } catch (\common_Exception $e) { $failedDeliveries[] = $instance; } } /** @var \core_kernel_classes_Resource $failedDelivery */ foreach ($failedDeliveries as $failedDelivery) { $failedDelivery->delete(true); $report->add(common_report_Report::createSuccess('Delivery deleted:'. $failedDelivery->getUri())); } return $report; }
php
protected function run() { $report = common_report_Report::createInfo('Deleting Failing deliveries'); /** @var ComplexSearchService $search */ $search = $this->getModel()->getSearchInterface(); $deliveryAssemblyService = DeliveryAssemblyService::singleton(); $queryBuilder = $search->query(); $query = $search->searchType($queryBuilder, $deliveryAssemblyService->getRootClass()->getUri(),true); $queryBuilder->setCriteria($query); $searchResult = $search->getGateway()->search($queryBuilder); $failedDeliveries = []; /** @var \core_kernel_classes_Resource $instance */ foreach ($searchResult as $instance) { try { $value = DeliveryAssemblyService::singleton()->getRuntime($instance); if (is_null($value)) { $failedDeliveries[] = $instance; } } catch (\common_Exception $e) { $failedDeliveries[] = $instance; } } /** @var \core_kernel_classes_Resource $failedDelivery */ foreach ($failedDeliveries as $failedDelivery) { $failedDelivery->delete(true); $report->add(common_report_Report::createSuccess('Delivery deleted:'. $failedDelivery->getUri())); } return $report; }
[ "protected", "function", "run", "(", ")", "{", "$", "report", "=", "common_report_Report", "::", "createInfo", "(", "'Deleting Failing deliveries'", ")", ";", "/** @var ComplexSearchService $search */", "$", "search", "=", "$", "this", "->", "getModel", "(", ")", "->", "getSearchInterface", "(", ")", ";", "$", "deliveryAssemblyService", "=", "DeliveryAssemblyService", "::", "singleton", "(", ")", ";", "$", "queryBuilder", "=", "$", "search", "->", "query", "(", ")", ";", "$", "query", "=", "$", "search", "->", "searchType", "(", "$", "queryBuilder", ",", "$", "deliveryAssemblyService", "->", "getRootClass", "(", ")", "->", "getUri", "(", ")", ",", "true", ")", ";", "$", "queryBuilder", "->", "setCriteria", "(", "$", "query", ")", ";", "$", "searchResult", "=", "$", "search", "->", "getGateway", "(", ")", "->", "search", "(", "$", "queryBuilder", ")", ";", "$", "failedDeliveries", "=", "[", "]", ";", "/** @var \\core_kernel_classes_Resource $instance */", "foreach", "(", "$", "searchResult", "as", "$", "instance", ")", "{", "try", "{", "$", "value", "=", "DeliveryAssemblyService", "::", "singleton", "(", ")", "->", "getRuntime", "(", "$", "instance", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "failedDeliveries", "[", "]", "=", "$", "instance", ";", "}", "}", "catch", "(", "\\", "common_Exception", "$", "e", ")", "{", "$", "failedDeliveries", "[", "]", "=", "$", "instance", ";", "}", "}", "/** @var \\core_kernel_classes_Resource $failedDelivery */", "foreach", "(", "$", "failedDeliveries", "as", "$", "failedDelivery", ")", "{", "$", "failedDelivery", "->", "delete", "(", "true", ")", ";", "$", "report", "->", "add", "(", "common_report_Report", "::", "createSuccess", "(", "'Delivery deleted:'", ".", "$", "failedDelivery", "->", "getUri", "(", ")", ")", ")", ";", "}", "return", "$", "report", ";", "}" ]
Run Script. Run the userland script. Implementers will use this method to implement the main logic of the script. @return \common_report_Report @throws \oat\search\base\exception\SearchGateWayExeption @throws \common_exception_Error
[ "Run", "Script", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/scripts/tools/CleanFailedCompiledDeliveriesScript.php#L58-L91
oat-sa/extension-tao-delivery-rdf
model/theme/DeliveryThemeDetailsProvider.php
DeliveryThemeDetailsProvider.getDeliveryExecutionId
protected function getDeliveryExecutionId() { $request = \Context::getInstance()->getRequest(); $deliveryExecutionId = ''; if ($request->hasParameter('deliveryExecution')) { $deliveryExecutionId = \tao_helpers_Uri::decode( $request->getParameter('deliveryExecution') ); } elseif ($request->hasParameter('testServiceCallId')) { $deliveryExecutionId = \tao_helpers_Uri::decode( $request->getParameter('testServiceCallId') ); } elseif ($request->hasParameter('serviceCallId')) { $deliveryExecutionId = \tao_helpers_Uri::decode( $request->getParameter('serviceCallId') ); } return $deliveryExecutionId; }
php
protected function getDeliveryExecutionId() { $request = \Context::getInstance()->getRequest(); $deliveryExecutionId = ''; if ($request->hasParameter('deliveryExecution')) { $deliveryExecutionId = \tao_helpers_Uri::decode( $request->getParameter('deliveryExecution') ); } elseif ($request->hasParameter('testServiceCallId')) { $deliveryExecutionId = \tao_helpers_Uri::decode( $request->getParameter('testServiceCallId') ); } elseif ($request->hasParameter('serviceCallId')) { $deliveryExecutionId = \tao_helpers_Uri::decode( $request->getParameter('serviceCallId') ); } return $deliveryExecutionId; }
[ "protected", "function", "getDeliveryExecutionId", "(", ")", "{", "$", "request", "=", "\\", "Context", "::", "getInstance", "(", ")", "->", "getRequest", "(", ")", ";", "$", "deliveryExecutionId", "=", "''", ";", "if", "(", "$", "request", "->", "hasParameter", "(", "'deliveryExecution'", ")", ")", "{", "$", "deliveryExecutionId", "=", "\\", "tao_helpers_Uri", "::", "decode", "(", "$", "request", "->", "getParameter", "(", "'deliveryExecution'", ")", ")", ";", "}", "elseif", "(", "$", "request", "->", "hasParameter", "(", "'testServiceCallId'", ")", ")", "{", "$", "deliveryExecutionId", "=", "\\", "tao_helpers_Uri", "::", "decode", "(", "$", "request", "->", "getParameter", "(", "'testServiceCallId'", ")", ")", ";", "}", "elseif", "(", "$", "request", "->", "hasParameter", "(", "'serviceCallId'", ")", ")", "{", "$", "deliveryExecutionId", "=", "\\", "tao_helpers_Uri", "::", "decode", "(", "$", "request", "->", "getParameter", "(", "'serviceCallId'", ")", ")", ";", "}", "return", "$", "deliveryExecutionId", ";", "}" ]
Returns the delivery execution identifier. @return string
[ "Returns", "the", "delivery", "execution", "identifier", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/theme/DeliveryThemeDetailsProvider.php#L71-L91
oat-sa/extension-tao-delivery-rdf
model/theme/DeliveryThemeDetailsProvider.php
DeliveryThemeDetailsProvider.getDeliveryThemeIdFromCache
public function getDeliveryThemeIdFromCache($deliveryId) { if ($this->getCachePersistence() === null) { return false; } return $this->getCachePersistence()->get($this->getCacheKey($deliveryId)); }
php
public function getDeliveryThemeIdFromCache($deliveryId) { if ($this->getCachePersistence() === null) { return false; } return $this->getCachePersistence()->get($this->getCacheKey($deliveryId)); }
[ "public", "function", "getDeliveryThemeIdFromCache", "(", "$", "deliveryId", ")", "{", "if", "(", "$", "this", "->", "getCachePersistence", "(", ")", "===", "null", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getCachePersistence", "(", ")", "->", "get", "(", "$", "this", "->", "getCacheKey", "(", "$", "deliveryId", ")", ")", ";", "}" ]
Returns the delivery theme id from cache or FALSE when it does not exist. @param $deliveryId @return bool|common_Serializable
[ "Returns", "the", "delivery", "theme", "id", "from", "cache", "or", "FALSE", "when", "it", "does", "not", "exist", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/theme/DeliveryThemeDetailsProvider.php#L163-L170
oat-sa/extension-tao-delivery-rdf
model/theme/DeliveryThemeDetailsProvider.php
DeliveryThemeDetailsProvider.getDeliveryThemeIdFromDb
public function getDeliveryThemeIdFromDb($deliveryId) { try { $delivery = new core_kernel_classes_Resource($deliveryId); $property = $delivery->getProperty(static::DELIVERY_THEME_ID_URI); return (string)$delivery->getOnePropertyValue($property); } catch (common_exception_Error $e) { return ''; } }
php
public function getDeliveryThemeIdFromDb($deliveryId) { try { $delivery = new core_kernel_classes_Resource($deliveryId); $property = $delivery->getProperty(static::DELIVERY_THEME_ID_URI); return (string)$delivery->getOnePropertyValue($property); } catch (common_exception_Error $e) { return ''; } }
[ "public", "function", "getDeliveryThemeIdFromDb", "(", "$", "deliveryId", ")", "{", "try", "{", "$", "delivery", "=", "new", "core_kernel_classes_Resource", "(", "$", "deliveryId", ")", ";", "$", "property", "=", "$", "delivery", "->", "getProperty", "(", "static", "::", "DELIVERY_THEME_ID_URI", ")", ";", "return", "(", "string", ")", "$", "delivery", "->", "getOnePropertyValue", "(", "$", "property", ")", ";", "}", "catch", "(", "common_exception_Error", "$", "e", ")", "{", "return", "''", ";", "}", "}" ]
Returns delivery theme id from database. @param $deliveryId @return string
[ "Returns", "delivery", "theme", "id", "from", "database", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/theme/DeliveryThemeDetailsProvider.php#L179-L189
oat-sa/extension-tao-delivery-rdf
model/theme/DeliveryThemeDetailsProvider.php
DeliveryThemeDetailsProvider.storeDeliveryThemeIdToCache
public function storeDeliveryThemeIdToCache($deliveryId, $themeId) { try { if ($this->getCachePersistence() !== null) { return $this->getCachePersistence()->set($this->getCacheKey($deliveryId), $themeId, $this->getCacheTtl()); } } catch (common_exception_NotImplemented $e) { } return false; }
php
public function storeDeliveryThemeIdToCache($deliveryId, $themeId) { try { if ($this->getCachePersistence() !== null) { return $this->getCachePersistence()->set($this->getCacheKey($deliveryId), $themeId, $this->getCacheTtl()); } } catch (common_exception_NotImplemented $e) { } return false; }
[ "public", "function", "storeDeliveryThemeIdToCache", "(", "$", "deliveryId", ",", "$", "themeId", ")", "{", "try", "{", "if", "(", "$", "this", "->", "getCachePersistence", "(", ")", "!==", "null", ")", "{", "return", "$", "this", "->", "getCachePersistence", "(", ")", "->", "set", "(", "$", "this", "->", "getCacheKey", "(", "$", "deliveryId", ")", ",", "$", "themeId", ",", "$", "this", "->", "getCacheTtl", "(", ")", ")", ";", "}", "}", "catch", "(", "common_exception_NotImplemented", "$", "e", ")", "{", "}", "return", "false", ";", "}" ]
Stores the delivery theme id to cache. @param $deliveryId @param $themeId @return bool
[ "Stores", "the", "delivery", "theme", "id", "to", "cache", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/theme/DeliveryThemeDetailsProvider.php#L199-L209
oat-sa/extension-tao-delivery-rdf
model/theme/DeliveryThemeDetailsProvider.php
DeliveryThemeDetailsProvider.getCachePersistence
protected function getCachePersistence() { if (is_null($this->cachePersistence) && $this->hasOption(static::OPTION_CACHE_PERSISTENCE)) { $persistenceOption = $this->getOption(static::OPTION_CACHE_PERSISTENCE); $this->cachePersistence = (is_object($persistenceOption)) ? $persistenceOption : common_persistence_KeyValuePersistence::getPersistence($persistenceOption); } return $this->cachePersistence; }
php
protected function getCachePersistence() { if (is_null($this->cachePersistence) && $this->hasOption(static::OPTION_CACHE_PERSISTENCE)) { $persistenceOption = $this->getOption(static::OPTION_CACHE_PERSISTENCE); $this->cachePersistence = (is_object($persistenceOption)) ? $persistenceOption : common_persistence_KeyValuePersistence::getPersistence($persistenceOption); } return $this->cachePersistence; }
[ "protected", "function", "getCachePersistence", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "cachePersistence", ")", "&&", "$", "this", "->", "hasOption", "(", "static", "::", "OPTION_CACHE_PERSISTENCE", ")", ")", "{", "$", "persistenceOption", "=", "$", "this", "->", "getOption", "(", "static", "::", "OPTION_CACHE_PERSISTENCE", ")", ";", "$", "this", "->", "cachePersistence", "=", "(", "is_object", "(", "$", "persistenceOption", ")", ")", "?", "$", "persistenceOption", ":", "common_persistence_KeyValuePersistence", "::", "getPersistence", "(", "$", "persistenceOption", ")", ";", "}", "return", "$", "this", "->", "cachePersistence", ";", "}" ]
Returns the cache persistence. @return common_persistence_KvDriver
[ "Returns", "the", "cache", "persistence", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/theme/DeliveryThemeDetailsProvider.php#L228-L238
oat-sa/extension-tao-delivery-rdf
model/theme/DeliveryThemeDetailsProvider.php
DeliveryThemeDetailsProvider.getCacheTtl
public function getCacheTtl() { if ($this->hasOption(static::OPTION_CACHE_PERSISTENCE_TTL)) { $cacheTtl = $this->getOption(static::OPTION_CACHE_PERSISTENCE_TTL); if (!is_null($cacheTtl)) { return $cacheTtl; } } return static::CACHE_PERSISTENCE_DEFAULT_TTL; }
php
public function getCacheTtl() { if ($this->hasOption(static::OPTION_CACHE_PERSISTENCE_TTL)) { $cacheTtl = $this->getOption(static::OPTION_CACHE_PERSISTENCE_TTL); if (!is_null($cacheTtl)) { return $cacheTtl; } } return static::CACHE_PERSISTENCE_DEFAULT_TTL; }
[ "public", "function", "getCacheTtl", "(", ")", "{", "if", "(", "$", "this", "->", "hasOption", "(", "static", "::", "OPTION_CACHE_PERSISTENCE_TTL", ")", ")", "{", "$", "cacheTtl", "=", "$", "this", "->", "getOption", "(", "static", "::", "OPTION_CACHE_PERSISTENCE_TTL", ")", ";", "if", "(", "!", "is_null", "(", "$", "cacheTtl", ")", ")", "{", "return", "$", "cacheTtl", ";", "}", "}", "return", "static", "::", "CACHE_PERSISTENCE_DEFAULT_TTL", ";", "}" ]
Returns the cache persistence's ttl. @return int|null
[ "Returns", "the", "cache", "persistence", "s", "ttl", "." ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/theme/DeliveryThemeDetailsProvider.php#L245-L255
oat-sa/extension-tao-delivery-rdf
model/tasks/UpdateDelivery.php
UpdateDelivery.createTask
public static function createTask($where = [], $propertyValues = []) { $serviceManager = ServiceManager::getServiceManager(); $action = new self(); $action->setServiceLocator($serviceManager); $parameters = [ self::OPTION_WHERE => $where, self::OPTION_PARAMETERS => $propertyValues ]; /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = ServiceManager::getServiceManager()->get(QueueDispatcher::SERVICE_ID); return $queueDispatcher->createTask($action, $parameters, null, null, true); }
php
public static function createTask($where = [], $propertyValues = []) { $serviceManager = ServiceManager::getServiceManager(); $action = new self(); $action->setServiceLocator($serviceManager); $parameters = [ self::OPTION_WHERE => $where, self::OPTION_PARAMETERS => $propertyValues ]; /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = ServiceManager::getServiceManager()->get(QueueDispatcher::SERVICE_ID); return $queueDispatcher->createTask($action, $parameters, null, null, true); }
[ "public", "static", "function", "createTask", "(", "$", "where", "=", "[", "]", ",", "$", "propertyValues", "=", "[", "]", ")", "{", "$", "serviceManager", "=", "ServiceManager", "::", "getServiceManager", "(", ")", ";", "$", "action", "=", "new", "self", "(", ")", ";", "$", "action", "->", "setServiceLocator", "(", "$", "serviceManager", ")", ";", "$", "parameters", "=", "[", "self", "::", "OPTION_WHERE", "=>", "$", "where", ",", "self", "::", "OPTION_PARAMETERS", "=>", "$", "propertyValues", "]", ";", "/** @var QueueDispatcher $queueDispatcher */", "$", "queueDispatcher", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "QueueDispatcher", "::", "SERVICE_ID", ")", ";", "return", "$", "queueDispatcher", "->", "createTask", "(", "$", "action", ",", "$", "parameters", ",", "null", ",", "null", ",", "true", ")", ";", "}" ]
Create a task to update a delivery @param array $where @param array $propertyValues @return TaskInterface
[ "Create", "a", "task", "to", "update", "a", "delivery" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/tasks/UpdateDelivery.php#L87-L100
oat-sa/extension-tao-delivery-rdf
model/SimpleDeliveryFactory.php
SimpleDeliveryFactory.create
public static function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label) { $factory = ServiceManager::getServiceManager()->get(DeliveryFactory::SERVICE_ID); return $factory->create($deliveryClass, $test, $label); }
php
public static function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label) { $factory = ServiceManager::getServiceManager()->get(DeliveryFactory::SERVICE_ID); return $factory->create($deliveryClass, $test, $label); }
[ "public", "static", "function", "create", "(", "core_kernel_classes_Class", "$", "deliveryClass", ",", "core_kernel_classes_Resource", "$", "test", ",", "$", "label", ")", "{", "$", "factory", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "DeliveryFactory", "::", "SERVICE_ID", ")", ";", "return", "$", "factory", "->", "create", "(", "$", "deliveryClass", ",", "$", "test", ",", "$", "label", ")", ";", "}" ]
Please use DeliveryFactory service @deprecated
[ "Please", "use", "DeliveryFactory", "service" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/SimpleDeliveryFactory.php#L39-L42
oat-sa/extension-tao-delivery-rdf
model/TrackedStorage.php
TrackedStorage.import
public function import($id, $directoryPath) { $this->ids[] = $id; return $this->getInternalStorage()->import($id, $directoryPath); }
php
public function import($id, $directoryPath) { $this->ids[] = $id; return $this->getInternalStorage()->import($id, $directoryPath); }
[ "public", "function", "import", "(", "$", "id", ",", "$", "directoryPath", ")", "{", "$", "this", "->", "ids", "[", "]", "=", "$", "id", ";", "return", "$", "this", "->", "getInternalStorage", "(", ")", "->", "import", "(", "$", "id", ",", "$", "directoryPath", ")", ";", "}" ]
{@inheritDoc} @see tao_models_classes_service_FileStorage::import()
[ "{" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/TrackedStorage.php#L64-L68
oat-sa/extension-tao-delivery-rdf
model/tasks/CompileDelivery.php
CompileDelivery.createTask
public static function createTask(\core_kernel_classes_Resource $test, \core_kernel_classes_Class $deliveryClass, array $initialProperties = []) { $action = new self(); /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = ServiceManager::getServiceManager()->get(QueueDispatcher::SERVICE_ID); $parameters = [ 'test' => $test->getUri(), 'initialProperties' => $initialProperties ]; if (!is_null($deliveryClass)) { $parameters['deliveryClass'] = $deliveryClass->getUri(); } return $queueDispatcher->createTask($action, $parameters, __('Publishing of "%s"', $test->getLabel()), null, true); }
php
public static function createTask(\core_kernel_classes_Resource $test, \core_kernel_classes_Class $deliveryClass, array $initialProperties = []) { $action = new self(); /** @var QueueDispatcher $queueDispatcher */ $queueDispatcher = ServiceManager::getServiceManager()->get(QueueDispatcher::SERVICE_ID); $parameters = [ 'test' => $test->getUri(), 'initialProperties' => $initialProperties ]; if (!is_null($deliveryClass)) { $parameters['deliveryClass'] = $deliveryClass->getUri(); } return $queueDispatcher->createTask($action, $parameters, __('Publishing of "%s"', $test->getLabel()), null, true); }
[ "public", "static", "function", "createTask", "(", "\\", "core_kernel_classes_Resource", "$", "test", ",", "\\", "core_kernel_classes_Class", "$", "deliveryClass", ",", "array", "$", "initialProperties", "=", "[", "]", ")", "{", "$", "action", "=", "new", "self", "(", ")", ";", "/** @var QueueDispatcher $queueDispatcher */", "$", "queueDispatcher", "=", "ServiceManager", "::", "getServiceManager", "(", ")", "->", "get", "(", "QueueDispatcher", "::", "SERVICE_ID", ")", ";", "$", "parameters", "=", "[", "'test'", "=>", "$", "test", "->", "getUri", "(", ")", ",", "'initialProperties'", "=>", "$", "initialProperties", "]", ";", "if", "(", "!", "is_null", "(", "$", "deliveryClass", ")", ")", "{", "$", "parameters", "[", "'deliveryClass'", "]", "=", "$", "deliveryClass", "->", "getUri", "(", ")", ";", "}", "return", "$", "queueDispatcher", "->", "createTask", "(", "$", "action", ",", "$", "parameters", ",", "__", "(", "'Publishing of \"%s\"'", ",", "$", "test", "->", "getLabel", "(", ")", ")", ",", "null", ",", "true", ")", ";", "}" ]
Create a task to compile a delivery into a delivery class @param \core_kernel_classes_Resource $test Test resource to be compiled @param \core_kernel_classes_Class $deliveryClass Delivery class where the test is compiled to @param array $initialProperties @return TaskInterface
[ "Create", "a", "task", "to", "compile", "a", "delivery", "into", "a", "delivery", "class" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/tasks/CompileDelivery.php#L121-L137
oat-sa/extension-tao-delivery-rdf
model/DeliveryAssemblyService.php
DeliveryAssemblyService.getFileStorage
protected function getFileStorage() { if (!$this->storageService) { $this->storageService = $this->getServiceManager()->get(\tao_models_classes_service_FileStorage::SERVICE_ID); } return $this->storageService; }
php
protected function getFileStorage() { if (!$this->storageService) { $this->storageService = $this->getServiceManager()->get(\tao_models_classes_service_FileStorage::SERVICE_ID); } return $this->storageService; }
[ "protected", "function", "getFileStorage", "(", ")", "{", "if", "(", "!", "$", "this", "->", "storageService", ")", "{", "$", "this", "->", "storageService", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "\\", "tao_models_classes_service_FileStorage", "::", "SERVICE_ID", ")", ";", "}", "return", "$", "this", "->", "storageService", ";", "}" ]
Return the file storage @return \tao_models_classes_service_FileStorage
[ "Return", "the", "file", "storage" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryAssemblyService.php#L78-L84
oat-sa/extension-tao-delivery-rdf
model/DeliveryAssemblyService.php
DeliveryAssemblyService.deleteInstance
public function deleteInstance(core_kernel_classes_Resource $assembly) { if ($this->deleteDeliveryRuntime($assembly)===false) { \common_Logger::i('Fail to delete runtimes assembly, process aborted'); } if ($this->deleteDeliveryDirectory($assembly)===false) { \common_Logger::i('Fail to delete directories assembly, process aborted'); } return $assembly->delete(); }
php
public function deleteInstance(core_kernel_classes_Resource $assembly) { if ($this->deleteDeliveryRuntime($assembly)===false) { \common_Logger::i('Fail to delete runtimes assembly, process aborted'); } if ($this->deleteDeliveryDirectory($assembly)===false) { \common_Logger::i('Fail to delete directories assembly, process aborted'); } return $assembly->delete(); }
[ "public", "function", "deleteInstance", "(", "core_kernel_classes_Resource", "$", "assembly", ")", "{", "if", "(", "$", "this", "->", "deleteDeliveryRuntime", "(", "$", "assembly", ")", "===", "false", ")", "{", "\\", "common_Logger", "::", "i", "(", "'Fail to delete runtimes assembly, process aborted'", ")", ";", "}", "if", "(", "$", "this", "->", "deleteDeliveryDirectory", "(", "$", "assembly", ")", "===", "false", ")", "{", "\\", "common_Logger", "::", "i", "(", "'Fail to delete directories assembly, process aborted'", ")", ";", "}", "return", "$", "assembly", "->", "delete", "(", ")", ";", "}" ]
Delete delivery by deleting runtime, directories & ontology record @param core_kernel_classes_Resource $assembly @return bool
[ "Delete", "delivery", "by", "deleting", "runtime", "directories", "&", "ontology", "record" ]
train
https://github.com/oat-sa/extension-tao-delivery-rdf/blob/340cee99ac75ccaaa63725b59a5befe4e2a7bb41/model/DeliveryAssemblyService.php#L112-L123