idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
49,700 | protected function generateTaoScss ( $ archiveDir , $ icons ) { if ( ! is_readable ( $ archiveDir . '/style.css' ) ) { return array ( 'error' => __ ( 'Unable to read the file : ' ) . $ archiveDir . '/style.css' ) ; } $ cssContent = file_get_contents ( $ archiveDir . '/style.css' ) ; $ iconCss = array ( 'classes' => '' ... | Generate TAO scss |
49,701 | protected function generateCkScss ( ) { $ ckIni = parse_ini_file ( $ this -> assetDir . '/ck-editor-classes.ini' ) ; $ cssContent = '@import "inc/bootstrap";' . "\n" ; $ cssContent .= '.cke_button_icon, .cke_button { @include tao-icon-setup;}' . "\n" ; foreach ( $ ckIni as $ ckIcon => $ taoIcon ) { if ( ! $ taoIcon ) {... | Generate scss for CK editor |
49,702 | protected function generatePhpClass ( $ iconSet ) { $ phpClass = file_get_contents ( $ this -> assetDir . '/class.Icon.tpl' ) ; $ phpClassPath = $ this -> tmpDir . '/class.Icon.php' ; $ constants = '' ; $ functions = '' ; $ patterns = array ( '{CONSTANTS}' , '{FUNCTIONS}' , '{DATE}' , '{DO_NOT_EDIT}' ) ; foreach ( $ ic... | Generate PHP icon class |
49,703 | protected function distribute ( $ tmpDir ) { foreach ( glob ( $ tmpDir . '/fonts/tao.*' ) as $ font ) { if ( ! copy ( $ font , $ this -> taoDir . '/views/css/font/tao/' . basename ( $ font ) ) ) { return array ( 'error' => 'Failed to copy ' . $ font ) ; } } ; foreach ( glob ( $ tmpDir . '/_tao-icon-*.scss' ) as $ scss ... | Distribute generated files to their final destination |
49,704 | protected function loadIconListing ( ) { $ icons = json_decode ( file_get_contents ( $ this -> currentSelection ) ) ; $ icons = $ icons -> icons ; usort ( $ icons , array ( $ this , 'sortIconListing' ) ) ; return $ icons ; } | List existing icons |
49,705 | function connect ( $ id , array $ params ) { $ this -> id = $ id ; $ this -> persistence = \ common_persistence_SqlPersistence :: getPersistence ( $ params [ 'persistenceId' ] ) ; unset ( $ params [ 'persistenceId' ] ) ; return new \ common_persistence_SqlPersistence ( $ params , $ this ) ; } | Allow to connect the driver and return the connection |
49,706 | public function create ( ) { $ formContainer = new Extension ( ) ; $ myForm = $ formContainer -> getForm ( ) ; if ( $ myForm -> isValid ( ) && $ myForm -> isSubmited ( ) ) { $ creator = new ExtensionCreator ( $ myForm -> getValue ( 'name' ) , $ myForm -> getValue ( 'label' ) , $ myForm -> getValue ( 'version' ) , $ myF... | Form to create a new extension |
49,707 | public function dolog ( common_log_Item $ item ) { if ( php_sapi_name ( ) != 'cli' ) { switch ( $ item -> getSeverity ( ) ) { case common_Logger :: ERROR_LEVEL : ChromePhp :: error ( $ item -> getDescription ( ) . ' at ' . $ item -> getCallerFile ( ) . ':' . $ item -> getCallerLine ( ) ) ; break ; case common_Logger ::... | wrap calls to the ChomePhp util |
49,708 | public function toString ( ) { $ string = ( string ) $ this -> buildMessageHeader ( ) ; foreach ( $ this -> segments as $ segment ) { $ string .= ( string ) $ segment ; } return $ string ; } | Transform message to HBCI string . |
49,709 | protected function buildMessageHeader ( ) { $ len = 0 ; foreach ( $ this -> segments as $ segment ) { $ len += strlen ( $ segment ) ; } return new HNHBK ( $ len , $ this -> dialogId , $ this -> messageNumber ) ; } | Builds the message header . |
49,710 | public function getDialogId ( ) { $ segment = $ this -> findSegment ( 'HNHBK' ) ; if ( null === $ segment ) { throw new \ Exception ( 'Could not find element HNHBK. Invalid response?' ) ; } return $ this -> getSegmentIndex ( 4 , $ segment ) ; } | Extracts dialog ID from response . |
49,711 | public function getBankName ( ) { $ bankName = null ; $ segment = $ this -> findSegment ( 'HIBPA' ) ; if ( null != $ segment ) { $ split = $ this -> splitSegment ( $ segment ) ; if ( isset ( $ split [ 3 ] ) ) { $ bankName = $ split [ 3 ] ; } } return $ bankName ; } | Extracts bank name from response . |
49,712 | public function getTouchDowns ( AbstractMessage $ message ) { $ touchdown = array ( ) ; $ messageSegments = $ message -> getEncryptedSegments ( ) ; foreach ( $ messageSegments as $ msgSeg ) { $ segment = $ this -> findSegmentForReference ( 'HIRMS' , $ msgSeg ) ; if ( null != $ segment ) { $ parts = $ this -> splitSegme... | Some kind of HBCI pagination . |
49,713 | public function getSupportedTanMechanisms ( ) { $ segments = $ this -> findSegments ( 'HIRMS' ) ; foreach ( $ segments as $ segment ) { $ segment = $ this -> splitSegment ( $ segment ) ; array_shift ( $ segment ) ; foreach ( $ segment as $ seg ) { list ( $ id , $ msg ) = explode ( '::' , $ seg , 2 ) ; if ( "3920" == $ ... | Extracts supported TAN mechanisms from response . |
49,714 | protected function createModelFromArray ( array $ array ) { if ( ! $ array [ 1 ] ) { return null ; } $ account = new Account ( ) ; list ( $ accountNumber , $ x , $ countryCode , $ bankCode ) = explode ( ':' , $ array [ 1 ] ) ; $ account -> setId ( $ array [ 1 ] ) ; $ account -> setAccountNumber ( $ accountNumber ) ; $ ... | Creates a Account model from array . |
49,715 | public function setAdapter ( AdapterInterface $ adapter ) { $ this -> adapter = $ adapter ; $ this -> connection = new Connection ( $ this -> adapter ) ; } | Sets the adapter to use . |
49,716 | public function getAccounts ( ) { $ dialog = $ this -> getDialog ( ) ; $ result = $ dialog -> syncDialog ( ) ; $ this -> bankName = $ dialog -> getBankName ( ) ; $ accounts = new GetAccounts ( $ result ) ; return $ accounts -> getAccountsArray ( ) ; } | Gets array of all accounts . |
49,717 | public function getSEPAAccounts ( ) { $ dialog = $ this -> getDialog ( ) ; $ dialog -> syncDialog ( ) ; $ dialog -> initDialog ( ) ; $ message = $ this -> getNewMessage ( $ dialog , array ( new HKSPA ( 3 ) ) , array ( AbstractMessage :: OPT_PINTAN_MECH => $ dialog -> getSupportedPinTanMechanisms ( ) ) ) ; $ result = $ ... | Gets array of all SEPA Accounts . |
49,718 | public function getStatementOfAccount ( SEPAAccount $ account , \ DateTime $ from , \ DateTime $ to ) { $ responses = array ( ) ; $ this -> logger -> info ( 'Start fetching statement of account results' ) ; $ this -> logger -> info ( 'Start date: ' . $ from -> format ( 'Y-m-d' ) ) ; $ this -> logger -> info ( 'End date... | Gets statement of account . |
49,719 | protected function createStateOfAccountMessage ( Dialog $ dialog , SepaAccount $ account , \ DateTime $ from , \ DateTime $ to , $ touchdown = null ) { switch ( $ dialog -> getHkkazMaxVersion ( ) ) { case 4 : case 5 : $ konto = new Deg ( ) ; $ konto -> addDataElement ( $ account -> getAccountNumber ( ) ) ; $ konto -> a... | Helper method to create a Statement of Account Message . |
49,720 | public function getSaldo ( SEPAAccount $ account ) { $ dialog = $ this -> getDialog ( ) ; $ dialog -> syncDialog ( ) ; $ dialog -> initDialog ( ) ; switch ( ( int ) $ dialog -> getHksalMaxVersion ( ) ) { case 4 : case 5 : $ hksalAccount = new Deg ( $ account -> getAccountNumber ( ) , $ account -> getSubAccount ( ) , st... | Gets the saldo of given SEPAAccount . |
49,721 | public function initDialog ( ) { $ this -> logger -> info ( 'Initialize Dialog' ) ; $ identification = new HKIDN ( 3 , $ this -> bankCode , $ this -> username , $ this -> systemId ) ; $ prepare = new HKVVB ( 4 , HKVVB :: DEFAULT_BPD_VERSION , HKVVB :: DEFAULT_UPD_VERSION , HKVVB :: LANG_DEFAULT ) ; $ message = new Mess... | Initializes a dialog . |
49,722 | public function syncDialog ( ) { $ this -> logger -> info ( 'Initialize SYNC' ) ; $ this -> messageNumber = 1 ; $ this -> systemId = 0 ; $ this -> dialogId = 0 ; $ identification = new HKIDN ( 3 , $ this -> bankCode , $ this -> username , 0 ) ; $ prepare = new HKVVB ( 4 , HKVVB :: DEFAULT_BPD_VERSION , HKVVB :: DEFAULT... | Sends sync request . |
49,723 | public function endDialog ( ) { $ this -> logger -> info ( 'Initialize END dialog message' ) ; $ endMsg = new Message ( $ this -> bankCode , $ this -> username , $ this -> pin , $ this -> systemId , $ this -> dialogId , $ this -> messageNumber , array ( new HKEND ( 3 , $ this -> dialogId ) ) ) ; $ this -> logger -> deb... | Ends a previous started dialog . |
49,724 | public function getStatementForDate ( $ date ) { if ( is_string ( $ date ) ) { $ date = new \ DateTime ( $ date ) ; } foreach ( $ this -> statements as $ stmt ) { if ( $ stmt -> getDate ( ) == $ date ) { return $ stmt ; } } return null ; } | Gets statement for given date . |
49,725 | public function hasStatementForDate ( $ date ) { if ( is_string ( $ date ) ) { $ date = new \ DateTime ( $ date ) ; } return null !== $ this -> getStatementForDate ( $ date ) ; } | Checks if a statement with given date exists . |
49,726 | public function getSaldoModel ( ) { $ model = null ; $ saldoSec = $ this -> findSegment ( static :: SEG_ACCOUNT_INFORMATION ) ; if ( is_string ( $ saldoSec ) ) { $ saldoSec = $ this -> splitSegment ( $ saldoSec ) ; array_shift ( $ saldoSec ) ; $ model = $ this -> createModelFromArray ( $ saldoSec ) ; } return $ model ;... | Creates a Saldo object from response body . |
49,727 | protected function createModelFromArray ( array $ array ) { $ model = new Saldo ( ) ; $ saldoDeg = $ this -> splitDeg ( $ array [ 3 ] ) ; $ amount = str_replace ( ',' , '.' , $ saldoDeg [ 1 ] ) ; $ creditDebit = trim ( $ saldoDeg [ 0 ] ) ; if ( static :: SALDO_DEBIT == $ creditDebit ) { $ amount = - ( float ) $ amount ... | Creates a Saldo model from array . |
49,728 | public function getSEPAAccountsArray ( ) { $ accounts = $ this -> findSegment ( static :: SEG_ACCOUNT_INFORMATION ) ; if ( is_string ( $ accounts ) ) { $ accounts = $ this -> splitSegment ( $ accounts ) ; array_shift ( $ accounts ) ; foreach ( $ accounts as $ account ) { $ array = $ this -> splitDeg ( $ account ) ; $ t... | Creates SEPA Account array list with SEPAAccount models . |
49,729 | protected function createModelFromArray ( array $ array ) { $ account = new SEPAAccount ( ) ; $ account -> setIban ( $ array [ 1 ] ) ; $ account -> setBic ( $ array [ 2 ] ) ; $ account -> setAccountNumber ( $ array [ 3 ] ) ; $ account -> setSubAccount ( $ array [ 4 ] ) ; $ account -> setBlz ( $ array [ 6 ] ) ; return $... | Creates a SEPAAccount model from array . |
49,730 | protected function addEncryptedSegment ( SegmentInterface $ segment ) { $ this -> encryptedSegmentsCount ++ ; $ this -> encryptedSegments [ ] = $ segment ; $ encodedData = $ this -> encryptionEnvelop -> getEncodedData ( ) -> getData ( ) ; $ encodedData .= ( string ) $ segment ; $ this -> encryptionEnvelop -> setEncoded... | Adds a encrypted segment to the message . |
49,731 | public function getRawMt940 ( ) { $ seg = $ this -> findSegment ( static :: SEG_ACCOUNT_INFORMATION ) ; if ( is_string ( $ seg ) ) { if ( preg_match ( '/@(\d+)@(.+)/ms' , $ seg , $ m ) ) { return $ m [ 2 ] ; } } return '' ; } | Gets the raw MT940 string from response . |
49,732 | public static function createModelFromRawMt940 ( $ rawMt940 ) { $ parser = new MT940 ( $ rawMt940 ) ; return static :: createModelFromArray ( $ parser -> parse ( MT940 :: TARGET_ARRAY ) ) ; } | Creates StatementOfAccount object from raw MT940 string . |
49,733 | protected static function addFromArray ( array $ array , StatementOfAccount $ statementOfAccount ) { foreach ( $ array as $ date => $ statement ) { if ( $ statementOfAccount -> hasStatementForDate ( $ date ) ) { $ statementModel = $ statementOfAccount -> getStatementForDate ( $ date ) ; } else { $ statementModel = new ... | Adds statements to an existing StatementOfAccount object . |
49,734 | public function toReadableString ( $ separator = AbstractArray :: DEFAULT_SEPARATOR , $ conjunction = ' and ' ) { $ elements = $ this -> elements ; $ lastElement = array_pop ( $ elements ) ; $ string = implode ( $ separator , $ elements ) . ( count ( $ elements ) ? $ conjunction : '' ) . $ lastElement ; unset ( $ eleme... | Implode the current array to a readable string with specified separator . |
49,735 | public function toJson ( $ options = 0 , $ depth = 512 ) { $ params = [ $ this -> elements , $ options , ] ; if ( version_compare ( PHP_VERSION , '5.5.0' , '>=' ) ) { $ params [ ] = $ depth ; } return call_user_func_array ( 'json_encode' , $ params ) ; } | Encode the current array to a JSON string . |
49,736 | public function merge ( array $ array , $ recursively = false ) { if ( true === $ recursively ) { return new static ( array_merge_recursive ( $ this -> elements , $ array ) ) ; } return new static ( array_merge ( $ this -> elements , $ array ) ) ; } | Merge the current array with the provided one . The latter array is overwriting . |
49,737 | public function replace ( array $ array , $ recursively = false ) { if ( true === $ recursively ) { return new static ( array_replace_recursive ( $ this -> elements , $ array ) ) ; } return new static ( array_replace ( $ this -> elements , $ array ) ) ; } | Replace values in the current array with values in the given one that have the same key . |
49,738 | public function walk ( callable $ func , $ recursively = false ) { if ( true === $ recursively ) { array_walk_recursive ( $ this -> elements , $ func ) ; } else { array_walk ( $ this -> elements , $ func ) ; } return $ this ; } | Apply the given function to the every element of the current array discarding the results . |
49,739 | public function exists ( callable $ func ) { $ isExists = false ; foreach ( $ this -> elements as $ key => $ value ) { if ( $ func ( $ key , $ value ) ) { $ isExists = true ; break ; } } return $ isExists ; } | Find the given value in An array using a closure |
49,740 | public function getRandomValues ( $ number ) { $ values = [ ] ; $ keys = $ number > 1 ? $ this -> getRandomKeys ( $ number ) : [ $ this -> getRandomKeys ( $ number ) ] ; foreach ( $ keys as $ key ) { $ values [ ] = $ this -> offsetGet ( $ key ) ; } return $ values ; } | Pick a given number of random values with non - duplicate indexes out of the array . |
49,741 | private function checkType ( $ type ) { $ isInType = true ; foreach ( $ this -> getKeys ( ) as $ key ) { if ( gettype ( $ key ) !== $ type ) { $ isInType = false ; break ; } } return $ isInType ; } | Check if an array keys are in a given variable type . |
49,742 | public function export ( $ return = false ) { if ( $ return ) { return var_export ( $ this -> elements , true ) ; } var_export ( $ this -> elements , false ) ; return $ this ; } | Exports array for using in PHP scripts . |
49,743 | public static function assertJsonValueMatches ( $ jsonDocument , string $ jsonPath , Constraint $ constraint ) { Assert :: assertThat ( $ jsonDocument , new JsonValueMatches ( $ jsonPath , $ constraint ) ) ; } | Asserts that at least one of a set of JSON values in a document match a given constraint |
49,744 | public static function assertAllJsonValuesMatch ( $ jsonDocument , string $ jsonPath , Constraint $ constraint ) { Assert :: assertThat ( $ jsonDocument , new JsonValueMatches ( $ jsonPath , $ constraint , true ) ) ; } | Asserts that all of a set of JSON values in a document match a given constraint |
49,745 | public static function assertJsonValueEquals ( $ jsonDocument , string $ jsonPath , $ expectedValue ) { static :: assertJsonValueMatches ( $ jsonDocument , $ jsonPath , new IsEqual ( $ expectedValue ) ) ; } | Asserts that at least one of a set of JSON values in a document is equal to a given value |
49,746 | public static function assertAllJsonValuesEqual ( $ jsonDocument , string $ jsonPath , $ expectedValue ) { static :: assertAllJsonValuesMatch ( $ jsonDocument , $ jsonPath , new IsEqual ( $ expectedValue ) ) ; } | Asserts that all of a set of JSON values in a document are equal to a given value |
49,747 | public function push ( Job $ job , $ delay = 0 ) { $ result = $ this -> database -> insert ( $ this -> jobs_table , array ( 'job' => serialize ( $ job ) , 'available_at' => $ this -> datetime ( $ delay ) , 'created_at' => $ this -> datetime ( ) , ) ) ; if ( ! $ result ) { return false ; } return $ this -> database -> i... | Push a job onto the queue . |
49,748 | public function pop ( ) { $ this -> release_reserved ( ) ; $ sql = $ this -> database -> prepare ( " SELECT * FROM {$this->jobs_table} WHERE reserved_at IS NULL AND available_at <= %s ORDER BY available_at LIMIT 1 " , $ this -> datetime ( ) ) ; $ raw_job = $ this -> database -> get_row ( $ sql ) ; if ( is_nu... | Retrieve a job from the queue . |
49,749 | public function delete ( $ job ) { $ where = array ( 'id' => $ job -> id ( ) , ) ; if ( $ this -> database -> delete ( $ this -> jobs_table , $ where ) ) { return true ; } return false ; } | Delete a job from the queue . |
49,750 | public function release ( $ job ) { $ data = array ( 'job' => serialize ( $ job ) , 'attempts' => $ job -> attempts ( ) , 'reserved_at' => null , ) ; $ where = array ( 'id' => $ job -> id ( ) , ) ; if ( $ this -> database -> update ( $ this -> jobs_table , $ data , $ where ) ) { return true ; } return false ; } | Release a job back onto the queue . |
49,751 | public function failure ( $ job , Exception $ exception ) { $ insert = $ this -> database -> insert ( $ this -> failures_table , array ( 'job' => serialize ( $ job ) , 'error' => $ this -> format_exception ( $ exception ) , 'failed_at' => $ this -> datetime ( ) , ) ) ; if ( $ insert ) { $ this -> delete ( $ job ) ; ret... | Push a job onto the failure queue . |
49,752 | protected function reserve ( $ job ) { $ data = array ( 'reserved_at' => $ this -> datetime ( ) , ) ; $ this -> database -> update ( $ this -> jobs_table , $ data , array ( 'id' => $ job -> id ( ) , ) ) ; } | Reserve a job in the queue . |
49,753 | protected function release_reserved ( ) { $ expired = $ this -> datetime ( - 300 ) ; $ sql = $ this -> database -> prepare ( " UPDATE {$this->jobs_table} SET attempts = attempts + 1, reserved_at = NULL WHERE reserved_at <= %s" , $ expired ) ; $ this -> database -> query ( $ sql ) ; } | Release reserved jobs back onto the queue . |
49,754 | protected function vitalize_job ( $ raw_job ) { $ job = unserialize ( $ raw_job -> job ) ; $ job -> set_id ( $ raw_job -> id ) ; $ job -> set_attempts ( $ raw_job -> attempts ) ; $ job -> set_reserved_at ( empty ( $ raw_job -> reserved_at ) ? null : new Carbon ( $ raw_job -> reserved_at ) ) ; $ job -> set_available_at ... | Vitalize Job with latest data . |
49,755 | protected function format_exception ( Exception $ exception ) { $ string = get_class ( $ exception ) ; if ( ! empty ( $ exception -> getMessage ( ) ) ) { $ string .= " : {$exception->getMessage()}" ; } if ( ! empty ( $ exception -> getCode ( ) ) ) { $ string .= " (#{$exception->getCode()})" ; } return $ string ; } | Format an exception error string . |
49,756 | public function cron ( $ attempts = 3 , $ interval = 5 ) { if ( is_null ( $ this -> cron ) ) { $ this -> cron = new Cron ( get_class ( $ this -> connection ) , $ this -> worker ( $ attempts ) , $ interval ) ; $ this -> cron -> init ( ) ; } return $ this -> cron ; } | Create a cron worker . |
49,757 | public function init ( ) { if ( ! $ this -> is_enabled ( ) ) { return false ; } add_filter ( 'cron_schedules' , array ( $ this , 'schedule_cron' ) ) ; add_action ( $ this -> id , array ( $ this , 'cron_worker' ) ) ; if ( ! wp_next_scheduled ( $ this -> id ) ) { wp_schedule_event ( time ( ) , $ this -> id , $ this -> id... | Init cron class . |
49,758 | public function schedule_cron ( $ schedules ) { $ schedules [ $ this -> id ] = array ( 'interval' => MINUTE_IN_SECONDS * $ this -> interval , 'display' => sprintf ( __ ( 'Every %d Minutes' ) , $ this -> interval ) , ) ; return $ schedules ; } | Add interval to cron schedules . |
49,759 | public function cron_worker ( ) { if ( $ this -> is_worker_locked ( ) ) { return ; } $ this -> start_time = time ( ) ; $ this -> lock_worker ( ) ; while ( ! $ this -> time_exceeded ( ) && ! $ this -> memory_exceeded ( ) ) { if ( ! $ this -> worker -> process ( ) ) { break ; } } $ this -> unlock_worker ( ) ; } | Process any jobs in the queue . |
49,760 | protected function get_memory_limit ( ) { if ( function_exists ( 'ini_get' ) ) { $ memory_limit = ini_get ( 'memory_limit' ) ; } else { $ memory_limit = '256M' ; } if ( ! $ memory_limit || - 1 == $ memory_limit ) { $ memory_limit = '1000M' ; } return intval ( $ memory_limit ) * 1024 * 1024 ; } | Get memory limit . |
49,761 | protected static function build ( $ connection ) { $ connections = static :: connections ( ) ; if ( empty ( $ connections [ $ connection ] ) ) { throw new ConnectionNotFoundException ( ) ; } static :: $ instances [ $ connection ] = new Queue ( $ connections [ $ connection ] ) ; return static :: $ instances [ $ connecti... | Build a queue instance . |
49,762 | public function process ( ) { $ job = $ this -> connection -> pop ( ) ; if ( ! $ job ) { return false ; } $ exception = null ; try { $ job -> handle ( ) ; } catch ( Exception $ exception ) { $ job -> release ( ) ; } if ( $ job -> attempts ( ) >= $ this -> attempts ) { if ( empty ( $ exception ) ) { $ exception = new Wo... | Process a job on the queue . |
49,763 | public function setPrompt ( $ prompt ) { if ( $ prompt === $ this -> prompt ) { return $ this ; } $ this -> prompt = $ prompt ; return $ this -> redraw ( ) ; } | prompt to prepend to input line |
49,764 | public function setMove ( $ move ) { $ this -> move = ! ! $ move ; return $ this -> moveCursorTo ( $ this -> strlen ( $ this -> linebuffer ) ) ; } | whether or not to support moving cursor left and right |
49,765 | public function getCursorCell ( ) { if ( $ this -> echo === false ) { return 0 ; } if ( $ this -> echo !== true ) { return $ this -> strwidth ( $ this -> echo ) * $ this -> linepos ; } return $ this -> strwidth ( $ this -> substr ( $ this -> linebuffer , 0 , $ this -> linepos ) ) ; } | Gets current cursor position measured in monospace cells . |
49,766 | public function moveCursorTo ( $ n ) { if ( $ n < 0 || $ n === $ this -> linepos || $ n > $ this -> strlen ( $ this -> linebuffer ) ) { return $ this ; } $ old = $ this -> getCursorCell ( ) ; $ this -> linepos = $ n ; if ( $ this -> getCursorCell ( ) !== $ old ) { $ this -> redraw ( ) ; } return $ this ; } | Moves cursor to given position in current line buffer . |
49,767 | public function addInput ( $ input ) { if ( $ input === '' ) { return $ this ; } $ pre = $ this -> substr ( $ this -> linebuffer , 0 , $ this -> linepos ) ; $ post = $ this -> substr ( $ this -> linebuffer , $ this -> linepos ) ; $ this -> linebuffer = $ pre . $ input . $ post ; $ this -> linepos += $ this -> strlen ( ... | Appends the given input to the current text input buffer at the current position |
49,768 | public function setInput ( $ input ) { if ( $ this -> linebuffer === $ input ) { return $ this ; } $ oldlen = ( is_string ( $ this -> echo ) ) ? $ this -> strlen ( $ this -> linebuffer ) : null ; $ this -> linebuffer = $ input ; $ this -> linepos = $ this -> strlen ( $ this -> linebuffer ) ; if ( $ this -> echo !== fal... | set current text input buffer |
49,769 | public function clearHistory ( ) { $ this -> historyLines = array ( ) ; $ this -> historyPosition = null ; if ( $ this -> historyUnsaved !== null ) { $ this -> setInput ( $ this -> historyUnsaved ) ; $ this -> historyUnsaved = null ; } return $ this ; } | Clears the complete history list |
49,770 | public function limitHistory ( $ limit ) { $ this -> historyLimit = $ limit === null ? null : $ limit ; if ( $ this -> historyLimit !== null && isset ( $ this -> historyLines [ $ this -> historyLimit ] ) ) { if ( $ this -> historyPosition !== null ) { $ this -> historyPosition -= count ( $ this -> historyLines ) - $ th... | Limits the history to a maximum of N entries and truncates the current history list accordingly |
49,771 | public function setAutocomplete ( $ autocomplete ) { if ( $ autocomplete !== null && ! is_callable ( $ autocomplete ) ) { throw new \ InvalidArgumentException ( 'Invalid autocomplete function given' ) ; } $ this -> autocomplete = $ autocomplete ; return $ this ; } | set autocompletion handler to use |
49,772 | public function getDrawString ( ) { $ output = $ this -> prompt ; if ( $ this -> echo !== false ) { if ( $ this -> echo === true ) { $ buffer = $ this -> linebuffer ; } else { $ buffer = str_repeat ( $ this -> echo , $ this -> strlen ( $ this -> linebuffer ) ) ; } $ output .= $ buffer . str_repeat ( "\x08" , $ this -> ... | Returns the string that is used to draw the input prompt |
49,773 | public function deleteChar ( $ n ) { $ len = $ this -> strlen ( $ this -> linebuffer ) ; if ( $ n < 0 || $ n >= $ len ) { return ; } $ pre = $ this -> substr ( $ this -> linebuffer , 0 , $ n ) ; $ post = $ this -> substr ( $ this -> linebuffer , $ n + 1 ) ; $ this -> linebuffer = $ pre . $ post ; if ( $ n < $ this -> l... | delete a character at the given position |
49,774 | protected function processLine ( $ eol ) { $ this -> historyPosition = null ; $ this -> historyUnsaved = null ; $ line = $ this -> linebuffer ; if ( $ line !== '' ) { $ this -> setInput ( '' ) ; } elseif ( $ this -> echo !== false ) { $ this -> redraw ( ) ; } $ this -> emit ( 'data' , array ( $ line . $ eol ) ) ; } | process the current line buffer emit event and redraw empty line |
49,775 | public function index ( ) { $ diagnostics = $ this -> getDiagnosticDataTable ( ) -> getDiagnostics ( $ this -> getRequestOptions ( ) ) ; $ config = $ this -> loadConfig ( ) ; $ data = array ( 'title' => __ ( 'Readiness diagnostics' ) , 'set' => json_encode ( $ diagnostics ) , 'config' => json_encode ( $ config [ 'diagn... | Display the list of all readiness checks performed on the given test center It also allows launching new ones . |
49,776 | public function diagnostic ( ) { $ config = $ this -> loadConfig ( ) ; $ data = array ( 'title' => __ ( 'Readiness Check' ) , 'config' => json_encode ( $ config [ 'diagnostic' ] ) , ) ; $ this -> defaultData ( ) ; $ this -> setData ( 'userLabel' , SessionManager :: getSession ( ) -> getUserLabel ( ) ) ; $ this -> setDa... | Display the diagnostic runner |
49,777 | public function diagnosticData ( ) { try { $ this -> returnJson ( $ this -> getDiagnosticDataTable ( ) -> getDiagnostics ( $ this -> getRequestOptions ( ) ) ) ; } catch ( ServiceNotFoundException $ e ) { \ common_Logger :: w ( __ ( 'No diagnostic service defined' ) ) ; $ this -> returnError ( __ ( 'Interface not availa... | Gets the list of diagnostic results |
49,778 | public function remove ( ) { $ id = $ this -> getRequestParameter ( 'id' ) ; $ this -> returnJson ( [ 'success' => $ this -> getDiagnosticDataTable ( ) -> removeDiagnostic ( $ id ) ] ) ; } | Removes diagnostic results |
49,779 | public function index ( ) { $ authorizationService = $ this -> getServiceLocator ( ) -> get ( Authorization :: SERVICE_ID ) ; if ( $ authorizationService -> isAuthorized ( ) ) { $ config = $ this -> loadConfig ( ) ; if ( ! empty ( $ config [ 'diagnostic' ] [ 'pageTitle' ] ) ) { $ this -> setData ( 'title' , $ config [ ... | If logged in display index view with config data If not forward to login |
49,780 | public function whichBrowser ( ) { $ result = [ 'browser' => $ this -> getBrowserDetector ( ) -> getName ( ) , 'browserVersion' => $ this -> getBrowserDetector ( ) -> getVersion ( ) , 'os' => $ this -> getOsDetector ( ) -> getName ( ) , 'osVersion' => $ this -> getOsDetector ( ) -> getVersion ( ) ] ; $ this -> returnJs... | Render browser detection view |
49,781 | public function upload ( ) { try { if ( $ this -> getRequestMethod ( ) !== \ Request :: HTTP_POST ) { throw new \ common_exception_NotImplemented ( 'Only post method is accepted.' ) ; } if ( ! isset ( $ _POST [ 'upload' ] ) || ! is_string ( $ _POST [ 'upload' ] ) ) { throw new \ common_exception_InconsistentData ( "'up... | Action is used to check upload speed from client side . |
49,782 | public function storeData ( ) { $ data = $ this -> getData ( ) ; $ id = $ this -> getId ( ) ; try { $ storageService = $ this -> getServiceLocator ( ) -> get ( Storage :: SERVICE_ID ) ; $ storageService -> store ( $ id , $ data ) ; $ this -> returnJson ( array ( 'success' => true , 'type' => 'success' ) ) ; } catch ( S... | Register data from the front end |
49,783 | public function schoolName ( ) { sleep ( 1 ) ; $ data = $ this -> getParameters ( ) ; $ required = [ 'school_number' , 'school_pin' ] ; $ response = [ ] ; $ success = true ; foreach ( $ required as $ fieldName ) { if ( ! isset ( $ data [ $ fieldName ] ) ) { $ success = false ; $ response [ 'errorCode' ] = 400 ; $ respo... | Retrieve a school name |
49,784 | protected function getData ( $ check = false ) { $ data = $ this -> getParameters ( ) ; if ( $ this -> hasRequestParameter ( 'type' ) ) { $ type = $ this -> getRequestParameter ( 'type' ) ; unset ( $ data [ 'type' ] ) ; if ( $ type !== 'custom_input' ) { foreach ( $ data as $ key => $ value ) { $ data [ $ type . '_' . ... | Fetch POST data Get login by cookie Get Ip If check parameters is true check mandatory parameters |
49,785 | protected function getId ( ) { if ( ! isset ( $ _COOKIE [ self :: COOKIE_ID ] ) ) { $ id = uniqid ( ) ; setcookie ( self :: COOKIE_ID , $ id ) ; } else { $ id = $ _COOKIE [ self :: COOKIE_ID ] ; } return $ id ; } | Get cookie id OR create it if doesnt exist |
49,786 | protected function loadConfig ( ) { $ service = $ this -> getServiceLocator ( ) -> get ( DiagnosticServiceInterface :: SERVICE_ID ) ; $ config = $ service -> getDiagnosticJsConfig ( ) ; $ config [ 'controller' ] = 'CompatibilityChecker' ; return $ config ; } | Get config parameters for compatibility check |
49,787 | protected function mapData ( array $ data ) { $ config = $ this -> loadConfig ( ) ; foreach ( $ data as $ k => $ d ) { if ( ! empty ( $ config [ 'diagnostic' ] [ 'customInput' ] [ $ k ] ) ) { $ data [ $ config [ 'diagnostic' ] [ 'customInput' ] [ $ k ] ] = $ d ; unset ( $ data [ $ k ] ) ; } } return $ data ; } | Map custom input data from the customInput configuration . |
49,788 | public function store ( $ id , $ data = array ( ) ) { $ data = array_merge ( [ self :: DIAGNOSTIC_ID => $ id ] , $ data ) ; $ data = $ this -> cleanInputData ( $ data ) ; $ this -> openFile ( ) ; $ this -> update ( $ id , $ data ) ; return $ this ; } | Merge id and data array Clean input data by adding empty column Open csv and create new entry |
49,789 | private function getColumns ( ) { $ class = new \ ReflectionClass ( __CLASS__ ) ; $ constants = $ class -> getConstants ( ) ; $ columns = [ ] ; foreach ( $ constants as $ constant => $ value ) { if ( strpos ( $ constant , 'DIAGNOSTIC_' ) === 0 ) { array_push ( $ columns , $ value ) ; } } if ( empty ( $ columns ) ) { th... | Return an array of Storage constant var |
49,790 | public function find ( $ id ) { if ( empty ( $ id ) ) { throw new StorageException ( 'Invalid id parameter.' ) ; } try { return $ this -> select ( null , [ self :: DIAGNOSTIC_ID => $ id ] , 1 ) -> fetch ( \ PDO :: FETCH_ASSOC ) ; } catch ( \ PDOException $ e ) { throw new StorageException ( $ e -> getMessage ( ) ) ; } ... | Gets an existing record in database by id |
49,791 | public function findPage ( $ page = null , $ size = self :: PAGE_SIZE , $ filter = null ) { try { $ offset = ( $ page - 1 ) * $ size ; return $ this -> select ( null , $ filter , $ size , $ offset ) -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; } catch ( \ PDOException $ e ) { throw new StorageException ( $ e -> getMessage ( ... | Gets a page from the storage model based on entity |
49,792 | public function count ( $ filter = null ) { try { return $ this -> select ( 'COUNT(*)' , $ filter ) -> fetchColumn ( ) ; } catch ( \ PDOException $ e ) { throw new StorageException ( $ e -> getMessage ( ) ) ; } } | Gets the number of rows from the storage model based on entity |
49,793 | public function delete ( $ id , $ filter = null ) { if ( empty ( $ id ) ) { throw new StorageException ( 'Invalid id parameter.' ) ; } if ( ! $ filter ) { $ filter = [ ] ; } $ filter [ self :: DIAGNOSTIC_ID ] = $ id ; try { \ common_Logger :: i ( 'Deleting diagnostic result ' . $ id ) ; $ query = 'DELETE FROM ' . self ... | Deletes a row from the storage model based on entity |
49,794 | protected function select ( $ columns = null , $ where = null , $ size = null , $ offset = null ) { if ( ! $ columns ) { $ columns = '*' ; } if ( ! is_array ( $ columns ) ) { $ columns = [ $ columns ] ; } $ query = 'SELECT ' . implode ( ',' , $ columns ) . ' FROM ' . self :: DIAGNOSTIC_TABLE ; return $ this -> query ( ... | Builds and runs a select query |
49,795 | protected function query ( $ query , $ where = null , $ size = null , $ offset = null ) { $ params = [ ] ; if ( is_array ( $ where ) ) { $ conditions = [ ] ; foreach ( $ where as $ column => $ value ) { $ placeholder = '?' ; $ value = '' . $ value ; $ conditions [ ] = $ column . ' = ' . $ placeholder ; $ params [ ] = $... | Builds and runs a query |
49,796 | public function paginate ( $ collection , $ options = array ( ) , $ dataRenderer = null ) { $ optRows = abs ( intval ( isset ( $ options [ self :: OPTION_ROWS ] ) ? $ options [ self :: OPTION_ROWS ] : self :: DEFAULT_ROWS ) ) ; $ optPage = abs ( intval ( isset ( $ options [ self :: OPTION_PAGE ] ) ? $ options [ self ::... | Paginates a collection to render a subset in a table |
49,797 | protected function getConfigByTheme ( array $ config , $ themeId = null ) { if ( null === $ themeId ) { $ themeService = $ this -> getServiceLocator ( ) -> get ( ThemeService :: SERVICE_ID ) ; $ themeId = $ themeService -> getCurrentThemeId ( ) ; } if ( is_array ( reset ( $ config ) ) ) { if ( array_key_exists ( $ them... | Returns the current theme s related config |
49,798 | public function getPersistence ( ) { $ persistenceOption = $ this -> getOption ( self :: DIAGNOSTIC_PERSISTENCE ) ; $ persistence = ( ! empty ( $ persistenceOption ) ) ? $ persistenceOption : 'default' ; return \ common_persistence_Manager :: getPersistence ( $ persistence ) ; } | Get persistence with configurable driver option of Sql Storage Get default driver if option is not set |
49,799 | public function store ( $ id , $ data = array ( ) ) { try { if ( empty ( $ id ) ) { throw new StorageException ( 'Invalid id parameter.' ) ; } $ this -> persistence = $ this -> getPersistence ( ) ; $ data = $ this -> cleanInputData ( $ data ) ; if ( ! $ this -> exists ( $ id ) ) { $ this -> insert ( $ id , $ data ) ; }... | If record already exists update it by new values Else insert new entry |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.