idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
11,000 | public function debug_decode ( $ json , $ assoc = false , $ depth = 512 , $ options = 0 ) { $ test = json_decode ( $ json , $ assoc , $ depth , $ options ) ; if ( ! empty ( $ test ) ) $ json = $ test ; $ data = $ this -> errorMessage ( json_last_error ( ) , $ json ) ; return json_encode ( $ data , JSON_PRETTY_PRINT ) ;... | Debugger to test json decode |
11,001 | public function fixControlChar ( $ string ) { for ( $ i = 0 ; $ i <= 9 ; ++ $ i ) { $ string = str_replace ( chr ( $ i ) , "" , $ string ) ; } for ( $ i = 11 ; $ i <= 12 ; ++ $ i ) { $ string = str_replace ( chr ( $ i ) , "" , $ string ) ; } for ( $ i = 14 ; $ i <= 31 ; ++ $ i ) { $ string = str_replace ( chr ( $ i ) ,... | Most common fixed hidden control char in json string which made json decode fails . |
11,002 | public function modifyJsonStringInArray ( $ data , $ jsonfield , $ setnewfield = "" ) { if ( is_array ( $ data ) ) { if ( count ( $ data ) == count ( $ data , COUNT_RECURSIVE ) ) { foreach ( $ data as $ value ) { if ( ! empty ( $ setnewfield ) ) { if ( is_array ( $ jsonfield ) ) { for ( $ i = 0 ; $ i < count ( $ jsonfi... | Modify json data string in some field array to be nice json data structure |
11,003 | public function minify ( $ json ) { $ tokenizer = "/\"|(\/\*)|(\*\/)|(\/\/)|\n|\r/" ; $ in_string = false ; $ in_multiline_comment = false ; $ in_singleline_comment = false ; $ tmp ; $ tmp2 ; $ new_str = array ( ) ; $ ns = 0 ; $ from = 0 ; $ lc ; $ rc ; $ lastIndex = 0 ; while ( preg_match ( $ tokenizer , $ json , $ tm... | Minify the json string |
11,004 | public function renderPageSummary ( ) { $ content = parent :: renderPageSummary ( ) ; if ( $ this -> showCustomPageSummary ) { if ( ! $ content ) { $ content = "<tfoot></tfoot>" ; } if ( $ this -> beforeSummary ) { foreach ( $ this -> beforeSummary as & $ row ) { if ( ! isset ( $ row [ 'options' ] ) ) { $ row [ 'option... | Custom renders the table page summary . |
11,005 | public function multi ( string $ name = null , string $ mail = null , string $ ip = null ) { return $ this -> makeRequest ( 'multi' , compact ( 'name' , 'mail' , 'ip' ) ) ; } | Test matches all parameters at once . |
11,006 | public function getContent ( ) { $ content = "" ; $ maxLen = 0 ; foreach ( $ this -> logs as $ log ) if ( $ log [ 0 ] ) { $ name = $ log [ 0 ] -> getFeature ( ) -> getName ( ) ; $ maxLen = strlen ( $ name ) > $ maxLen ? strlen ( $ name ) : $ maxLen ; } foreach ( $ this -> logs as $ log ) $ content .= sprintf ( "%-{$max... | Returns the log file s content . Tabular output is generated . |
11,007 | public function render_screen ( ) { $ this -> register_batches ( ) ; ?> <div class="wrap"> <h2> <?php $ this -> _e ( 'Do Batch Actions' ) ?> </h2> <?php if ( $ this -> batches ) : ?> <form id="batch-form" method="post" action=" <?= admin_url ( 'admin-ajax.php' ) ?> "> <input type="hidden" name="action" value="w... | Render Admin screen |
11,008 | protected function register_batches ( ) { static $ batch_registered = false ; if ( ! $ batch_registered ) { $ auto_loader = AutoLoader :: get_instance ( ) ; $ root = $ auto_loader -> namespace_root ; $ namespace = $ auto_loader -> namespace ; if ( $ namespace && $ root && is_dir ( $ root . '/Batches' ) ) { foreach ( sc... | Register Batch classes |
11,009 | public function request ( array $ curl_options ) { $ curl = $ this -> _init ( $ curl_options ) ; $ response = $ this -> _execute ( $ curl ) ; if ( $ response === FALSE ) { $ this -> _handle_error ( $ curl ) ; return FALSE ; } $ this -> _close ( $ curl ) ; return $ response ; } | Perform a cURL request |
11,010 | protected function _init ( array $ curl_options ) { $ options = array ( CURLOPT_SSL_VERIFYPEER => FALSE , CURLOPT_SSL_VERIFYHOST => FALSE , CURLOPT_RETURNTRANSFER => TRUE , CURLOPT_FOLLOWLOCATION => TRUE , CURLOPT_MAXREDIRS => 10 ) ; $ options += $ curl_options ; $ curl = curl_init ( ) ; curl_setopt_array ( $ curl , $ ... | Initializes a cURL resource and set options |
11,011 | protected function _handle_error ( $ curl ) { $ code = curl_errno ( $ curl ) ; $ error = curl_error ( $ curl ) ; $ this -> _close ( $ curl ) ; throw new Exception_Source ( 'Fetching :source_name data failed: :error (:code)' , 'remote' , array ( ':error' => $ error , ':code' => $ code ) ) ; } | Handle cURL errors |
11,012 | public static function getValues ( $ name , $ index = 'code' ) { if ( $ property_id = self :: getId ( $ name ) ) { $ a = [ ] ; foreach ( Lookup :: find ( ) -> select ( [ 'position' , 'name' ] ) -> where ( [ 'property_id' => $ property_id ] ) -> orderBy ( $ index ) -> all ( ) as $ item ) $ a [ $ item -> $ index ] = $ it... | Get all property values as array with Code or Position as index . |
11,013 | private function set_cron_event ( ) { $ interval = $ this -> get_interval ( ) ; if ( $ interval > 0 ) { if ( ! wp_next_scheduled ( $ this -> get_hook_name ( ) ) ) { if ( $ this -> is_running_cron_process ( ) ) { return ; } wp_schedule_single_event ( time ( ) + $ interval , $ this -> get_hook_name ( ) ) ; } } } | set cron event |
11,014 | public function isValid ( $ value , array $ context = null ) { $ context = ( array ) $ context ; if ( ! array_key_exists ( $ this -> identity , $ context ) || empty ( $ context [ $ this -> identity ] ) ) { return false ; } if ( ! array_key_exists ( $ this -> credential , $ context ) || empty ( $ context [ $ this -> cre... | Test if authentication is valid |
11,015 | protected function fires ( ) { $ className = isset ( $ this -> notification -> classname ) ? snake_case ( class_basename ( $ this -> notification -> classname ) ) : false ; if ( ! $ className ) { return [ ] ; } $ before = event ( 'notifications:' . $ className . '.render.before' ) ; $ after = event ( 'notifications:' .... | fires events for notification template |
11,016 | public function save ( array $ options = array ( ) ) { $ fired = $ this -> fires ( ) ; $ content = count ( $ fired ) ? str_replace ( [ $ fired [ 'before' ] , $ fired [ 'after' ] ] , '' , $ this -> content ) : $ this -> content ; $ this -> setAttribute ( 'content' , $ content ) ; $ this -> attributes [ 'content' ] = $ c... | saves notification content without data from fired events |
11,017 | public function get ( $ key , $ defaultValue = null ) { $ keys = explode ( '.' , $ key ) ; $ config = $ this -> _arr ; foreach ( $ keys as $ value ) { if ( is_array ( $ config ) ) { if ( array_key_exists ( $ value , $ config ) ) { $ config = $ config [ $ value ] ; } else { return $ defaultValue ; } } else { return $ de... | Gets config value based on key . |
11,018 | public function set ( $ key , $ value ) { $ keys = explode ( '.' , $ key ) ; $ config = & $ this -> _arr ; foreach ( $ keys as $ val ) { $ config = & $ config [ $ val ] ; } $ config = $ value ; } | Sets config value based on key . |
11,019 | public function remove ( $ key ) { $ keys = explode ( '.' , $ key ) ; $ cKeys = count ( $ keys ) ; $ config = & $ this -> _arr ; for ( $ i = 0 ; $ i < $ cKeys ; ++ $ i ) { if ( $ i === ( $ cKeys - 1 ) ) { unset ( $ config [ $ keys [ $ i ] ] ) ; } elseif ( is_array ( $ config ) ) { if ( array_key_exists ( $ keys [ $ i ]... | Removes config value based on key . |
11,020 | public function has ( $ key ) { $ keys = explode ( '.' , $ key ) ; $ cKeys = count ( $ keys ) ; $ config = $ this -> _arr ; for ( $ i = 0 ; $ i < $ cKeys ; ++ $ i ) { if ( is_array ( $ config ) ) { if ( array_key_exists ( $ keys [ $ i ] , $ config ) ) { $ config = $ config [ $ keys [ $ i ] ] ; } else { return false ; }... | Checks whether config has a certain key . |
11,021 | public function add_fonts ( array $ fonts ) { if ( ! \ defined ( 'BBN_LIB_PATH' ) ) { die ( 'You must define BBN_LIB_PATH!' ) ; } if ( ! is_dir ( BBN_LIB_PATH . 'mpdf/mpdf/ttfonts/' ) ) { die ( "You don't have the mpdf/mpdf/ttfonts directory." ) ; } foreach ( $ fonts as $ f => $ fs ) { foreach ( $ fs as $ i => $ v ) { ... | Adds custom fonts |
11,022 | static public function confirmAspectMockConfigured ( ) { $ httpDouble = test :: double ( 'SimpleSAML\Utils\HTTP' , [ 'getAcceptLanguage' => [ 'some-lang' ] ] ) ; if ( [ 'some-lang' ] !== \ SimpleSAML \ Utils \ HTTP :: getAcceptLanguage ( ) ) { throw new \ Exception ( "Aspect mock does not seem to be configured" ) ; } r... | Checks that AspectMock is configured and can override HTTP Util methods |
11,023 | private function setupConnection ( ) { $ requiredMode = $ this -> options -> quoteIdentifier ; if ( $ requiredMode == ezcDbMssqlOptions :: QUOTES_GUESS ) { $ result = parent :: query ( "SELECT sessionproperty('QUOTED_IDENTIFIER')" ) ; $ rows = $ result -> fetchAll ( ) ; $ mode = ( int ) $ rows [ 0 ] [ 0 ] ; if ( $ mode... | Sets up opened connection according to options . |
11,024 | protected function rebuildClassPathCache ( $ path , $ cacheFile ) { if ( $ cacheFile !== false ) { $ tmp = $ this -> classPath ; $ this -> classPath = array ( ) ; } $ list = glob ( rtrim ( $ path , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . '*' ) ; if ( is_array ( $ list ) ) { foreach ( $ list as $ f ) { if ( is_dir... | rebuilds class paths scans the given directory recursively and saves all paths in the given file |
11,025 | public function loadPlugin ( $ class , $ forceRehash = true ) { if ( ! isset ( $ this -> classPath [ $ class ] ) || ! ( include $ this -> classPath [ $ class ] ) ) { if ( $ forceRehash ) { $ this -> rebuildClassPathCache ( $ this -> corePluginDir , $ this -> cacheDir . 'classpath.cache.d' . Dwoo :: RELEASE_TAG . '.php'... | loads a plugin file |
11,026 | public static function render ( $ source , $ rules = array ( ) , $ directory = null ) { if ( ! $ directory ) $ directory = getcwd ( ) ; return self :: fromSpecification ( fphp \ Specification \ TemplateSpecification :: fromArrayAndSettings ( array ( "source" => $ source , "rules" => $ rules ) , fphp \ Settings :: inDir... | A quick way to directly render a template file with some replacement rules . |
11,027 | public function getContent ( ) { $ content = file_get_contents ( $ this -> fileSource ) ; foreach ( $ this -> rules as $ rule ) $ content = $ rule -> apply ( $ content ) ; return new TextFileContent ( $ content ) ; } | Returns the template file s content . The content consists of the file content with every rule applied . |
11,028 | public function listAction ( ) { $ this -> performAccessChecks ( ) ; $ crons = $ this -> cronService -> getCrons ( ) ; return $ this -> render ( 'SmileEzUICronBundle:cron:tab/crons/list.html.twig' , [ 'datas' => $ crons ] ) ; } | List crons definition |
11,029 | public function editAction ( Request $ request , $ type , $ alias ) { $ this -> performAccessChecks ( ) ; $ value = $ request -> get ( 'value' ) ; $ response = new Response ( ) ; try { $ this -> cronService -> updateCron ( $ alias , $ type , $ value ) ; $ response -> setStatusCode ( 200 , $ this -> translator -> trans ... | Edition cron definition |
11,030 | public function detect ( ) { foreach ( $ this -> detectors as $ detector ) { $ locales = ( array ) $ this -> getInstance ( $ detector ) -> detect ( ) ; foreach ( $ locales as $ locale ) { if ( $ this -> isSupportedLocale ( $ locale ) ) { return $ locale ; } } } return false ; } | Detect any supported locale and return the first match . |
11,031 | public function tables ( ) { $ schema = $ this -> db -> connection ( ) -> getDoctrineConnection ( ) -> getSchemaManager ( ) ; $ tables = $ schema -> listTableNames ( ) ; foreach ( $ tables as $ table ) { $ columns = $ this -> describer -> describe ( $ table ) ; yield compact ( 'table' , 'columns' ) ; } } | Return a description for each table . |
11,032 | public function flush ( ) { if ( $ this -> recordSize === 0 ) { return ; } $ str = '' ; foreach ( $ this -> records as $ record ) { $ str .= $ this -> recordFormat ( $ record ) ; } $ this -> clear ( ) ; $ this -> write ( $ str ) ; } | flush data to file . |
11,033 | public function getLogPath ( ) { if ( ! $ this -> basePath ) { throw new \ InvalidArgumentException ( 'The property basePath is required.' ) ; } return $ this -> getBasePath ( ) . '/' . ( $ this -> subFolder ? $ this -> subFolder . '/' : '' ) ; } | get log path |
11,034 | private function saveIncident ( $ report_xml ) { if ( ! empty ( $ report_xml ) && $ report_xml = simplexml_load_string ( $ report_xml ) ) { $ this -> feedName = 'default' ; if ( $ this -> isKnownFeed ( ) && $ this -> isEnabledFeed ( ) ) { $ report_raw = json_decode ( json_encode ( $ report_xml ) , true ) ; $ report = $... | Uses the XML to create incidents |
11,035 | private function setPayload ( array $ parameters ) : void { $ this -> payload = [ ] ; foreach ( $ parameters as $ parameter => $ value ) { $ this -> setPayloadParameter ( $ parameter , $ value ) ; } } | Set payload . |
11,036 | public function getAuthType ( ) { if ( isset ( $ this -> auth [ 'username' ] ) && isset ( $ this -> auth [ 'password' ] ) ) { return self :: HTTP_PASSWORD ; } if ( isset ( $ this -> auth [ 'client_id' ] ) && isset ( $ this -> auth [ 'client_secret' ] ) ) { return self :: URL_SECRET ; } if ( isset ( $ this -> auth [ 'ac... | Calculating the Authentication Type |
11,037 | public function httpPassword ( Event $ event ) { $ event [ 'request' ] -> setHeader ( 'Authorization' , sprintf ( 'Basic %s' , base64_encode ( $ this -> auth [ 'username' ] . ':' . $ this -> auth [ 'password' ] ) ) ) ; } | Basic Authorization with username and password |
11,038 | public function urlSecret ( Event $ event ) { $ query = $ event [ 'request' ] -> getQuery ( ) ; $ query -> set ( 'client_id' , $ this -> auth [ 'client_id' ] ) ; $ query -> set ( 'client_secret' , $ this -> auth [ 'client_secret' ] ) ; } | OAUTH2 Authorization with client secret |
11,039 | public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { throw new \ Exception ( 'Must supply key to modify arguments in an AssociativeArray.' ) ; } else { $ this -> _args [ $ offset ] = $ value ; } } | Override the offsetSet function to modify values of the wrapped array . Key is enforced . |
11,040 | public function Elements ( ) { $ fcvdo = new \ Nblum \ FlexibleContent \ FlexibleContentVersionedDataObject ( ) ; $ defaultStage = $ fcvdo -> getDefaultStage ( ) ; if ( isset ( $ _GET [ 'stage' ] ) && $ defaultStage == $ _GET [ 'stage' ] && \ Permission :: check ( 'CMS_ACCESS' ) ) { $ stage = $ defaultStage ; } else { ... | creates List of all rows with content |
11,041 | public static function convert ( $ value , $ to , $ from ) { if ( $ from instanceof Measure === false || $ to instanceof Measure === false ) { throw new Exception ( '`from` or `to` parameter is not a Measure' ) ; } if ( $ from -> type !== $ to -> type ) { throw new Exception ( 'Measures have different types' ) ; } if (... | Convert a value from one measure to another |
11,042 | public static function format ( $ value , $ to , $ from = null ) { if ( $ to instanceof Measure === false ) { throw new Exception ( 'Unknown object' ) ; } if ( $ from instanceof Measure ) { $ value = static :: convert ( $ value , $ to , $ from ) ; } $ formatter = $ to -> use_custom_formatter == true ? $ to -> formatter... | Format a value by rule as a string |
11,043 | public static function parseString ( $ source , $ matchRules ) { foreach ( ( array ) $ matchRules as $ matchRule ) { if ( is_callable ( $ matchRule ) === true ) { return call_user_func ( $ matchRule , $ source ) ; } else { if ( preg_match ( $ matchRule , $ source , $ matches ) === 1 ) { $ value = $ matches [ 'integral'... | Parse string by regexp or closure . |
11,044 | private function addHeadersSection ( ezcMailHeadersHolder $ headers ) { $ result = "" ; foreach ( $ headers -> getCaseSensitiveArray ( ) as $ header => $ value ) { $ result .= $ header . ": " . $ value . ezcMailTools :: lineBreak ( ) ; } return $ result ; } | Returns the generated text for a section of the delivery - status part . |
11,045 | public function createRecipient ( ) { $ result = count ( $ this -> recipients ) ; $ this -> recipients [ $ result ] = new ezcMailHeadersHolder ( ) ; return $ result ; } | Adds a new recipient to this delivery - status message and returns the index of the last added recipient . |
11,046 | public function validate ( $ cache ) { $ original = $ cache ; if ( is_callable ( $ cache ) ) { $ failed = false ; try { $ cache = $ cache ( $ this -> container ) ; } catch ( \ Exception $ e ) { $ failed = true ; $ this -> container [ 'log' ] -> warning ( 'Unable to connect to the cache backend.' ) ; } if ( ! $ failed &... | Validate a cache to ensure it implements the Cache Contract and that we are able to connect to the cache backend . |
11,047 | public function injectResponse ( ViewEvent $ e ) { $ renderer = $ e -> getRenderer ( ) ; if ( $ renderer !== $ this -> renderer ) { return ; } $ result = $ e -> getResult ( ) ; $ response = $ e -> getResponse ( ) ; $ response -> setContent ( $ result ) ; $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeader... | Inject the response with the feed payload and appropriate Content - Type header |
11,048 | public function getPdf ( $ id = '' ) { $ id = $ id ? : $ this -> attributes [ $ this -> primary_column ] ; return $ this -> request ( 'GET' , sprintf ( '%s/%s' , $ this -> getUrl ( ) , $ id ) , array ( ) , "" , "pdf" ) ; } | Retrieves a PDF file of an invoice |
11,049 | public function generateFiles ( $ class , $ target ) { $ files = array ( ) ; $ includes = "" ; $ registers = "" ; foreach ( $ this -> aspects as $ aspect ) { $ files [ ] = $ aspect -> getStoredFile ( ) ; $ includes .= "require_once __DIR__ . '/" . str_replace ( "'" , "\'" , $ aspect -> getRelativeFileTarget ( $ target ... | Generates the aspect kernel s files . This includes all aspect files and the aspect kernel itself . |
11,050 | public function build ( $ name , Collection $ fields = null ) { $ path = $ this -> getClassFilePath ( $ name ) ; $ tableName = source_table_name ( $ name ) ; $ contents = view ( '_hierarchy::entities.model' , [ 'tableName' => $ tableName , 'name' => $ this -> getClassName ( $ name ) , 'fields' => $ this -> makeFields (... | Builds a source model |
11,051 | protected function makeSearchableFields ( Collection $ fields = null , $ tableName ) { if ( is_null ( $ fields ) ) { return '' ; } $ searchables = [ ] ; foreach ( $ fields as $ field ) { if ( intval ( $ field -> search_priority ) > 0 ) { $ searchables [ ] = "'{$tableName}.{$field->name}' => {$field->search_priority}" ;... | Makes searchable fields |
11,052 | protected function makeMutatableFields ( Collection $ fields = null ) { if ( is_null ( $ fields ) ) { return '' ; } $ mutatables = [ ] ; foreach ( $ fields as $ field ) { if ( in_array ( $ field -> type , [ 'document' , 'gallery' , 'markdown' , 'node' , 'node_collection' ] ) ) { $ mutatables [ ] = "'{$field->name}' => ... | Makes mutatable fields |
11,053 | public function run ( ) : bool { if ( $ this -> startup ) { $ this -> logger -> debug ( 'Calling startup callback' ) ; call_user_func ( $ this -> startup , $ this ) ; } $ actions = implode ( ', ' , array_keys ( $ this -> callbacks ) ) ; $ this -> logger -> info ( "Component running with callbacks for $actions" ) ; $ th... | Run the SDK . |
11,054 | public function getFileData ( $ file = null , $ offset = null ) { if ( null === $ file ) $ file = & $ this -> file ; if ( null === $ offset ) $ offset = $ this -> file_offset ; $ this -> IO = fopen ( $ file , 'r' ) ; fseek ( $ this -> IO , $ offset ) ; try { $ this -> raw = stream_get_contents ( $ this -> IO ) ; } catc... | read file from offset |
11,055 | static function get ( $ post_id ) { global $ db ; $ sql = "SELECT * FROM " . POSTS_TABLE . " WHERE post_id=" . intval ( $ post_id ) ; $ result = $ db -> sql_query ( $ sql ) ; $ post_data = $ db -> sql_fetchrow ( $ result ) ; $ db -> sql_freeresult ( $ result ) ; if ( ! $ post_data ) { return false ; } return post :: fr... | static method loads the post with a given post_id from database . returns false if the post does not exist |
11,056 | function get_topic ( $ all_posts = false ) { if ( ! $ this -> _topic ) { if ( $ this -> post_id ) { $ this -> _topic = topic :: get ( $ this -> topic_id , $ all_posts ) ; if ( $ all_posts ) { for ( $ i = 0 ; $ i < sizeof ( $ this -> _topic -> posts ) ; $ i ++ ) { if ( $ this -> _topic -> posts [ $ i ] -> post_id == $ t... | loads and returns the topic for this post |
11,057 | function add ( $ type , $ id , $ field , $ amount = 1 ) { $ this -> init ( $ type , $ id ) ; if ( ! isset ( $ this -> data [ $ type ] [ $ id ] [ 'add' ] [ $ field ] ) ) { $ this -> data [ $ type ] [ $ id ] [ 'add' ] [ $ field ] = 0 ; } $ this -> data [ $ type ] [ $ id ] [ 'add' ] [ $ field ] += $ amount ; } | increments or decrements a field . |
11,058 | private function open_pdo_connection ( ) { try { $ this -> connection = in_array ( $ this -> dbtype , [ 'sqlite3' , 'pgsql' ] ) ? new \ PDO ( $ this -> connection_string ) : new \ PDO ( $ this -> connection_string , $ this -> dbuser , $ this -> dbpass ) ; self :: $ logger -> debug ( sprintf ( "SQL: connection opened: '... | Open PDO connection . |
11,059 | private function format_connection_string ( ) { if ( ! in_array ( $ this -> dbtype , [ 'sqlite3' , 'mysql' , 'pgsql' ] ) ) { $ this -> verified_params = null ; self :: $ logger -> error ( sprintf ( "SQL: database not supported: '%s'." , $ this -> dbtype ) ) ; throw new SQLError ( SQLError :: DBTYPE_ERROR , $ this -> db... | Verify and format connection string . |
11,060 | final public function time ( ) { if ( $ this -> dbtype == 'pgsql' ) return $ this -> query ( "SELECT EXTRACT('epoch' from CURRENT_TIMESTAMP) AS now" ) [ 'now' ] ; if ( $ this -> dbtype == 'mysql' ) return $ this -> query ( "SELECT UNIX_TIMESTAMP() AS now" ) [ 'now' ] ; return $ this -> query ( "SELECT strftime('%s', CU... | Get Unix timestamp from database server . |
11,061 | private function stmt_fragment_datetime ( $ delta ) { $ sign = $ delta >= 0 ? '+' : '-' ; $ delta = abs ( $ delta ) ; $ date = '' ; switch ( $ this -> dbtype ) { case 'sqlite3' : $ date = "(datetime('now', '%s%s second'))" ; break ; case 'pgsql' : $ date = ( "(" . "now() at time zone 'utc' %s " . "interval '%s second'"... | SQL datetime fragment . |
11,062 | public function stmt_fragment ( $ part , $ args = [ ] ) { $ type = $ this -> dbtype ; if ( $ part == 'engine' ) { if ( $ type == 'mysql' ) return "ENGINE=InnoDB" ; return '' ; } if ( $ part == "index" ) { if ( $ type == 'pgsql' ) return 'SERIAL PRIMARY KEY' ; if ( $ type == 'mysql' ) return 'INTEGER PRIMARY KEY AUTO_IN... | SQL statement fragment . |
11,063 | public function table_exists ( $ table ) { if ( ! preg_match ( '!^[0-9a-z_]+$!i' , $ table ) ) return false ; self :: $ logger -> deactivate ( ) ; try { $ this -> query ( sprintf ( "SELECT 1 FROM %s LIMIT 1" , $ table ) ) ; self :: $ logger -> activate ( ) ; return true ; } catch ( SQLError $ e ) { self :: $ logger -> ... | Check if a table or view exists . |
11,064 | private function prepare_statement ( $ stmt , $ args = [ ] ) { if ( ! $ this -> connection ) { self :: $ logger -> error ( sprintf ( "SQL: connection failed: '%s'." , json_encode ( $ this -> verified_params ) ) ) ; throw new SQLError ( SQLError :: CONNECTION_ERROR , $ this -> dbtype . " connection error." ) ; } $ conn ... | Prepare and execute statement . |
11,065 | final public function query_raw ( $ stmt , $ args = [ ] ) { $ pstmt = $ this -> prepare_statement ( $ stmt , $ args ) ; self :: $ logger -> info ( sprintf ( "SQL: query raw ok: %s." , $ stmt ) ) ; return $ pstmt ; } | Execute raw query . |
11,066 | final public function insert ( $ table , $ args = [ ] , $ pk = null ) { $ keys = $ vals = [ ] ; $ keys = array_keys ( $ args ) ; $ vals = array_fill ( 0 , count ( $ args ) , '?' ) ; $ columns = implode ( ',' , $ keys ) ; $ placeholders = implode ( ',' , $ vals ) ; $ stmt = "INSERT INTO $table ($columns) VALUES ($placeh... | Insert statement . |
11,067 | public function registerStandardObjects ( ) { $ this -> extensionMap = new ExtensionMap ( ) ; $ this -> extensions = $ this -> extensionMap -> getRegisteredExtensionNames ( ) ; $ this -> finder -> files ( ) ; } | Registers the extension map and sets the finder to look for files |
11,068 | public function filterByExtension ( ) { $ filter = function ( \ SplFileInfo $ file ) { return in_array ( $ file -> getExtension ( ) , $ this -> extensions ) ; } ; $ this -> filter ( $ filter ) ; } | Filters file results by their extension |
11,069 | public function fetch ( ) { $ this -> filterByExtension ( ) ; $ results = Array ( ) ; foreach ( $ this -> finder as $ file ) { $ config = new ConfigFile ( $ this -> fs , $ this -> fileInfo , $ this -> extracter ) ; $ config -> load ( $ file -> getRealPath ( ) ) ; $ results [ ] = $ config ; } $ this -> finder = new Find... | Fetches results of current instance of the finder |
11,070 | public function setDirectory ( $ directory ) { $ this -> directory = $ directory ; $ this -> finder -> in ( $ directory ) ; return $ this ; } | Sets the directory value |
11,071 | protected function _update ( & $ Schema , $ table = null ) { $ db = ConnectionManager :: getDataSource ( $ this -> Schema -> connection ) ; $ this -> out ( __d ( 'cake_console' , 'Comparing Database to Schema...' ) ) ; $ options = array ( ) ; $ this -> params [ 'force' ] = false ; if ( isset ( $ this -> params [ 'force... | Update database with Schema object Should be called via the run method |
11,072 | public function createPidfile ( $ appName , $ path = '/var/run' ) { if ( ! $ this -> control ) { $ this -> createControl ( ) ; } return new Pidfile ( $ this -> control , strtolower ( $ appName ) , $ path ) ; } | Create Pid file for process |
11,073 | protected function replaces ( PackageInterface $ source , PackageInterface $ target ) { foreach ( $ source -> getReplaces ( ) as $ link ) { if ( $ link -> getTarget ( ) === $ target -> getName ( ) ) { return true ; } } return false ; } | Checks if source replaces a package with the same name as target . |
11,074 | final public static function className ( string $ fullName = null ) : string { $ fullName = $ fullName ? : self :: fullName ( ) ; $ fullName = str_replace ( '\\' , '/' , $ fullName ) ; return basename ( $ fullName ) ; } | get called class name |
11,075 | public static function resolve ( $ name , $ callable ) { $ invokable = Resolver :: of ( $ callable ) ; $ annotations = $ invokable -> annotations ( ) ; $ annotations [ 'method' ] = $ invokable ; return new Logic ( $ name , $ annotations ) ; } | Resolve logic from callable |
11,076 | public function bitXor ( $ value1 , $ value2 ) { $ value1 = $ this -> getIdentifier ( $ value1 ) ; $ value2 = $ this -> getIdentifier ( $ value2 ) ; return "( {$value1} + {$value2} - bitand( {$value1}, {$value2} ) * 2 )" ; } | Returns the SQL that performs the bitwise XOR on two values . |
11,077 | public function unixTimestamp ( $ column ) { $ column = $ this -> getIdentifier ( $ column ) ; if ( $ column != 'NOW()' ) { $ column = "CAST( {$column} AS TIMESTAMP )" ; } $ date1 = "CAST( SYS_EXTRACT_UTC( {$column} ) AS DATE )" ; $ date2 = "TO_DATE( '19700101000000', 'YYYYMMDDHH24MISS' )" ; return " ROUND( ( {$date1} ... | Returns the SQL that converts a timestamp value to a unix timestamp . |
11,078 | public function dateSub ( $ column , $ expr , $ type ) { $ type = $ this -> intervalMap [ $ type ] ; $ column = $ this -> getIdentifier ( $ column ) ; if ( $ column != 'NOW()' ) { $ column = "CAST( {$column} AS TIMESTAMP )" ; } return " {$column} - INTERVAL '{$expr}' {$type} " ; } | Returns the SQL that subtracts an interval from a timestamp value . |
11,079 | public function dateAdd ( $ column , $ expr , $ type ) { $ type = $ this -> intervalMap [ $ type ] ; $ column = $ this -> getIdentifier ( $ column ) ; if ( $ column != 'NOW()' ) { $ column = "CAST( {$column} AS TIMESTAMP )" ; } return " {$column} + INTERVAL '{$expr}' {$type} " ; } | Returns the SQL that adds an interval to a timestamp value . |
11,080 | public function in ( $ column ) { $ args = func_get_args ( ) ; if ( count ( $ args ) < 2 ) { throw new ezcQueryVariableParameterException ( 'in' , count ( $ args ) , 2 ) ; } if ( is_array ( $ args [ 1 ] ) && count ( $ args [ 1 ] ) == 0 ) { throw new ezcQueryInvalidParameterException ( 'in' , 2 , 'empty array' , 'non-em... | Returns the SQL to check if a value is one in a set of given values . |
11,081 | protected function mergeComposerJsonFiles ( string $ composer_file , \ stdClass $ original_composer , \ stdClass $ new_composer , callable $ callback = NULL ) { $ new_composer = $ this -> mergeComposerObjects ( $ original_composer , $ new_composer , $ callback ) ; $ composer_content = file_get_contents ( $ composer_fil... | Merges the original composer file with a new composer file . |
11,082 | protected function mergeComposerObjects ( \ stdClass $ original_composer , \ stdClass $ new_composer , callable $ callback = NULL ) { foreach ( $ original_composer as $ key => $ values ) { $ is_array = is_array ( $ values ) ; $ values = ( array ) $ values ; if ( isset ( $ new_composer -> { $ key } ) ) { $ value = ( arr... | Merges two composer objects into one . |
11,083 | protected function calculateRequirementChanges ( $ replace_composer , $ new_composer ) { $ changes = [ 'install' => [ ] , 'update' => [ ] , 'remove' => [ ] , ] ; foreach ( [ 'require' , 'require-dev' ] as $ key ) { $ old_requirements = ! empty ( $ replace_composer -> { $ key } ) ? $ replace_composer -> { $ key } : [ ] ... | Calculated requirements that need to be removed from the system . |
11,084 | public function toXhtml ( \ DOMDocument $ document , \ DOMElement $ root ) { $ content = '' ; $ caption = '' ; foreach ( $ this -> node -> nodes as $ node ) { $ content .= $ node -> token -> content ; } $ matches = array ( ) ; if ( preg_match ( '/([^<]*)<?([^>]*)>?/' , $ content , $ matches ) ) { if ( isset ( $ matches... | Transform text role to HTML . |
11,085 | public function _getParams ( $ key = - 1 ) { if ( $ key >= 0 ) { if ( isset ( self :: $ params [ $ key ] ) ) { return self :: $ params [ $ key ] ; } else { return NULL ; } } else { return self :: $ params ; } } | get Route Paramenters |
11,086 | public function setParams ( $ key , $ value = '' ) { if ( is_array ( $ key ) ) { self :: $ RealParams = $ key ; } else { self :: $ RealParams [ $ key ] = $ value ; } } | Set route paramters |
11,087 | public function isPut ( ) { if ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) { if ( $ _SERVER [ 'REQUEST_METHOD' ] == 'PUT' || ( isset ( $ _POST [ '_METHOD' ] ) && $ _POST [ '_METHOD' ] == 'PUT' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ vars ) ; if ( isset ( $ vars [ '_METHOD' ] ) ) { unset ( $ vars [ '_... | Check request of Put method |
11,088 | public function isDelete ( ) { if ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) { if ( $ _SERVER [ 'REQUEST_METHOD' ] == 'DELETE' || ( isset ( $ _POST [ '_METHOD' ] ) && $ _POST [ '_METHOD' ] == 'DELETE' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ vars ) ; if ( isset ( $ vars [ '_METHOD' ] ) ) { unset ( $ ... | Check request of delete method |
11,089 | public function isPatch ( ) { if ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) { if ( $ _SERVER [ 'REQUEST_METHOD' ] == 'PATCH' || ( isset ( $ _POST [ '_METHOD' ] ) && $ _POST [ '_METHOD' ] == 'PATCH' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ vars ) ; if ( isset ( $ vars [ '_METHOD' ] ) ) { unset ( $ var... | Check request of Patch method |
11,090 | public function isOptions ( ) { if ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) { if ( $ _SERVER [ 'REQUEST_METHOD' ] == 'OPTIONS' || ( isset ( $ _POST [ '_METHOD' ] ) && $ _POST [ '_METHOD' ] == 'OPTIONS' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ vars ) ; if ( isset ( $ vars [ '_METHOD' ] ) ) { unset (... | Check request of Options method |
11,091 | public function transform ( $ block ) { $ block = $ this -> entityToArray ( Block :: class , $ block ) ; return [ 'id' => $ this -> setNullableValue ( $ block [ 'id' ] ) , 'type' => $ block [ 'type' ] , 'region' => $ block [ 'region' ] , 'filter' => $ block [ 'filter' ] , 'options' => $ block [ 'options' ] , 'theme' =>... | Transforms block entity |
11,092 | public function add_js ( $ js ) { $ current = $ this -> dwoo_data -> js_files ; $ current [ ] = $ js ; $ this -> dwoo_data -> js_files = $ current ; } | Add Javascript files to template |
11,093 | public function add_css ( $ css ) { $ current = $ this -> dwoo_data -> css_files ; $ current [ ] = $ css ; $ this -> dwoo_data -> css_files = $ current ; } | Add Css stylesheets to template |
11,094 | public function display ( $ sTemplate , $ return = FALSE ) { $ CI = get_instance ( ) ; $ CI -> benchmark -> mark ( 'dwoo_parse_start' ) ; if ( ! file_exists ( $ this -> template_dir . $ sTemplate ) ) { $ message = sprintf ( 'Template file \'%s\' not found.' , $ sTemplate ) ; show_error ( $ message ) ; log_message ( 'er... | Display or return the compiled template Since we assign the results to the standard CI output module you can also use the helper from CI in your templates!! |
11,095 | private function initialize ( ) { $ CI = get_instance ( ) ; $ CI -> config -> load ( 'dwootemplate' , TRUE ) ; $ config = $ CI -> config -> item ( 'dwootemplate' ) ; foreach ( $ config as $ key => $ val ) { $ this -> $ key = $ val ; } } | Assign the dwootemplate config items to the instance |
11,096 | public function getModelAdminSearchContext ( ) { return SearchContext :: create ( get_class ( $ this -> getOwner ( ) ) , $ this -> getOwner ( ) -> scaffoldSearchFields ( ) , $ this -> getOwner ( ) -> defaultSearchFilters ( ) ) ; } | Get a custom search context for model admin plus |
11,097 | public function combine ( $ another ) { if ( is_a ( $ another , DC_DataHolder :: getKlass ( ) ) ) { if ( empty ( $ this -> identifier ) ) { debug_message ( "DC_DataHolder::identifier should not be empty!!" ) ; $ this -> identifier = $ another -> identifier ; } elseif ( strcmp ( substr ( $ this -> identifier , - strlen ... | Combines this object with another DC_DataHolder object |
11,098 | private function generateThumbs ( $ episode , $ cache_asset ) { $ uri = $ this -> asset_helper -> getAbsoluteUrl ( $ episode -> getVideo ( ) ) ; $ path = $ this -> asset_helper -> getPath ( $ cache_asset , true ) ; $ cmd = sprintf ( "ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1" , $ uri , $ this -> sprite_width , $ this ... | takes episode and creates thumbnails in given width and height |
11,099 | public function removeBehaviour ( BehaviourAbstract $ behaviour ) { foreach ( $ this -> behaviours as $ key => $ thisBehaviour ) { if ( $ behaviour == $ thisBehaviour ) { unset ( $ this -> behaviours [ $ key ] ) ; } } } | Removes a behaviour from the collection |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.