idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
1,300 | protected function renderCTypeShortcut ( PageLayoutView $ parentObject , & $ row ) { $ shortcutContent = '' ; if ( $ row [ 'records' ] ) { $ shortcutItems = explode ( ',' , $ row [ 'records' ] ) ; $ collectedItems = [ ] ; foreach ( $ shortcutItems as $ shortcutItem ) { $ shortcutItem = trim ( $ shortcutItem ) ; if ( strpos ( $ shortcutItem , 'pages_' ) !== false ) { $ this -> collectContentDataFromPages ( $ shortcutItem , $ collectedItems , $ row [ 'recursive' ] , $ row [ 'uid' ] , $ row [ 'sys_language_uid' ] ) ; } else { if ( strpos ( $ shortcutItem , '_' ) === false || strpos ( $ shortcutItem , 'tt_content_' ) !== false ) { $ this -> collectContentData ( $ shortcutItem , $ collectedItems , $ row [ 'uid' ] , $ row [ 'sys_language_uid' ] ) ; } } } if ( ! empty ( $ collectedItems ) ) { foreach ( $ collectedItems as $ item ) { if ( $ item ) { $ className = $ item [ 'tx_gridelements_reference_container' ] ? 'reference container_reference' : 'reference' ; $ shortcutContent .= '<div class="' . $ className . '">' ; $ shortcutContent .= $ this -> renderSingleElementHTML ( $ parentObject , $ item ) ; $ shortcutContent .= '<div class="reference-overlay"></div></div></div>' ; } } } } return $ shortcutContent ; } | renders the HTML output for elements of the CType shortcut |
1,301 | protected function collectContentDataFromPages ( $ shortcutItem , & $ collectedItems , $ recursive = 0 , $ parentUid = 0 , $ language = 0 ) { $ itemList = str_replace ( 'pages_' , '' , $ shortcutItem ) ; if ( $ recursive ) { if ( ! $ this -> tree instanceof QueryGenerator ) { $ this -> tree = GeneralUtility :: makeInstance ( QueryGenerator :: class ) ; } $ itemList = $ this -> tree -> getTreeList ( $ itemList , ( int ) $ recursive , 0 , 1 ) ; } $ itemList = GeneralUtility :: intExplode ( ',' , $ itemList ) ; $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ items = $ queryBuilder -> select ( '*' ) -> addSelectLiteral ( $ queryBuilder -> expr ( ) -> inSet ( 'pid' , $ queryBuilder -> createNamedParameter ( $ itemList , Connection :: PARAM_INT_ARRAY ) ) . ' AS inSet' ) -> from ( 'tt_content' ) -> where ( $ queryBuilder -> expr ( ) -> neq ( 'uid' , $ queryBuilder -> createNamedParameter ( ( int ) $ parentUid , \ PDO :: PARAM_INT ) ) , $ queryBuilder -> expr ( ) -> in ( 'pid' , $ queryBuilder -> createNamedParameter ( $ itemList , Connection :: PARAM_INT_ARRAY ) ) , $ queryBuilder -> expr ( ) -> gte ( 'colPos' , $ queryBuilder -> createNamedParameter ( 0 , \ PDO :: PARAM_INT ) ) , $ queryBuilder -> expr ( ) -> in ( 'sys_language_uid' , $ queryBuilder -> createNamedParameter ( [ 0 , - 1 ] , Connection :: PARAM_INT_ARRAY ) ) ) -> orderBy ( 'inSet' ) -> addOrderBy ( 'colPos' ) -> addOrderBy ( 'sorting' ) -> execute ( ) -> fetchAll ( ) ; foreach ( $ items as $ item ) { if ( ! empty ( $ this -> extentensionConfiguration [ 'overlayShortcutTranslation' ] ) && $ language > 0 ) { $ translatedItem = BackendUtility :: getRecordLocalization ( 'tt_content' , $ item [ 'uid' ] , $ language ) ; if ( ! empty ( $ translatedItem ) ) { $ item = array_shift ( $ translatedItem ) ; } } if ( $ this -> helper -> getBackendUser ( ) -> workspace > 0 ) { BackendUtility :: workspaceOL ( 'tt_content' , $ item , $ this -> helper -> getBackendUser ( ) -> workspace ) ; } $ item [ 'tx_gridelements_reference_container' ] = $ item [ 'pid' ] ; $ collectedItems [ ] = $ item ; } } | Collects tt_content data from a single page or a page tree starting at a given page |
1,302 | public function contentCollapseIcon ( array & $ data , $ sortField , $ level , & $ contentCollapseIcon , DatabaseRecordListXclass $ parentObj ) { if ( $ data [ '_EXPAND_TABLE_' ] === 'tt_content' ) { $ expandTitle = $ this -> languageService -> sL ( 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.expandElement' ) ; $ collapseTitle = $ this -> languageService -> sL ( 'LLL:EXT:gridelements/Resources/Private/Language/locallang_db.xlf:list.collapseElement' ) ; $ expandedGridelements = $ parentObj -> getExpandedGridelements ( ) ; if ( $ expandedGridelements [ $ data [ 'uid' ] ] ) { $ href = htmlspecialchars ( ( $ parentObj -> listURL ( ) . '&gridelementsExpand[' . ( int ) $ data [ 'uid' ] . ']=0' ) ) ; $ contentCollapseIcon = '<a class="btn btn-default t3js-toggle-gridelements-list open-gridelements-container" data-state="expanded" href="' . $ href . '" id="t3-gridelements-' . $ data [ 'uid' ] . '" title="' . $ collapseTitle . '" data-toggle-title="' . $ expandTitle . '">' . $ this -> getIconFactory ( ) -> getIcon ( 'actions-view-list-expand' , 'small' ) -> render ( ) . $ this -> getIconFactory ( ) -> getIcon ( 'actions-view-list-collapse' , 'small' ) -> render ( ) . '</a>' ; } else { $ href = htmlspecialchars ( ( $ parentObj -> listURL ( ) . '&gridelementsExpand[' . ( int ) $ data [ 'uid' ] . ']=1' ) ) ; $ contentCollapseIcon = '<a class="btn btn-default t3js-toggle-gridelements-list" data-state="collapsed" href="' . $ href . '" id="t3-gridelements-' . $ data [ 'uid' ] . '" title="' . $ expandTitle . '" data-toggle-title="' . $ collapseTitle . '">' . $ this -> getIconFactory ( ) -> getIcon ( 'actions-view-list-expand' , 'small' ) -> render ( ) . $ this -> getIconFactory ( ) -> getIcon ( 'actions-view-list-collapse' , 'small' ) -> render ( ) . '</a>' ; } } } | return content collapse icon |
1,303 | public function checkForAllowedLanguages ( array & $ items , $ gridContainerId ) { if ( ! $ gridContainerId ) { return ; } $ parentContainer = BackendUtility :: getRecordWSOL ( 'tt_content' , $ gridContainerId ) ; if ( ! empty ( $ items ) && ( int ) $ parentContainer [ 'uid' ] > 0 ) { foreach ( $ items as $ item => $ valueArray ) { if ( ( int ) $ parentContainer [ 'sys_language_uid' ] > - 1 && ( int ) $ valueArray [ 1 ] !== ( int ) $ parentContainer [ 'sys_language_uid' ] ) { unset ( $ items [ $ item ] ) ; } } } } | Checks if a language is allowed in this particular container - only this one container defines the allowed languages regardless of any parent |
1,304 | public function columnsItemsProcFunc ( array & $ params ) { $ this -> init ( $ params [ 'row' ] [ 'pid' ] ) ; $ gridContainerId = is_array ( $ params [ 'row' ] [ 'tx_gridelements_container' ] ) ? ( int ) $ params [ 'row' ] [ 'tx_gridelements_container' ] [ 0 ] : ( int ) $ params [ 'row' ] [ 'tx_gridelements_container' ] ; if ( $ gridContainerId > 0 ) { $ gridElement = $ this -> layoutSetup -> cacheCurrentParent ( $ gridContainerId , true ) ; $ params [ 'items' ] = $ this -> layoutSetup -> getLayoutColumnsSelectItems ( $ gridElement [ 'tx_gridelements_backend_layout' ] ) ; $ ContentType = is_array ( $ params [ 'row' ] [ 'CType' ] ) ? $ params [ 'row' ] [ 'CType' ] [ 0 ] : $ params [ 'row' ] [ 'CType' ] ; if ( ! empty ( $ ContentType ) && is_array ( $ params [ 'items' ] ) ) { foreach ( $ params [ 'items' ] as $ itemKey => $ itemArray ) { if ( $ itemArray [ 3 ] !== '' && $ itemArray [ 3 ] !== '*' && ! GeneralUtility :: inList ( $ itemArray [ 3 ] , $ ContentType ) ) { unset ( $ params [ 'items' ] [ $ itemKey ] ) ; } } } } } | ItemProcFunc for columns items |
1,305 | public function containerItemsProcFunc ( array & $ params ) { $ this -> init ( $ params [ 'row' ] [ 'pid' ] ) ; $ possibleContainers = [ ] ; $ this -> removeItemsFromListOfSelectableContainers ( $ params , $ possibleContainers ) ; if ( ! empty ( $ possibleContainers ) ) { $ params [ 'items' ] = array_merge ( $ params [ 'items' ] , $ possibleContainers ) ; } $ itemUidList = '' ; if ( count ( $ params [ 'items' ] ) > 1 ) { foreach ( $ params [ 'items' ] as $ container ) { if ( $ container [ 1 ] > 0 ) { $ itemUidList .= $ itemUidList ? ',' . $ container [ 1 ] : $ container [ 1 ] ; } } } if ( $ itemUidList ) { $ this -> deleteDisallowedContainers ( $ params , $ itemUidList ) ; } } | ItemProcFunc for container items removes items of the children chain from the list of selectable containers if the element itself already is a container |
1,306 | public function removeItemsFromListOfSelectableContainers ( array & $ params , array & $ possibleContainers ) { $ contentType = is_array ( $ params [ 'row' ] [ 'CType' ] ) ? $ params [ 'row' ] [ 'CType' ] [ 0 ] : $ params [ 'row' ] [ 'CType' ] ; if ( $ contentType === 'gridelements_pi1' && count ( $ params [ 'items' ] ) > 1 ) { $ items = $ params [ 'items' ] ; $ params [ 'items' ] = [ 0 => array_shift ( $ items ) ] ; foreach ( $ items as $ item ) { $ possibleContainers [ $ item [ '1' ] ] = $ item ; } if ( $ params [ 'row' ] [ 'uid' ] > 0 ) { $ this -> lookForChildContainersRecursively ( ( int ) $ params [ 'row' ] [ 'uid' ] , $ possibleContainers ) ; } } } | removes items of the children chain from the list of selectable containers |
1,307 | public function lookForChildContainersRecursively ( $ containerIds , array & $ possibleContainers ) { if ( ! $ containerIds ) { return ; } $ containerIds = GeneralUtility :: intExplode ( ',' , $ containerIds ) ; $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ childrenOnNextLevel = $ queryBuilder -> select ( 'uid' , 'tx_gridelements_container' ) -> from ( 'tt_content' ) -> where ( $ queryBuilder -> expr ( ) -> andX ( $ queryBuilder -> expr ( ) -> eq ( 'CType' , $ queryBuilder -> createNamedParameter ( 'gridelements_pi1' ) ) , $ queryBuilder -> expr ( ) -> in ( 'tx_gridelements_container' , $ queryBuilder -> createNamedParameter ( $ containerIds , Connection :: PARAM_INT_ARRAY ) ) ) ) -> execute ( ) -> fetchAll ( ) ; if ( ! empty ( $ childrenOnNextLevel ) && ! empty ( $ possibleContainers ) ) { $ containerIds = '' ; foreach ( $ childrenOnNextLevel as $ childOnNextLevel ) { if ( isset ( $ possibleContainers [ $ childOnNextLevel [ 'uid' ] ] ) ) { unset ( $ possibleContainers [ $ childOnNextLevel [ 'uid' ] ] ) ; } $ containerIds .= $ containerIds ? ',' . ( int ) $ childOnNextLevel [ 'uid' ] : ( int ) $ childOnNextLevel [ 'uid' ] ; if ( $ containerIds !== '' ) { $ this -> lookForChildContainersRecursively ( $ containerIds , $ possibleContainers ) ; } } } } | Recursive function to remove any container from the list of possible containers that is already a subcontainer on any level of the current container |
1,308 | public function layoutItemsProcFunc ( array & $ params ) { $ this -> init ( $ params [ 'row' ] [ 'pid' ] ) ; $ layoutSelectItems = $ this -> layoutSetup -> getLayoutSelectItems ( isset ( $ params [ 'row' ] [ 'colPos' ] [ 0 ] ) ? $ params [ 'row' ] [ 'colPos' ] [ 0 ] : $ params [ 'row' ] [ 'colPos' ] , $ params [ 'row' ] [ 'tx_gridelements_columns' ] , $ params [ 'row' ] [ 'tx_gridelements_container' ] , $ this -> layoutSetup -> getRealPid ( ) ) ; $ params [ 'items' ] = ArrayUtility :: keepItemsInArray ( $ layoutSelectItems , $ params [ 'items' ] , true ) ; } | ItemProcFunc for layout items removes items that are available for grid boxes on the first level only and items that are excluded for a certain branch or user |
1,309 | public function init ( $ pageId , array $ typoScriptSetup = [ ] ) { $ this -> setLanguageService ( $ GLOBALS [ 'LANG' ] ) ; $ pageId = ( strpos ( $ pageId , 'NEW' ) === 0 ) ? 0 : ( int ) $ pageId ; if ( ( int ) $ pageId < 0 ) { $ pageId = Helper :: getInstance ( ) -> getPidFromUid ( $ pageId ) ; } $ this -> realPid = $ pageId ; $ this -> loadLayoutSetup ( $ pageId ) ; foreach ( $ this -> layoutSetup as $ key => $ setup ) { $ columns = $ this -> getLayoutColumns ( $ key ) ; if ( $ columns [ 'allowed' ] || $ columns [ 'disallowed' ] || $ columns [ 'maxitems' ] ) { $ this -> layoutSetup [ $ key ] [ 'columns' ] = $ columns ; unset ( $ this -> layoutSetup [ $ key ] [ 'columns' ] [ 'allowed' ] ) ; $ this -> layoutSetup [ $ key ] [ 'allowed' ] = $ columns [ 'allowed' ] ? : [ ] ; $ this -> layoutSetup [ $ key ] [ 'disallowed' ] = $ columns [ 'disallowed' ] ? : [ ] ; $ this -> layoutSetup [ $ key ] [ 'maxitems' ] = $ columns [ 'maxitems' ] ? : [ ] ; } } $ this -> setTypoScriptSetup ( $ typoScriptSetup ) ; return $ this ; } | Load page TSconfig |
1,310 | public function getLayoutColumns ( $ layoutId ) { if ( ! isset ( $ this -> layoutSetup [ $ layoutId ] ) ) { return [ ] ; } if ( empty ( $ GLOBALS [ 'tx_gridelements' ] [ 'ceBackendLayoutData' ] [ $ layoutId ] ) ) { if ( ! empty ( $ this -> layoutSetup [ $ layoutId ] [ 'config' ] [ 'rows.' ] ) ) { $ GLOBALS [ 'tx_gridelements' ] [ 'ceBackendLayoutData' ] [ $ layoutId ] = $ this -> checkAvailableColumns ( $ this -> layoutSetup [ $ layoutId ] ) ; } } return $ GLOBALS [ 'tx_gridelements' ] [ 'ceBackendLayoutData' ] [ $ layoutId ] ; } | fetches all available columns for a certain grid container |
1,311 | public function getTypoScriptSetup ( $ layoutId ) { $ typoScriptSetup = [ ] ; if ( $ layoutId == '0' && isset ( $ this -> typoScriptSetup [ 'setup.' ] [ 'default.' ] ) ) { $ typoScriptSetup = $ this -> typoScriptSetup [ 'setup.' ] [ 'default.' ] ; } elseif ( $ layoutId && isset ( $ this -> typoScriptSetup [ 'setup.' ] [ $ layoutId . '.' ] ) ) { $ typoScriptSetup = $ this -> typoScriptSetup [ 'setup.' ] [ $ layoutId . '.' ] ; } elseif ( $ layoutId ) { $ typoScriptSetup = $ this -> typoScriptSetup [ 'setup.' ] [ 'default.' ] ; } if ( empty ( $ typoScriptSetup ) ) { $ typoScriptSetup [ 'columns.' ] [ 'default.' ] [ 'renderObj' ] = '<tt_content' ; } return $ typoScriptSetup ; } | fetches the setup for each of the columns assigns a default setup if there is none available |
1,312 | public function getLayoutSelectItems ( $ colPos , $ gridColPos = 0 , $ containerId = 0 , $ pageId = 0 ) { $ allowed = [ '*' => '*' ] ; $ disallowed = [ ] ; $ selectItems = [ ] ; if ( $ containerId > 0 ) { $ container = $ this -> cacheCurrentParent ( ( int ) $ containerId , true ) ; if ( ! empty ( $ container ) ) { $ containerLayout = $ this -> layoutSetup [ $ container [ 'tx_gridelements_backend_layout' ] ] ; $ allowed = $ containerLayout [ 'allowed' ] [ $ gridColPos ] [ 'tx_gridelements_backend_layout' ] ; $ disallowed = $ containerLayout [ 'disallowed' ] [ $ gridColPos ] [ 'tx_gridelements_backend_layout' ] ; } } elseif ( $ pageId > 0 ) { $ pageLayout = Helper :: getInstance ( ) -> getSelectedBackendLayout ( $ pageId ) ; if ( ! empty ( $ pageLayout ) ) { $ allowed = $ pageLayout [ 'allowed' ] [ $ colPos ] [ 'tx_gridelements_backend_layout' ] ; $ disallowed = $ pageLayout [ 'disallowed' ] [ $ colPos ] [ 'tx_gridelements_backend_layout' ] ; } } foreach ( $ this -> layoutSetup as $ layoutId => $ item ) { if ( ( ( int ) $ colPos === - 1 && $ item [ 'top_level_layout' ] ) || ( ! empty ( $ allowed ) && ! isset ( $ allowed [ '*' ] ) && ! isset ( $ allowed [ $ layoutId ] ) ) || ( ! empty ( $ disallowed ) && ( isset ( $ disallowed [ '*' ] ) || isset ( $ disallowed [ $ layoutId ] ) ) ) ) { continue ; } $ icon = 'gridelements-default' ; if ( $ item [ 'iconIdentifier' ] ) { $ icon = $ item [ 'iconIdentifier' ] ; } elseif ( ! empty ( $ item [ 'icon' ] ) ) { if ( is_array ( $ item [ 'icon' ] ) && ! empty ( $ item [ 'icon' ] [ 0 ] ) ) { $ icon = $ item [ 'icon' ] [ 0 ] ; } else { $ icon = $ item [ 'icon' ] ; } if ( StringUtility :: beginsWith ( $ icon , '../' ) ) { $ icon = PATH_site . str_replace ( '../' , '' , $ icon ) ; } } $ selectItems [ ] = [ $ this -> languageService -> sL ( $ item [ 'title' ] ) , $ layoutId , $ icon ] ; } return $ selectItems ; } | Returns the item array for form field selection . |
1,313 | public function cacheCurrentParent ( $ gridContainerId = 0 , $ doReturn = false ) { if ( $ gridContainerId > 0 ) { if ( empty ( $ GLOBALS [ 'tx_gridelements' ] [ 'parentElement' ] [ $ gridContainerId ] ) ) { $ GLOBALS [ 'tx_gridelements' ] [ 'parentElement' ] [ $ gridContainerId ] = BackendUtility :: getRecordWSOL ( 'tt_content' , $ gridContainerId ) ; } } if ( $ doReturn ) { return $ GLOBALS [ 'tx_gridelements' ] [ 'parentElement' ] [ $ gridContainerId ] ; } return null ; } | Caches Container - Records and their setup to avoid multiple selects of the same record during a single request |
1,314 | public function getLayoutSetup ( $ layoutId = '' ) { if ( isset ( $ this -> layoutSetup [ $ layoutId ] ) ) { return $ this -> layoutSetup [ $ layoutId ] ; } return $ this -> layoutSetup ; } | Returns the grid layout setup |
1,315 | public function getFlexformConfiguration ( $ layoutId ) { $ layoutSetup = $ this -> getLayoutSetup ( $ layoutId ) ; if ( $ layoutSetup [ 'pi_flexform_ds_file' ] ) { $ flexformConfiguration = GeneralUtility :: getUrl ( GeneralUtility :: getFileAbsFileName ( $ layoutSetup [ 'pi_flexform_ds_file' ] ) ) ; } elseif ( strpos ( $ layoutSetup [ 'pi_flexform_ds' ] , 'FILE:' ) === 0 ) { $ flexformConfiguration = GeneralUtility :: getUrl ( GeneralUtility :: getFileAbsFileName ( substr ( $ layoutSetup [ 'pi_flexform_ds' ] , 5 ) ) ) ; } elseif ( $ layoutSetup [ 'pi_flexform_ds' ] ) { $ flexformConfiguration = $ layoutSetup [ 'pi_flexform_ds' ] ; } else { $ flexformConfiguration = GeneralUtility :: getUrl ( GeneralUtility :: getFileAbsFileName ( $ this -> flexformConfigurationPathAndFileName ) ) ; } return $ flexformConfiguration ; } | Returns the FlexForm configuration of a grid layout |
1,316 | public function setLanguageService ( LanguageService $ languageService = null ) { $ this -> languageService = $ languageService instanceof LanguageService ? $ languageService : GeneralUtility :: makeInstance ( LanguageService :: class ) ; if ( $ this -> getBackendUser ( ) ) { $ this -> languageService -> init ( $ this -> getBackendUser ( ) -> uc [ 'lang' ] ) ; } } | setter for languageService object |
1,317 | protected function addHeaderRowToCSV ( ) { $ fieldArray = array_combine ( $ this -> fieldArray , $ this -> fieldArray ) ; $ hooks = $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SC_OPTIONS' ] [ __CLASS__ ] [ 'customizeCsvHeader' ] ?? [ ] ; if ( ! empty ( $ hooks ) ) { $ hookParameters = [ 'fields' => & $ fieldArray , ] ; foreach ( $ hooks as $ hookFunction ) { GeneralUtility :: callUserFunction ( $ hookFunction , $ hookParameters , $ this ) ; } } $ this -> addToCSV ( $ fieldArray ) ; } | Add header line with field names as CSV line |
1,318 | protected function addToCSV ( array $ row = [ ] ) { $ rowReducedByControlFields = self :: removeControlFieldsFromFieldRow ( $ row ) ; $ fieldArray = array_intersect_key ( array_flip ( $ this -> fieldArray ) , $ rowReducedByControlFields ) ; $ rowReducedToSelectedColumns = array_replace ( $ fieldArray , array_intersect_key ( $ rowReducedByControlFields , $ fieldArray ) ) ; $ this -> setCsvRow ( $ rowReducedToSelectedColumns ) ; } | Adds selected columns of one table row as CSV line . |
1,319 | public function setCsvRow ( $ csvRow ) { $ csvDelimiter = $ this -> modTSconfig [ 'properties' ] [ 'csvDelimiter' ] ?? ',' ; $ csvQuote = $ this -> modTSconfig [ 'properties' ] [ 'csvQuote' ] ?? '"' ; $ this -> csvLines [ ] = CsvUtility :: csvValues ( $ csvRow , $ csvDelimiter , $ csvQuote ) ; } | Adds input row of values to the internal csvLines array as a CSV formatted line |
1,320 | public function recPath ( $ pid ) { if ( ! isset ( $ this -> recPath_cache [ $ pid ] ) ) { $ this -> recPath_cache [ $ pid ] = BackendUtility :: getRecordPath ( $ pid , $ this -> perms_clause , 20 ) ; } return $ this -> recPath_cache [ $ pid ] ; } | Returns the path for a certain pid The result is cached internally for the session thus you can call this function as much as you like without performance problems . |
1,321 | 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 |
1,322 | public function makeLocalizationPanel ( $ table , $ row ) { $ out = [ 0 => '' , 1 => '' , ] ; $ this -> translations = [ ] ; $ out [ 0 ] = $ this -> languageFlag ( $ row [ $ GLOBALS [ 'TCA' ] [ $ table ] [ 'ctrl' ] [ 'languageField' ] ] ) ; 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' ] ; $ 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 ] = ' ' . $ out [ 0 ] ; } return $ out ; } | Creates the localization panel |
1,323 | 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' ] ; $ layoutSetupInstance = GeneralUtility :: makeInstance ( LayoutSetup :: class ) -> init ( $ pageUid ) ; $ layoutSetup = $ layoutSetupInstance -> getLayoutSetup ( $ layoutId ) ; if ( $ layoutSetup [ 'pi_flexform_ds_file' ] ) { $ 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 { $ identifier = [ 'type' => 'gridelements-dummy' , ] ; } } else { $ identifier = [ 'type' => 'gridelements-dummy' , ] ; } } else { $ identifier = [ ] ; } return $ identifier ; } | Method to find flex form configuration of a tt_content gridelements content element . |
1,324 | 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 |
1,325 | 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 |
1,326 | 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 |
1,327 | public function setDefaultFieldValues ( array & $ fieldArray , $ uidPid = 0 ) { $ newRow = [ ] ; $ 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 ; } } } } $ 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 ; } } } if ( $ uidPid < 0 && ! empty ( $ record ) && $ GLOBALS [ 'TCA' ] [ 'tt_content' ] [ 'ctrl' ] [ 'useColumnsForDefaultValues' ] ) { $ 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 |
1,328 | 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 |
1,329 | 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 |
1,330 | 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 |
1,331 | 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 |
1,332 | 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 |
1,333 | 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 |
1,334 | 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 |
1,335 | public function renderChildrenIntoParentColumns ( $ typoScriptSetup = [ ] , $ sortColumns = [ ] ) { $ 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 ; $ 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 ; } $ 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 |
1,336 | 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 |
1,337 | 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 { $ 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 |
1,338 | 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 |
1,339 | protected function processChildRecord ( $ record ) { $ id = ( int ) $ record [ 'uid' ] ; $ this -> checkOptions ( $ record ) ; $ 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 |
1,340 | 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 |
1,341 | 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 |
1,342 | 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 |
1,343 | 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 |
1,344 | 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 |
1,345 | 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 |
1,346 | 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 |
1,347 | 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 ] ; } } $ tcaColumns = rtrim ( '-2,-1,' . implode ( ',' , $ temp ) , ',' ) ; } return $ tcaColumns ; } | fetches all available columns for a certain grid container based on TCA settings and layout records |
1,348 | 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 . |
1,349 | 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 |
1,350 | 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 . |
1,351 | 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 . |
1,352 | 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 |
1,353 | private function getRelativePath ( \ SimpleXMLElement $ fileName ) { $ dirOfSrcFiles = $ this -> element -> project -> directory [ "name" ] ; $ projectRoot = $ this -> rootDir ; $ dirFromProjectRoot = substr ( $ dirOfSrcFiles , strlen ( $ projectRoot ) + 1 ) ; $ 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 . |
1,354 | protected function setThemeNameSelectorOptions ( ) { $ elementUri = tao_helpers_Uri :: encode ( DeliveryThemeDetailsProvider :: DELIVERY_THEME_ID_URI ) ; if ( ! $ this -> form -> hasElement ( $ elementUri ) ) { return false ; } $ 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 . |
1,355 | 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 |
1,356 | 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 |
1,357 | 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 |
1,358 | 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 |
1,359 | 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 |
1,360 | 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 . |
1,361 | 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 . |
1,362 | 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 . |
1,363 | 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 . |
1,364 | public static function createTask ( $ where = [ ] , $ propertyValues = [ ] ) { $ serviceManager = ServiceManager :: getServiceManager ( ) ; $ action = new self ( ) ; $ action -> setServiceLocator ( $ serviceManager ) ; $ parameters = [ self :: OPTION_WHERE => $ where , self :: OPTION_PARAMETERS => $ propertyValues ] ; $ queueDispatcher = ServiceManager :: getServiceManager ( ) -> get ( QueueDispatcher :: SERVICE_ID ) ; return $ queueDispatcher -> createTask ( $ action , $ parameters , null , null , true ) ; } | Create a task to update a delivery |
1,365 | 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 |
1,366 | public static function createTask ( \ core_kernel_classes_Resource $ test , \ core_kernel_classes_Class $ deliveryClass , array $ initialProperties = [ ] ) { $ action = new self ( ) ; $ 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 |
1,367 | 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 |
1,368 | 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 |
1,369 | protected function deleteDeliveryRuntime ( core_kernel_classes_Resource $ assembly ) { $ deliveryAssignement = $ this -> getServiceManager ( ) -> get ( GroupAssignment :: SERVICE_ID ) ; $ deliveryAssignement -> onDelete ( $ assembly ) ; $ runtimeResource = $ assembly -> getUniquePropertyValue ( new core_kernel_classes_Property ( self :: PROPERTY_DELIVERY_RUNTIME ) ) ; return $ runtimeResource -> delete ( ) ; } | Delete a runtime of a delivery |
1,370 | public function deleteDeliveryDirectory ( core_kernel_classes_Resource $ assembly ) { $ success = true ; $ deleted = 0 ; $ directories = $ assembly -> getPropertyValues ( new core_kernel_classes_Property ( self :: PROPERTY_DELIVERY_DIRECTORY ) ) ; foreach ( $ directories as $ directory ) { $ instances = $ this -> getRootClass ( ) -> getInstances ( true , array ( self :: PROPERTY_DELIVERY_DIRECTORY => $ directory ) ) ; unset ( $ instances [ $ assembly -> getUri ( ) ] ) ; if ( empty ( $ instances ) ) { $ success = $ this -> getFileStorage ( ) -> deleteDirectoryById ( $ directory ) ? $ success : false ; $ deleted ++ ; } } \ common_Logger :: i ( '(' . ( int ) $ deleted . ') deletions for delivery assembly: ' . $ assembly -> getUri ( ) ) ; return $ success ; } | Delete directories related to a delivery don t remove if dir is used by another delivery |
1,371 | public function getRuntime ( core_kernel_classes_Resource $ assembly ) { return $ this -> getServiceLocator ( ) -> get ( RuntimeService :: SERVICE_ID ) -> getRuntime ( $ assembly -> getUri ( ) ) ; } | Gets the service call to run this assembly |
1,372 | public function guest ( ) { common_session_SessionManager :: endSession ( ) ; $ session = new GuestTestTakerSession ( ) ; common_session_SessionManager :: startSession ( $ session ) ; $ returnUrl = $ this -> getServiceLocator ( ) -> get ( ReturnUrlService :: SERVICE_ID ) -> getReturnUrl ( ) ; $ this -> redirect ( $ returnUrl ) ; } | Init guest session and redirect to module index |
1,373 | private function deactivate ( ) { $ guestAccess = new GuestAccess ( ) ; try { if ( $ this -> entryPointService -> deactivateEntryPoint ( $ guestAccess -> getId ( ) , EntryPointService :: OPTION_PRELOGIN ) ) { $ rule = new AccessRule ( 'grant' , TaoRoles :: ANONYMOUS , 'oat\taoDeliveryRdf\controller\Guest@guest' ) ; AclProxy :: revokeRule ( $ rule ) ; return Report :: createSuccess ( 'The guest entry point has been correctly deactivated' ) ; } else { return Report :: createInfo ( 'The guest entry point was already deactivated' ) ; } } catch ( \ common_exception_InconsistentData $ e ) { return Report :: createFailure ( $ e -> getMessage ( ) ) ; } } | Try to deactivate the guest entry point |
1,374 | private function activate ( ) { $ guestAccess = new GuestAccess ( ) ; try { $ this -> entryPointService -> activateEntryPoint ( $ guestAccess -> getId ( ) , EntryPointService :: OPTION_PRELOGIN ) ; $ rule = new AccessRule ( 'grant' , TaoRoles :: ANONYMOUS , 'oat\taoDeliveryRdf\controller\Guest@guest' ) ; AclProxy :: applyRule ( $ rule ) ; return Report :: createSuccess ( 'The guest entry point has been correctly activated' ) ; } catch ( \ common_exception_InconsistentData $ e ) { return Report :: createFailure ( $ e -> getMessage ( ) ) ; } } | Try to activate the guest entry point |
1,375 | private function generateNewTmpPath ( $ fileName ) { $ folder = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . "tmp" . md5 ( $ fileName . uniqid ( '' , true ) ) . DIRECTORY_SEPARATOR ; if ( ! file_exists ( $ folder ) ) { mkdir ( $ folder ) ; } $ this -> tmpDir = $ folder ; } | generate unique tmp folder based on delivery . |
1,376 | public function generate ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) { throw new \ common_exception_MissingParameter ( self :: REST_DELIVERY_TEST_ID , $ this -> getRequestURI ( ) ) ; } $ test = $ this -> getResource ( $ this -> getRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) ; if ( ! $ test -> exists ( ) ) { throw new \ common_exception_NotFound ( 'Unable to find a test associated to the given uri.' ) ; } $ label = 'Delivery of ' . $ test -> getLabel ( ) ; $ deliveryClass = $ this -> getDeliveryClassByParameters ( ) ; $ deliveryFactory = $ this -> getServiceManager ( ) -> get ( DeliveryFactory :: SERVICE_ID ) ; $ report = $ deliveryFactory -> create ( $ deliveryClass , $ test , $ label ) ; if ( $ report -> getType ( ) == \ common_report_Report :: TYPE_ERROR ) { $ this -> logInfo ( 'Unable to generate delivery execution ' . 'into taoDeliveryRdf::RestDelivery for test uri ' . $ test -> getUri ( ) ) ; throw new \ common_Exception ( 'Unable to generate delivery execution.' ) ; } $ delivery = $ report -> getData ( ) ; $ deliveryFactoryService = $ this -> getServiceManager ( ) -> get ( DeliveryFactory :: SERVICE_ID ) ; $ initialProperties = $ deliveryFactoryService -> getInitialPropertiesFromRequest ( $ this -> getRequest ( ) ) ; $ delivery = $ deliveryFactoryService -> setInitialProperties ( $ initialProperties , $ delivery ) ; $ this -> returnSuccess ( array ( 'delivery' => $ delivery -> getUri ( ) ) ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | Generate a delivery from test uri Test uri has to be set and existing |
1,377 | public function generateDeferred ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) { throw new \ common_exception_MissingParameter ( self :: REST_DELIVERY_TEST_ID , $ this -> getRequestURI ( ) ) ; } $ test = $ this -> getResource ( $ this -> getRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) ; if ( ! $ test -> exists ( ) ) { throw new \ common_exception_NotFound ( 'Unable to find a test associated to the given uri.' ) ; } $ deliveryClass = $ this -> getDeliveryClassByParameters ( ) ; $ deliveryFactoryService = $ this -> getServiceManager ( ) -> get ( DeliveryFactory :: SERVICE_ID ) ; $ initialProperties = $ deliveryFactoryService -> getInitialPropertiesFromRequest ( $ this -> getRequest ( ) ) ; $ task = CompileDelivery :: createTask ( $ test , $ deliveryClass , $ initialProperties ) ; $ result = [ 'reference_id' => $ task -> getId ( ) ] ; $ taskLog = $ this -> getServiceManager ( ) -> get ( TaskLogInterface :: SERVICE_ID ) ; $ report = $ taskLog -> getReport ( $ task -> getId ( ) ) ; if ( ! empty ( $ report ) ) { if ( $ report instanceof \ common_report_Report ) { $ report = json_decode ( $ report ) ; } $ result [ 'common_report_Report' ] = $ report ; } return $ this -> returnSuccess ( $ result ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | Put task to generate a delivery from test uri to the task queue Test uri has to be set and existing |
1,378 | public function deleteDeferred ( ) { try { if ( $ this -> getRequestMethod ( ) !== \ Request :: HTTP_DELETE ) { throw new \ common_exception_NotImplemented ( 'Only delete method is accepted to deleting delivery' ) ; } if ( ! $ this -> hasRequestParameter ( 'uri' ) ) { throw new \ common_exception_MissingParameter ( 'uri' , $ this -> getRequestURI ( ) ) ; } $ uri = $ this -> getRequestParameter ( 'uri' ) ; $ delivery = $ this -> getResource ( $ uri ) ; if ( ! $ delivery -> exists ( ) ) { $ this -> returnFailure ( new \ common_exception_NotFound ( 'Delivery has not been found' ) ) ; } $ queueDispatcher = $ this -> getServiceManager ( ) -> get ( QueueDispatcher :: SERVICE_ID ) ; $ task = new DeliveryDeleteTask ( ) ; $ task -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; $ taskParameters = [ 'deliveryId' => $ uri ] ; $ task = $ queueDispatcher -> createTask ( $ task , $ taskParameters , __ ( 'Deleting of "%s"' , $ delivery -> getLabel ( ) ) , null , true ) ; $ data = $ this -> getTaskLogReturnData ( $ task -> getId ( ) , DeliveryDeleteTask :: class ) ; $ this -> returnSuccess ( $ data ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | Delete delivery by URI |
1,379 | public function get ( ) { try { if ( $ this -> getRequestMethod ( ) !== \ Request :: HTTP_GET ) { throw new \ common_exception_NotImplemented ( 'Only get method is accepted to getting deliveries' ) ; } $ limit = 0 ; if ( $ this -> hasRequestParameter ( 'limit' ) ) { $ limit = $ this -> getRequestParameter ( 'limit' ) ; if ( ! is_numeric ( $ limit ) || ( int ) $ limit != $ limit || $ limit < 0 ) { throw new \ common_exception_ValidationFailed ( 'limit' , '\'Limit\' should be a positive integer' ) ; } } $ offset = 0 ; if ( $ this -> hasRequestParameter ( 'offset' ) ) { $ offset = $ this -> getRequestParameter ( 'offset' ) ; if ( ! is_numeric ( $ offset ) || ( int ) $ offset != $ offset || $ offset < 0 ) { throw new \ common_exception_ValidationFailed ( 'offset' , '\'Offset\' should be a positive integer' ) ; } } $ service = DeliveryAssemblyService :: singleton ( ) ; $ deliveries = $ service -> getAllAssemblies ( ) ; $ overallCount = count ( $ deliveries ) ; if ( $ offset || $ limit ) { if ( $ overallCount <= $ offset ) { throw new \ common_exception_ValidationFailed ( 'offset' , '\'Offset\' is too large' ) ; } $ deliveries = array_slice ( $ deliveries , $ offset , $ limit ) ; } $ mappedDeliveries = [ ] ; foreach ( $ deliveries as $ delivery ) { $ mappedDeliveries [ ] = [ 'uri' => $ delivery -> getUri ( ) , 'label' => $ delivery -> getLabel ( ) , ] ; } $ response = [ 'items' => $ mappedDeliveries , 'overallCount' => $ overallCount , ] ; $ this -> returnSuccess ( $ response ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | List all deliveries or paginated range |
1,380 | public function getStatus ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: TASK_ID_PARAM ) ) { throw new \ common_exception_MissingParameter ( self :: TASK_ID_PARAM , $ this -> getRequestURI ( ) ) ; } $ data = $ this -> getTaskLogReturnData ( $ this -> getRequestParameter ( self :: TASK_ID_PARAM ) , CompileDelivery :: class ) ; $ children = $ this -> getStatusesForChildren ( $ this -> getRequestParameter ( self :: TASK_ID_PARAM ) ) ; $ data [ 'children' ] = $ children ; $ this -> returnSuccess ( $ data ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | Action to retrieve test compilation task status from queue |
1,381 | public function createClass ( ) { try { $ class = $ this -> createSubClass ( $ this -> getDeliveryRootClass ( ) ) ; $ result = [ 'message' => __ ( 'Class successfully created.' ) , 'delivery-uri' => $ class -> getUri ( ) , ] ; $ this -> returnSuccess ( $ result ) ; } catch ( \ common_exception_ClassAlreadyExists $ e ) { $ result = [ 'message' => $ e -> getMessage ( ) , 'delivery-uri' => $ e -> getClass ( ) -> getUri ( ) , ] ; $ this -> returnSuccess ( $ result ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } } | Create a Delivery Class |
1,382 | protected function getDeliveryClassByParameters ( ) { $ rootDeliveryClass = $ this -> getDeliveryRootClass ( ) ; if ( $ this -> hasRequestParameter ( self :: REST_DELIVERY_CLASS_URI ) ) { $ deliveryClass = $ this -> getClass ( $ this -> getRequestParameter ( self :: REST_DELIVERY_CLASS_URI ) ) ; if ( $ deliveryClass == $ rootDeliveryClass || ( $ deliveryClass -> exists ( ) && $ deliveryClass -> isSubClassOf ( $ rootDeliveryClass ) ) ) { return $ deliveryClass ; } throw new \ common_Exception ( __ ( 'Delivery class uri provided is not a valid delivery class.' ) ) ; } if ( $ this -> hasRequestParameter ( self :: REST_DELIVERY_CLASS_LABEL ) ) { $ label = $ this -> getRequestParameter ( self :: REST_DELIVERY_CLASS_LABEL ) ; $ deliveryClasses = $ rootDeliveryClass -> getSubClasses ( true ) ; $ classes = [ $ rootDeliveryClass -> getUri ( ) ] ; foreach ( $ deliveryClasses as $ class ) { $ classes [ ] = $ class -> getUri ( ) ; } $ search = $ this -> getServiceManager ( ) -> get ( ComplexSearchService :: SERVICE_ID ) ; $ queryBuilder = $ search -> query ( ) ; $ criteria = $ queryBuilder -> newQuery ( ) -> add ( OntologyRdfs :: RDFS_LABEL ) -> equals ( $ label ) -> add ( OntologyRdfs :: RDFS_SUBCLASSOF ) -> in ( $ classes ) ; $ queryBuilder -> setCriteria ( $ criteria ) ; $ result = $ search -> getGateway ( ) -> search ( $ queryBuilder ) ; switch ( $ result -> count ( ) ) { case 0 : throw new \ common_exception_NotFound ( __ ( 'Delivery with label "%s" not found' , $ label ) ) ; case 1 : return $ this -> getClass ( $ result -> current ( ) -> getUri ( ) ) ; default : $ availableClasses = [ ] ; foreach ( $ result as $ raw ) { $ availableClasses [ ] = $ raw -> getUri ( ) ; } throw new \ common_exception_NotFound ( __ ( 'Multiple delivery class found for label "%s": %s' , $ label , implode ( ',' , $ availableClasses ) ) ) ; } } return $ rootDeliveryClass ; } | Get a delivery class based on parameters |
1,383 | public function getProviders ( DeliveryExecution $ execution ) { $ serviceManager = $ this -> getServiceManager ( ) ; $ providerService = $ serviceManager -> get ( TestProviderService :: SERVICE_ID ) ; $ providers = $ providerService -> getAllProviders ( ) ; return array_filter ( $ providers , function ( $ provider ) { return ! is_null ( $ provider ) && $ provider -> isActive ( ) ; } ) ; } | Get the list of providers for the current execution |
1,384 | public function getPlugins ( DeliveryExecution $ deliveryExecution ) { $ serviceManager = $ this -> getServiceManager ( ) ; $ pluginService = $ serviceManager -> get ( TestPluginService :: SERVICE_ID ) ; $ testRunnerFeatureService = $ serviceManager -> get ( TestRunnerFeatureService :: SERVICE_ID ) ; $ allPlugins = $ pluginService -> getAllPlugins ( ) ; $ allTestRunnerFeatures = $ testRunnerFeatureService -> getAll ( ) ; $ activeTestRunnerFeaturesIds = $ this -> getActiveFeatures ( $ deliveryExecution -> getDelivery ( ) ) ; if ( count ( $ allTestRunnerFeatures ) > 0 ) { $ pluginsToDisable = [ ] ; foreach ( $ allTestRunnerFeatures as $ feature ) { if ( ! in_array ( $ feature -> getId ( ) , $ activeTestRunnerFeaturesIds ) ) { $ pluginsToDisable = array_merge ( $ pluginsToDisable , $ feature -> getPluginsIds ( ) ) ; } } foreach ( $ allPlugins as $ plugin ) { if ( ! is_null ( $ plugin ) && in_array ( $ plugin -> getId ( ) , $ pluginsToDisable ) ) { $ plugin -> setActive ( false ) ; } } } return array_filter ( $ allPlugins , function ( $ plugin ) { return ! is_null ( $ plugin ) && $ plugin -> isActive ( ) ; } ) ; } | Get the list of active plugins for the current execution |
1,385 | public function exportCompiledDelivery ( core_kernel_classes_Resource $ compiledDelivery , $ fsExportPath = '' ) { $ this -> logDebug ( "Exporting Delivery Assembly '" . $ compiledDelivery -> getUri ( ) . "'..." ) ; $ fileName = \ tao_helpers_Display :: textCleaner ( $ compiledDelivery -> getLabel ( ) ) . '.zip' ; $ path = \ tao_helpers_File :: concat ( array ( \ tao_helpers_Export :: getExportPath ( ) , $ fileName ) ) ; if ( ! \ tao_helpers_File :: securityCheck ( $ path , true ) ) { throw new \ Exception ( 'Unauthorized file name' ) ; } if ( file_exists ( $ path ) ) { unlink ( $ path ) ; } $ zipArchive = new \ ZipArchive ( ) ; if ( $ zipArchive -> open ( $ path , \ ZipArchive :: CREATE ) !== true ) { throw new \ Exception ( 'Unable to create archive at ' . $ path ) ; } $ this -> doExportCompiledDelivery ( $ path , $ compiledDelivery , $ zipArchive ) ; $ zipArchive -> close ( ) ; if ( ! empty ( $ fsExportPath ) ) { $ this -> logDebug ( "Writing Delivery Assembly '" . $ compiledDelivery -> getUri ( ) . "' into shared file system at location '${fsExportPath}'..." ) ; $ fsExportPath = trim ( $ fsExportPath ) ; $ fsExportPath = ltrim ( $ fsExportPath , "/\\" ) ; $ zipArchiveHandler = fopen ( $ path , 'r' ) ; $ this -> getExportDirectory ( ) -> getFile ( $ fsExportPath ) -> put ( $ zipArchiveHandler ) ; fclose ( $ zipArchiveHandler ) ; } return $ path ; } | export a compiled delivery into an archive |
1,386 | protected function doExportCompiledDelivery ( $ path , core_kernel_classes_Resource $ compiledDelivery , \ ZipArchive $ zipArchive ) { $ taoDeliveryVersion = \ common_ext_ExtensionsManager :: singleton ( ) -> getInstalledVersion ( 'taoDelivery' ) ; $ data = array ( 'dir' => array ( ) , 'label' => $ compiledDelivery -> getLabel ( ) , 'version' => $ taoDeliveryVersion ) ; $ directories = $ compiledDelivery -> getPropertyValues ( new core_kernel_classes_Property ( DeliveryAssemblyService :: PROPERTY_DELIVERY_DIRECTORY ) ) ; foreach ( $ directories as $ id ) { $ directory = \ tao_models_classes_service_FileStorage :: singleton ( ) -> getDirectoryById ( $ id ) ; $ files = $ directory -> getIterator ( ) ; foreach ( $ files as $ file ) { \ tao_helpers_File :: addFilesToZip ( $ zipArchive , $ directory -> readPsrStream ( $ file ) , $ directory -> getRelativePath ( ) . $ file ) ; } $ data [ 'dir' ] [ $ id ] = $ directory -> getRelativePath ( ) ; } $ runtime = $ compiledDelivery -> getUniquePropertyValue ( new core_kernel_classes_Property ( DeliveryAssemblyService :: PROPERTY_DELIVERY_RUNTIME ) ) ; $ serviceCall = \ tao_models_classes_service_ServiceCall :: fromResource ( $ runtime ) ; $ data [ 'runtime' ] = base64_encode ( $ serviceCall -> serializeToString ( ) ) ; $ rdfExporter = new \ tao_models_classes_export_RdfExporter ( ) ; $ rdfdata = $ rdfExporter -> getRdfString ( array ( $ compiledDelivery ) ) ; if ( ! $ zipArchive -> addFromString ( 'delivery.rdf' , $ rdfdata ) ) { throw new \ common_Exception ( 'Unable to add metadata to exported delivery assembly' ) ; } $ data [ 'meta' ] = 'delivery.rdf' ; $ content = json_encode ( $ data ) ; if ( ! $ zipArchive -> addFromString ( self :: MANIFEST_FILE , $ content ) ) { $ zipArchive -> close ( ) ; unlink ( $ path ) ; throw new \ common_Exception ( 'Unable to add manifest to exported delivery assembly' ) ; } } | Do Export Compiled Delivery |
1,387 | protected function isUserExcluded ( \ core_kernel_classes_Resource $ delivery , User $ user ) { $ excludedUsers = $ delivery -> getPropertyValues ( new \ core_kernel_classes_Property ( DeliveryContainerService :: PROPERTY_EXCLUDED_SUBJECTS ) ) ; return in_array ( $ user -> getIdentifier ( ) , $ excludedUsers ) ; } | Check if a user is excluded from a delivery |
1,388 | public function getGuestAccessDeliveries ( ) { $ class = new core_kernel_classes_Class ( DeliveryAssemblyService :: CLASS_URI ) ; return $ class -> searchInstances ( array ( DeliveryContainerService :: PROPERTY_ACCESS_SETTINGS => DeliveryAssemblyService :: PROPERTY_DELIVERY_GUEST_ACCESS ) , array ( 'recursive' => true ) ) ; } | Search for deliveries configured for guest access |
1,389 | protected function hasDeliveryGuestAccess ( core_kernel_classes_Resource $ delivery ) { $ returnValue = false ; $ properties = $ delivery -> getPropertiesValues ( array ( new core_kernel_classes_Property ( DeliveryContainerService :: PROPERTY_ACCESS_SETTINGS ) , ) ) ; $ propAccessSettings = current ( $ properties [ DeliveryContainerService :: PROPERTY_ACCESS_SETTINGS ] ) ; $ accessSetting = ( ! ( is_object ( $ propAccessSettings ) ) or ( $ propAccessSettings == "" ) ) ? null : $ propAccessSettings -> getUri ( ) ; if ( ! is_null ( $ accessSetting ) ) { $ returnValue = ( $ accessSetting === DeliveryAssemblyService :: PROPERTY_DELIVERY_GUEST_ACCESS ) ; } return $ returnValue ; } | Check if delivery configured for guest access |
1,390 | protected function areWeInRange ( $ startDate , $ endDate ) { return ( empty ( $ startDate ) || date_create ( ) >= $ startDate ) && ( empty ( $ endDate ) || date_create ( ) <= $ endDate ) ; } | Check if the date are in range |
1,391 | protected function orderAssignments ( array $ assignments ) { usort ( $ assignments , function ( $ a , $ b ) { return $ a -> getDisplayOrder ( ) - $ b -> getDisplayOrder ( ) ; } ) ; return $ assignments ; } | Order Assignments of a given user . |
1,392 | private function helpAction ( $ message = null ) { if ( $ message !== null ) { $ this -> report = new Report ( Report :: TYPE_ERROR , $ message . PHP_EOL ) ; } $ helpReport = new Report ( Report :: TYPE_INFO , "Usage: " . __CLASS__ . " <mode> [<args>]" . PHP_EOL . PHP_EOL . "Available modes:" . PHP_EOL . " list get list of all deliveries" . PHP_EOL . " archive archive all deliveries use --force to forge regeneration" . PHP_EOL . " unarchive unarchive all deliveries --force to forge unarchiving" . PHP_EOL . " delete delete all archives deliveries" . PHP_EOL ) ; if ( $ this -> report ) { $ this -> report -> add ( $ helpReport ) ; } else { $ this -> report = $ helpReport ; } } | Set help report |
1,393 | protected function createDeliveryResource ( core_kernel_classes_Class $ deliveryClass , \ tao_models_classes_service_ServiceCall $ serviceCall , $ container , $ properties = array ( ) ) { $ properties [ DeliveryAssemblyService :: PROPERTY_DELIVERY_TIME ] = time ( ) ; $ properties [ DeliveryAssemblyService :: PROPERTY_DELIVERY_RUNTIME ] = $ serviceCall -> toOntology ( ) ; if ( ! isset ( $ properties [ DeliveryContainerService :: PROPERTY_RESULT_SERVER ] ) ) { $ properties [ DeliveryContainerService :: PROPERTY_RESULT_SERVER ] = \ taoResultServer_models_classes_ResultServerAuthoringService :: singleton ( ) -> getDefaultResultServer ( ) ; } if ( ! is_null ( $ container ) ) { $ properties [ ContainerRuntime :: PROPERTY_CONTAINER ] = json_encode ( $ container ) ; } if ( $ this -> deliveryResource instanceof core_kernel_classes_Resource ) { $ compilationInstance = $ this -> deliveryResource ; $ compilationInstance -> setPropertiesValues ( $ properties ) ; } else { $ compilationInstance = $ deliveryClass -> createInstanceWithProperties ( $ properties ) ; } $ eventManager = $ this -> getServiceManager ( ) -> get ( EventManager :: SERVICE_ID ) ; $ eventManager -> trigger ( new DeliveryCreatedEvent ( $ compilationInstance -> getUri ( ) ) ) ; return $ compilationInstance ; } | Create a delivery resource based on a successfull compilation |
1,394 | public function getFileInfo ( ) { $ ret = array ( 'uploadId' => $ this -> id , 'mimeType' => $ this -> mime_type , 'filename' => $ this -> filename , 'extension' => $ this -> extension , 'fileSize' => $ this -> getFileSize ( ) , 'hashKey' => $ this -> getHashKey ( ) ) ; if ( ! $ this -> id && is_file ( $ this -> filename ) ) { $ ret [ 'mimeType' ] = $ this -> _getMimeType ( $ this -> filename ) ; $ ret [ 'extension' ] = substr ( strrchr ( $ this -> filename , '.' ) , 1 ) ; } $ size = $ this -> getImageDimensions ( ) ; if ( $ size ) { $ ret [ 'image' ] = true ; $ ret [ 'imageHandyScaleFactor' ] = Kwf_Media_Image :: getHandyScaleFactor ( $ size ) ; if ( abs ( $ size [ 'rotation' ] ) == 90 ) { $ size = array ( 'width' => $ size [ 'height' ] , 'height' => $ size [ 'width' ] ) ; } $ ret [ 'imageWidth' ] = $ size [ 'width' ] ; $ ret [ 'imageHeight' ] = $ size [ 'height' ] ; } else { $ ret [ 'image' ] = false ; } return $ ret ; } | wird von upload - feld verwendet |
1,395 | protected function _getComponentId ( $ select ) { $ componentId = null ; if ( $ select ) { if ( $ select -> getPart ( Kwf_Model_Select :: WHERE_EQUALS ) ) { foreach ( $ select -> getPart ( Kwf_Model_Select :: WHERE_EQUALS ) as $ k => $ i ) { if ( $ k == 'component_id' ) $ componentId = $ i ; } } } return $ componentId ; } | Extracts the component id from select |
1,396 | protected function _getTrlRow ( $ proxiedRow , $ componentId ) { $ row = null ; $ proxyId = $ proxiedRow -> id ; $ select = $ this -> _trlModel -> select ( ) -> whereEquals ( 'component_id' , $ componentId ) -> whereEquals ( 'master_id' , $ proxyId ) ; $ trlRow = $ this -> _trlModel -> getRows ( $ select ) -> current ( ) ; if ( $ trlRow ) { $ row = $ trlRow ; } else { $ row = $ this -> _trlModel -> createRow ( ) ; $ row -> master_id = $ proxyId ; $ row -> component_id = $ componentId ; $ row -> save ( ) ; } return $ row ; } | returns the related trl - row |
1,397 | public function getRow ( $ select ) { $ componentId = $ this -> _getComponentId ( $ select ) ; $ masterId = $ this -> _getId ( $ select ) ; if ( $ componentId && $ masterId ) { $ select = new Kwf_Model_Select ( ) ; $ c = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ componentId , array ( 'ignoreVisible' => true ) ) ; $ select -> whereEquals ( 'component_id' , $ c -> chained -> dbId ) ; $ select -> whereEquals ( 'id' , $ masterId ) ; $ proxyRow = $ this -> _proxyModel -> getRow ( $ select ) ; return $ this -> getRowByProxiedRowAndComponentId ( $ proxyRow , $ componentId ) ; } else { $ trlRow = $ this -> _trlModel -> getRow ( $ select ) ; $ masterSelect = new Kwf_Model_Select ( ) ; $ masterSelect -> whereId ( $ trlRow -> master_id ) ; $ masterRow = $ this -> _proxyModel -> getRow ( $ masterSelect ) ; return $ this -> getRowByProxiedRowAndComponentId ( $ masterRow , $ trlRow -> component_id ) ; } throw new Kwf_Exception_NotYetImplemented ( ) ; } | Should return the specified row componentId and id has to be defined |
1,398 | protected function _getPseudoPageUrl ( ) { $ data = $ this ; $ filename = '' ; $ hadStaticPage = false ; do { if ( $ hadStaticPage && isset ( $ data -> generator ) && ! $ data -> isPseudoPage && $ data -> generator -> getAddUrlPart ( ) ) { $ filename = $ data -> id . ( $ filename ? ':' : '' ) . $ filename ; } if ( $ data -> isPseudoPage || $ data -> componentId == 'root' ) { if ( $ data -> filename ) $ filename = $ data -> filename . ( $ filename ? '/' : '' ) . $ filename ; if ( $ data -> componentId != 'root' && $ data -> generator -> getGeneratorFlag ( 'static' ) ) { $ hadStaticPage = true ; } else { $ hadStaticPage = false ; } } } while ( $ data = $ data -> parent ) ; $ baseUrl = Kwf_Setup :: getBaseUrl ( ) ; return ( $ baseUrl ? $ baseUrl : '' ) . '/' . $ filename ; } | Like - > url but also works for pseudoPages |
1,399 | public function getExpandedComponentId ( ) { if ( $ this -> _expandedComponentIdCache ) { return $ this -> _expandedComponentIdCache ; } $ generator = $ this -> generator ; if ( $ generator instanceof Kwc_Root_Category_Generator ) { $ separator = '_' ; } else { $ separator = $ generator -> getIdSeparator ( ) ; } $ this -> _expandedComponentIdCache = $ this -> parent -> getExpandedComponentId ( ) . $ separator . $ this -> id ; return $ this -> _expandedComponentIdCache ; } | Returns component_id with seperate entries from every page in tree |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.