idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
1,200 | protected function setBasicOptions ( array $ config ) { if ( ! isset ( $ config [ 'timeout' ] ) ) { $ config [ 'timeout' ] = static :: DEFAULT_REQUEST_TIMEOUT ; } if ( isset ( $ config [ 'base_uri' ] ) && strpos ( $ config [ 'base_uri' ] , 'http' ) === false ) { $ config [ 'base_uri' ] = 'https://' . $ config [ 'base_uri' ] ; return $ config ; } return $ config ; } | Set timeout and base_uri options |
1,201 | protected function setConfigOption ( $ what , $ value ) { $ closure = function ( ) use ( $ what , $ value ) { $ this -> config [ $ what ] = $ value ; } ; $ closure = $ closure -> bindTo ( $ this , \ GuzzleHttp \ Client :: class ) ; $ closure ( ) ; } | Set values on the private \ GuzzleHttp \ Client - > config |
1,202 | protected function setDebugHandler ( $ options , $ fp = null ) { try { if ( is_bool ( $ fp ) ) { $ fp = null ; } $ handler = $ this -> getConfig ( 'handler' ) ; if ( $ handler && $ this -> debugHandler ) { return $ options ; } if ( isset ( $ options [ 'handler' ] ) ) { $ handler = $ options [ 'handler' ] ; } if ( $ handler === null ) { $ handler = \ GuzzleHttp \ HandlerStack :: create ( ) ; } if ( ! $ this -> debugHandler ) { $ this -> debugHandler = new DebugHandler ( $ fp ) ; } $ handler -> after ( 'allow_redirects' , $ this -> debugHandler , 'debug' ) ; } catch ( \ InvalidArgumentException $ e ) { $ handler -> push ( $ this -> debugHandler , 'debug' ) ; } $ options [ 'handler' ] = $ handler ; return $ options ; } | Add the Debug handler to the HandlerStack |
1,203 | protected function setLogHandler ( \ GuzzleHttp \ HandlerStack $ handlerStack , callable $ logHandler ) { try { $ handlerStack -> after ( 'history' , $ logHandler , 'logger' ) ; } catch ( \ InvalidArgumentException $ e ) { try { $ handlerStack -> before ( 'allow_redirects' , $ logHandler , 'logger' ) ; } catch ( \ InvalidArgumentException $ e ) { $ handlerStack -> push ( $ logHandler , 'logger' ) ; } } return $ this ; } | Add the Log handler to the HandlerStack |
1,204 | protected function setVerboseHandler ( $ options , $ fp = null ) { try { if ( is_bool ( $ fp ) || $ fp === null ) { $ fp = [ 'outputStream' => null , 'errorStream' => null ] ; } elseif ( ! is_array ( $ fp ) ) { $ fp = [ 'outputStream' => $ fp , 'errorStream' => $ fp ] ; } $ handler = $ this -> getConfig ( 'handler' ) ; if ( $ handler && $ this -> verboseHandler ) { return $ options ; } if ( isset ( $ options [ 'handler' ] ) ) { $ handler = $ options [ 'handler' ] ; } if ( $ handler === null ) { $ handler = \ GuzzleHttp \ HandlerStack :: create ( ) ; } if ( ! $ this -> verboseHandler ) { $ this -> verboseHandler = new VerboseHandler ( array_shift ( $ fp ) , array_shift ( $ fp ) ) ; } $ handler -> after ( 'allow_redirects' , $ this -> verboseHandler , 'verbose' ) ; } catch ( \ InvalidArgumentException $ e ) { $ handler -> push ( $ this -> verboseHandler , 'verbose' ) ; } $ options [ 'handler' ] = $ handler ; return $ options ; } | Add the Verbose handler to the HandlerStack |
1,205 | protected function setRequestOptions ( array $ options ) { if ( isset ( $ options [ 'timestamp' ] ) ) { $ this -> authentication -> setTimestamp ( $ options [ 'timestamp' ] ) ; } elseif ( ! $ this -> getConfig ( 'timestamp' ) ) { $ this -> authentication -> setTimestamp ( ) ; } if ( isset ( $ options [ 'nonce' ] ) ) { $ this -> authentication -> setNonce ( $ options [ 'nonce' ] ) ; } if ( isset ( $ options [ 'handler' ] ) ) { $ options = $ this -> setAuthenticationHandler ( $ options , $ this -> authentication ) ; } if ( $ fp = $ this -> isVerbose ( ) ) { $ options = $ this -> setVerboseHandler ( $ options , $ fp ) ; } $ options [ 'debug' ] = $ this -> getDebugOption ( $ options ) ; if ( $ fp = $ this -> isDebug ( ) ) { $ options = $ this -> setDebugHandler ( $ options , $ fp ) ; } if ( $ this -> logger && isset ( $ options [ 'handler' ] ) ) { $ this -> setLogHandler ( $ options [ 'handler' ] , $ this -> logger ) ; return $ options ; } return $ options ; } | Set request specific options |
1,206 | public function setSigner ( \ Akamai \ Open \ EdgeGrid \ Authentication $ auth = null ) { $ this -> signer = $ auth ; if ( $ this -> signer === null ) { $ this -> signer = new Signer ( ) ; } } | Inject signer object |
1,207 | public static function createFromEdgeRcFile ( $ section = 'default' , $ file = null ) { $ signer = Signer :: createFromEdgeRcFile ( $ section , $ file ) ; $ auth = new static ( ) ; $ auth -> setSigner ( $ signer ) ; return $ auth ; } | Create Handler using an . edgerc file |
1,208 | public function add ( Message $ message ) { $ this -> queue -> insert ( $ message , is_null ( $ message -> getPosition ( ) ) ? null : - $ message -> getPosition ( ) ) ; $ this -> copyQueue ( clone $ this -> queue ) ; return $ this ; } | Add message to collection . |
1,209 | protected function copyQueue ( \ SplPriorityQueue $ queue ) { $ this -> items = [ ] ; foreach ( $ queue as $ item ) { $ this -> items [ ] = $ item ; } } | Copy queue items . |
1,210 | public function onFlash ( $ eventName , array $ data ) { $ this -> validateEventData ( $ data ) ; list ( $ notification , $ notificationBag , $ message ) = $ data ; $ key = implode ( '.' , [ $ this -> key , $ notificationBag -> getName ( ) ] ) ; $ this -> session -> push ( $ key , $ message ) ; return true ; } | Execute this event to flash messages . |
1,211 | public function getContainerTypes ( $ container ) { if ( isset ( $ this -> types [ $ container ] ) ) { return $ this -> types [ $ container ] ; } return $ this -> defaultTypes ; } | Return types for a container . |
1,212 | public function getContainerFormat ( $ container ) { if ( isset ( $ this -> format [ $ container ] ) ) { return $ this -> format [ $ container ] ; } return $ this -> defaultFormat ; } | Return format for a container . |
1,213 | public function getContainerFormats ( $ container ) { if ( isset ( $ this -> formats [ $ container ] ) ) { return $ this -> formats [ $ container ] ; } return $ this -> defaultFormats ; } | Return formats for a container . |
1,214 | public function addContainer ( $ container , $ types = [ ] , $ defaultFormat = null , $ formats = [ ] ) { if ( isset ( $ this -> containers [ $ container ] ) ) { return $ this ; } $ this -> containers [ $ container ] = new NotificationsBag ( $ container , $ types , $ defaultFormat , $ formats ) ; $ this -> containers [ $ container ] -> setNotification ( $ this ) ; return $ this ; } | Add new container . |
1,215 | public function container ( $ container = null , Closure $ callback = null ) { $ container = is_null ( $ container ) ? $ this -> defaultContainer : $ container ; if ( ! isset ( $ this -> containers [ $ container ] ) ) { $ this -> addContainer ( $ container , $ this -> getContainerTypes ( $ container ) , $ this -> getContainerFormat ( $ container ) , $ this -> getContainerFormats ( $ container ) ) ; } if ( is_callable ( $ callback ) ) { $ callback ( $ this -> containers [ $ container ] ) ; } return $ this -> containers [ $ container ] ; } | Returns container instance . |
1,216 | public function fire ( $ event , NotificationsBag $ notificationBag , Message $ message ) { if ( ! isset ( static :: $ dispatcher ) ) { return true ; } $ event = "notification.{$event}: " . $ notificationBag -> getName ( ) ; return static :: $ dispatcher -> fire ( $ event , array ( $ this , $ notificationBag , $ message ) ) ; } | Fire given event . |
1,217 | public function addType ( $ type ) { if ( func_num_args ( ) > 1 ) { foreach ( func_get_args ( ) as $ t ) { $ this -> addType ( $ t ) ; } } else { if ( is_array ( $ type ) ) { foreach ( $ type as $ t ) { $ this -> addType ( $ t ) ; } } else { if ( ! $ this -> typeIsAvailable ( $ type ) ) { $ this -> types [ ] = $ type ; } } } return $ this ; } | Add new available type of message to bag . |
1,218 | protected function extractType ( $ name ) { if ( count ( $ this -> types ) <= 0 ) { return false ; } foreach ( $ this -> types as $ type ) { foreach ( $ this -> matcher as $ function => $ pattern ) { if ( str_replace ( array ( '{type}' , '{uType}' ) , array ( $ type , ucfirst ( $ type ) ) , $ pattern ) === $ name ) { return array ( $ type , $ function ) ; } } } return false ; } | Extract type from a given string . |
1,219 | public function setFormats ( $ formats ) { foreach ( $ formats as $ type => $ format ) { $ this -> setFormat ( $ type , $ format ) ; } return $ this ; } | Set formats for a given types . |
1,220 | public function setFormat ( $ type , $ format ) { if ( $ this -> typeIsAvailable ( $ type ) ) { $ this -> formats [ $ type ] = $ format ; } return $ this ; } | Set format for a given type . |
1,221 | public function getFormat ( $ type ) { if ( ! $ this -> typeIsAvailable ( $ type ) ) { return false ; } if ( isset ( $ this -> formats [ $ type ] ) ) { return $ this -> formats [ $ type ] ; } if ( ! is_null ( $ this -> getDefaultFormat ( ) ) ) { return $ this -> getDefaultFormat ( ) ; } return false ; } | Return format for a given type . |
1,222 | protected function checkFormat ( $ format , $ type = null ) { return ! is_null ( $ format ) ? $ format : $ this -> getFormat ( $ type ) ; } | Returns valid format . |
1,223 | protected function addInstance ( Message $ message , $ type , $ flash = true , $ format = null ) { $ message -> setType ( $ type ) ; if ( $ message -> isFlash ( ) != $ flash ) { $ message -> setFlash ( $ flash ) ; } if ( is_null ( $ message -> getFormat ( ) ) ) { $ message -> setFormat ( $ this -> getFormat ( $ type ) ) ; } if ( ! is_null ( $ format ) ) { $ message -> setFormat ( $ this -> checkFormat ( $ format , $ type ) ) ; } } | Add message by instance . |
1,224 | public function get ( $ type ) { $ collection = new Collection ( ) ; foreach ( $ this -> notifications as $ key => $ message ) { if ( $ message -> getType ( ) == $ type ) { $ collection -> add ( $ message ) ; } } return $ collection ; } | Returns all messages for given type . |
1,225 | public function clear ( $ type = null ) { if ( is_null ( $ type ) ) { $ this -> notifications = new Collection ( ) ; } else { $ notifications = new Collection ( ) ; foreach ( $ this -> notifications as $ message ) { if ( $ message -> getType ( ) != $ type ) { $ notifications -> add ( $ message ) ; } } $ this -> notifications = $ notifications ; } return $ this ; } | Clears message for a given type . |
1,226 | public function show ( $ type = null , $ format = null ) { $ messages = $ this -> getMessagesForRender ( $ type ) ; $ this -> groupForRender = array ( ) ; $ output = '' ; foreach ( $ messages as $ message ) { if ( ! $ message -> isFlash ( ) ) { if ( ! is_null ( $ format ) ) { $ message -> setFormat ( $ format ) ; } $ output .= $ message -> render ( ) ; } } return $ output ; } | Returns generated output of non flash messages . |
1,227 | protected function getMessagesForRender ( $ type = null ) { if ( is_null ( $ type ) ) { if ( count ( $ this -> groupForRender ) > 0 ) { $ messages = array ( ) ; foreach ( $ this -> groupForRender as $ typeToRender ) { $ messages = array_merge ( $ messages , $ this -> get ( $ typeToRender ) -> all ( ) ) ; } return new Collection ( $ messages ) ; } return $ this -> all ( ) ; } return $ this -> get ( $ type ) ; } | Resolves which messages should be returned for rendering . |
1,228 | public function addToGrouping ( $ type ) { if ( ! $ this -> typeIsAvailable ( $ type ) ) { return $ this ; } if ( ! in_array ( $ type , $ this -> groupForRender ) ) { $ this -> groupForRender [ ] = $ type ; } return $ this ; } | Adds type for rendering . |
1,229 | public function removeFromGrouping ( $ type ) { foreach ( $ this -> groupForRender as $ key => $ typeToRender ) { if ( $ type == $ typeToRender ) { unset ( $ this -> groupForRender [ $ key ] ) ; } } $ this -> groupForRender = array_values ( $ this -> groupForRender ) ; return $ this ; } | Removes type from rendering . |
1,230 | public function has ( $ type = null ) { if ( $ this -> count ( ) <= 0 ) { return false ; } if ( is_null ( $ type ) ) { return true ; } if ( ! $ this -> typeIsAvailable ( $ type ) ) { return false ; } foreach ( $ this -> notifications as $ key => $ message ) { if ( $ message -> getType ( ) == $ type ) { return true ; } } return false ; } | Check if a message is set for given type . |
1,231 | protected function fireEvent ( $ event , $ message ) { if ( ! isset ( $ this -> notification ) ) { return true ; } return $ this -> getNotification ( ) -> fire ( $ event , $ this , $ message ) ; } | Fire event for a given message . |
1,232 | public function onKernelResponse ( FilterResponseEvent $ event ) { if ( HttpKernelInterface :: MASTER_REQUEST !== $ event -> getRequestType ( ) || ! $ this -> routeMatcher -> match ( $ event -> getRequest ( ) , $ this -> routes ) ) { return ; } $ event -> getResponse ( ) -> headers -> setCookie ( new Cookie ( $ this -> cookieName , $ this -> angularCsrfTokenManager -> getToken ( ) -> getValue ( ) , 0 === $ this -> cookieExpire ? $ this -> cookieExpire : time ( ) + $ this -> cookieExpire , $ this -> cookiePath , $ this -> cookieDomain , $ this -> cookieSecure , false ) ) ; } | Sets a cookie to the response containing the CRSF token . |
1,233 | public function onKernelRequest ( GetResponseEvent $ event ) { if ( HttpKernelInterface :: MASTER_REQUEST !== $ event -> getRequestType ( ) || $ this -> routeMatcher -> match ( $ event -> getRequest ( ) , $ this -> exclude ) || ! $ this -> routeMatcher -> match ( $ event -> getRequest ( ) , $ this -> routes ) ) { return ; } $ value = $ event -> getRequest ( ) -> headers -> get ( $ this -> headerName ) ; if ( ! $ value || ! $ this -> angularCsrfTokenManager -> isTokenValid ( $ value ) ) { throw new AccessDeniedHttpException ( 'Bad CSRF token.' ) ; } } | Handles CSRF token validation . |
1,234 | public function isTokenValid ( $ value ) { $ csrfToken = new CsrfToken ( $ this -> tokenId , $ value ) ; return $ this -> csrfTokenManager -> isTokenValid ( $ csrfToken ) ; } | Tests if the given token value is valid . |
1,235 | public function getRuntime ( DeliveryExecution $ execution ) { $ delivery = $ execution -> getDelivery ( ) ; return $ this -> getServiceLocator ( ) -> get ( RuntimeService :: SERVICE_ID ) -> getRuntime ( $ delivery -> getUri ( ) ) ; } | Return the service call to run the delivery |
1,236 | public function updateDeliveryExecutionStatus ( KVDeliveryExecution $ deliveryExecution , $ old , $ new ) { $ this -> update ( $ deliveryExecution ) ; $ userId = $ deliveryExecution -> getUserIdentifier ( ) ; if ( $ old != null ) { $ oldReferences = $ this -> getDeliveryExecutionsByStatus ( $ userId , $ old ) ; foreach ( array_keys ( $ oldReferences ) as $ key ) { if ( $ oldReferences [ $ key ] -> getIdentifier ( ) == $ deliveryExecution -> getIdentifier ( ) ) { unset ( $ oldReferences [ $ key ] ) ; } } $ this -> setDeliveryExecutions ( $ userId , $ old , $ oldReferences ) ; } $ newReferences = $ this -> getDeliveryExecutionsByStatus ( $ userId , $ new ) ; $ newReferences [ $ deliveryExecution -> getIdentifier ( ) ] = $ deliveryExecution ; return $ this -> setDeliveryExecutions ( $ userId , $ new , $ newReferences ) ; } | Update the collection of deliveries |
1,237 | public function getExecutionsByDelivery ( core_kernel_classes_Resource $ compiled ) { if ( ! $ this -> implementsMonitoring ( ) ) { throw new common_exception_NoImplementation ( get_class ( $ this -> getImplementation ( ) ) . ' does not implement \oat\taoDelivery\model\execution\Monitoring' ) ; } return $ this -> getImplementation ( ) -> getExecutionsByDelivery ( $ compiled ) ; } | Implemented in the monitoring interface |
1,238 | private function areColumnsExist ( \ common_persistence_sql_SchemaManager $ schemaManager ) { $ columnNames = [ RdsDeliveryExecutionService :: COLUMN_ID , RdsDeliveryExecutionService :: COLUMN_USER_ID , RdsDeliveryExecutionService :: COLUMN_DELIVERY_ID , RdsDeliveryExecutionService :: COLUMN_LABEL , RdsDeliveryExecutionService :: COLUMN_STATUS , RdsDeliveryExecutionService :: COLUMN_STARTED_AT , RdsDeliveryExecutionService :: COLUMN_FINISHED_AT , ] ; $ tableColumns = array_map ( function ( Column $ column ) { return $ column -> getName ( ) ; } , $ schemaManager -> getColumnNames ( RdsDeliveryExecutionService :: TABLE_NAME ) ) ; return array_reduce ( $ columnNames , function ( $ areColumnsExist , $ column ) use ( $ tableColumns ) { $ areColumnsExist = $ areColumnsExist && in_array ( $ column , $ tableColumns ) ; return $ areColumnsExist ; } , true ) ; } | Returns that the delivery_executions table columns are already exist in the table or not |
1,239 | private function createTable ( Schema $ schema ) { $ table = $ schema -> createTable ( RdsDeliveryExecutionService :: TABLE_NAME ) ; $ table -> addOption ( "engine" , "InnoDB" ) ; $ table -> addOption ( "charset" , "utf8" ) ; $ table -> addOption ( "collate" , "utf8_unicode_ci" ) ; $ this -> createColumns ( $ table ) ; $ this -> createIndex ( $ table , [ RdsDeliveryExecutionService :: COLUMN_DELIVERY_ID , RdsDeliveryExecutionService :: COLUMN_USER_ID , ] ) ; $ this -> createIndex ( $ table , [ RdsDeliveryExecutionService :: COLUMN_USER_ID , ] ) ; } | Creates the table in the database for the Delivery |
1,240 | private function createIndex ( Table $ table , array $ columns ) { if ( count ( $ columns ) > 0 ) { $ indexPrefix = "idx_" . RdsDeliveryExecutionService :: TABLE_NAME . "_" ; $ indexName = substr ( $ indexPrefix . implode ( "_" , $ columns ) , 0 , 63 ) ; $ table -> addIndex ( $ columns , $ indexName ) ; } } | Generates index for the given columns |
1,241 | public function getAssignments ( User $ user ) { $ assignments = [ ] ; foreach ( $ this -> getInternalServices ( ) as $ service ) { $ assignments = array_merge ( $ assignments , $ service -> getAssignments ( $ user ) ) ; } return $ assignments ; } | Returns the deliveries available to a user |
1,242 | public function getAssignedUsers ( $ deliveryId ) { $ users = [ ] ; foreach ( $ this -> getInternalServices ( ) as $ service ) { $ users = array_merge ( $ users , $ service -> getAssignedUsers ( $ deliveryId ) ) ; } return $ users ; } | Returns the ids of users assigned to a delivery |
1,243 | protected function getViewDataFromRequest ( ) { $ lookupParams = [ 'warning' , 'error' ] ; $ result = [ ] ; foreach ( $ lookupParams as $ lookupParam ) { if ( $ this -> getRequest ( ) -> hasParameter ( $ lookupParam ) && ! empty ( $ this -> getRequest ( ) -> getParameter ( $ lookupParam ) ) ) { $ result [ ] = [ 'level' => $ lookupParam , 'content' => $ this -> getRequest ( ) -> getParameter ( $ lookupParam ) , 'timeout' => - 1 ] ; } } return $ result ; } | Get data from request to be passed to renderer |
1,244 | protected function _initDeliveryExecution ( ) { $ compiledDelivery = new \ core_kernel_classes_Resource ( \ tao_helpers_Uri :: decode ( $ this -> getRequestParameter ( 'uri' ) ) ) ; $ user = common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ assignmentService = $ this -> getServiceLocator ( ) -> get ( AssignmentService :: SERVICE_ID ) ; $ this -> verifyDeliveryStartAuthorized ( $ compiledDelivery -> getUri ( ) ) ; if ( ! $ assignmentService -> isDeliveryExecutionAllowed ( $ compiledDelivery -> getUri ( ) , $ user ) ) { throw new common_exception_Unauthorized ( ) ; } $ stateService = $ this -> getServiceLocator ( ) -> get ( StateServiceInterface :: SERVICE_ID ) ; $ deliveryExecution = $ stateService -> createDeliveryExecution ( $ compiledDelivery -> getUri ( ) , $ user , $ compiledDelivery -> getLabel ( ) ) ; return $ deliveryExecution ; } | Init a delivery execution from the current delivery . |
1,245 | public function initDeliveryExecution ( ) { try { $ deliveryExecution = $ this -> _initDeliveryExecution ( ) ; $ this -> redirect ( _url ( 'runDeliveryExecution' , null , null , array ( 'deliveryExecution' => $ deliveryExecution -> getIdentifier ( ) ) ) ) ; } catch ( UnAuthorizedException $ e ) { return $ this -> redirect ( $ e -> getErrorPage ( ) ) ; } catch ( common_exception_Unauthorized $ e ) { return $ this -> returnJson ( [ 'success' => false , 'message' => __ ( 'You are no longer allowed to take this test' ) ] , 403 ) ; } } | Init the selected delivery execution and forward to the execution screen |
1,246 | public function runDeliveryExecution ( ) { $ deliveryExecution = $ this -> getCurrentDeliveryExecution ( ) ; if ( ! $ this -> hasSessionAttribute ( DeliveryExecution :: getDeliveryIdSessionKey ( $ deliveryExecution -> getIdentifier ( ) ) ) ) { $ this -> setSessionAttribute ( DeliveryExecution :: getDeliveryIdSessionKey ( $ deliveryExecution -> getIdentifier ( ) ) , $ deliveryExecution -> getDelivery ( ) -> getUri ( ) ) ; } try { $ this -> verifyDeliveryExecutionAuthorized ( $ deliveryExecution ) ; } catch ( UnAuthorizedException $ e ) { return $ this -> redirect ( $ e -> getErrorPage ( ) ) ; } $ userUri = common_session_SessionManager :: getSession ( ) -> getUserUri ( ) ; if ( $ deliveryExecution -> getUserIdentifier ( ) != $ userUri ) { throw new common_exception_Error ( 'User ' . $ userUri . ' is not the owner of the execution ' . $ deliveryExecution -> getIdentifier ( ) ) ; } $ delivery = $ deliveryExecution -> getDelivery ( ) ; $ this -> initResultServer ( $ delivery , $ deliveryExecution -> getIdentifier ( ) , $ userUri ) ; $ deliveryExecutionStateService = $ this -> getServiceManager ( ) -> get ( StateServiceInterface :: SERVICE_ID ) ; $ deliveryExecutionStateService -> run ( $ deliveryExecution ) ; $ container = $ this -> getDeliveryServer ( ) -> getDeliveryContainer ( $ deliveryExecution ) ; $ container -> setData ( 'client_config_url' , $ this -> getClientConfigUrl ( ) ) ; $ container -> setData ( 'client_timeout' , $ this -> getClientTimeout ( ) ) ; $ container -> setData ( 'returnUrl' , $ this -> getReturnUrl ( ) ) ; $ container -> setData ( 'finishUrl' , $ this -> getfinishDeliveryExecutionUrl ( $ deliveryExecution ) ) ; $ this -> setData ( 'additional-header' , $ container -> getContainerHeader ( ) ) ; $ this -> setData ( 'container-body' , $ container -> getContainerBody ( ) ) ; $ this -> setData ( 'userLabel' , common_session_SessionManager :: getSession ( ) -> getUserLabel ( ) ) ; $ this -> setData ( 'showControls' , $ this -> showControls ( ) ) ; $ this -> setData ( 'returnUrl' , $ this -> getReturnUrl ( ) ) ; $ urlRouteService = $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) ; $ this -> setData ( 'logout' , $ urlRouteService -> getUrl ( 'logoutDelivery' , [ ] ) ) ; $ this -> setData ( 'content-template' , 'DeliveryServer/runDeliveryExecution.tpl' ) ; $ this -> setData ( 'content-extension' , 'taoDelivery' ) ; $ this -> setView ( 'DeliveryServer/layout.tpl' , 'taoDelivery' ) ; } | Displays the execution screen |
1,247 | public function finishDeliveryExecution ( ) { $ deliveryExecution = $ this -> getCurrentDeliveryExecution ( ) ; if ( $ deliveryExecution -> getUserIdentifier ( ) == common_session_SessionManager :: getSession ( ) -> getUserUri ( ) ) { $ stateService = $ this -> getServiceManager ( ) -> get ( StateServiceInterface :: SERVICE_ID ) ; $ stateService -> finish ( $ deliveryExecution ) ; } else { common_Logger :: w ( 'Non owner ' . common_session_SessionManager :: getSession ( ) -> getUserUri ( ) . ' tried to finish deliveryExecution ' . $ deliveryExecution -> getIdentifier ( ) ) ; } $ this -> redirect ( $ this -> getReturnUrl ( ) ) ; } | Finish the delivery execution |
1,248 | protected function initResultServer ( $ compiledDelivery , $ executionIdentifier , $ userUri ) { $ this -> getDeliveryServer ( ) -> initResultServer ( $ compiledDelivery , $ executionIdentifier , $ userUri ) ; } | Initialize the result server using the delivery configuration and for this results session submission |
1,249 | protected function getReturnUrl ( ) { if ( $ this -> getServiceLocator ( ) -> has ( ReturnUrlService :: SERVICE_ID ) ) { $ deliveryExecution = $ this -> getCurrentDeliveryExecution ( ) ; return $ this -> getServiceLocator ( ) -> get ( ReturnUrlService :: SERVICE_ID ) -> getReturnUrl ( $ deliveryExecution -> getIdentifier ( ) ) ; } return _url ( 'index' , 'DeliveryServer' , 'taoDelivery' ) ; } | Defines the returning URL in the top - right corner action menu |
1,250 | protected function verifyDeliveryStartAuthorized ( $ deliveryId ) { $ user = common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ this -> getAuthorizationProvider ( ) -> verifyStartAuthorization ( $ deliveryId , $ user ) ; } | Verify if the start of the delivery is allowed . Throws an exception if not |
1,251 | protected function verifyDeliveryExecutionAuthorized ( DeliveryExecution $ deliveryExecution ) { $ user = common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ this -> getAuthorizationProvider ( ) -> verifyResumeAuthorization ( $ deliveryExecution , $ user ) ; } | Check wether the delivery execution is authorized to run Throws an exception if not |
1,252 | public function getLabel ( ) { $ deliveryFieldsService = $ this -> getServiceLocator ( ) -> get ( DeliveryFieldsService :: SERVICE_ID ) ; $ label = $ deliveryFieldsService -> getLabel ( $ this -> getImplementation ( ) -> getDelivery ( ) , $ this -> getImplementation ( ) -> getLabel ( ) ) ; return $ label ; } | Returns a human readable test representation of the delivery execution Should respect the current user s language |
1,253 | public function legacyTransition ( DeliveryExecution $ deliveryExecution , $ state ) { switch ( $ state ) { case DeliveryExecution :: STATE_FINISHED : $ result = $ this -> finish ( $ deliveryExecution ) ; break ; case DeliveryExecution :: STATE_ACTIVE : $ result = $ this -> run ( $ deliveryExecution ) ; break ; case DeliveryExecution :: STATE_PAUSED : $ result = $ this -> pause ( $ deliveryExecution ) ; break ; default : $ this -> logWarning ( 'Unrecognised state ' . $ state ) ; $ result = $ this -> setState ( $ deliveryExecution , $ state ) ; } return $ result ; } | Legacy function to ensure all calls to setState use the correct transition instead |
1,254 | public function initResultServer ( $ compiledDelivery , $ executionIdentifier , $ userUri ) { $ this -> getServiceManager ( ) -> get ( \ oat \ taoResultServer \ models \ classes \ ResultServerService :: SERVICE_ID ) -> initResultServer ( $ compiledDelivery , $ executionIdentifier , $ userUri ) ; } | Initialize the result server for a given execution |
1,255 | public function getDeliveryContainer ( DeliveryExecution $ deliveryExecution ) { $ runtimeService = $ this -> getServiceLocator ( ) -> get ( RuntimeService :: SERVICE_ID ) ; $ deliveryContainer = $ runtimeService -> getDeliveryContainer ( $ deliveryExecution -> getDelivery ( ) -> getUri ( ) ) ; return $ deliveryContainer -> getExecutionContainer ( $ deliveryExecution ) ; } | Returns the container for the delivery execution |
1,256 | public function count ( $ statusUri ) { $ persistence = $ this -> getPersistence ( ) ; $ key = $ this -> getStatusKey ( $ statusUri ) ; return intval ( $ persistence -> get ( $ key ) ) ; } | Get number of delivery executions of given status . |
1,257 | public function getLabel ( ) { $ deliveryFieldsService = ServiceManager :: getServiceManager ( ) -> get ( DeliveryFieldsService :: SERVICE_ID ) ; $ delivery = $ this -> getResource ( $ this -> getDeliveryId ( ) ) ; $ label = $ deliveryFieldsService -> getLabel ( $ delivery , $ this -> label ) ; return $ label ; } | Returns the label of the asignment which will often correspond to the label of the delivery |
1,258 | public function getLabel ( \ core_kernel_classes_Resource $ delivery , $ label = '' ) { $ user = \ common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ customLabelRoles = $ this -> getOption ( self :: PROPERTY_CUSTOM_LABEL ) ; if ( array_intersect ( $ customLabelRoles , $ user -> getRoles ( ) ) ) { $ property = $ this -> getProperty ( self :: PROPERTY_CUSTOM_LABEL ) ; if ( ( string ) $ delivery -> getOnePropertyValue ( $ property ) ) { $ label = $ delivery -> getOnePropertyValue ( $ property ) ; } } return ( string ) $ label ; } | Getting custom label from Delivery |
1,259 | public function getReturnUrl ( $ deliveryExecutionUri = '' ) { $ ext = ( $ this -> hasOption ( self :: EXTENSION_OPTION ) ) ? $ this -> getOption ( self :: EXTENSION_OPTION ) : 'taoDelivery' ; $ ctrl = ( $ this -> hasOption ( self :: CONTROLLER_OPTION ) ) ? $ this -> getOption ( self :: CONTROLLER_OPTION ) : 'DeliveryServer' ; $ method = ( $ this -> hasOption ( self :: METHOD_OPTION ) ) ? $ this -> getOption ( self :: METHOD_OPTION ) : 'index' ; return _url ( $ method , $ ctrl , $ ext ) ; } | Get the full url to go at the end of a test |
1,260 | public function verifyStartAuthorization ( $ deliveryId , User $ user ) { foreach ( $ this -> getProviders ( ) as $ provider ) { $ provider -> verifyStartAuthorization ( $ deliveryId , $ user ) ; } } | Verify that a given delivery is allowed to be started |
1,261 | protected function getProviders ( ) { if ( is_null ( $ this -> providers ) ) { $ this -> providers = array ( ) ; if ( $ this -> hasOption ( self :: OPTION_PROVIDERS ) ) { foreach ( $ this -> getOption ( self :: OPTION_PROVIDERS ) as $ provider ) { if ( $ provider instanceof ServiceLocatorAwareInterface ) { $ provider -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; } $ this -> providers [ ] = $ provider ; } } } return $ this -> providers ; } | Returns a list of providers that need to be verified |
1,262 | public function addProvider ( AuthorizationProvider $ provider ) { $ providers = $ this -> getOption ( self :: OPTION_PROVIDERS ) ; $ providers [ ] = $ provider ; $ this -> setOption ( self :: OPTION_PROVIDERS , $ providers ) ; } | Add an additional authorization provider that needs to be satisfied as well |
1,263 | public function unregister ( $ providerClass ) { $ providers = $ this -> getOption ( self :: OPTION_PROVIDERS ) ; foreach ( $ providers as $ key => $ provider ) { if ( get_class ( $ provider ) == $ providerClass ) { unset ( $ providers [ $ key ] ) ; } } $ this -> setOption ( self :: OPTION_PROVIDERS , $ providers ) ; } | Remove an existing authorization provider identified by exact class |
1,264 | public function getExecutionsByDelivery ( core_kernel_classes_Resource $ compiled ) { $ query = $ this -> getQueryBuilder ( ) -> select ( "*" ) -> from ( self :: TABLE_NAME ) -> where ( self :: COLUMN_DELIVERY_ID . " = :deliveryId" ) -> setParameter ( "deliveryId" , $ compiled -> getUri ( ) ) ; return array_map ( function ( $ row ) { return $ this -> parseQueryResult ( $ row ) ; } , $ query -> execute ( ) -> fetchAll ( ) ) ; } | Returns the delivery executions for a compiled directory |
1,265 | public function getUserExecutions ( core_kernel_classes_Resource $ assembly , $ userUri ) { $ query = $ this -> getQueryBuilder ( ) -> select ( "*" ) -> from ( self :: TABLE_NAME ) -> where ( self :: COLUMN_DELIVERY_ID . " = :deliveryId" ) -> andWhere ( self :: COLUMN_USER_ID . " = :userId" ) -> setParameter ( "deliveryId" , $ assembly -> getUri ( ) ) -> setParameter ( "userId" , $ userUri ) ; return array_map ( function ( $ row ) { return $ this -> parseQueryResult ( $ row ) ; } , $ query -> execute ( ) -> fetchAll ( ) ) ; } | Returns the executions the user has of a specified assembly |
1,266 | public function getDeliveryExecutionsByStatus ( $ userUri , $ status ) { $ query = $ this -> getQueryBuilder ( ) -> select ( "*" ) -> from ( self :: TABLE_NAME ) -> where ( self :: COLUMN_USER_ID . " = :userId" ) -> andWhere ( self :: COLUMN_STATUS . " = :status" ) -> setParameter ( "userId" , $ userUri ) -> setParameter ( "status" , $ status ) ; return array_map ( function ( $ row ) { return $ this -> parseQueryResult ( $ row ) ; } , $ query -> execute ( ) -> fetchAll ( ) ) ; } | Returns all Delivery Executions of a User with a specific status |
1,267 | public function getDeliveryExecution ( $ identifier ) { $ query = $ this -> getQueryBuilder ( ) -> select ( "*" ) -> from ( self :: TABLE_NAME ) -> where ( self :: COLUMN_ID . " = :id" ) -> setParameter ( "id" , $ identifier ) ; $ result = $ query -> execute ( ) -> fetch ( ) ; if ( ! $ result ) { $ result = [ ] ; } return $ this -> parseQueryResult ( $ result ) ; } | Returns the delivery execution instance associated to the implementation |
1,268 | public function updateDeliveryExecutionState ( $ identifier , $ fromState , $ toState ) { try { if ( $ fromState === $ toState ) { return true ; } $ query = $ this -> getQueryBuilder ( ) -> update ( self :: TABLE_NAME ) -> set ( self :: COLUMN_STATUS , ":status" ) -> where ( self :: COLUMN_ID . " = :id" ) -> setParameter ( "status" , $ toState ) -> setParameter ( "id" , $ identifier ) ; if ( $ toState === DeliveryExecutionInterface :: STATE_FINISHED ) { $ query -> set ( self :: COLUMN_FINISHED_AT , ":finishedAt" ) -> setParameter ( "finishedAt" , $ this -> getCurrentDateTime ( ) ) ; } return $ query -> execute ( ) === 1 ; } catch ( \ Exception $ e ) { return false ; } } | Updates the state of the given deliveryexecution |
1,269 | private function parseQueryResult ( $ result = [ ] ) { $ rdsDeliveryExecution = new RdsDeliveryExecution ( $ this ) ; if ( array_key_exists ( self :: COLUMN_ID , $ result ) ) { $ rdsDeliveryExecution -> setIdentifier ( $ result [ self :: COLUMN_ID ] ) ; } if ( array_key_exists ( self :: COLUMN_LABEL , $ result ) ) { $ rdsDeliveryExecution -> setLabel ( $ result [ self :: COLUMN_LABEL ] ) ; } if ( array_key_exists ( self :: COLUMN_DELIVERY_ID , $ result ) ) { $ rdsDeliveryExecution -> setDelivery ( $ result [ self :: COLUMN_DELIVERY_ID ] ) ; } if ( array_key_exists ( self :: COLUMN_STATUS , $ result ) ) { $ rdsDeliveryExecution -> setState ( $ result [ self :: COLUMN_STATUS ] ) ; } if ( array_key_exists ( self :: COLUMN_USER_ID , $ result ) ) { $ rdsDeliveryExecution -> setUserIdentifier ( $ result [ self :: COLUMN_USER_ID ] ) ; } if ( array_key_exists ( self :: COLUMN_STARTED_AT , $ result ) ) { $ rdsDeliveryExecution -> setStartTime ( new \ DateTime ( $ result [ self :: COLUMN_STARTED_AT ] ) ) ; } if ( array_key_exists ( self :: COLUMN_FINISHED_AT , $ result ) ) { $ rdsDeliveryExecution -> setFinishTime ( new \ DateTime ( $ result [ self :: COLUMN_FINISHED_AT ] ) ) ; } return $ this -> propagate ( new DeliveryExecution ( $ rdsDeliveryExecution ) ) ; } | Parses the query result array and constructs a new DeliveryExecution object from it |
1,270 | public function getDeliveryIdFromSession ( $ deliveryExecutionId ) { if ( \ PHPSession :: singleton ( ) -> hasAttribute ( static :: getDeliveryIdSessionKey ( $ deliveryExecutionId ) ) ) { return \ PHPSession :: singleton ( ) -> getAttribute ( static :: getDeliveryIdSessionKey ( $ deliveryExecutionId ) ) ; } return false ; } | Returns the deliveryId from session . |
1,271 | public function getDeliveryThemeId ( $ deliveryId ) { $ themeId = $ this -> getDeliveryThemeIdFromCache ( $ deliveryId ) ; if ( $ themeId === false ) { $ themeId = $ this -> getDeliveryThemeIdFromDb ( $ deliveryId ) ; $ this -> storeDeliveryThemeIdToCache ( $ deliveryId , $ themeId ) ; } return $ themeId ; } | Returns the delivery theme id . |
1,272 | public function appendContents ( $ path , $ content ) { return $ this -> invoker -> invokeCall ( 'putContents' , [ 'path' => $ path , 'chunk' => base64_encode ( $ content ) , 'flags' => FILE_APPEND , ] ) -> then ( function ( $ payload ) { return \ React \ Promise \ resolve ( $ payload [ 'written' ] ) ; } ) ; } | Appends the given content to the specified file . If the file does not exist the file will be created . |
1,273 | public function map ( array $ parts ) : array { if ( $ this -> isMatchingSinglePart ( $ parts ) ) { $ parts [ 0 ] = new Suffix ( $ parts [ 0 ] , $ this -> suffixes [ $ this -> getKey ( $ parts [ 0 ] ) ] ) ; return $ parts ; } $ start = count ( $ parts ) - 1 ; for ( $ k = $ start ; $ k > 1 ; $ k -- ) { $ part = $ parts [ $ k ] ; if ( ! $ this -> isSuffix ( $ part ) ) { break ; } $ parts [ $ k ] = new Suffix ( $ part , $ this -> suffixes [ $ this -> getKey ( $ part ) ] ) ; } return $ parts ; } | map suffixes in the parts array |
1,274 | protected function parseSplitName ( $ first , $ second , $ third ) : Name { $ parts = array_merge ( $ this -> getFirstSegmentParser ( ) -> parse ( $ first ) -> getParts ( ) , $ this -> getSecondSegmentParser ( ) -> parse ( $ second ) -> getParts ( ) , $ this -> getThirdSegmentParser ( ) -> parse ( $ third ) -> getParts ( ) ) ; return new Name ( $ parts ) ; } | handles split - parsing of comma - separated name parts |
1,275 | public function getMappers ( ) : array { if ( empty ( $ this -> mappers ) ) { $ this -> setMappers ( [ new NicknameMapper ( $ this -> getNicknameDelimiters ( ) ) , new SalutationMapper ( $ this -> getSalutations ( ) , $ this -> getMaxSalutationIndex ( ) ) , new SuffixMapper ( $ this -> getSuffixes ( ) ) , new InitialMapper ( ) , new LastnameMapper ( $ this -> getPrefixes ( ) ) , new FirstnameMapper ( ) , new MiddlenameMapper ( ) , ] ) ; } return $ this -> mappers ; } | get the mappers for this parser |
1,276 | protected function normalize ( string $ name ) : string { $ whitespace = $ this -> getWhitespace ( ) ; $ name = trim ( $ name ) ; return preg_replace ( '/[' . preg_quote ( $ whitespace ) . ']+/' , ' ' , $ name ) ; } | normalize the name |
1,277 | public function map ( array $ parts ) : array { if ( count ( $ parts ) < 2 ) { return [ $ this -> handleSinglePart ( $ parts [ 0 ] ) ] ; } $ pos = $ this -> findFirstnamePosition ( $ parts ) ; if ( null !== $ pos ) { $ parts [ $ pos ] = new Firstname ( $ parts [ $ pos ] ) ; } return $ parts ; } | map firstnames in parts array |
1,278 | public function map ( array $ parts ) : array { $ max = ( $ this -> maxIndex > 0 ) ? $ this -> maxIndex : floor ( count ( $ parts ) / 2 ) ; for ( $ k = 0 ; $ k < $ max ; $ k ++ ) { $ part = $ parts [ $ k ] ; if ( $ part instanceof AbstractPart ) { break ; } if ( $ this -> isSalutation ( $ part ) ) { $ parts [ $ k ] = new Salutation ( $ part , $ this -> salutations [ $ this -> getKey ( $ part ) ] ) ; } } return $ parts ; } | map salutations in the parts array |
1,279 | public function map ( array $ parts ) : array { $ isEncapsulated = false ; $ regexp = $ this -> buildRegexp ( ) ; $ closingDelimiter = '' ; foreach ( $ parts as $ k => $ part ) { if ( $ part instanceof AbstractPart ) { continue ; } if ( preg_match ( $ regexp , $ part , $ matches ) ) { $ isEncapsulated = true ; $ part = substr ( $ part , 1 ) ; $ closingDelimiter = $ this -> delimiters [ $ matches [ 1 ] ] ; } if ( ! $ isEncapsulated ) { continue ; } if ( $ closingDelimiter === substr ( $ part , - 1 ) ) { $ isEncapsulated = false ; $ part = substr ( $ part , 0 , - 1 ) ; } $ parts [ $ k ] = new Nickname ( str_replace ( [ '"' , '\'' ] , '' , $ part ) ) ; } return $ parts ; } | map nicknames in the parts array |
1,280 | public function map ( array $ parts ) : array { $ last = count ( $ parts ) - 1 ; foreach ( $ parts as $ k => $ part ) { if ( $ part instanceof AbstractPart ) { continue ; } if ( ! $ this -> matchLastPart && $ k === $ last ) { continue ; } if ( $ this -> isInitial ( $ part ) ) { $ parts [ $ k ] = new Initial ( $ part ) ; } } return $ parts ; } | map intials in parts array |
1,281 | public function map ( array $ parts ) : array { if ( ! $ this -> matchSinglePart && count ( $ parts ) < 2 ) { return $ parts ; } return $ this -> mapParts ( $ parts ) ; } | map lastnames in the parts array |
1,282 | protected function mapParts ( array $ parts ) : array { $ k = $ this -> skipIgnoredParts ( $ parts ) + 1 ; $ remapIgnored = true ; while ( -- $ k >= 0 ) { $ part = $ parts [ $ k ] ; if ( $ part instanceof AbstractPart ) { break ; } if ( $ this -> isFollowedByLastnamePart ( $ parts , $ k ) ) { if ( $ this -> isApplicablePrefix ( $ parts , $ k ) ) { $ parts [ $ k ] = new LastnamePrefix ( $ part , $ this -> prefixes [ $ this -> getKey ( $ part ) ] ) ; continue ; } if ( $ this -> shouldStopMapping ( $ parts , $ k ) ) { break ; } } $ parts [ $ k ] = new Lastname ( $ part ) ; $ remapIgnored = false ; } if ( $ remapIgnored ) { $ parts = $ this -> remapIgnored ( $ parts ) ; } return $ parts ; } | we map the parts in reverse order because it makes more sense to parse for the lastname starting from the end |
1,283 | protected function skipIgnoredParts ( array $ parts ) : int { $ k = count ( $ parts ) ; while ( -- $ k >= 0 ) { if ( ! $ this -> isIgnoredPart ( $ parts [ $ k ] ) ) { break ; } } return $ k ; } | skip through the parts we want to ignore and return the start index |
1,284 | protected function remapIgnored ( array $ parts ) : array { $ k = count ( $ parts ) ; while ( -- $ k >= 0 ) { $ part = $ parts [ $ k ] ; if ( ! $ this -> isIgnoredPart ( $ part ) ) { break ; } $ parts [ $ k ] = new Lastname ( $ part ) ; } return $ parts ; } | remap ignored parts as lastname |
1,285 | protected function isApplicablePrefix ( array $ parts , int $ index ) : bool { if ( ! $ this -> isPrefix ( $ parts [ $ index ] ) ) { return false ; } return $ this -> hasUnmappedPartsBefore ( $ parts , $ index ) ; } | Assuming that the part at the given index is matched as a prefix determines if the prefix should be applied to the lastname . |
1,286 | protected function skipNicknameParts ( $ parts , $ startIndex ) { $ total = count ( $ parts ) ; for ( $ i = $ startIndex ; $ i < $ total ; $ i ++ ) { if ( ! ( $ parts [ $ i ] instanceof Nickname ) ) { return $ i ; } } return $ total - 1 ; } | find the next non - nickname index in parts |
1,287 | protected function hasUnmappedPartsBefore ( array $ parts , $ index ) : bool { foreach ( $ parts as $ k => $ part ) { if ( $ k === $ index ) { break ; } if ( ! ( $ part instanceof AbstractPart ) ) { return true ; } } return false ; } | checks if there are still unmapped parts left before the given position |
1,288 | protected function export ( string $ type , bool $ strict = false ) : string { $ matched = [ ] ; foreach ( $ this -> parts as $ part ) { if ( $ part instanceof AbstractPart && $ this -> isType ( $ part , $ type , $ strict ) ) { $ matched [ ] = $ part -> normalize ( ) ; } } return implode ( ' ' , $ matched ) ; } | helper method used by getters to extract and format relevant name parts |
1,289 | protected function isType ( AbstractPart $ part , string $ type , bool $ strict = false ) : bool { $ className = sprintf ( '%s\\%s' , self :: PARTS_NAMESPACE , $ type ) ; if ( $ strict ) { return get_class ( $ part ) === $ className ; } return is_a ( $ part , $ className ) ; } | helper method to check if a part is of the given type |
1,290 | public function map ( array $ parts ) : array { $ minumumParts = ( $ this -> mapWithoutLastname ? 2 : 3 ) ; if ( count ( $ parts ) < $ minumumParts ) { return $ parts ; } $ start = $ this -> findFirstMapped ( Firstname :: class , $ parts ) ; if ( false === $ start ) { return $ parts ; } return $ this -> mapFrom ( $ start , $ parts ) ; } | map middlenames in the parts array |
1,291 | public function cleanupCollapsedStatesInUC ( ) { $ backendUser = $ this -> getBackendUser ( ) ; if ( is_array ( $ backendUser -> uc [ 'moduleData' ] [ 'page' ] [ 'gridelementsCollapsedColumns' ] ) ) { $ collapsedGridelementColumns = $ backendUser -> uc [ 'moduleData' ] [ 'page' ] [ 'gridelementsCollapsedColumns' ] ; foreach ( $ collapsedGridelementColumns as $ item => $ collapsed ) { if ( empty ( $ collapsed ) ) { unset ( $ collapsedGridelementColumns [ $ item ] ) ; } } $ backendUser -> uc [ 'moduleData' ] [ 'page' ] [ 'gridelementsCollapsedColumns' ] = $ collapsedGridelementColumns ; $ backendUser -> writeUC ( $ backendUser -> uc ) ; } } | Processes the collapsed states of Gridelements columns and removes columns with 0 values |
1,292 | public function preProcess ( PageLayoutView & $ parentObject , & $ drawItem , & $ headerContent , & $ itemContent , array & $ row ) { if ( $ row [ 'CType' ] ) { $ this -> showHidden = $ parentObject -> tt_contentConfig [ 'showHidden' ] ? true : false ; if ( $ this -> helper -> getBackendUser ( ) -> uc [ 'hideContentPreview' ] ) { $ itemContent = '' ; $ drawItem = false ; } switch ( $ row [ 'CType' ] ) { case 'gridelements_pi1' : $ drawItem = false ; $ itemContent .= $ this -> renderCTypeGridelements ( $ parentObject , $ row ) ; $ refIndexObj = GeneralUtility :: makeInstance ( ReferenceIndex :: class ) ; $ refIndexObj -> updateRefIndexTable ( 'tt_content' , ( int ) $ row [ 'uid' ] ) ; break ; case 'shortcut' : $ drawItem = false ; $ itemContent .= $ this -> renderCTypeShortcut ( $ parentObject , $ row ) ; break ; } } $ listType = $ row [ 'list_type' ] && $ row [ 'CType' ] === 'list' ? ' data-list_type="' . $ row [ 'list_type' ] . '"' : '' ; $ gridType = $ row [ 'tx_gridelements_backend_layout' ] && $ row [ 'CType' ] === 'gridelements_pi1' ? ' data-tx_gridelements_backend_layout="' . $ row [ 'tx_gridelements_backend_layout' ] . '"' : '' ; $ headerContent = '<div id="element-tt_content-' . $ row [ 'uid' ] . '" class="t3-ctype-identifier " data-ctype="' . $ row [ 'CType' ] . '" ' . $ listType . $ gridType . '>' . $ headerContent . '</div>' ; } | Processes the item to be rendered before the actual example content gets rendered Deactivates the original example content output |
1,293 | protected function renderCTypeGridelements ( PageLayoutView $ parentObject , & $ row ) { $ head = [ ] ; $ gridContent = [ ] ; $ editUidList = [ ] ; $ colPosValues = [ ] ; $ singleColumn = false ; $ gridContainerId = $ row [ 'uid' ] ; if ( $ row [ 'pid' ] < 0 ) { $ originalRecord = BackendUtility :: getRecord ( 'tt_content' , $ row [ 't3ver_oid' ] ) ; } else { $ originalRecord = $ row ; } $ layoutSetup = GeneralUtility :: makeInstance ( LayoutSetup :: class ) -> init ( $ originalRecord [ 'pid' ] ) ; $ gridElement = $ layoutSetup -> cacheCurrentParent ( $ gridContainerId , true ) ; $ layoutUid = $ gridElement [ 'tx_gridelements_backend_layout' ] ; $ layout = $ layoutSetup -> getLayoutSetup ( $ layoutUid ) ; $ parserRows = null ; if ( isset ( $ layout [ 'config' ] ) && isset ( $ layout [ 'config' ] [ 'rows.' ] ) ) { $ parserRows = $ layout [ 'config' ] [ 'rows.' ] ; } if ( is_array ( $ parserRows ) && ! empty ( $ parserRows ) ) { $ this -> setMultipleColPosValues ( $ parserRows , $ colPosValues , $ layout ) ; } else { $ singleColumn = true ; $ this -> setSingleColPosItems ( $ parentObject , $ colPosValues , $ gridElement ) ; } $ outerTtContentDataArray = $ parentObject -> tt_contentData [ 'nextThree' ] ; if ( ! empty ( $ colPosValues ) ) { $ this -> renderGridColumns ( $ parentObject , $ colPosValues , $ gridContent , $ gridElement , $ editUidList , $ singleColumn , $ head ) ; } $ parentObject -> tt_contentData [ 'nextThree' ] = $ outerTtContentDataArray ; if ( $ layoutUid && isset ( $ layout [ 'config' ] ) ) { $ itemContent = $ this -> renderGridLayoutTable ( $ layout , $ gridElement , $ head , $ gridContent , $ parentObject ) ; } else { $ itemContent = '<div class="t3-grid-container t3-grid-element-container">' ; $ itemContent .= '<table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table">' ; $ itemContent .= '<tr><td valign="top" class="t3-grid-cell t3-page-column t3-page-column-0">' . $ gridContent [ 0 ] . '</td></tr>' ; $ itemContent .= '</table></div>' ; } return $ itemContent ; } | renders the HTML output for elements of the CType gridelements_pi1 |
1,294 | protected function setMultipleColPosValues ( $ parserRows , & $ colPosValues , $ layout ) { if ( is_array ( $ parserRows ) ) { foreach ( $ parserRows as $ parserRow ) { if ( is_array ( $ parserRow [ 'columns.' ] ) && ! empty ( $ parserRow [ 'columns.' ] ) ) { foreach ( $ parserRow [ 'columns.' ] as $ parserColumns ) { $ name = $ this -> languageService -> sL ( $ parserColumns [ 'name' ] ) ; if ( isset ( $ parserColumns [ 'colPos' ] ) && $ parserColumns [ 'colPos' ] !== '' ) { $ columnKey = ( int ) $ parserColumns [ 'colPos' ] ; $ colPosValues [ $ columnKey ] = [ 'name' => $ name , 'allowed' => $ layout [ 'allowed' ] [ $ columnKey ] , 'disallowed' => $ layout [ 'disallowed' ] [ $ columnKey ] , 'maxitems' => $ layout [ 'maxitems' ] [ $ columnKey ] , ] ; } else { $ colPosValues [ 32768 ] = [ 'name' => $ this -> languageService -> getLL ( 'notAssigned' ) , 'allowed' => '' , 'disallowed' => '*' , 'maxitems' => 0 , ] ; } } } } } } | Sets column positions based on a selected gridelement layout |
1,295 | protected function setSingleColPosItems ( PageLayoutView $ parentObject , & $ colPosValues , & $ row ) { $ specificIds = $ this -> helper -> getSpecificIds ( $ row ) ; $ expressionBuilder = GeneralUtility :: makeInstance ( ConnectionPool :: class ) -> getQueryBuilderForTable ( 'tt_content' ) -> expr ( ) ; $ queryBuilder = $ parentObject -> getQueryBuilder ( 'tt_content' , $ specificIds [ 'pid' ] , [ $ expressionBuilder -> eq ( 'colPos' , - 1 ) , $ expressionBuilder -> in ( 'tx_gridelements_container' , [ ( int ) $ row [ 'uid' ] , $ specificIds [ 'uid' ] ] ) , ] ) ; $ restrictions = $ queryBuilder -> getRestrictions ( ) ; if ( $ this -> showHidden ) { $ restrictions -> removeByType ( HiddenRestriction :: class ) ; } $ restrictions -> removeByType ( StartTimeRestriction :: class ) ; $ restrictions -> removeByType ( EndTimeRestriction :: class ) ; $ queryBuilder -> setRestrictions ( $ restrictions ) ; $ colPosValues [ ] = [ 0 , '' ] ; return $ parentObject -> getResult ( $ queryBuilder -> execute ( ) ) ; } | Directly returns the items for a single column if the rendering mode is set to single columns only |
1,296 | protected function checkIfTranslationsExistInLanguage ( array $ contentElements , $ language , PageLayoutView $ parentObject ) { $ allowInconsistentLanguageHandling = BackendUtility :: getPagesTSconfig ( $ parentObject -> id ) [ 'mod.' ] [ 'web_layout.' ] [ 'allowInconsistentLanguageHandling' ] ?? [ ] ; if ( $ language === 0 || $ language === - 1 || $ allowInconsistentLanguageHandling [ 'value' ] === '1' ) { return false ; } if ( ! isset ( $ this -> languageHasTranslationsCache [ $ language ] ) ) { foreach ( $ contentElements as $ contentElement ) { if ( ( int ) $ contentElement [ 'l18n_parent' ] === 0 ) { $ this -> languageHasTranslationsCache [ $ language ] [ 'hasStandAloneContent' ] = true ; } if ( ( int ) $ contentElement [ 'l18n_parent' ] > 0 ) { $ this -> languageHasTranslationsCache [ $ language ] [ 'hasTranslations' ] = true ; } } if ( $ this -> languageHasTranslationsCache [ $ language ] [ 'hasStandAloneContent' ] && $ this -> languageHasTranslationsCache [ $ language ] [ 'hasTranslations' ] ) { $ message = GeneralUtility :: makeInstance ( FlashMessage :: class , sprintf ( $ this -> getLanguageService ( ) -> getLL ( 'staleTranslationWarning' ) , $ parentObject -> languageIconTitles [ $ language ] [ 'title' ] ) , sprintf ( $ this -> getLanguageService ( ) -> getLL ( 'staleTranslationWarningTitle' ) , $ parentObject -> languageIconTitles [ $ language ] [ 'title' ] ) , FlashMessage :: WARNING ) ; $ service = GeneralUtility :: makeInstance ( FlashMessageService :: class ) ; $ queue = $ service -> getMessageQueueByIdentifier ( ) ; $ queue -> enqueue ( $ message ) ; } } if ( $ this -> languageHasTranslationsCache [ $ language ] [ 'hasTranslations' ] ) { return true ; } return false ; } | Checks whether translated Content Elements exist in the desired language If so deny creating new ones via the UI |
1,297 | protected function renderSingleElementHTML ( PageLayoutView $ parentObject , $ item ) { $ singleElementHTML = '' ; $ unset = false ; if ( ! isset ( $ parentObject -> tt_contentData [ 'nextThree' ] [ $ item [ 'uid' ] ] ) ) { $ unset = true ; $ parentObject -> tt_contentData [ 'nextThree' ] [ $ item [ 'uid' ] ] = $ item [ 'uid' ] ; } if ( ! $ parentObject -> tt_contentConfig [ 'languageMode' ] ) { $ singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility :: getUniqueId ( ) . '">' ; } $ singleElementHTML .= $ parentObject -> tt_content_drawHeader ( $ item , $ parentObject -> tt_contentConfig [ 'showInfo' ] ? 15 : 5 , $ parentObject -> defLangBinding , true , true ) ; $ singleElementHTML .= ( ! empty ( $ item [ '_ORIG_uid' ] ) ? '<div class="ver-element">' : '' ) . '<div class="t3-page-ce-body-inner t3-page-ce-body-inner-' . $ item [ 'CType' ] . '">' . $ parentObject -> tt_content_drawItem ( $ item ) . '</div>' . ( ! empty ( $ item [ '_ORIG_uid' ] ) ? '</div>' : '' ) ; $ singleElementHTML .= $ this -> tt_content_drawFooter ( $ parentObject , $ item ) ; if ( ! $ parentObject -> tt_contentConfig [ 'languageMode' ] ) { $ singleElementHTML .= '</div>' ; } if ( $ unset ) { unset ( $ parentObject -> tt_contentData [ 'nextThree' ] [ $ item [ 'uid' ] ] ) ; } return $ singleElementHTML ; } | Renders the HTML code for a single tt_content element |
1,298 | protected function tt_content_drawFooter ( PageLayoutView $ parentObject , array $ row ) { $ content = '' ; $ info = [ ] ; $ parentObject -> getProcessedValue ( 'tt_content' , 'starttime,endtime,fe_group,space_before_class,space_after_class' , $ row , $ info ) ; if ( ! empty ( $ GLOBALS [ 'TCA' ] [ 'tt_content' ] [ 'ctrl' ] [ 'descriptionColumn' ] ) && ! empty ( $ row [ $ GLOBALS [ 'TCA' ] [ 'tt_content' ] [ 'ctrl' ] [ 'descriptionColumn' ] ] ) ) { $ info [ ] = htmlspecialchars ( $ row [ $ GLOBALS [ 'TCA' ] [ 'tt_content' ] [ 'ctrl' ] [ 'descriptionColumn' ] ] ) ; } foreach ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SC_OPTIONS' ] [ 'cms/layout/class.tx_cms_layout.php' ] [ 'tt_content_drawFooter' ] ?? [ ] as $ className ) { $ hookObject = GeneralUtility :: makeInstance ( $ className ) ; if ( ! $ hookObject instanceof PageLayoutViewDrawFooterHookInterface ) { throw new \ UnexpectedValueException ( $ className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface :: class , 1404378171 ) ; } $ hookObject -> preProcess ( $ parentObject , $ info , $ row ) ; } if ( ! empty ( $ info ) ) { $ content = '<div class="t3-page-ce-info"> ' . implode ( '<br>' , $ info ) . ' </div>' ; } if ( ! empty ( $ content ) ) { $ content = '<div class="t3-page-ce-footer">' . $ content . '</div>' ; } return $ content ; } | Draw the footer for a single tt_content element |
1,299 | protected function setColumnHeader ( PageLayoutView $ parentObject , & $ head , & $ colPos , & $ name , & $ editUidList , $ expanded = true ) { $ head [ $ colPos ] = $ this -> tt_content_drawColHeader ( $ name , ( $ parentObject -> doEdit && $ editUidList [ $ colPos ] ) ? '&edit[tt_content][' . $ editUidList [ $ colPos ] . ']=edit' : '' , $ parentObject , $ expanded ) ; } | Sets the headers for a grid before content and headers are put together |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.