idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
42,300 | function sendPostData ( $ url , $ postdata , $ file_field_array = array ( ) , $ ip = null , $ timeout = 30 ) { curl_setopt ( $ this -> ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ this -> ch , CURLOPT_RETURNTRANSFER , true ) ; if ( $ ip ) { if ( $ this -> debug ) { echo "Binding to ip $ip\n" ; } curl_setopt ( $ this ->... | Send multipart post data to the target URL return data returned from url or false if error occured ( contribution by vule nikolic vule |
42,301 | public function increment ( $ delt = 1 ) { $ n = $ this -> get ( ) ; $ n += $ delt ; $ this -> set ( $ n ) ; return $ n ; } | if you want t to log the number under multi - thread system please open the lock use a + mod . then fopen the file will not destroy the data . |
42,302 | static function quickGet ( $ url ) { $ bits = parse_url ( $ url ) ; $ host = $ bits [ 'host' ] ; $ port = isset ( $ bits [ 'port' ] ) ? $ bits [ 'port' ] : 80 ; $ path = isset ( $ bits [ 'path' ] ) ? $ bits [ 'path' ] : '/' ; if ( isset ( $ bits [ 'query' ] ) ) { $ path .= '?' . $ bits [ 'query' ] ; } $ client = new se... | Quick static methods |
42,303 | function children ( $ idx = - 1 ) { if ( $ idx === - 1 ) { return $ this -> children ; } if ( isset ( $ this -> children [ $ idx ] ) ) { return $ this -> children [ $ idx ] ; } return null ; } | returns children of node |
42,304 | function assign ( $ tpl_var , $ value = null ) { if ( is_array ( $ tpl_var ) ) { foreach ( $ tpl_var as $ key => $ val ) { if ( $ key != '' ) { $ this -> _tpl_vars [ $ key ] = $ val ; } } } else { if ( $ tpl_var != '' ) $ this -> _tpl_vars [ $ tpl_var ] = $ value ; } } | assigns values to template variables |
42,305 | function clear_assign ( $ tpl_var ) { if ( is_array ( $ tpl_var ) ) foreach ( $ tpl_var as $ curr_var ) unset ( $ this -> _tpl_vars [ $ curr_var ] ) ; else unset ( $ this -> _tpl_vars [ $ tpl_var ] ) ; } | clear the given assigned template variable . |
42,306 | function register_compiler_function ( $ function , $ function_impl , $ cacheable = true ) { $ this -> _plugins [ 'compiler' ] [ $ function ] = array ( $ function_impl , null , null , false , $ cacheable ) ; } | Registers compiler function |
42,307 | function register_modifier ( $ modifier , $ modifier_impl ) { $ this -> _plugins [ 'modifier' ] [ $ modifier ] = array ( $ modifier_impl , null , null , false ) ; } | Registers modifier to be used in templates |
42,308 | function & get_template_vars ( $ name = null ) { if ( ! isset ( $ name ) ) { return $ this -> _tpl_vars ; } elseif ( isset ( $ this -> _tpl_vars [ $ name ] ) ) { return $ this -> _tpl_vars [ $ name ] ; } else { $ _tmp = null ; return $ _tmp ; } } | Returns an array containing template variables |
42,309 | function & get_config_vars ( $ name = null ) { if ( ! isset ( $ name ) && is_array ( $ this -> _config [ 0 ] ) ) { return $ this -> _config [ 0 ] [ 'vars' ] ; } else if ( isset ( $ this -> _config [ 0 ] [ 'vars' ] [ $ name ] ) ) { return $ this -> _config [ 0 ] [ 'vars' ] [ $ name ] ; } else { $ _tmp = null ; return $ ... | Returns an array containing config variables |
42,310 | function display ( $ resource_name , $ cache_id = null , $ compile_id = null ) { $ this -> fetch ( $ resource_name , $ cache_id , $ compile_id , true ) ; } | executes & displays the template results |
42,311 | function _get_plugin_filepath ( $ type , $ name ) { $ _params = array ( 'type' => $ type , 'name' => $ name ) ; require_once ( SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php' ) ; return smarty_core_assemble_plugin_filepath ( $ _params , $ this ) ; } | get filepath of requested plugin |
42,312 | function _is_compiled ( $ resource_name , $ compile_path ) { if ( ! $ this -> force_compile && file_exists ( $ compile_path ) ) { if ( ! $ this -> compile_check ) { return true ; } else { $ _params = array ( 'resource_name' => $ resource_name , 'get_source' => false ) ; if ( ! $ this -> _fetch_resource_info ( $ _params... | test if resource needs compiling |
42,313 | function _compile_resource ( $ resource_name , $ compile_path ) { $ _params = array ( 'resource_name' => $ resource_name ) ; if ( ! $ this -> _fetch_resource_info ( $ _params ) ) { return false ; } $ _source_content = $ _params [ 'source_content' ] ; $ _cache_include = substr ( $ compile_path , 0 , - 4 ) . '.inc' ; if ... | compile the template |
42,314 | function _compile_source ( $ resource_name , & $ source_content , & $ compiled_content , $ cache_include_path = null ) { if ( file_exists ( SMARTY_DIR . $ this -> compiler_file ) ) { require_once ( SMARTY_DIR . $ this -> compiler_file ) ; } else { require_once ( $ this -> compiler_file ) ; } $ smarty_compiler = new $ t... | compile the given source |
42,315 | function _parse_resource_name ( & $ params ) { $ _resource_name_parts = explode ( ':' , $ params [ 'resource_name' ] , 2 ) ; if ( count ( $ _resource_name_parts ) == 1 ) { $ params [ 'resource_type' ] = $ this -> default_resource_type ; $ params [ 'resource_name' ] = $ _resource_name_parts [ 0 ] ; } else { if ( strlen ... | parse out the type and name from the resource |
42,316 | function _dequote ( $ string ) { if ( ( substr ( $ string , 0 , 1 ) == "'" || substr ( $ string , 0 , 1 ) == '"' ) && substr ( $ string , - 1 ) == substr ( $ string , 0 , 1 ) ) return substr ( $ string , 1 , - 1 ) ; else return $ string ; } | Remove starting and ending quotes from the string |
42,317 | function _read_file ( $ filename ) { if ( file_exists ( $ filename ) && ( $ fd = @ fopen ( $ filename , 'rb' ) ) ) { $ contents = '' ; while ( ! feof ( $ fd ) ) { $ contents .= fread ( $ fd , 8192 ) ; } fclose ( $ fd ) ; return $ contents ; } else { return false ; } } | read in a file |
42,318 | function _get_auto_filename ( $ auto_base , $ auto_source = null , $ auto_id = null ) { $ _compile_dir_sep = $ this -> use_sub_dirs ? DIRECTORY_SEPARATOR : '^' ; $ _return = $ auto_base . DIRECTORY_SEPARATOR ; if ( isset ( $ auto_id ) ) { $ auto_id = str_replace ( '%7C' , $ _compile_dir_sep , ( urlencode ( $ auto_id ) ... | get a concrete filename for automagically created content |
42,319 | function _unlink ( $ resource , $ exp_time = null ) { if ( isset ( $ exp_time ) ) { if ( time ( ) - @ filemtime ( $ resource ) >= $ exp_time ) { return @ unlink ( $ resource ) ; } } else { return @ unlink ( $ resource ) ; } } | unlink a file possibly using expiration time |
42,320 | function _get_auto_id ( $ cache_id = null , $ compile_id = null ) { if ( isset ( $ cache_id ) ) return ( isset ( $ compile_id ) ) ? $ cache_id . '|' . $ compile_id : $ cache_id ; elseif ( isset ( $ compile_id ) ) return $ compile_id ; else return null ; } | returns an auto_id for auto - file - functions |
42,321 | function _trigger_fatal_error ( $ error_msg , $ tpl_file = null , $ tpl_line = null , $ file = null , $ line = null , $ error_type = E_USER_ERROR ) { if ( isset ( $ file ) && isset ( $ line ) ) { $ info = ' (' . basename ( $ file ) . ", line $line)" ; } else { $ info = '' ; } if ( isset ( $ tpl_line ) && isset ( $ tpl_... | trigger Smarty plugin error |
42,322 | function _process_compiled_include_callback ( $ match ) { $ _func = '_smarty_tplfunc_' . $ match [ 2 ] . '_' . $ match [ 3 ] ; ob_start ( ) ; $ _func ( $ this ) ; $ _ret = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ _ret ; } | callback function for preg_replace to call a non - cacheable block |
42,323 | function & _smarty_cache_attrs ( $ cache_serial , $ count ) { $ _cache_attrs = & $ this -> _cache_info [ 'cache_attrs' ] [ $ cache_serial ] [ $ count ] ; if ( $ this -> _cache_including ) { $ _return = current ( $ _cache_attrs ) ; next ( $ _cache_attrs ) ; return $ _return ; } else { $ _cache_attrs [ ] = array ( ) ; re... | get or set an array of cached attributes for function that is not cacheable |
42,324 | function printOptions ( $ program = null ) { if ( empty ( $ program ) ) { global $ argv ; $ program = "{$argv[0]}" ; } echo str_repeat ( "=" , 80 ) . "\nUsage: {$program}\n" . str_repeat ( "=" , 80 ) . "\n" ; $ lines = $ this -> outputOptions ( ) ; echo join ( "\n" , $ lines ) ; echo "\n\n" ; } | print options descriptions to stdout |
42,325 | function display ( $ _swoole_tpl_file = '' ) { if ( empty ( $ _swoole_tpl_file ) ) { $ _swoole_tpl_file = strtolower ( $ this -> swoole -> env [ 'mvc' ] [ 'controller' ] ) . '/' . strtolower ( $ this -> swoole -> env [ 'mvc' ] [ 'view' ] ) . '.php' ; } if ( ! is_file ( $ this -> template_dir . $ _swoole_tpl_file ) ) { ... | render template file then display it . |
42,326 | public function doHandshake ( Swoole \ Request $ request , Swoole \ Response $ response ) { if ( ! isset ( $ request -> header [ 'Sec-WebSocket-Key' ] ) ) { $ this -> log ( 'Bad protocol implementation: it is not RFC6455.' ) ; return false ; } $ key = $ request -> header [ 'Sec-WebSocket-Key' ] ; if ( 0 === preg_match ... | Do the handshake . |
42,327 | function cleanConnection ( ) { $ now = time ( ) ; foreach ( $ this -> connections as $ client_id => $ conn ) { if ( $ conn [ 'time' ] < $ now - $ this -> heart_time ) { $ this -> log ( "connection[$client_id] timeout." , 'CLOSE' ) ; $ this -> close ( $ client_id ) ; } } $ this -> log ( 'clean connections' ) ; } | clean all connection |
42,328 | function onWebSocketRequest ( Swoole \ Request $ request ) { $ response = $ this -> currentResponse = new Swoole \ Response ( ) ; $ this -> doHandshake ( $ request , $ response ) ; return $ response ; } | Produce response for WebSocket request . |
42,329 | public function onReceive ( $ server , $ fd , $ from_id , $ data ) { if ( ! isset ( $ this -> connections [ $ fd ] ) ) { return parent :: onReceive ( $ server , $ fd , $ from_id , $ data ) ; } while ( strlen ( $ data ) > 0 and isset ( $ this -> connections [ $ fd ] ) ) { if ( ! isset ( $ this -> frame_list [ $ fd ] ) )... | Read a frame . |
42,330 | public function newFrame ( $ message , $ opcode = self :: OPCODE_TEXT_FRAME , $ end = true ) { $ fin = true === $ end ? 0x1 : 0x0 ; $ rsv1 = 0x0 ; $ rsv2 = 0x0 ; $ rsv3 = 0x0 ; $ length = strlen ( $ message ) ; $ out = chr ( ( $ fin << 7 ) | ( $ rsv1 << 6 ) | ( $ rsv2 << 5 ) | ( $ rsv3 << 4 ) | $ opcode ) ; if ( 0xffff... | Write a frame . |
42,331 | public function close ( $ fd , $ code = self :: CLOSE_NORMAL , $ reason = '' ) { $ this -> send ( $ fd , pack ( 'n' , $ code ) . $ reason , self :: OPCODE_CONNECTION_CLOSE ) ; $ this -> log ( "server close connection[$fd]. reason: $reason, close_code = $code" ) ; return $ this -> server -> close ( $ fd ) ; } | Close a connection . |
42,332 | protected function parse ( ) { if ( ( $ s = $ this -> copy_until_char ( '<' ) ) === '' ) { return $ this -> read_tag ( ) ; } $ node = new Node ( $ this ) ; ++ $ this -> cursor ; $ node -> _ [ self :: HDOM_INFO_TEXT ] = $ s ; $ this -> link_nodes ( $ node , false ) ; return true ; } | parse html content |
42,333 | protected function link_nodes ( & $ node , $ is_child ) { $ node -> parent = $ this -> parent ; $ this -> parent -> nodes [ ] = $ node ; if ( $ is_child ) { $ this -> parent -> children [ ] = $ node ; } } | link node s parent |
42,334 | static function buildFromString ( $ str , $ lowercase = true , $ forceTagsClosed = true , $ target_charset = self :: DEFAULT_TARGET_CHARSET , $ stripRN = true , $ defaultBRText = self :: DEFAULT_BR_TEXT , $ defaultSpanText = self :: DEFAULT_SPAN_TEXT ) { $ dom = new Tree ( null , $ lowercase , $ forceTagsClosed , $ tar... | get html dom from string |
42,335 | function findAndRemove ( $ selector , $ idx = null , $ excludes = array ( ) ) { if ( empty ( $ excludes ) ) return $ this -> find ( $ selector , $ idx ) ; foreach ( $ excludes as $ exclude ) { foreach ( $ this -> find ( $ exclude ) as $ node ) { $ node -> outertext = '' ; } } $ this -> load ( $ this -> save ( ) ) ; ret... | find and remove dom node by css selector |
42,336 | public function send ( $ data , $ type = 'text' , $ masked = true ) { if ( empty ( $ data ) ) { throw new \ Exception ( "data is empty" ) ; } if ( ! $ this -> handshake ) { trigger_error ( "not complete handshake." ) ; return false ; } if ( $ this -> haveSwooleEncoder ) { switch ( $ type ) { case 'text' : $ _type = WEB... | send string data |
42,337 | final protected function createHeader ( ) { $ host = $ this -> host ; if ( $ host === '127.0.0.1' || $ host === '0.0.0.0' ) { $ host = 'localhost' ; } return "GET {$this->path} HTTP/1.1" . "\r\n" . "Origin: null" . "\r\n" . "Host: {$host}:{$this->port}" . "\r\n" . "Sec-WebSocket-Key: {$this->key}" . "\r\n" . "User-Agen... | Create header for websocket client |
42,338 | final protected function parseIncomingRaw ( $ header ) { $ retval = array ( ) ; $ content = "" ; $ fields = explode ( "\r\n" , preg_replace ( '/\x0D\x0A[\x09\x20]+/' , ' ' , $ header ) ) ; foreach ( $ fields as $ field ) { if ( preg_match ( '/([^:]+): (.+)/m' , $ field , $ match ) ) { $ match [ 1 ] = preg_replace_callb... | Parse raw incoming data |
42,339 | function set_path ( $ config_path ) { if ( ! empty ( $ config_path ) ) { if ( ! is_string ( $ config_path ) || ! file_exists ( $ config_path ) || ! is_dir ( $ config_path ) ) { $ this -> _trigger_error_msg ( "Bad config file path '$config_path'" ) ; return ; } if ( substr ( $ config_path , - 1 ) != DIRECTORY_SEPARATOR ... | Set the path where configuration files can be found . |
42,340 | function get ( $ file_name , $ section_name = NULL , $ var_name = NULL ) { if ( empty ( $ file_name ) ) { $ this -> _trigger_error_msg ( 'Empty config file name' ) ; return ; } else { $ file_name = $ this -> _config_path . $ file_name ; if ( ! isset ( $ this -> _config_data [ $ file_name ] ) ) $ this -> load_file ( $ f... | Retrieves config info based on the file section and variable name . |
42,341 | function & get_key ( $ config_key ) { list ( $ file_name , $ section_name , $ var_name ) = explode ( '/' , $ config_key , 3 ) ; $ result = & $ this -> get ( $ file_name , $ section_name , $ var_name ) ; return $ result ; } | Retrieves config info based on the key . |
42,342 | function get_section_names ( $ file_name ) { $ file_name = $ this -> _config_path . $ file_name ; if ( ! isset ( $ this -> _config_data [ $ file_name ] ) ) { $ this -> _trigger_error_msg ( "Unknown config file '$file_name'" ) ; return ; } return array_keys ( $ this -> _config_data [ $ file_name ] [ "sections" ] ) ; } | Get all section names from a loaded file . |
42,343 | function get_var_names ( $ file_name , $ section = NULL ) { if ( empty ( $ file_name ) ) { $ this -> _trigger_error_msg ( 'Empty config file name' ) ; return ; } else if ( ! isset ( $ this -> _config_data [ $ file_name ] ) ) { $ this -> _trigger_error_msg ( "Unknown config file '$file_name'" ) ; return ; } if ( empty (... | Get all global or section variable names . |
42,344 | function clear ( $ file_name = NULL ) { if ( $ file_name === NULL ) $ this -> _config_data = array ( ) ; else if ( isset ( $ this -> _config_data [ $ file_name ] ) ) $ this -> _config_data [ $ file_name ] = array ( ) ; } | Clear loaded config data for a certain file or all files . |
42,345 | function load_file ( $ file_name , $ prepend_path = true ) { if ( $ prepend_path && $ this -> _config_path != "" ) $ config_file = $ this -> _config_path . $ file_name ; else $ config_file = $ file_name ; ini_set ( 'track_errors' , true ) ; $ fp = @ fopen ( $ config_file , "r" ) ; if ( ! is_resource ( $ fp ) ) { $ this... | Load a configuration file manually . |
42,346 | function set_file_contents ( $ config_file , $ contents ) { $ this -> _config_data [ $ config_file ] = $ this -> parse_contents ( $ contents ) ; return true ; } | Store the contents of a file manually . |
42,347 | function parse_contents ( $ contents ) { if ( $ this -> fix_newlines ) { $ contents = preg_replace ( '!\r\n?!' , "\n" , $ contents ) ; } $ config_data = array ( ) ; $ config_data [ 'sections' ] = array ( ) ; $ config_data [ 'vars' ] = array ( ) ; $ vars = & $ config_data [ 'vars' ] ; preg_match_all ( '!^.*\r?\n?!m' , $... | parse the source of a configuration file manually . |
42,348 | protected function connectPusher ( $ options = [ ] ) { if ( $ this -> getConfig ( 'broadcast.enable' ) ) { $ appId = $ this -> getConfig ( 'broadcast.pusher.app_id' ) ; $ appKey = $ this -> getConfig ( 'broadcast.pusher.app_key' ) ; $ appSecret = $ this -> getConfig ( 'broadcast.pusher.app_secret' ) ; $ appOptions = $ ... | Make pusher connection . |
42,349 | public function transmission ( Message $ message ) { if ( ! $ this -> pusher ) { return false ; } $ sender = $ message -> sender -> toArray ( ) ; $ messageArray = $ message -> toArray ( ) ; $ messageArray [ 'sender' ] = $ sender ; $ this -> dispatch ( new Webcast ( $ messageArray ) ) ; } | Dispatch the job to the queue . |
42,350 | protected function getSerializeUser ( $ user1 , $ user2 ) { $ user = [ ] ; $ user [ 'one' ] = ( $ user1 < $ user2 ) ? $ user1 : $ user2 ; $ user [ 'two' ] = ( $ user1 < $ user2 ) ? $ user2 : $ user1 ; return $ user ; } | make two users as serialize with ascending order . |
42,351 | protected function makeMessage ( $ conversationId , $ message ) { $ message = $ this -> message -> create ( [ 'message' => $ message , 'conversation_id' => $ conversationId , 'user_id' => $ this -> authUserId , 'is_seen' => 0 , ] ) ; $ message -> conversation -> touch ( ) ; $ this -> broadcast -> transmission ( $ messa... | create a new message by using conversationId . |
42,352 | protected function newConversation ( $ receiverId ) { $ conversationId = $ this -> isConversationExists ( $ receiverId ) ; $ user = $ this -> getSerializeUser ( $ this -> authUserId , $ receiverId ) ; if ( $ conversationId === false ) { $ conversation = $ this -> conversation -> create ( [ 'user_one' => $ user [ 'one' ... | make new conversation the given receiverId with currently loggedin user . |
42,353 | public function isConversationExists ( $ userId ) { if ( empty ( $ userId ) ) { return false ; } $ user = $ this -> getSerializeUser ( $ this -> authUserId , $ userId ) ; return $ this -> conversation -> isExistsAmongTwoUsers ( $ user [ 'one' ] , $ user [ 'two' ] ) ; } | make sure is this conversation exist for this user with currently loggedin user . |
42,354 | public function isAuthenticUser ( $ conversationId , $ userId ) { if ( $ conversationId && $ userId ) { return $ this -> conversation -> isUserExists ( $ conversationId , $ userId ) ; } return false ; } | check the given user exist for the given conversation . |
42,355 | public function sendMessage ( $ conversatonId , $ message ) { if ( $ conversatonId && $ message ) { if ( $ this -> conversation -> existsById ( $ conversatonId ) ) { $ message = $ this -> makeMessage ( $ conversatonId , $ message ) ; return $ message ; } } return false ; } | send a message by using converstionid . |
42,356 | public function sendMessageByUserId ( $ receiverId , $ message ) { if ( $ conversationId = $ this -> isConversationExists ( $ receiverId ) ) { $ message = $ this -> makeMessage ( $ conversationId , $ message ) ; return $ message ; } $ convId = $ this -> newConversation ( $ receiverId ) ; $ message = $ this -> makeMessa... | create a new message by using receiverid . |
42,357 | public function getInbox ( $ order = 'desc' , $ offset = 0 , $ take = 20 ) { return $ this -> conversation -> threads ( $ this -> authUserId , $ order , $ offset , $ take ) ; } | fetch all inbox for currently loggedin user with pagination . |
42,358 | public function getInboxAll ( $ order = 'desc' , $ offset = 0 , $ take = 20 ) { return $ this -> conversation -> threadsAll ( $ this -> authUserId , $ order , $ offset , $ take ) ; } | fetch all inbox with soft deleted message for currently loggedin user with pagination . |
42,359 | public function getConversationsById ( $ conversationId , $ offset = 0 , $ take = 20 ) { $ conversations = $ this -> conversation -> getMessagesById ( $ conversationId , $ this -> authUserId , $ offset , $ take ) ; return $ this -> makeMessageCollection ( $ conversations ) ; } | fetch all conversation by using coversation id . |
42,360 | public function getConversationsAllById ( $ conversationId , $ offset = 0 , $ take = 20 ) { $ conversations = $ this -> conversation -> getMessagesAllById ( $ conversationId , $ offset , $ take ) ; return $ this -> makeMessageCollection ( $ conversations ) ; } | fetch all conversation with soft deleted messages by using coversation id . |
42,361 | public function readMessage ( $ messageId = null ) { if ( ! is_null ( $ messageId ) ) { $ message = $ this -> message -> with ( [ 'sender' , 'conversation' ] ) -> find ( $ messageId ) ; if ( $ message -> coversation -> user_one == $ this -> authUserId || $ message -> coversation -> user_two == $ this -> authUserId ) { ... | read a single message by message id . |
42,362 | public function makeSeen ( $ messageId ) { $ seen = $ this -> message -> update ( $ messageId , [ 'is_seen' => 1 ] ) ; if ( $ seen ) { return true ; } return false ; } | make a message as seen . |
42,363 | public function getReceiverInfo ( $ conversationId ) { $ conversation = $ this -> conversation -> find ( $ conversationId ) ; $ receiver = '' ; if ( $ conversation -> user_one == $ this -> authUserId ) { $ receiver = $ conversation -> user_two ; } else { $ receiver = $ conversation -> user_one ; } $ userModel = $ this ... | get receiver information for this conversation . |
42,364 | public function deleteForever ( $ messageId ) { $ deleteMessage = $ this -> message -> delete ( $ messageId ) ; if ( $ deleteMessage ) { return true ; } return false ; } | permanently delete message for this id . |
42,365 | public function deleteConversations ( $ id ) { $ deleteConversation = $ this -> conversation -> delete ( $ id ) ; if ( $ deleteConversation ) { return $ this -> message -> deleteMessages ( $ id ) ; } return false ; } | delete message threat or conversation by conversation id . |
42,366 | public function toHtml ( ) { if ( config ( 'talk.oembed.enabled' ) ) { $ parsedUrl = parse_url ( config ( 'talk.oembed.url' ) ) ; $ this -> driver -> addProvider ( $ parsedUrl [ 'host' ] , Adapter :: class , [ 'api_key' => config ( 'talk.oembed.key' ) , ] ) ; } $ result = $ this -> driver -> autoEmbed ( $ this -> strin... | Get content as a string of HTML . |
42,367 | public function updateProperty ( \ ReflectionProperty $ reflectionProperty , Schema $ property ) { try { $ docBlock = $ this -> docBlockFactory -> create ( $ reflectionProperty ) ; } catch ( \ Exception $ e ) { return ; } if ( ! $ title = $ docBlock -> getSummary ( ) ) { foreach ( $ docBlock -> getTagsByName ( 'var' ) ... | Update the Swagger information with information from the DocBlock comment . |
42,368 | public function updateProperty ( \ ReflectionProperty $ reflectionProperty , Schema $ property ) { $ annotations = $ this -> annotationsReader -> getPropertyAnnotations ( $ reflectionProperty ) ; foreach ( $ annotations as $ annotation ) { if ( $ annotation instanceof Assert \ NotBlank || $ annotation instanceof Assert... | Update the given property and schema with defined Symfony constraints . |
42,369 | private function getSchemaPropertyName ( Schema $ property ) { if ( null === $ this -> schema ) { return null ; } foreach ( $ this -> schema -> getProperties ( ) as $ name => $ schemaProperty ) { if ( $ schemaProperty === $ property ) { return $ name ; } } return null ; } | Get assigned property name for property schema . |
42,370 | private function appendPattern ( Schema $ property , $ newPattern ) { if ( null === $ newPattern ) { return ; } if ( null !== $ property -> getPattern ( ) ) { $ property -> setPattern ( sprintf ( '%s, %s' , $ property -> getPattern ( ) , $ newPattern ) ) ; } else { $ property -> setPattern ( $ newPattern ) ; } } | Append the pattern from the constraint to the existing pattern . |
42,371 | public function orderByASC ( array $ cols , $ order_asc = true ) { $ this -> order_asc = $ order_asc ; return $ this -> addOrderBy ( $ cols ) ; } | order by ASC OR DESC |
42,372 | protected function prepareCurrentRow ( ) : void { $ this -> currentRow = array_shift ( $ this -> bufferedRow ) ; if ( \ is_array ( $ this -> currentRow ) ) { $ datas = [ ] ; foreach ( $ this -> currentRow as $ key => $ value ) { if ( $ this -> hasHeaders ) { $ datas [ $ this -> columns [ $ key ] ] = html_entity_decode ... | Prepare the row to return . |
42,373 | public static function generateSitemapIndex ( string $ folder , string $ baseUrl , string $ pattern = 'sitemap*.xml' , string $ filename = 'sitemap.xml' ) : void { $ content = "<?xml version='1.0' encoding='UTF-8'?" . ">\n<sitemapindex xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www... | Generates the sitemap index from the sitemap part avaible in the folder . |
42,374 | private function generateNewPart ( ) : void { if ( $ this -> buffer ) { $ this -> closeSitemap ( ) ; } $ this -> bufferUrlCount = 0 ; $ this -> bufferSize = 0 ; ++ $ this -> bufferPart ; if ( ! is_writable ( $ this -> folder ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to write to folder: %s' , $ this -> fold... | Generate a new sitemap part . |
42,375 | private function addSitemapLine ( string $ line ) : void { if ( $ this -> bufferUrlCount >= self :: LIMIT_URL ) { $ this -> generateNewPart ( ) ; } if ( ( $ this -> bufferSize + \ strlen ( $ line ) + 9 ) > self :: LIMIT_SIZE ) { $ this -> generateNewPart ( ) ; } ++ $ this -> bufferUrlCount ; $ this -> bufferSize += fwr... | Add a new line into the sitemap part . |
42,376 | private function buildData ( array $ data ) : array { $ default = [ 'url' => null , 'lastmod' => 'now' , 'changefreq' => 'weekly' , 'priority' => 0.5 , 'type' => 'default' , ] ; $ data = array_merge ( $ default , $ data ) ; $ this -> fixDataType ( $ data ) ; return $ data ; } | Build data with default parameters . |
42,377 | private function fixDataType ( array & $ data ) : void { if ( 'default' === $ data [ 'type' ] ) { return ; } $ valid_var_name = [ 'image' => 'images' , 'video' => 'video' , ] ; if ( ! isset ( $ valid_var_name [ $ data [ 'type' ] ] , $ data [ $ valid_var_name [ $ data [ 'type' ] ] ] ) || ! \ is_array ( $ data [ $ valid_... | Fix type of data if data type is specific he must to be defined in data and he must to be a array . |
42,378 | private function generateDefaultLine ( array $ data ) : string { return sprintf ( ' ' . '<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%s</priority></url>' . "\n" , $ data [ 'url' ] , date ( 'Y-m-d' , strtotime ( $ data [ 'lastmod' ] ) ) , $ data [ 'changefreq' ] , $ data [ 'priority' ]... | Generate standard line of sitemap . |
42,379 | private function generateImageLine ( array $ data ) : string { $ images = '' ; if ( \ count ( $ data [ 'images' ] ) > 1000 ) { $ data [ 'images' ] = array_splice ( $ data [ 'images' ] , 1000 ) ; } $ builder = [ 'url' => 'loc' , 'location' => 'geo_location' , ] ; foreach ( $ data [ 'images' ] as $ image ) { $ images .= ... | Generate image line of sitemap . |
42,380 | private function generateVideoLine ( array $ data ) : string { $ videos = '' ; $ builder = [ 'thumbnail' => 'thumbnail_loc' , ] ; foreach ( $ data [ 'video' ] as $ key => $ video ) { $ videos .= sprintf ( '<video:%1$s>%2$s</video:%1$s>' , ( $ builder [ $ key ] ?? $ key ) , $ video ) ; } return sprintf ( ' ' . '<url>... | Generate video line of sitemap . |
42,381 | private function getHeaderByFlag ( ) : string { $ namespaces = [ 'video' => 'xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"' , 'image' => 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"' , ] ; $ result = '' ; foreach ( $ this -> headers as $ flag ) { $ result .= ' ' . $ namespaces [ $ flag... | Generate additional header with namespace adapted to the content . |
42,382 | private function getXmlString ( array $ fields = [ ] ) : string { $ xmlData = [ ] ; $ xmlData [ ] = '<Row>' ; foreach ( $ fields as $ key => $ value ) { $ value = htmlspecialchars ( $ value ) ; $ value = str_replace ( [ "\r\n" , "\r" , "\n" ] , ' ' , $ value ) ; $ dataType = 'String' ; if ( 0 !== $ this -> position... | Prepare and return XML string for MS Excel XML from array . |
42,383 | private function generateNewPart ( ) : void { if ( $ this -> buffer ) { $ this -> closeFeed ( ) ; } $ this -> bufferSize = 0 ; ++ $ this -> bufferPart ; if ( ! $ this -> folder -> isWritable ( ) ) { throw new \ RuntimeException ( sprintf ( 'Unable to write to folder: %s' , $ this -> folder ) ) ; } $ this -> buffer = fo... | Generates a new file . |
42,384 | public function setMetadataDirs ( array $ namespacePrefixToDirMap ) : self { foreach ( $ namespacePrefixToDirMap as $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new InvalidArgumentException ( sprintf ( 'The directory "%s" does not exist.' , $ dir ) ) ; } } $ this -> metadataDirs = $ namespacePrefixToDirMap ; return $ th... | Sets a map of namespace prefixes to directories . |
42,385 | public function addMetadataDirs ( array $ namespacePrefixToDirMap ) : self { foreach ( $ namespacePrefixToDirMap as $ prefix => $ dir ) { $ this -> addMetadataDir ( $ dir , $ prefix ) ; } return $ this ; } | Adds a map of namespace prefixes to directories . |
42,386 | private function addNamespaceAttributes ( ClassMetadata $ metadata , \ DOMElement $ element ) : void { foreach ( $ metadata -> xmlNamespaces as $ prefix => $ uri ) { $ attribute = 'xmlns' ; if ( '' !== $ prefix ) { $ attribute .= ':' . $ prefix ; } elseif ( $ element -> namespaceURI === $ uri ) { continue ; } $ element... | Adds namespace attributes to the XML root element |
42,387 | public static function parseDirection ( string $ dirStr ) : int { switch ( strtolower ( $ dirStr ) ) { case 'serialization' : return GraphNavigatorInterface :: DIRECTION_SERIALIZATION ; case 'deserialization' : return GraphNavigatorInterface :: DIRECTION_DESERIALIZATION ; default : throw new InvalidArgumentException ( ... | Parses a direction string to one of the direction constants . |
42,388 | protected function parseSection ( $ hex , array $ sections , $ octet = false ) { $ parsedString = '' ; foreach ( $ sections as $ section ) { $ start = $ octet ? $ section : $ section [ 0 ] ; $ length = $ octet ? 2 : $ section [ 1 ] ; $ parsedString .= substr ( $ hex , $ start , $ length ) ; } return $ parsedString ; } | Return the specified section of the hexadecimal string . |
42,389 | protected function decodePropValue ( $ hex , $ string = false ) { $ decodePropValue = '' ; $ blobs = str_split ( $ hex , 6 ) ; foreach ( $ blobs as $ blob ) { $ bin = decbin ( hexdec ( $ blob ) ) ; $ controlY = substr ( $ bin , 4 , 6 ) ; $ nibbleY = substr ( $ bin , 10 , 4 ) ; $ controlX = substr ( $ bin , 14 , 6 ) ; $... | Decode the property by inspecting the nibbles of each blob checking the control and adding up the results into a final value . |
42,390 | protected function encodePropValue ( $ value , $ string = false ) { $ chars = $ string ? MbString :: split ( $ value ) : array_reverse ( str_split ( $ this -> dec2hex ( $ value , 8 ) , 2 ) ) ; $ encoded = '' ; foreach ( $ chars as $ char ) { $ bits = sprintf ( '%08b' , $ string ? MbString :: ord ( $ char ) : hexdec ( $... | Get the encoded property value as a binary blob . |
42,391 | protected function getNibbleWithControl ( $ nibbleType , $ nibble ) { $ dec = bindec ( $ nibble ) ; if ( $ dec > 9 ) { $ dec -= 9 ; $ control = self :: NIBBLE_CONTROL [ $ nibbleType ] [ 1 ] ; } else { $ control = self :: NIBBLE_CONTROL [ $ nibbleType ] [ 0 ] ; } return $ control . sprintf ( '%04d' , decbin ( $ dec ) ) ... | Get the nibble value with the control prefixed . |
42,392 | public function getAttribute ( $ key , $ subKey = null ) { if ( ! $ key ) { return ; } $ key = $ this -> normalizeAttributeKey ( $ key ) ; if ( is_null ( $ subKey ) && $ this -> hasAttribute ( $ key ) ) { return $ this -> attributes [ $ key ] ; } elseif ( $ this -> hasAttribute ( $ key , $ subKey ) ) { return $ this ->... | Returns the models attribute with the specified key . |
42,393 | public function fill ( array $ attributes = [ ] ) { foreach ( $ attributes as $ key => $ value ) { $ this -> setAttribute ( $ key , $ value ) ; } return $ this ; } | Fills the entry with the supplied attributes . |
42,394 | public function setAttribute ( $ key , $ value , $ subKey = null ) { $ key = $ this -> normalizeAttributeKey ( $ key ) ; $ key = ( $ key == 'dn' ? $ this -> schema -> distinguishedName ( ) : $ key ) ; if ( is_null ( $ subKey ) ) { $ this -> attributes [ $ key ] = is_array ( $ value ) ? $ value : [ $ value ] ; } else { ... | Sets an attributes value by the specified key and sub - key . |
42,395 | public function setRawAttributes ( array $ attributes = [ ] ) { $ this -> attributes = array_change_key_case ( $ this -> filterRawAttributes ( $ attributes ) , CASE_LOWER ) ; if ( $ dn = Arr :: get ( $ attributes , 'dn' ) ) { if ( is_array ( $ dn ) ) { $ dn = Arr :: first ( $ dn ) ; } $ this -> setDistinguishedName ( $... | Sets the attributes property . |
42,396 | public function filterRawAttributes ( array $ attributes = [ ] , $ keys = [ 'count' , 'dn' ] ) { $ attributes = Arr :: except ( $ attributes , $ keys ) ; array_walk ( $ attributes , function ( & $ value ) use ( $ keys ) { $ value = is_array ( $ value ) ? $ this -> filterRawAttributes ( $ value , $ keys ) : $ value ; } ... | Filters the count key recursively from raw LDAP attributes . |
42,397 | protected function getConnectionString ( $ hosts , $ protocol , $ port ) { $ hosts = is_array ( $ hosts ) ? $ hosts : [ $ hosts ] ; $ hosts = array_map ( function ( $ host ) use ( $ protocol , $ port ) { return "{$protocol}{$host}:{$port}" ; } , $ hosts ) ; return implode ( ' ' , $ hosts ) ; } | Generates an LDAP connection string for each host given . |
42,398 | protected function wildcardContainsEvent ( $ wildcard , $ eventName ) { $ patterns = Arr :: wrap ( $ wildcard ) ; if ( empty ( $ patterns ) ) { return false ; } foreach ( $ patterns as $ pattern ) { if ( $ pattern == $ eventName ) { return true ; } $ pattern = preg_quote ( $ pattern , '#' ) ; $ pattern = str_replace ( ... | Determine if the wildcard matches or contains the given event . |
42,399 | protected function prepareConnection ( ) { if ( $ this -> configuration -> get ( 'use_ssl' ) ) { $ this -> connection -> ssl ( ) ; } elseif ( $ this -> configuration -> get ( 'use_tls' ) ) { $ this -> connection -> tls ( ) ; } $ options = array_replace ( $ this -> configuration -> get ( 'custom_options' ) , [ LDAP_OPT_... | Prepares the connection by setting configured parameters . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.