idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
24,400 | protected function updatePlayer ( $ player ) { $ time = time ( ) ; $ upTime = $ time - $ this -> playerLastUpTime [ $ player -> getLogin ( ) ] ; $ this -> playerLastUpTime [ $ player -> getLogin ( ) ] = $ time ; $ player -> setOnlineTime ( $ player -> getOnlineTime ( ) + $ upTime ) ; } | Update player information . |
24,401 | public function getPlayer ( $ login ) { if ( isset ( $ this -> loggedInPlayers [ $ login ] ) ) { return $ this -> loggedInPlayers [ $ login ] ; } return $ this -> playerQueryBuilder -> findByLogin ( $ login ) ; } | Get data on a player . |
24,402 | public static function render ( Chart $ chart , array $ styleOptions = array ( ) ) { if ( empty ( self :: $ rendererChain ) ) { self :: pushRenderer ( '\Altamira\ChartRenderer\DefaultRenderer' ) ; } $ outputString = '' ; for ( $ i = count ( self :: $ rendererChain ) - 1 ; $ i >= 0 ; $ i -- ) { $ renderer = self :: $ rendererChain [ $ i ] ; $ outputString .= call_user_func_array ( array ( $ renderer , 'preRender' ) , array ( $ chart , $ styleOptions ) ) ; } for ( $ i = 0 ; $ i < count ( self :: $ rendererChain ) ; $ i ++ ) { $ renderer = self :: $ rendererChain [ $ i ] ; $ outputString .= call_user_func_array ( array ( $ renderer , 'postRender' ) , array ( $ chart , $ styleOptions ) ) ; } return $ outputString ; } | Renders a single chart by passing it through the renderer chain |
24,403 | public static function pushRenderer ( $ renderer ) { if ( ! in_array ( 'Altamira\ChartRenderer\RendererInterface' , class_implements ( $ renderer ) ) ) { throw new \ UnexpectedValueException ( "Renderer must be instance of or string name of a class implementing RendererInterface" ) ; } array_push ( self :: $ rendererChain , $ renderer ) ; return self :: getInstance ( ) ; } | Adds a renderer to the end of the renderer chain |
24,404 | public static function unshiftRenderer ( $ renderer ) { if ( ! in_array ( 'Altamira\ChartRenderer\RendererInterface' , class_implements ( $ renderer ) ) ) { throw new \ UnexpectedValueException ( "Renderer must be instance of or string name of a class implementing RendererInterface" ) ; } array_unshift ( self :: $ rendererChain , $ renderer ) ; return self :: getInstance ( ) ; } | Prepends a renderer to the beginning of renderer chain |
24,405 | public function createField ( $ fieldName , $ defaultValue = null ) { $ fieldType = $ this -> fieldType ; $ field = $ fieldType :: create ( $ fieldName , $ this -> Title , $ defaultValue ) ; $ field -> addExtraClass ( $ this -> ExtraClass ) ; $ this -> extend ( 'updateCreateField' , $ field ) ; return $ field ; } | Create the actual field Overwrite this on the field subclass |
24,406 | public function create ( $ group ) { if ( is_string ( $ group ) ) { $ group = $ this -> groupFactory -> createForPlayer ( $ group ) ; } else { if ( is_array ( $ group ) ) { $ group = $ this -> groupFactory -> createForPlayers ( $ group ) ; } } if ( ! is_null ( $ this -> guiHandler -> getManialink ( $ group , $ this ) ) ) { $ this -> update ( $ group ) ; return $ group ; } $ ml = $ this -> createManialink ( $ group ) ; $ this -> guiHandler -> addToDisplay ( $ ml , $ this ) ; $ this -> createContent ( $ ml ) ; $ this -> updateContent ( $ ml ) ; return $ group ; } | Creates a new manialink . |
24,407 | public function update ( $ group ) { if ( is_string ( $ group ) ) { $ group = $ this -> groupFactory -> createForPlayer ( $ group ) ; } else { if ( is_array ( $ group ) ) { $ group = $ this -> groupFactory -> createForPlayers ( $ group ) ; } } $ ml = $ this -> guiHandler -> getManialink ( $ group , $ this ) ; if ( $ ml ) { $ this -> actionFactory -> destroyNotPermanentActions ( $ ml ) ; if ( $ ml instanceof Window ) { $ ml -> busyCounter += 1 ; if ( $ ml -> isBusy && $ ml -> busyCounter > 1 ) { $ ml -> setBusy ( false ) ; } } $ this -> updateContent ( $ ml ) ; $ this -> guiHandler -> addToDisplay ( $ ml , $ this ) ; } } | Request an update for manialink . |
24,408 | public function destroy ( Group $ group ) { $ ml = $ this -> guiHandler -> getManialink ( $ group , $ this ) ; if ( $ ml ) { $ this -> guiHandler -> addToHide ( $ ml , $ this ) ; } } | Hides and frees manialink resources |
24,409 | protected function createManialink ( Group $ group ) { $ className = $ this -> className ; return new $ className ( $ this , $ group , $ this -> name , $ this -> sizeX , $ this -> sizeY , $ this -> posX , $ this -> posY ) ; } | Create manialink object for user group . |
24,410 | public function connect ( $ serverLogin , $ apikey ) { $ this -> apiKey = $ apikey ; $ this -> serverLogin = $ serverLogin ; if ( empty ( $ this -> apiKey ) ) { $ this -> console -> writeln ( 'MxKarma error: You need to define a api key' ) ; return ; } if ( empty ( $ this -> serverLogin ) ) { $ this -> console -> writeln ( 'MxKarma error: You need to define server login' ) ; return ; } $ params = [ "serverLogin" => $ serverLogin , "applicationIdentifier" => "eXpansion v " . AbstractApplication :: EXPANSION_VERSION , "testMode" => "false" , ] ; $ this -> console -> writeln ( '> MxKarma attempting to connect...' ) ; $ this -> http -> get ( $ this -> buildUrl ( "startSession" , $ params ) , [ $ this , "xConnect" ] ) ; } | connect to MX karma |
24,411 | public function loadVotes ( $ players = array ( ) , $ getVotesOnly = false ) { if ( ! $ this -> connected ) { $ this -> console -> writeln ( '> MxKarma trying to load votes when not connected: $ff0aborting!' ) ; return ; } $ this -> console -> writeln ( '> MxKarma attempting to load votes...' ) ; $ params = array ( "sessionKey" => $ this -> sessionKey ) ; $ postData = [ "gamemode" => $ this -> getGameMode ( ) , "titleid" => $ this -> gameDataStorage -> getVersion ( ) -> titleId , "mapuid" => $ this -> mapStorage -> getCurrentMap ( ) -> uId , "getvotesonly" => $ getVotesOnly , "playerlogins" => $ players , ] ; $ this -> http -> post ( $ this -> buildUrl ( "getMapRating" , $ params ) , json_encode ( $ postData ) , array ( $ this , "xGetRatings" ) , [ ] , $ this -> options ) ; } | loads votes from server |
24,412 | public function zip ( $ sSourceFile , $ sDestinationFile = null ) { if ( $ sDestinationFile === null ) $ sDestinationFile = $ this -> getDefaultDestinationFilename ( $ sSourceFile ) ; if ( ! ( $ fh = fopen ( $ sSourceFile , 'rb' ) ) ) throw new FileOpenException ( $ sSourceFile ) ; if ( ! ( $ zp = gzopen ( $ sDestinationFile , 'wb9' ) ) ) throw new FileOpenException ( $ sDestinationFile ) ; while ( ! feof ( $ fh ) ) { $ data = fread ( $ fh , static :: READ_SIZE ) ; if ( false === $ data ) throw new FileReadException ( $ sSourceFile ) ; $ sz = strlen ( $ data ) ; if ( $ sz !== gzwrite ( $ zp , $ data , $ sz ) ) throw new FileWriteException ( $ sDestinationFile ) ; } gzclose ( $ zp ) ; fclose ( $ fh ) ; return $ sDestinationFile ; } | Gzip a file |
24,413 | private function error ( OutputInterface $ output , $ message , $ args = array ( ) ) { $ output -> writeln ( '<error>' . sprintf ( $ message , $ args ) . '</error>' ) ; exit ( 0 ) ; } | Prints an info log message to the console with the warning message colour |
24,414 | public function requestRememberPasswordAction ( Request $ request , $ userClass ) { $ form = $ this -> get ( 'form.factory' ) -> createNamedBuilder ( '' , RequestRememberPasswordType :: class , null , [ 'csrf_protection' => false , ] ) -> getForm ( ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { try { $ this -> get ( 'bengor_user.' . $ userClass . '.api_command_bus' ) -> handle ( $ form -> getData ( ) ) ; return new JsonResponse ( ) ; } catch ( UserDoesNotExistException $ exception ) { return new JsonResponse ( sprintf ( 'The "%s" user email does not exist ' , $ form -> getData ( ) -> email ( ) ) , 400 ) ; } } return new JsonResponse ( FormErrorSerializer :: errors ( $ form ) , 400 ) ; } | Request remember user password action . |
24,415 | public function get ( $ key , $ default = null ) { if ( ! $ this -> id ) { throw new Exception ( 'Cannot use get without active session.' ) ; } return array_key_exists ( $ key , $ this -> data ) ? $ this -> data [ $ key ] : $ default ; } | Get a value from the session |
24,416 | public function id ( $ id = null ) { if ( $ id ) { if ( ! $ this -> isValidId ( $ id ) ) { throw new \ InvalidArgumentException ( '$id may contain only [a-zA-Z0-9-_]' ) ; } if ( $ this -> id ) { throw new Exception ( 'Cannot set id while session is active' ) ; } $ this -> requestedId = $ id ; } return $ this -> id ; } | Get the session ID or request an ID to be used when the session begins . |
24,417 | public function persistedDataExists ( $ id ) { if ( ! $ this -> id ) { $ this -> handler -> open ( $ this -> savePath , $ this -> name ) ; } $ ret = ( bool ) $ this -> handler -> read ( $ id ) ; if ( ! $ this -> id ) { $ this -> handler -> close ( ) ; } return $ ret ; } | Does the storage handler have data under this ID? |
24,418 | public function destroy ( $ removeCookie = false ) { if ( $ this -> id ) { if ( $ removeCookie ) { $ this -> removeCookie ( ) ; } $ this -> handler -> destroy ( $ this -> id ) ; $ this -> handler -> close ( ) ; $ this -> id = '' ; $ this -> data = null ; return true ; } return false ; } | Stop the session and destroy its persisted data . |
24,419 | public function regenerateId ( $ deleteOldSession = false ) { if ( headers_sent ( ) || ! $ this -> id ) { return false ; } $ oldId = $ this -> id ; $ this -> id = IdGenerator :: generateSessionId ( $ this -> idLength ) ; $ this -> setCookie ( $ this -> name , $ this -> id ) ; if ( $ oldId && $ deleteOldSession ) { $ this -> handler -> destroy ( $ oldId ) ; } return true ; } | Regenerate the session ID update the browser s cookie and optionally remove the previous ID s session storage . |
24,420 | public function removeCookie ( ) { return setcookie ( $ this -> name , '' , time ( ) - 86400 , $ this -> cookie_path , $ this -> cookie_domain , ( bool ) $ this -> cookie_secure , ( bool ) $ this -> cookie_httponly ) ; } | Remove the session cookie |
24,421 | protected function sendStartHeaders ( ) { $ lastModified = self :: formatAsGmt ( filemtime ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) ) ; $ ce = $ this -> cache_expire ; switch ( $ this -> cache_limiter ) { case self :: CACHE_LIMITER_PUBLIC : header ( 'Expires: ' . self :: formatAsGmt ( time ( ) + $ ce ) ) ; header ( "Cache-Control: public, max-age=$ce" ) ; header ( 'Last-Modified: ' . $ lastModified ) ; break ; case self :: CACHE_LIMITER_PRIVATE_NO_EXPIRE : header ( "Cache-Control: private, max-age=$ce, pre-check=$ce" ) ; header ( 'Last-Modified: ' . $ lastModified ) ; break ; case self :: CACHE_LIMITER_PRIVATE : header ( 'Expires: Thu, 19 Nov 1981 08:52:00 GMT' ) ; header ( "Cache-Control: private, max-age=$ce, pre-check=$ce" ) ; header ( 'Last-Modified: ' . $ lastModified ) ; break ; case self :: CACHE_LIMITER_NOCACHE : header ( 'Expires: Thu, 19 Nov 1981 08:52:00 GMT' ) ; header ( 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Pragma: no-cache' ) ; break ; case self :: CACHE_LIMITER_NONE : break ; } } | Send headers based on cache_limiter and cache_expire properties |
24,422 | public function validate ( $ value , $ constraints = null , $ groups = null ) { return $ this -> decoratedValidator -> validate ( $ value , $ constraints , $ groups ) ; } | Validates a value against a constraint or a list of constraints . |
24,423 | public function validateProperty ( $ object , $ propertyName , $ groups = null ) { return $ this -> decoratedValidator -> validateProperty ( $ object , $ propertyName , $ groups ) ; } | Validates a property of an object against the constraints specified for this property . |
24,424 | public function validatePropertyValue ( $ objectOrClass , $ propertyName , $ value , $ groups = null ) { return $ this -> decoratedValidator -> validatePropertyValue ( $ objectOrClass , $ propertyName , $ value , $ groups ) ; } | Validates a value against the constraints specified for an object s property . |
24,425 | public function isHtml ( ) { $ ext = $ this -> _controller -> request -> param ( 'ext' ) ; if ( empty ( $ ext ) ) { return true ; } $ prefers = $ this -> _controller -> RequestHandler -> prefers ( ) ; if ( empty ( $ prefers ) ) { $ prefers = 'html' ; } $ responseMimeType = $ this -> _controller -> response -> getMimeType ( $ prefers ) ; if ( ! $ responseMimeType ) { return false ; } return in_array ( 'text/html' , ( array ) $ responseMimeType ) ; } | Checking the response is HTML . |
24,426 | protected function _addSpecificResponse ( Controller & $ controller ) { $ controller -> response -> type ( [ 'sse' => 'text/event-stream' ] ) ; $ controller -> response -> type ( [ 'mod' => 'text/html' ] ) ; $ controller -> response -> type ( [ 'pop' => 'text/html' ] ) ; $ controller -> response -> type ( [ 'prt' => 'text/html' ] ) ; } | Adding response for SSE print preview modal and popup request |
24,427 | protected function _setUiLangVar ( Controller & $ controller ) { $ uiLcid2 = $ this -> _language -> getCurrentUiLang ( true ) ; $ uiLcid3 = $ this -> _language -> getCurrentUiLang ( false ) ; $ controller -> set ( compact ( 'uiLcid2' , 'uiLcid3' ) ) ; } | Set global variable of current UI language |
24,428 | protected function _setLayout ( Controller & $ controller ) { $ isModal = $ controller -> request -> is ( 'modal' ) ; $ isPopup = $ controller -> request -> is ( 'popup' ) ; $ isSSE = $ controller -> request -> is ( 'sse' ) ; $ isPrint = $ controller -> request -> is ( 'print' ) ; if ( $ isModal || $ isPopup || $ isSSE ) { $ controller -> layout = 'CakeTheme.default' ; } elseif ( $ isPrint ) { $ controller -> viewPath = mb_ereg_replace ( DS . 'prt' , '' , $ controller -> viewPath ) ; $ controller -> response -> type ( 'html' ) ; } } | Set layout for SSE modal and popup response |
24,429 | protected function _getSessionKeyRedirect ( $ key = null ) { if ( empty ( $ key ) ) { $ key = $ this -> _controller -> request -> here ( ) ; } $ cacheKey = md5 ( ( string ) $ key ) ; return $ cacheKey ; } | Return MD5 cache key from key string |
24,430 | public function setRedirectUrl ( $ redirect = null , $ key = null ) { if ( empty ( $ redirect ) ) { $ redirect = $ this -> _controller -> request -> referer ( true ) ; } elseif ( $ redirect === true ) { $ redirect = $ this -> _controller -> request -> here ( true ) ; } if ( empty ( $ redirect ) || $ this -> _controller -> request -> is ( 'popup' ) || $ this -> _controller -> request -> is ( 'print' ) ) { return false ; } $ cacheKey = $ this -> _getSessionKeyRedirect ( $ key ) ; $ data = CakeSession :: read ( $ cacheKey ) ; if ( ! empty ( $ data ) && ( md5 ( ( string ) $ data ) === md5 ( ( string ) $ redirect ) ) ) { return false ; } return CakeSession :: write ( $ cacheKey , $ redirect ) ; } | Set redirect URL to cache |
24,431 | protected function _getRedirectCache ( $ key = null ) { $ cacheKey = $ this -> _getSessionKeyRedirect ( $ key ) ; $ redirect = CakeSession :: consume ( $ cacheKey ) ; return $ redirect ; } | Get redirect URL from cache |
24,432 | public function getRedirectUrl ( $ defaultRedirect = null , $ key = null ) { $ redirect = $ this -> _getRedirectCache ( $ key ) ; if ( empty ( $ redirect ) ) { if ( ! empty ( $ defaultRedirect ) ) { if ( $ defaultRedirect === true ) { $ redirect = $ this -> _controller -> request -> here ( ) ; } else { $ redirect = $ defaultRedirect ; } } else { $ redirect = [ 'action' => 'index' ] ; } } return $ redirect ; } | Get redirect URL |
24,433 | public function redirectByUrl ( $ defaultRedirect = null , $ key = null ) { $ redirectUrl = $ this -> getRedirectUrl ( $ defaultRedirect , $ key ) ; return $ this -> _controller -> redirect ( $ redirectUrl ) ; } | Redirect by URL |
24,434 | protected function _setLocale ( ) { $ language = $ this -> _language -> getCurrentUiLang ( false ) ; return ( bool ) setlocale ( LC_ALL , $ language ) ; } | Set locale for current UI language . |
24,435 | public function setProgressSseTask ( $ taskName = null ) { if ( empty ( $ taskName ) ) { return false ; } $ tasks = ( array ) CakeSession :: read ( 'SSE.progress' ) ; if ( in_array ( $ taskName , $ tasks ) ) { return true ; } $ tasks [ ] = $ taskName ; return CakeSession :: write ( 'SSE.progress' , $ tasks ) ; } | Set task to display the progress of execution from task queue |
24,436 | public function setExceptionMessage ( $ message = '' , $ defaultRedirect = null , $ key = null ) { $ statusCode = null ; $ redirectUrl = null ; if ( $ message instanceof Exception ) { if ( $ this -> _controller -> request -> is ( 'ajax' ) ) { $ statusCode = $ message -> getCode ( ) ; } } if ( empty ( $ statusCode ) ) { $ this -> _controller -> Flash -> error ( $ message ) ; $ redirectUrl = $ this -> getRedirectUrl ( $ defaultRedirect , $ key ) ; } return $ this -> _controller -> redirect ( $ redirectUrl , $ statusCode ) ; } | Set Flash message of exception |
24,437 | public function callbackApply ( ManialinkInterface $ manialink , $ login , $ entries , $ args ) { $ grid = $ manialink -> getData ( 'grid' ) ; $ grid -> updateDataCollection ( $ entries ) ; $ settings = [ ] ; foreach ( $ grid -> getDataCollection ( ) -> getAll ( ) as $ key => $ value ) { $ settings [ $ value [ 'name' ] ] = $ value [ 'value' ] ; } try { $ this -> factory -> getConnection ( ) -> setModeScriptSettings ( $ settings ) ; $ this -> closeManialink ( $ manialink ) ; } catch ( \ Exception $ ex ) { $ this -> factory -> getConnection ( ) -> chatSendServerMessage ( "error: " . $ ex -> getMessage ( ) ) ; $ this -> console -> writeln ( '$f00Error: $fff' . $ ex -> getMessage ( ) ) ; } } | Callback for apply button |
24,438 | public function fetchScriptSettings ( ) { $ data = [ ] ; $ scriptSettings = $ this -> factory -> getConnection ( ) -> getModeScriptSettings ( ) ; $ i = 1 ; foreach ( $ scriptSettings as $ name => $ value ) { $ data [ ] = [ 'index' => $ i ++ , 'name' => $ name , 'value' => $ value , ] ; } return $ data ; } | helper function to fetch script settings |
24,439 | public function processRecord ( $ login , $ score , $ checkpoints ) { if ( $ this -> enabled -> get ( ) == false ) { return false ; } if ( $ this -> isDisabled ( ) ) { return false ; } $ tempRecords = $ this -> recordsByLogin ; $ tempPositions = $ this -> ranksByLogin ; if ( isset ( $ this -> recordsByLogin [ $ login ] ) ) { $ record = $ this -> recordsByLogin [ $ login ] ; } else { $ record = new DedimaniaRecord ( $ login ) ; $ pla = $ this -> playerStorage -> getPlayerInfo ( $ login ) ; $ record -> nickName = $ pla -> getNickName ( ) ; } $ tempRecords [ $ login ] = clone $ record ; $ oldRecord = clone $ record ; if ( $ score < $ oldRecord -> best || $ oldRecord -> best == - 1 ) { $ record -> best = $ score ; $ record -> checks = implode ( "," , $ checkpoints ) ; $ tempRecords [ $ login ] = $ record ; uasort ( $ tempRecords , [ $ this , "compare" ] ) ; if ( ! isset ( $ this -> players [ $ login ] ) ) { echo "player $login not connected\n" ; return false ; } $ player = $ this -> players [ $ login ] ; $ rank = 1 ; $ newRecord = false ; foreach ( $ tempRecords as $ key => $ tempRecord ) { $ tempRecords [ $ key ] -> rank = $ rank ; $ tempPositions [ $ key ] = $ rank ; if ( $ tempRecord -> login == $ login && ( $ rank <= $ this -> serverMaxRank || $ rank <= $ player -> maxRank ) && $ rank < 100 ) { $ newRecord = $ tempRecords [ $ login ] ; } $ rank ++ ; } $ tempRecords = array_slice ( $ tempRecords , 0 , 100 , true ) ; $ tempPositions = array_slice ( $ tempPositions , 0 , 100 , true ) ; if ( $ newRecord ) { $ this -> recordsByLogin = $ tempRecords ; $ outRecords = usort ( $ tempRecords , [ $ this , 'compare' ] ) ; $ this -> ranksByLogin = $ tempPositions ; $ params = [ $ newRecord , $ oldRecord , $ outRecords , $ newRecord -> rank , $ oldRecord -> rank , ] ; $ this -> dispatcher -> dispatch ( "expansion.dedimania.records.update" , [ $ params ] ) ; return $ newRecord ; } } return false ; } | Check and Add a new record if needed |
24,440 | public function onVoteNew ( Player $ player , $ cmdName , $ cmdValue ) { if ( $ cmdValue instanceof Vote ) { $ this -> updateVoteWidgetFactory -> create ( $ this -> players ) ; $ this -> voteWidgetFactory -> create ( $ this -> players ) ; } else { $ this -> voteService -> startVote ( $ player , $ cmdName , [ 'value' => $ cmdValue ] ) ; } } | When a new vote is addressed |
24,441 | public function onVoteCancelled ( Player $ player , $ cmdName , $ cmdValue ) { if ( $ cmdValue instanceof Vote ) { $ this -> voteWidgetFactory -> destroy ( $ this -> players ) ; $ this -> updateVoteWidgetFactory -> destroy ( $ this -> players ) ; } else { $ this -> voteService -> cancel ( ) ; } } | When vote gets cancelled |
24,442 | public function onVoteNo ( Player $ player , $ vote ) { if ( $ this -> voteService -> getCurrentVote ( ) instanceof AbstractVotePlugin ) { $ this -> updateVoteWidgetFactory -> updateVote ( $ vote ) ; } } | When vote Fails |
24,443 | protected function _getBehaviorConfig ( Model $ model , $ configParam = null ) { if ( empty ( $ configParam ) || ! isset ( $ model -> Behaviors -> Tree -> settings [ $ model -> alias ] [ $ configParam ] ) ) { return null ; } $ result = $ model -> Behaviors -> Tree -> settings [ $ model -> alias ] [ $ configParam ] ; return $ result ; } | Return value of configuration behavior by parameter . |
24,444 | protected function _changeParent ( Model $ model , $ id = null , $ parentId = null ) { $ parentField = $ this -> _getBehaviorConfig ( $ model , 'parent' ) ; if ( empty ( $ id ) || ( $ parentField === null ) ) { return false ; } $ model -> recursive = - 1 ; $ treeItem = $ model -> read ( null , $ id ) ; if ( empty ( $ treeItem ) ) { return false ; } $ treeItem [ $ model -> alias ] [ $ parentField ] = $ parentId ; $ result = ( bool ) $ model -> save ( $ treeItem ) ; return $ result ; } | Change parent ID of item . |
24,445 | protected function _getSubTree ( Model $ model , $ id = null ) { $ result = [ ] ; $ parentField = $ this -> _getBehaviorConfig ( $ model , 'parent' ) ; $ leftField = $ this -> _getBehaviorConfig ( $ model , 'left' ) ; if ( ( $ parentField === null ) || ( $ leftField === null ) ) { return $ result ; } $ conditions = [ $ model -> alias . '.' . $ parentField => null ] ; if ( ! empty ( $ id ) ) { $ conditions [ $ model -> alias . '.' . $ parentField ] = ( int ) $ id ; } if ( $ model -> Behaviors -> Tree -> settings [ $ model -> alias ] [ 'scope' ] !== '1 = 1' ) { $ conditions [ ] = $ model -> Behaviors -> Tree -> settings [ $ model -> alias ] [ 'scope' ] ; } $ fields = [ $ model -> alias . '.' . $ model -> primaryKey , ] ; $ order = [ $ model -> alias . '.' . $ leftField => 'asc' ] ; $ model -> recursive = - 1 ; $ data = $ model -> find ( 'list' , compact ( 'conditions' , 'fields' , 'order' ) ) ; if ( ! empty ( $ data ) ) { $ result = array_keys ( $ data ) ; } return $ result ; } | Return list ID of subtree for item . |
24,446 | public function moveItem ( Model $ model , $ direct = null , $ id = null , $ delta = 1 ) { $ direct = mb_strtolower ( $ direct ) ; $ delta = ( int ) $ delta ; if ( in_array ( $ direct , [ 'up' , 'down' ] ) && ( $ delta < 0 ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Invalid delta for moving record' ) ) ; } if ( ! in_array ( $ direct , [ 'top' , 'up' , 'down' , 'bottom' ] ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Invalid direction for moving record' ) ) ; } switch ( $ direct ) { case 'top' : $ delta = true ; case 'up' : $ method = 'moveUp' ; break ; case 'bottom' : $ delta = true ; case 'down' : $ method = 'moveDown' ; break ; } $ newParentId = null ; $ optionsEvent = compact ( 'id' , 'newParentId' , 'method' , 'delta' ) ; $ event = new CakeEvent ( 'Model.beforeUpdateTree' , $ model , [ $ optionsEvent ] ) ; $ model -> getEventManager ( ) -> dispatch ( $ event ) ; if ( $ event -> isStopped ( ) ) { return false ; } $ result = $ model -> $ method ( $ id , $ delta ) ; if ( $ result ) { $ event = new CakeEvent ( 'Model.afterUpdateTree' , $ model ) ; $ model -> getEventManager ( ) -> dispatch ( $ event ) ; } return $ result ; } | Move item to new position of tree |
24,447 | public function moveDrop ( Model $ model , $ id = null , $ newParentId = null , $ oldParentId = null , $ dropData = null ) { if ( empty ( $ id ) ) { return false ; } $ changeRoot = false ; $ dataSource = $ model -> getDataSource ( ) ; $ dataSource -> begin ( ) ; if ( $ newParentId != $ oldParentId ) { $ changeRoot = true ; if ( ! $ this -> _changeParent ( $ model , $ id , $ newParentId ) ) { $ dataSource -> rollback ( ) ; return false ; } } $ newDataList = [ ] ; if ( ! empty ( $ dropData ) && is_array ( $ dropData ) ) { $ newDataList = Hash :: extract ( $ dropData , '0.{n}.id' ) ; } $ oldDataList = $ this -> _getSubTree ( $ model , $ newParentId ) ; if ( $ newDataList == $ oldDataList ) { if ( ! $ changeRoot ) { return true ; } $ dataSource -> rollback ( ) ; return false ; } $ indexNew = array_search ( $ id , $ newDataList ) ; $ indexOld = array_search ( $ id , $ oldDataList ) ; if ( ( $ indexNew === false ) || ( $ indexOld === false ) ) { return false ; } $ delta = $ indexNew - $ indexOld ; $ method = 'moveDown' ; if ( $ delta < 0 ) { $ delta *= - 1 ; $ method = 'moveUp' ; } $ optionsEvent = compact ( 'id' , 'newParentId' , 'method' , 'delta' ) ; $ event = new CakeEvent ( 'Model.beforeUpdateTree' , $ model , [ $ optionsEvent ] ) ; $ model -> getEventManager ( ) -> dispatch ( $ event ) ; if ( $ event -> isStopped ( ) ) { $ dataSource -> rollback ( ) ; return false ; } $ result = $ model -> $ method ( $ id , $ delta ) ; if ( $ result ) { $ dataSource -> commit ( ) ; $ event = new CakeEvent ( 'Model.afterUpdateTree' , $ model ) ; $ model -> getEventManager ( ) -> dispatch ( $ event ) ; } else { $ dataSource -> rollback ( ) ; } return $ result ; } | Move item to new position of tree use drag and drop . |
24,448 | public function _wp_oembed_blog_card_render ( ) { if ( empty ( $ _GET [ 'url' ] ) ) { return ; } header ( 'Content-Type: text/html; charset=utf-8' ) ; $ url = esc_url_raw ( wp_unslash ( $ _GET [ 'url' ] ) ) ; echo wp_kses_post ( View :: get_template ( $ url ) ) ; die ( ) ; } | Render blog card with ajax |
24,449 | public function getLastPeriodOfFiscalYear ( array $ input ) { $ period = $ this -> Period -> lastPeriodbyOrganizationAndByFiscalYear ( $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) , $ input [ 'id' ] ) -> toArray ( ) ; $ period [ 'endDate' ] = $ this -> Carbon -> createFromFormat ( 'Y-m-d' , $ period [ 'end_date' ] ) -> format ( $ this -> Lang -> get ( 'form.phpShortDateFormat' ) ) ; unset ( $ period [ 'end_date' ] ) ; $ period [ 'month' ] = $ period [ 'month' ] . ' - ' . $ this -> Lang -> get ( 'decima-accounting::period-management.' . $ period [ 'month' ] ) ; return json_encode ( $ period ) ; } | Get last period of fiscal year |
24,450 | public function getCurrentMonthPeriod ( $ organizationId = null ) { if ( empty ( $ organizationId ) ) { $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; } $ fiscalYearId = $ this -> FiscalYear -> lastFiscalYearByOrganization ( $ organizationId ) ; $ Date = new Carbon ( 'first day of this month' ) ; $ Date2 = new Carbon ( 'last day of this month' ) ; return $ this -> Period -> periodByStardDateByEndDateByFiscalYearAndByOrganizationId ( $ Date -> format ( 'Y-m-d' ) , $ Date2 -> format ( 'Y-m-d' ) , $ fiscalYearId , $ organizationId ) ; } | Get current month period |
24,451 | public function getPeriodByDateAndByOrganizationId ( $ date , $ organizationId = null , $ databaseConnectionName = null ) { if ( empty ( $ organizationId ) ) { $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; } return $ this -> Period -> periodByDateAndByOrganizationId ( $ date , $ organizationId , $ databaseConnectionName ) ; } | Get period by date |
24,452 | public function getBalanceAccountsClosingPeriods ( array $ input ) { $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; $ fiscalYearId = $ this -> FiscalYear -> lastFiscalYearByOrganization ( $ organizationId ) ; if ( $ fiscalYearId == $ input [ 'id' ] ) { return json_encode ( array ( 'info' => $ this -> Lang -> get ( 'decima-accounting::period-management.invalidFiscalYear' ) ) ) ; } $ period = json_decode ( $ this -> getLastPeriodOfFiscalYear ( $ input ) , true ) ; $ FiscalYear = $ this -> FiscalYear -> byId ( $ input [ 'id' ] ) ; $ FiscalYear = $ this -> FiscalYear -> byYearAndByOrganization ( $ FiscalYear -> year + 1 , $ organizationId ) ; $ period2 = $ this -> Period -> firstPeriodbyOrganizationAndByFiscalYear ( $ this -> AuthenticationManager -> getCurrentUserOrganizationId ( ) , $ FiscalYear -> id ) -> toArray ( ) ; $ period2 [ 'endDate' ] = $ this -> Carbon -> createFromFormat ( 'Y-m-d' , $ period2 [ 'end_date' ] ) -> format ( $ this -> Lang -> get ( 'form.phpShortDateFormat' ) ) ; unset ( $ period2 [ 'end_date' ] ) ; $ period2 [ 'month' ] = $ period2 [ 'month' ] . ' - ' . $ this -> Lang -> get ( 'decima-accounting::period-management.' . $ period2 [ 'month' ] ) ; return json_encode ( array ( 'id0' => $ period [ 'id' ] , 'month0' => $ period [ 'month' ] , 'endDate0' => $ period [ 'endDate' ] , 'id1' => $ period2 [ 'id' ] , 'month1' => $ period2 [ 'month' ] , 'endDate1' => $ period2 [ 'endDate' ] , 'fiscalYearId' => $ FiscalYear -> id ) ) ; } | Get last period of fiscal year and first period of the next fiscal year |
24,453 | public function openPeriod ( array $ input ) { $ this -> DB -> transaction ( function ( ) use ( $ input ) { $ loggedUserId = $ this -> AuthenticationManager -> getLoggedUserId ( ) ; $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; $ Period = $ this -> Period -> byId ( $ input [ 'id' ] ) ; $ Journal = $ this -> Journal -> create ( array ( 'journalized_id' => $ input [ 'id' ] , 'journalized_type' => $ this -> Period -> getTable ( ) , 'user_id' => $ loggedUserId , 'organization_id' => $ organizationId ) ) ; $ this -> Journal -> attachDetail ( $ Journal -> id , array ( 'note' => $ this -> Lang -> get ( 'decima-accounting::period-management.periodOpenedJournal' , array ( 'period' => $ this -> Lang -> get ( 'decima-accounting::period-management.' . $ Period -> month ) ) ) , $ Journal ) ) ; $ this -> Period -> update ( array ( 'is_closed' => false ) , $ Period ) ; } ) ; return json_encode ( array ( 'success' => $ this -> Lang -> get ( 'form.defaultSuccessOperationMessage' ) , 'periods' => $ this -> getPeriods ( ) , 'periodsFilter' => $ this -> getPeriods2 ( ) ) ) ; } | Open an existing period |
24,454 | public function closePeriod ( array $ input ) { $ canBeClosed = true ; $ this -> DB -> transaction ( function ( ) use ( $ input , & $ canBeClosed ) { $ loggedUserId = $ this -> AuthenticationManager -> getLoggedUserId ( ) ; $ organizationId = $ this -> AuthenticationManager -> getCurrentUserOrganization ( 'id' ) ; if ( $ this -> JournalVoucher -> getByOrganizationByPeriodAndByStatus ( $ organizationId , array ( $ input [ 'id' ] ) , 'A' ) -> count ( ) > 0 ) { $ canBeClosed = false ; return ; } $ Period = $ this -> Period -> byId ( $ input [ 'id' ] ) ; $ Journal = $ this -> Journal -> create ( array ( 'journalized_id' => $ input [ 'id' ] , 'journalized_type' => $ this -> Period -> getTable ( ) , 'user_id' => $ loggedUserId , 'organization_id' => $ organizationId ) ) ; $ this -> Journal -> attachDetail ( $ Journal -> id , array ( 'note' => $ this -> Lang -> get ( 'decima-accounting::period-management.periodClosedJournal' , array ( 'period' => $ this -> Lang -> get ( 'decima-accounting::period-management.' . $ Period -> month ) ) ) , $ Journal ) ) ; $ this -> Period -> update ( array ( 'is_closed' => true ) , $ Period ) ; } ) ; if ( ! $ canBeClosed ) { return json_encode ( array ( 'success' => false , 'info' => $ this -> Lang -> get ( 'decima-accounting::period-management.voucherException' ) ) ) ; } return json_encode ( array ( 'success' => $ this -> Lang -> get ( 'form.defaultSuccessOperationMessage' ) , 'periods' => $ this -> getPeriods ( ) , 'periodsFilter' => $ this -> getPeriods2 ( ) ) ) ; } | Close an existing period |
24,455 | public function get_signable_parameters ( ) { $ params = $ this -> parameters ; if ( isset ( $ params [ 'oauth_signature' ] ) ) { unset ( $ params [ 'oauth_signature' ] ) ; } $ keys = OAuthUtil :: urlencode_rfc3986 ( array_keys ( $ params ) ) ; $ values = OAuthUtil :: urlencode_rfc3986 ( array_values ( $ params ) ) ; $ params = array_combine ( $ keys , $ values ) ; uksort ( $ params , 'strcmp' ) ; $ pairs = array ( ) ; foreach ( $ params as $ key => $ value ) { if ( is_array ( $ value ) ) { natsort ( $ value ) ; foreach ( $ value as $ v2 ) { $ pairs [ ] = $ key . '=' . $ v2 ; } } else { $ pairs [ ] = $ key . '=' . $ value ; } } return implode ( '&' , $ pairs ) ; } | Returns the normalized parameters of the request |
24,456 | public function to_postdata ( ) { $ total = array ( ) ; foreach ( $ this -> parameters as $ k => $ v ) { if ( is_array ( $ v ) ) { foreach ( $ v as $ va ) { $ total [ ] = OAuthUtil :: urlencode_rfc3986 ( $ k ) . "[]=" . OAuthUtil :: urlencode_rfc3986 ( $ va ) ; } } else { $ total [ ] = OAuthUtil :: urlencode_rfc3986 ( $ k ) . "=" . OAuthUtil :: urlencode_rfc3986 ( $ v ) ; } } $ out = implode ( "&" , $ total ) ; return $ out ; } | builds the data one would send in a POST request |
24,457 | protected function buildValidationRules ( ) { $ rules = new RuleList ( ) ; $ options = $ this -> getOptions ( ) ; $ options [ self :: OPTION_ENTITY_TYPES ] = $ this -> getEmbeddedEntityTypeMap ( ) ; $ rules -> push ( new EmbeddedEntityListRule ( 'valid-embedded-entity-list-data' , $ options ) ) ; return $ rules ; } | Return a list of rules used to validate a specific attribute instance s value . |
24,458 | public function getScripts ( ) { $ retVal = '' ; while ( $ this -> scripts -> valid ( ) ) { $ retVal .= "<script type='text/javascript'>\n{$this->scripts->get()}\n</script>\n" ; $ this -> scripts -> next ( ) ; } return $ retVal ; } | Returns inline js in case you don t want to immediately render . |
24,459 | public function getLibraries ( ) { $ config = \ Altamira \ Config :: getInstance ( ) ; $ libraryToPath = array ( \ Altamira \ JsWriter \ Flot :: LIBRARY => $ config [ 'js.flotlib' ] , \ Altamira \ JsWriter \ JqPlot :: LIBRARY => $ config [ 'js.jqplotlib' ] ) ; $ libraryKeys = array_unique ( array_keys ( $ this -> libraries ) ) ; $ libraryPaths = array ( ) ; foreach ( $ libraryKeys as $ key ) { $ libraryPaths [ ] = $ libraryToPath [ $ key ] ; } return $ libraryPaths ; } | Provides libraries paths based on config values |
24,460 | public function renderCss ( ) { $ config = \ Altamira \ Config :: getInstance ( ) ; foreach ( $ this -> libraries as $ library => $ junk ) { switch ( $ library ) { case \ Altamira \ JsWriter \ Flot :: LIBRARY : break ; case \ Altamira \ JsWriter \ JqPlot :: LIBRARY : default : $ cssPath = $ config [ 'css.jqplotpath' ] ; } } if ( isset ( $ cssPath ) ) { echo "<link rel='stylesheet' type='text/css' href='{$cssPath}'></link>" ; } return $ this ; } | Echoes any CSS that is needed for the libraries to render correctly |
24,461 | protected function getForm ( $ configPath ) { $ form = null ; $ melisConfig = $ this -> serviceLocator -> get ( 'MelisInstallerConfig' ) ; $ formConfig = $ melisConfig -> getItem ( $ configPath ) ; if ( $ formConfig ) { $ factory = new \ Zend \ Form \ Factory ( ) ; $ formElements = $ this -> getServiceLocator ( ) -> get ( 'FormElementManager' ) ; $ factory -> setFormElementManager ( $ formElements ) ; $ form = $ factory -> createForm ( $ formConfig ) ; } return $ form ; } | Retrieves the array configuration from app . forms |
24,462 | protected function systemConfigurationChecker ( ) { $ response = [ ] ; $ data = [ ] ; $ errors = [ ] ; $ dataExt = [ ] ; $ dataVar = [ ] ; $ checkDataExt = 0 ; $ success = 0 ; $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ installHelper = $ this -> getServiceLocator ( ) -> get ( 'InstallerHelper' ) ; $ installHelper -> setRequiredExtensions ( [ 'openssl' , 'json' , 'pdo_mysql' , 'intl' , ] ) ; foreach ( $ installHelper -> getRequiredExtensions ( ) as $ ext ) { if ( in_array ( $ ext , $ installHelper -> getPhpExtensions ( ) ) ) { $ dataExt [ $ ext ] = $ installHelper -> isExtensionsExists ( $ ext ) ; } else { $ dataExt [ $ ext ] = sprintf ( $ translator -> translate ( 'tr_melis_installer_step_1_0_extension_not_loaded' ) , $ ext ) ; } } $ dataVar = $ installHelper -> checkEnvironmentVariables ( ) ; if ( ! empty ( $ dataExt ) ) { foreach ( $ dataExt as $ ext => $ status ) { if ( ( int ) $ status === 1 ) { $ checkDataExt = 1 ; } else { $ checkDataExt = 0 ; } } } if ( ! empty ( $ dataVar ) ) { foreach ( $ dataVar as $ var => $ value ) { $ currentVal = trim ( $ value ) ; if ( is_null ( $ currentVal ) ) { $ dataVar [ $ var ] = sprintf ( $ translator -> translate ( 'tr_melis_installer_step_1_0_php_variable_not_set' ) , $ var ) ; array_push ( $ errors , sprintf ( $ translator -> translate ( 'tr_melis_installer_step_1_0_php_variable_not_set' ) , $ var ) ) ; } elseif ( $ currentVal || $ currentVal == '0' || $ currentVal == '-1' ) { $ dataVar [ $ var ] = 1 ; } } } else { array_push ( $ errors , $ translator -> translate ( 'tr_melis_installer_step_1_0_php_requied_variables_empty' ) ) ; } if ( empty ( $ errors ) && $ checkDataExt === 1 ) { $ success = 1 ; } $ response = [ 'success' => $ success , 'errors' => $ errors , 'data' => [ 'extensions' => $ dataExt , 'variables' => $ dataVar , ] , ] ; return $ response ; } | Checks the PHP Environment and Variables |
24,463 | protected function vHostSetupChecker ( ) { $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ success = 0 ; $ error = [ ] ; $ platform = null ; $ module = null ; if ( ! empty ( getenv ( 'MELIS_PLATFORM' ) ) ) { $ platform = getenv ( 'MELIS_PLATFORM' ) ; } else { $ error [ 'platform' ] = $ translator -> translate ( 'tr_melis_installer_step_1_1_no_paltform_declared' ) ; } if ( ! empty ( getenv ( 'MELIS_MODULE' ) ) ) { $ module = getenv ( 'MELIS_MODULE' ) ; } else { $ error [ 'module' ] = $ translator -> translate ( 'tr_melis_installer_step_1_1_no_module_declared' ) ; } if ( empty ( $ error ) ) { $ success = 1 ; } $ response = [ 'success' => $ success , 'errors' => $ error , 'data' => [ 'platform' => $ platform , 'module' => $ module , ] , ] ; return $ response ; } | Checks if the Vhost platform and module variable are set |
24,464 | protected function checkDirectoryRights ( ) { $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ installHelper = $ this -> getServiceLocator ( ) -> get ( 'InstallerHelper' ) ; $ configDir = $ installHelper -> getDir ( 'config' ) ; $ module = $ this -> getModuleSvc ( ) -> getAllModules ( ) ; $ success = 0 ; $ errors = [ ] ; $ data = [ ] ; for ( $ x = 0 ; $ x < count ( $ configDir ) ; $ x ++ ) { $ configDir [ $ x ] = 'config/' . $ configDir [ $ x ] ; } array_push ( $ configDir , 'config' ) ; array_push ( $ configDir , 'config/autoload/platforms/' ) ; array_push ( $ configDir , 'module/MelisModuleConfig/' ) ; array_push ( $ configDir , 'module/MelisModuleConfig/languages' ) ; array_push ( $ configDir , 'module/MelisModuleConfig/config' ) ; array_push ( $ configDir , 'module/MelisSites/' ) ; array_push ( $ configDir , 'dbdeploy/' ) ; array_push ( $ configDir , 'dbdeploy/data' ) ; array_push ( $ configDir , 'public/' ) ; array_push ( $ configDir , 'cache/' ) ; array_push ( $ configDir , 'test/' ) ; for ( $ x = 0 ; $ x < count ( $ module ) ; $ x ++ ) { $ module [ $ x ] = $ this -> getModuleSvc ( ) -> getModulePath ( $ module [ $ x ] , false ) . '/config' ; } $ dirs = array_merge ( $ configDir , $ module ) ; $ results = [ ] ; foreach ( $ dirs as $ dir ) { if ( file_exists ( $ dir ) ) { if ( $ installHelper -> isDirWritable ( $ dir ) ) { $ results [ $ dir ] = 1 ; } else { $ results [ $ dir ] = sprintf ( $ translator -> translate ( 'tr_melis_installer_step_1_2_dir_not_writable' ) , $ dir ) ; array_push ( $ errors , sprintf ( $ translator -> translate ( 'tr_melis_installer_step_1_2_dir_not_writable' ) , $ dir ) ) ; } } } if ( empty ( $ errors ) ) { $ success = 1 ; } $ response = [ 'success' => $ success , 'errors' => $ errors , 'data' => $ results , ] ; return $ response ; } | Check the directory rights if it is writable or not |
24,465 | protected function getEnvironments ( ) { $ env = [ ] ; $ container = new Container ( 'melisinstaller' ) ; if ( isset ( $ container [ 'environments' ] ) && isset ( $ container [ 'environments' ] [ 'new' ] ) ) { $ env = $ container [ 'environments' ] [ 'new' ] ; } return $ env ; } | Returns the set environments in the session |
24,466 | protected function getCurrentPlatform ( ) { $ env = [ ] ; $ container = new Container ( 'melisinstaller' ) ; if ( isset ( $ container [ 'environments' ] ) && isset ( $ container [ 'environments' ] [ 'default_environment' ] ) ) { $ env = $ container [ 'environments' ] [ 'default_environment' ] ; } return $ env ; } | Returns the current values environment in the session |
24,467 | public function checkSysConfigAction ( ) { $ success = 0 ; $ errors = [ ] ; if ( $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ response = $ this -> systemConfigurationChecker ( ) ; $ success = $ response [ 'success' ] ; $ errors = $ response [ 'errors' ] ; $ container = new Container ( 'melisinstaller' ) ; $ container [ 'steps' ] [ $ this -> steps [ 0 ] ] = [ 'page' => 1 , 'success' => $ success ] ; } return new JsonModel ( [ 'success' => $ success , 'errors' => $ errors , ] ) ; } | This function is used for rechecking the status the desired step |
24,468 | public function checkVhostSetupAction ( ) { $ success = 0 ; $ errors = [ ] ; if ( $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ response = $ this -> vHostSetupChecker ( ) ; $ success = $ response [ 'success' ] ; $ errors = $ response [ 'errors' ] ; $ container = new Container ( 'melisinstaller' ) ; $ container [ 'steps' ] [ $ this -> steps [ 1 ] ] = [ 'page' => 2 , 'success' => $ success ] ; } return new JsonModel ( [ 'success' => $ success , 'errors' => $ errors , ] ) ; } | This step rechecks the Step 1 . 1 which is the Vhost Setup just to check that everything fine . |
24,469 | public function checkFileSystemRightsAction ( ) { $ success = 0 ; $ errors = [ ] ; if ( $ this -> getRequest ( ) -> isXmlHttpRequest ( ) ) { $ response = $ this -> checkDirectoryRights ( ) ; $ success = $ response [ 'success' ] ; $ errors = $ response [ 'errors' ] ; $ container = new Container ( 'melisinstaller' ) ; $ container [ 'steps' ] [ $ this -> steps [ 2 ] ] = [ 'page' => 3 , 'success' => $ success ] ; } return new JsonModel ( [ 'success' => $ success , 'errors' => $ errors , ] ) ; } | Rechecks Step 1 . 2 File System Rights |
24,470 | public function rollBackAction ( ) { $ success = 0 ; $ errors = [ ] ; $ installHelper = $ this -> getServiceLocator ( ) -> get ( 'InstallerHelper' ) ; $ container = new Container ( 'melisinstaller' ) ; if ( ! empty ( $ container -> getArrayCopy ( ) ) && in_array ( array_keys ( $ container [ 'steps' ] ) , [ $ this -> steps ] ) ) { $ tablesInstalled = isset ( $ container [ 'db_install_tables' ] ) ? $ container [ 'db_install_tables' ] : [ ] ; $ siteModule = 'module/MelisSites/' . $ container [ 'cms_data' ] [ 'website_module' ] . '/' ; $ dbConfigFile = 'config/autoload/platforms/' . $ installHelper -> getMelisPlatform ( ) . '.php' ; $ config = include ( $ dbConfigFile ) ; $ installHelper -> setDbAdapter ( $ config [ 'db' ] ) ; foreach ( $ tablesInstalled as $ table ) { if ( $ installHelper -> isDbTableExists ( $ table ) ) { $ installHelper -> executeRawQuery ( "DROP TABLE " . trim ( $ table ) ) ; } } if ( file_exists ( $ siteModule ) ) { unlink ( $ siteModule ) ; } if ( file_exists ( $ dbConfigFile ) ) { unlink ( $ dbConfigFile ) ; } $ container -> getManager ( ) -> destroy ( ) ; $ success = 1 ; } return new JsonModel ( [ 'success' => $ success , ] ) ; } | Execute this when setup has errors or setup has failed |
24,471 | protected function hasMelisCmsModule ( ) { $ modulesSvc = $ this -> getServiceLocator ( ) -> get ( 'MelisAssetManagerModulesService' ) ; $ modules = $ modulesSvc -> getAllModules ( ) ; $ path = $ modulesSvc -> getModulePath ( 'MelisCms' ) ; $ isExists = 0 ; if ( file_exists ( $ path ) ) { $ isExists = 1 ; } return $ isExists ; } | Checks if the current project has MelisCms Module |
24,472 | public function build ( ConfigInterface $ config , $ width , ManialinkInterface $ manialink , ManialinkFactory $ manialinkFactory ) : Renderable { $ input = $ this -> uiFactory -> createInput ( $ config -> getPath ( ) , '' ) -> setWidth ( $ width * 0.66 ) ; $ addButton = $ this -> uiFactory -> createButton ( 'Add' ) -> setWidth ( $ width * 0.33 ) -> setAction ( $ this -> actionFactory -> createManialinkAction ( $ manialink , function ( ManialinkInterface $ manialink , $ login , $ entries , $ args ) use ( $ manialinkFactory ) { $ config = $ args [ 'config' ] ; if ( ! empty ( $ entries [ $ config -> getPath ( ) ] ) ) { $ config -> add ( trim ( $ entries [ $ config -> getPath ( ) ] ) ) ; $ manialinkFactory -> update ( $ manialink -> getUserGroup ( ) ) ; } } , [ 'config' => $ config ] ) ) ; $ elements = [ $ this -> uiFactory -> createLayoutLine ( 0 , 0 , [ $ input , $ addButton ] ) ] ; foreach ( $ config -> get ( ) as $ element ) { $ elements [ ] = $ this -> getElementLine ( $ config , $ manialink , $ element , $ width , $ manialinkFactory ) ; } return $ this -> uiFactory -> createLayoutRow ( 0 , 0 , $ elements , 0.5 ) ; } | Create interface for the config value . |
24,473 | protected function getElementLine ( $ config , $ manialink , $ element , $ width , $ manialinkFactory ) { $ label = $ this -> uiFactory -> createLabel ( $ this -> getElementName ( $ element ) ) -> setX ( 2 ) -> setWidth ( $ width * 0.66 ) ; $ delButton = $ this -> uiFactory -> createButton ( 'Remove' ) -> setWidth ( $ width * 0.33 ) -> setAction ( $ this -> actionFactory -> createManialinkAction ( $ manialink , function ( ManialinkInterface $ manialink , $ login , $ entries , $ args ) use ( $ manialinkFactory ) { $ config = $ args [ 'config' ] ; $ config -> remove ( $ args [ 'element' ] ) ; $ manialinkFactory -> update ( $ manialink -> getUserGroup ( ) ) ; } , [ 'config' => $ config , 'element' => $ element ] ) ) ; return $ this -> uiFactory -> createLayoutLine ( 0 , 0 , [ $ label , $ delButton ] ) ; } | Get the display of a single line . |
24,474 | private function renderActions ( ) { $ this -> beginButtonGroup ( ) ; foreach ( $ this -> visibleActions as $ action ) { $ label = ArrayHelper :: getValue ( $ action , $ this -> actionLabelProperty , '' ) ; $ url = ArrayHelper :: getValue ( $ action , $ this -> actionUrlProperty , null ) ; $ options = ArrayHelper :: getValue ( $ action , $ this -> actionOptionsProperty , [ ] ) ; $ actionClasses = ArrayHelper :: getValue ( $ options , 'class' , [ ] ) ; $ options [ 'class' ] = $ this -> linkClasses ; Html :: addCssClass ( $ options , $ actionClasses ) ; echo Html :: a ( $ label , $ url , $ options ) ; } $ this -> endButtonGroup ( ) ; } | Render the actions as separate links |
24,475 | private function renderActionButton ( ) { $ actionButtonOptions = $ this -> actionButtonOptions ; Html :: addCssClass ( $ actionButtonOptions , $ this -> linkClasses ) ; $ this -> beginButtonGroup ( ) ; echo Html :: button ( $ this -> actionsButtonLabel . $ this -> caretHtml , $ actionButtonOptions ) ; echo Html :: beginTag ( 'ul' , [ 'class' => 'dropdown-menu dropdown-menu-right' ] ) ; foreach ( $ this -> visibleActions as $ action ) { $ label = ArrayHelper :: getValue ( $ action , $ this -> actionLabelProperty , '' ) ; $ url = ArrayHelper :: getValue ( $ action , $ this -> actionUrlProperty , null ) ; $ options = ArrayHelper :: getValue ( $ action , $ this -> actionOptionsProperty , [ ] ) ; echo Html :: tag ( 'li' , Html :: a ( $ label , $ url , $ options ) ) ; } echo Html :: endTag ( 'ul' ) ; $ this -> endButtonGroup ( ) ; } | Render the action button dropdown |
24,476 | public function copy ( string $ destination , $ overwrite = false ) : bool { $ copied = false ; if ( $ this -> isFile ( ) ) { $ exists = file_exists ( $ destination ) ; if ( ! $ exists || ( $ exists && $ overwrite ) ) { $ copied = copy ( $ this -> realPath , $ destination ) ; } } return $ copied ; } | Copy the current source to destination . |
24,477 | public function delete ( ) : bool { $ removed = null ; if ( $ this -> isDirectory ( ) ) { $ removed = rmdir ( $ this -> realPath ) ; } else { $ removed = unlink ( $ this -> realPath ) ; } return $ removed ; } | Remove a file from the disk . |
24,478 | public function getSize ( ) : int { $ size = - 1 ; if ( $ this -> isFile ( ) ) { $ size = filesize ( $ this -> realPath ) ; } return $ size ; } | Gets the size of a file . If the current source is not a file returns - 1 . |
24,479 | public function read ( ) { $ contents = false ; if ( $ this -> isFile ( ) && $ this -> isReadable ( ) ) { $ contents = file_get_contents ( $ this -> realPath ) ; } return $ contents ; } | Read the file contents based on PHP file_get_contents function This function will return a string containing the contents or FALSE on failure . |
24,480 | public function rename ( string $ newName ) : bool { $ renamed = rename ( $ this -> realPath , $ newName ) ; if ( $ renamed ) { $ this -> realPath = realpath ( $ newName ) ; } return $ renamed ; } | Give the source a new name . |
24,481 | protected function autoLoad_XmlnukeFramework ( $ className ) { foreach ( AutoLoad :: $ _folders [ AutoLoad :: FRAMEWORK_XMLNUKE ] as $ prefix ) { $ class = PHPXMLNUKEDIR . $ prefix . str_replace ( '\\' , '/' , $ className ) ; $ class = ( file_exists ( "$class.php" ) ? "$class.php" : ( file_exists ( "$class.class.php" ) ? "$class.class.php" : null ) ) ; if ( ! empty ( $ class ) && \ Xmlnuke \ Util \ FileUtil :: isReadable ( $ class ) ) { require_once ( $ class ) ; break ; } } } | Auto Load method for Core Xmlnuke and 3rd Party |
24,482 | protected function autoLoad_UserProjects ( $ className ) { $ class = str_replace ( '\\' , '/' , ( $ className [ 0 ] == '\\' ? substr ( $ className , 1 ) : $ className ) ) ; foreach ( AutoLoad :: $ _folders [ AutoLoad :: USER_PROJECTS ] as $ libName => $ libDir ) { $ file = $ libDir . '/' . $ class ; $ file = ( file_exists ( "$file.php" ) ? "$file.php" : ( file_exists ( "$file.class.php" ) ? "$file.class.php" : null ) ) ; if ( ! empty ( $ file ) && \ Xmlnuke \ Util \ FileUtil :: isReadable ( $ file ) ) { require_once $ file ; return ; } } return ; } | MODULES HAVE AN SPECIAL WAY OF LOAD . |
24,483 | public function createPayment ( $ gateway ) { if ( ! GatewayInfo :: isSupported ( $ gateway ) ) { user_error ( _t ( "PaymentProcessor.INVALID_GATEWAY" , "`{gateway}` is not supported." , null , array ( 'gateway' => ( string ) $ gateway ) ) , E_USER_ERROR ) ; } $ this -> payment = Payment :: create ( ) -> init ( $ gateway , $ this -> reservation -> Total , self :: config ( ) -> get ( 'currency' ) ) ; $ this -> payment -> ReservationID = $ this -> reservation -> ID ; return $ this -> payment ; } | Create a payment trough the given payment gateway |
24,484 | public function createServiceFactory ( ) { $ factory = ServiceFactory :: create ( ) ; $ service = $ factory -> getService ( $ this -> payment , ServiceFactory :: INTENT_PAYMENT ) ; try { $ serviceResponse = $ service -> initiate ( $ this -> getGatewayData ( ) ) ; } catch ( Exception $ ex ) { user_error ( $ ex -> getMessage ( ) , E_USER_WARNING ) ; return null ; } return $ serviceResponse ; } | Create the service factory Catch any exceptions that might occur |
24,485 | public function doHydrateList ( array $ list , $ parentKey = null ) { $ retVal = parent :: doHydrateList ( $ list , $ parentKey ) ; if ( 'Id' === $ parentKey ) { if ( $ retVal -> count ( ) > 0 ) { return $ retVal -> get ( 0 ) ; } return null ; } return $ retVal ; } | Regard duplicate Id attributes that come as a list transform into single result . |
24,486 | public function remove ( $ key , $ remove = true ) { if ( $ remove && $ this -> has ( $ key , self :: HAS_EXISTS ) ) { $ key = $ this -> normalizeKey ( $ key ) ; unset ( $ this -> data [ $ key ] ) ; } return $ this ; } | Removes specified collection item . |
24,487 | public function removeEmpty ( $ considerEmpty = [ '' ] ) { foreach ( $ this -> all ( ) as $ key => $ value ) { if ( ! is_scalar ( $ value ) && ! is_null ( $ value ) ) { continue ; } foreach ( $ considerEmpty as $ empty ) { if ( $ value === $ empty ) { $ this -> remove ( $ key ) ; break ; } } } return $ this ; } | Removes empty collection items . |
24,488 | public function sort ( $ sortBy = self :: SORT_BY_KEYS_ASC , $ sortFlags = SORT_REGULAR ) { $ sortFunctions = [ self :: SORT_BY_KEYS_ASC => 'ksort' , self :: SORT_BY_KEYS_DESC => 'krsort' , self :: SORT_BY_VALUES_ASC => 'asort' , self :: SORT_BY_VALUES_DESC => 'arsort' , ] ; if ( ! isset ( $ sortFunctions [ $ sortBy ] ) ) { throw new InvalidArgumentException ( "SortBy {$sortBy} not supported" ) ; } $ function = $ sortFunctions [ $ sortBy ] ; $ function ( $ this -> data , $ sortFlags ) ; return $ this ; } | Sort collection . |
24,489 | private function generateList ( $ caption , $ paragraph , $ filelist , $ xslUsed , $ xsl ) { $ paragraph -> addXmlnukeObject ( new XmlnukeText ( $ caption , true ) ) ; $ listCollection = new XmlListCollection ( XmlListType :: UnorderedList ) ; $ paragraph -> addXmlnukeObject ( $ listCollection ) ; foreach ( $ filelist as $ file ) { $ xslname = FileUtil :: ExtractFileName ( $ file ) ; $ xslname = $ xsl -> removeLanguage ( $ xslname ) ; if ( ! in_array ( $ xslname , $ xslUsed ) ) { $ objectList = new XmlnukeSpanCollection ( ) ; $ listCollection -> addXmlnukeObject ( $ objectList ) ; $ xslUsed [ ] = $ xslname ; if ( $ xslname == "index" ) { $ anchor = new XmlAnchorCollection ( "engine:xmlnuke?xml=index&xsl=index" ) ; $ anchor -> addXmlnukeObject ( new XmlnukeText ( $ xslname , true ) ) ; $ objectList -> addXmlnukeObject ( $ anchor ) ; } else { $ anchor = new XmlAnchorCollection ( "module:Xmlnuke.XSLTheme?xsl=" . $ xslname ) ; $ anchor -> addXmlnukeObject ( new XmlnukeText ( $ xslname , true ) ) ; $ objectList -> addXmlnukeObject ( $ anchor ) ; } } } } | Create and show the list of Xsl Templates |
24,490 | function translate ( $ path ) { if ( static :: isWindowsOS ( ) ) { if ( preg_match ( '%^([A-Z]):(.*)%' , $ path , $ matches ) ) { $ drive = $ matches [ 1 ] ; $ file = $ matches [ 2 ] ; $ unixFile = str_replace ( '\\' , '/' , $ file ) ; if ( static :: isWindowsMsys ( ) ) { $ path = '/' . strtolower ( $ drive ) . $ unixFile ; } else if ( static :: isWindowsCygwin ( ) ) { $ path = '/cygdrive/' . strtolower ( $ drive ) . $ unixFile ; } } else { if ( static :: isWindowsMsys ( ) || static :: isWindowsCygwin ( ) ) $ path = str_replace ( '\\' , '/' , $ path ) ; ; } } return $ path ; } | Translate a Windows path into a POSIX path if necessary . |
24,491 | private function definition ( ContainerBuilder $ container , $ class , $ tag , array $ arguments = [ ] ) { $ definition = new Definition ( strtr ( __NAMESPACE__ , [ 'ServiceContainer' => $ class ] ) , $ arguments ) ; return $ container -> setDefinition ( $ tag . '.' . self :: id ( $ class ) , $ definition ) -> addTag ( $ tag ) ; } | Define a new service in DI container . |
24,492 | public function invoke ( $ obj , string $ method , array $ params = [ ] ) { if ( is_string ( $ obj ) ) { $ obj = $ this -> get ( $ obj ) ; } elseif ( ! is_object ( $ obj ) ) { throw new \ Exception ( 'Invalid object' ) ; } $ map = $ this -> generateArgumentsMap ( $ obj , $ method , $ params ) ; $ mapParams = $ this -> getParamsFromMap ( $ map ) ; return $ obj -> $ method ( ... $ mapParams ) ; } | Calls an object method injecting its dependencies . |
24,493 | private function build ( string $ name ) { $ instance = null ; $ map = $ this -> map [ $ name ] ; if ( is_array ( $ map ) ) { $ params = $ this -> getParamsFromMap ( $ map ) ; $ instance = new $ name ( ... $ params ) ; } elseif ( $ map instanceof \ Closure ) { $ instance = $ map ( $ this ) ; } elseif ( is_object ( $ map ) ) { $ instance = $ map ; } elseif ( is_string ( $ map ) ) { $ instance = $ this -> get ( $ map ) ; } else { throw new \ Exception ( 'Invalid map' ) ; } return $ instance ; } | Build an object according to the map information . |
24,494 | public static function sort ( ArrayList & $ list , Comparator $ comparator ) { $ array = $ list -> toArray ( ) ; usort ( $ array , [ $ comparator , "compare" ] ) ; $ list -> replace ( $ array ) ; return $ list ; } | Sorts the specified list according to the order induced by the specified comparator . All elements in the list must be mutually comparable . |
24,495 | public function getPluginPath ( $ library ) { switch ( $ library ) { case \ Altamira \ JsWriter \ Flot :: LIBRARY : return $ this [ 'js.flotpluginpath' ] ; case \ Altamira \ JsWriter \ JqPlot :: LIBRARY : return $ this [ 'js.jqplotpluginpath' ] ; } } | Provided a library returns a path for plugins |
24,496 | public function reset ( Map $ map ) { $ this -> pluginManager -> reset ( $ map ) ; $ this -> dataProviderManager -> reset ( $ this -> pluginManager , $ map ) ; } | Reset the dispatcher elements when game mode changes . |
24,497 | private function prepareEntriesToDeliver ( array $ entries ) { $ binaryAttributes = [ 'objectguid' , 'objectsid' ] ; foreach ( $ entries as $ key => & $ entry ) { foreach ( $ binaryAttributes as $ binaryAttribute ) { if ( array_key_exists ( $ binaryAttribute , $ entry ) ) { if ( is_array ( $ entry [ $ binaryAttribute ] ) ) { foreach ( $ entry [ $ binaryAttribute ] as & $ value ) { $ value = bin2hex ( $ value ) ; } } else { $ entry [ $ binaryAttribute ] = bin2hex ( $ entry [ $ binaryAttribute ] ) ; } } } } return $ entries ; } | Replaces bin values with hex representations in order to be able to deliver entries safely |
24,498 | public function consume ( $ url , Provider $ provider = null , $ format = self :: FORMAT_DEFAULT ) { if ( $ this -> requestParameters instanceof RequestParameters ) { $ cacheKey = sha1 ( $ url . json_encode ( $ this -> requestParameters -> toArray ( ) ) ) ; } else { $ cacheKey = sha1 ( $ url ) ; } if ( $ this -> resourceCache -> has ( $ cacheKey ) ) { return $ this -> resourceCache -> get ( $ cacheKey ) ; } try { if ( ! $ provider ) { $ provider = $ this -> findProviderForUrl ( $ url ) ; } if ( $ provider instanceof Provider ) { $ endPoint = $ provider -> getEndpoint ( ) ; } else { $ discover = new Discoverer ( ) ; $ endPoint = $ discover -> getEndpointForUrl ( $ url ) ; } $ requestUrl = $ this -> buildOEmbedRequestUrl ( $ url , $ endPoint , $ format ) ; $ content = $ this -> browser -> getContent ( $ requestUrl ) ; $ methodName = 'process' . ucfirst ( strtolower ( $ format ) ) . 'Response' ; $ resource = $ this -> $ methodName ( $ content ) ; $ this -> resourceCache -> set ( $ cacheKey , $ resource ) ; } catch ( Exception $ exception ) { $ this -> systemLogger -> logException ( $ exception ) ; $ resource = null ; } return $ this -> postProcessResource ( $ resource ) ; } | Consume an oEmbed resource using the specified provider if supplied or try to discover the right one . |
24,499 | protected function buildOEmbedRequestUrl ( $ resource , $ endPoint , $ format = self :: FORMAT_DEFAULT ) { $ parameters = [ 'url' => $ resource , 'format' => $ format , 'version' => self :: VERSION ] ; if ( $ this -> getRequestParameters ( ) !== null ) { $ parameters = Arrays :: arrayMergeRecursiveOverrule ( $ this -> getRequestParameters ( ) -> toArray ( ) , $ parameters ) ; } $ urlParams = http_build_query ( $ parameters , '' , '&' ) ; $ url = $ endPoint . ( ( strpos ( $ endPoint , '?' ) !== false ) ? '&' : '?' ) . $ urlParams ; return $ url ; } | Build the oEmbed request URL according to the specification . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.