idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
9,600
public function getTopGames ( $ params = [ ] ) { $ defaults = [ 'limit' => 10 , 'offset' => 0 , ] ; return $ this -> wrapper -> request ( 'GET' , 'games/top' , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults ) ] ) ; }
Returns a list of games objects sorted by number of current viewers on Twitch most popular first .
9,601
public function load ( $ workingDir ) { $ locator = new FileLocator ( $ this -> getPotentialDirectories ( $ workingDir ) ) ; $ loader = new YamlLoader ( $ locator ) ; $ processor = new Processor ( ) ; $ schema = new BuddySchema ( ) ; $ files = $ locator -> locate ( static :: FILENAME , NULL , FALSE ) ; foreach ( $ files as $ file ) { $ raw = $ loader -> load ( $ file ) ; $ conf = $ processor -> processConfiguration ( $ schema , array ( 'buddy' => $ raw ) ) ; if ( isset ( $ conf [ 'commands' ] ) ) { foreach ( $ conf [ 'commands' ] as $ command => $ specs ) { if ( ! isset ( $ this -> commands [ $ command ] ) ) { $ this -> commands [ $ command ] = array ( 'options' => $ specs , 'file' => $ file , ) ; } } } if ( ! empty ( $ values [ 'root' ] ) ) { break ; } } return $ this ; }
Loads the configuration file data .
9,602
public function getCommand ( $ command ) { return new CommandShortcut ( $ command , $ this -> commands [ $ command ] [ 'options' ] , $ this -> commands [ $ command ] [ 'file' ] ) ; }
Provides the command specification .
9,603
protected function getPotentialDirectories ( $ workingDir ) { $ paths = array ( ) ; $ path = '' ; foreach ( explode ( '/' , $ workingDir ) as $ part ) { $ path .= $ part . '/' ; $ paths [ ] = rtrim ( $ path , '/' ) ; } return $ paths ; }
Helper to provide potential directories to look for . buddy . yml files .
9,604
public function get_group_by ( array $ cfg ) : string { $ res = '' ; $ group_to_put = [ ] ; if ( ! empty ( $ cfg [ 'group_by' ] ) ) { foreach ( $ cfg [ 'group_by' ] as $ g ) { if ( isset ( $ cfg [ 'available_fields' ] [ $ g ] ) ) { $ group_to_put [ ] = $ this -> escape ( $ g ) ; } else { $ this -> db -> error ( "Error! The column '$g' doesn't exist for group by " . print_r ( $ cfg , true ) ) ; } } if ( count ( $ group_to_put ) ) { $ res .= 'GROUP BY ' . implode ( ', ' , $ group_to_put ) . PHP_EOL ; } } return $ res ; }
Returns a string with the GROUP BY part of the query if there is empty otherwise
9,605
public function get_having ( array $ cfg ) : string { $ res = '' ; if ( ! empty ( $ cfg [ 'group_by' ] ) && ! empty ( $ cfg [ 'having' ] ) && ( $ cond = $ this -> get_conditions ( $ cfg [ 'having' ] , $ cfg , true ) ) ) { $ res .= 'HAVING ' . $ cond . PHP_EOL ; } return $ res ; }
Returns a string with the HAVING part of the query if there is empty otherwise
9,606
public function create_index ( string $ table , $ column , bool $ unique = false , $ length = null ) : bool { $ column = ( array ) $ column ; if ( $ length ) { $ length = ( array ) $ length ; } $ name = bbn \ str :: encode_filename ( $ table ) ; if ( $ table = $ this -> table_full_name ( $ table , true ) ) { foreach ( $ column as $ i => $ c ) { if ( ! bbn \ str :: check_name ( $ c ) ) { $ this -> db -> error ( "Illegal column $c" ) ; } $ name .= '_' . $ c ; $ column [ $ i ] = $ this -> escape ( $ column [ $ i ] ) ; if ( \ is_int ( $ length [ $ i ] ) && $ length [ $ i ] > 0 ) { $ column [ $ i ] .= '(' . $ length [ $ i ] . ')' ; } } $ name = bbn \ str :: cut ( $ name , 50 ) ; return ( bool ) $ this -> db -> query ( 'CREATE ' . ( $ unique ? 'UNIQUE ' : '' ) . "INDEX `$name` ON $table ( " . implode ( ', ' , $ column ) . ' )' ) ; } return false ; }
Creates an index
9,607
public function delete_user ( string $ user ) : bool { if ( bbn \ str :: check_name ( $ user ) ) { $ this -> db -> raw_query ( " REVOKE ALL PRIVILEGES ON *.* FROM $user" ) ; return ( bool ) $ this -> db -> query ( "DROP USER $user" ) ; } return false ; }
Deletes a database user
9,608
public function manageRoles ( User $ user ) { $ this -> authorize ( 'roles' , $ user ) ; $ roles = Role :: all ( ) ; return view ( 'laralum_users::roles' , [ 'user' => $ user , 'roles' => $ roles ] ) ; }
Manage roles from users .
9,609
public function transform ( $ user ) { $ user = $ this -> entityToArray ( User :: class , $ user ) ; return [ 'id' => ( int ) $ user [ 'id' ] , 'email' => $ user [ 'email' ] , 'nick' => $ user [ 'nick' ] , 'firstName' => $ user [ 'first_name' ] , 'lastName' => $ user [ 'last_name' ] , 'roles' => ! empty ( $ user [ 'roles' ] ) ? $ user [ 'roles' ] : [ ] ] ; }
Transforms user entity
9,610
public function handleXmlHttpRequest ( MvcEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( $ request -> isXMLHttpRequest ( ) ) { $ dispatchResult = $ event -> getResult ( ) ; if ( $ dispatchResult instanceof ViewModel ) { $ dispatchResult -> setTerminal ( true ) ; } } }
If request is an XML HTTP Request disable layouts
9,611
protected function allowedSessionsExceeded ( $ orderedSessions , $ allowableSessions , SessionRegistry $ registry ) { if ( $ this -> errorIfMaximumExceeded ) { throw new MaxSessionsExceededException ( sprintf ( 'Maximum number of sessions (%s) exceeded' , $ allowableSessions ) ) ; } $ orderedSessionsVector = array_values ( $ orderedSessions ) ; for ( $ i = $ allowableSessions - 1 , $ countSessions = count ( $ orderedSessionsVector ) ; $ i < $ countSessions ; $ i ++ ) { $ registry -> expireNow ( $ orderedSessionsVector [ $ i ] -> getSessionId ( ) ) ; } }
Allows subclasses to customize behavior when too many sessions are detected .
9,612
public function actionGetMenus ( ) { $ request = \ Yii :: $ app -> request ; if ( $ request -> getIsOptions ( ) ) { return $ this -> ResponseOptions ( $ this -> verbs ( ) [ 'index' ] ) ; } try { return Menu :: getMenuSource ( ) ; } catch ( Exception $ e ) { throw new Exception ( $ e ) ; } }
list all menus
9,613
public function actionGetSavedRoutes ( ) { $ request = \ Yii :: $ app -> request ; if ( $ request -> getIsOptions ( ) ) { return $ this -> ResponseOptions ( $ this -> verbs ( ) [ 'index' ] ) ; } try { return Menu :: getSavedRoutes ( ) ; } catch ( Exception $ e ) { throw new Exception ( $ e ) ; } }
list all menus route
9,614
public function generate ( $ obj ) { if ( ! is_object ( $ obj ) ) { throw new \ InvalidArgumentException ( 'OpenGraphGenerator::generate only accept object argument.' ) ; } $ openGraph = new OpenGraph ( ) ; $ classType = get_class ( $ obj ) ; $ metadata = $ this -> factory -> getMetadataForClass ( $ classType ) ; if ( is_array ( $ metadata -> namespaces ) ) { foreach ( $ metadata -> namespaces as $ namespace ) { $ openGraph -> addNamespace ( $ namespace -> prefix , $ namespace -> uri ) ; } } if ( is_array ( $ metadata -> nodes ) ) { foreach ( $ metadata -> nodes as $ graphNode ) { if ( ! empty ( $ graphNode [ 'node' ] -> namespaceUri ) ) { $ openGraph -> addNamespace ( $ graphNode [ 'node' ] -> namespace , $ graphNode [ 'node' ] -> namespaceUri ) ; } $ openGraph -> add ( $ graphNode [ 'node' ] -> namespace , $ graphNode [ 'node' ] -> tag , $ graphNode [ 'object' ] -> getValue ( $ obj ) ) ; } } return $ openGraph ; }
Generate OpenGraph through metadata
9,615
private function getStreamInformationsOfEpisode ( $ episode ) { $ uri = $ this -> getContainer ( ) -> get ( 'bprs.asset_helper' ) -> getAbsoluteUrl ( $ episode -> getVideo ( ) ) ; if ( ! $ uri ) { $ this -> logbook -> error ( 'oktolab_media.episode_assetdatajob_nourl' , [ ] , $ this -> args [ 'uniqID' ] ) ; return false ; } $ metadata = [ 'video' => false , 'audio' => false ] ; try { $ metainfo = json_decode ( shell_exec ( sprintf ( 'ffprobe -v error -show_streams -print_format json %s' , $ uri ) ) , true ) ; foreach ( $ metainfo [ 'streams' ] as $ stream ) { if ( $ metadata [ 'video' ] && $ metadata [ 'audio' ] ) { break ; } if ( $ stream [ 'codec_type' ] == "audio" ) { $ metadata [ 'audio' ] = $ stream ; } if ( $ stream [ 'codec_type' ] == "video" ) { $ metadata [ 'video' ] = $ stream ; } } } catch ( Exception $ e ) { $ metadata = null ; } return $ metadata ; }
extracts streaminformations of an episode from its video . returns false if informations can t be extracted returns array of video and audio info .
9,616
public static function createLayoutFactoryBuilder ( ) { $ builder = new LayoutFactoryBuilder ( new ExpressionProcessor ( new ExpressionLanguage ( ) , new ExpressionEncoderRegistry ( [ 'json' => new JsonExpressionEncoder ( new ExpressionManipulator ( ) ) ] ) ) ) ; $ builder -> addExtension ( new CoreExtension ( ) ) ; return $ builder ; }
Creates a layout factory builder with the default configuration .
9,617
public static function clearXml ( $ xml = '' , $ remEnc = false ) { $ aFind = [ 'xmlns:default="http://www.w3.org/2000/09/xmldsig#"' , ' standalone="no"' , 'default:' , ':default' , "\n" , "\r" , "\t" , ] ; if ( $ remEnc ) { $ aFind [ ] = '<?xml version="1.0"?>' ; $ aFind [ ] = '<?xml version="1.0" encoding="utf-8"?>' ; $ aFind [ ] = '<?xml version="1.0" encoding="UTF-8"?>' ; $ aFind [ ] = '<?xml version="1.0" encoding="utf-8" standalone="no"?>' ; $ aFind [ ] = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' ; } $ retXml = str_replace ( $ aFind , '' , $ xml ) ; return $ retXml ; }
clearXml Remove \ r \ n \ s \ t .
9,618
public static function countChars ( $ string ) { if ( function_exists ( 'iconv_strlen' ) ) { return iconv_strlen ( $ string , 'utf-8' ) ; } elseif ( function_exists ( 'mb_strlen' ) ) { return mb_strlen ( $ string , 'utf-8' ) ; } elseif ( function_exists ( 'utf8_decode' ) ) { return strlen ( utf8_decode ( $ string ) ) ; } $ count = count_chars ( $ string ) ; return array_sum ( array_slice ( $ count , 0 , 0x80 ) ) + array_sum ( array_slice ( $ count , 0xC2 , 0x33 ) ) ; }
Count the number of characters in a string .
9,619
public static function convertToUTF8 ( $ data , $ encoding = 'UTF-8' ) { if ( function_exists ( 'mb_convert_encoding' ) ) { $ save = ini_get ( 'mbstring.substitute_character' ) ; ini_set ( 'mbstring.substitute_character' , "none" ) ; $ data = mb_convert_encoding ( $ data , 'UTF-8' , $ encoding ) ; ini_set ( 'mbstring.substitute_character' , $ save ) ; } elseif ( function_exists ( 'iconv' ) && $ encoding != 'auto' ) { $ data = @ iconv ( $ encoding , 'UTF-8//IGNORE' , $ data ) ; } else { throw new Exception ( 'Not implemented, please install mbstring or iconv' ) ; } if ( substr ( $ data , 0 , 3 ) === "\xEF\xBB\xBF" ) { $ data = substr ( $ data , 3 ) ; } return $ data ; }
Convert data from the given encoding to UTF - 8 .
9,620
public static function checkForIllegalCodepoints ( $ data ) { if ( ! function_exists ( 'preg_match_all' ) ) { throw HTML5_Exception ( 'The PCRE library is not loaded or is not available.' ) ; } $ errors = array ( ) ; for ( $ i = 0 , $ count = substr_count ( $ data , "\0" ) ; $ i < $ count ; $ i ++ ) { $ errors [ ] = 'null-character' ; } $ count = preg_match_all ( '/(?: [\x01-\x08\x0B\x0E-\x1F\x7F] # U+0001 to U+0008, U+000B, U+000E to U+001F and U+007F | \xC2[\x80-\x9F] # U+0080 to U+009F | \xED(?:\xA0[\x80-\xFF]|[\xA1-\xBE][\x00-\xFF]|\xBF[\x00-\xBF]) # U+D800 to U+DFFFF | \xEF\xB7[\x90-\xAF] # U+FDD0 to U+FDEF | \xEF\xBF[\xBE\xBF] # U+FFFE and U+FFFF | [\xF0-\xF4][\x8F-\xBF]\xBF[\xBE\xBF] # U+nFFFE and U+nFFFF (1 <= n <= 10_{16}) )/x' , $ data , $ matches ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ errors [ ] = 'invalid-codepoint' ; } return $ errors ; }
Checks for Unicode code points that are not valid in a document .
9,621
public function apply ( $ context ) { if ( ! $ context instanceof RContext ) { $ context = new Context ( $ context ) ; } return $ this -> evaluate ( $ context ) ; }
Evaluate the Rule with the given Context .
9,622
public static function generateMessageId ( $ hostname ) { if ( strpos ( $ hostname , '@' ) !== false ) { $ hostname = strstr ( $ hostname , '@' ) ; } else { $ hostname = '@' . $ hostname ; } return date ( 'YmdGHjs' ) . '.' . getmypid ( ) . '.' . self :: $ idCounter ++ . $ hostname ; }
Returns an unique message ID to be used for a mail message .
9,623
public static function mimeDecode ( $ text , $ charset = 'utf-8' ) { $ origtext = $ text ; $ text = @ iconv_mime_decode ( $ text , 0 , $ charset ) ; if ( $ text !== false ) { return $ text ; } $ text = preg_replace_callback ( '/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/' , create_function ( '$matches' , 'return strtoupper($matches[0]);' ) , $ origtext ) ; $ text = @ iconv_mime_decode ( $ text , 0 , $ charset ) ; if ( $ text !== false ) { return $ text ; } $ text = str_replace ( array ( '?b?' , '?q?' ) , array ( '?B?' , '?Q?' ) , $ origtext ) ; $ text = @ iconv_mime_decode ( $ text , 0 , $ charset ) ; if ( $ text !== false ) { return $ text ; } $ text = preg_replace ( '/=\?([^?]+)\?/' , '=?iso-8859-1?' , $ origtext ) ; $ text = iconv_mime_decode ( $ text , 0 , $ charset ) ; return $ text ; }
Decodes mime encoded fields and tries to recover from errors .
9,624
static public function replyToMail ( ezcMail $ mail , ezcMailAddress $ from , $ type = self :: REPLY_SENDER , $ subjectPrefix = "Re: " , $ mailClass = "ezcMail" ) { $ reply = new $ mailClass ( ) ; $ reply -> from = $ from ; if ( $ mail -> getHeader ( 'Reply-To' ) != '' ) { $ reply -> to = ezcMailTools :: parseEmailAddresses ( $ mail -> getHeader ( 'Reply-To' ) ) ; } else { $ reply -> to = array ( $ mail -> from ) ; } if ( $ type == self :: REPLY_ALL ) { $ cc = array ( ) ; foreach ( $ mail -> to as $ address ) { if ( $ address -> email != $ from -> email ) { $ cc [ ] = $ address ; } } foreach ( $ mail -> cc as $ address ) { if ( $ address -> email != $ from -> email ) { $ cc [ ] = $ address ; } } $ reply -> cc = $ cc ; } $ reply -> subject = $ subjectPrefix . $ mail -> subject ; if ( $ mail -> getHeader ( 'Message-Id' ) ) { $ reply -> setHeader ( 'In-Reply-To' , $ mail -> getHeader ( 'Message-ID' ) ) ; if ( $ mail -> getHeader ( 'References' ) != '' ) { $ reply -> setHeader ( 'References' , $ mail -> getHeader ( 'References' ) . ' ' . $ mail -> getHeader ( 'Message-ID' ) ) ; } else { $ reply -> setHeader ( 'References' , $ mail -> getHeader ( 'Message-ID' ) ) ; } } else { $ reply -> setHeader ( 'References' , $ mail -> getHeader ( 'References' ) ) ; } return $ reply ; }
Returns a new mail object that is a reply to the current object .
9,625
static public function guessContentType ( $ fileName , & $ contentType , & $ mimeType ) { $ extension = strtolower ( pathinfo ( $ fileName , PATHINFO_EXTENSION ) ) ; switch ( $ extension ) { case 'gif' : $ contentType = 'image' ; $ mimeType = 'gif' ; break ; case 'jpg' : case 'jpe' : case 'jpeg' : $ contentType = 'image' ; $ mimeType = 'jpeg' ; break ; case 'png' : $ contentType = 'image' ; $ mimeType = 'png' ; break ; case 'bmp' : $ contentType = 'image' ; $ mimeType = 'bmp' ; break ; case 'tif' : case 'tiff' : $ contentType = 'image' ; $ mimeType = 'tiff' ; break ; default : return false ; } return true ; }
Guesses the content and mime type by using the file extension .
9,626
public function authenticate ( Authenticatable $ user , array $ credentials ) { $ handler = ldap_connect ( $ this -> host ) ; if ( ! $ handler ) { throw new RuntimeException ( "Connection fail! Check your server address: '{$this->host}'." ) ; } try { ldap_set_option ( $ handler , LDAP_OPT_PROTOCOL_VERSION , 3 ) ; } catch ( \ ErrorException $ e ) { ; } $ username = strtok ( $ user -> email , '@' ) ; $ rdn = $ this -> makeRdn ( $ username ) ; try { $ bind = ldap_bind ( $ handler , $ rdn , $ credentials [ 'password' ] ) ; } catch ( \ ErrorException $ e ) { $ bind = false ; } if ( $ handler ) { ldap_close ( $ handler ) ; unset ( $ handler ) ; } if ( $ bind ) { $ user -> save ( ) ; } return $ bind ; }
Check user s credentials against LDAP server .
9,627
public function getList ( array $ query = [ ] ) { $ list = $ this -> execute ( self :: HTTP_GET , self :: DOMUSERP_API_PEDIDOVENDA . '/empresas' ) ; return $ list ; }
List of companies
9,628
public function flush ( ) { rewind ( $ this -> handle ) ; $ out = stream_get_contents ( $ this -> handle ) ; fseek ( $ this -> handle , 0 , SEEK_END ) ; return $ out ; }
Output all written data as string .
9,629
private function write ( array $ row ) { if ( $ this -> encodingFrom !== null && $ this -> encodingTo !== null ) { foreach ( $ row as $ k => $ v ) { $ row [ $ k ] = iconv ( $ this -> encodingFrom , $ this -> encodingTo , $ v ) ; } } return fputcsv ( $ this -> handle , $ row , $ this -> delimiter , $ this -> enclosure , $ this -> escape ) ; }
Wrapper for fputcsv function
9,630
public function createTemporaryTable ( $ tableName , $ tableDefinition ) { $ tableName = str_replace ( '%' , '' , $ tableName ) ; $ tableName = $ this -> getPrefixedTableNames ( $ tableName ) ; $ this -> db -> exec ( "CREATE TEMPORARY TABLE $tableName ($tableDefinition)" ) ; return $ tableName ; }
Create temporary table .
9,631
public function handles ( $ name ) { try { $ this -> view -> getHelper ( $ name ) ; } catch ( Zend_Loader_PluginLoader_Exception $ e ) { return false ; } return true ; }
Called from Dwoo_Compiler to check if the requested plugin is available
9,632
public function decorate ( Collection $ items , $ type = 'notification' ) { $ view = config ( 'antares/notifications::templates.' . $ type ) ; if ( is_null ( $ view ) ) { throw new RuntimeException ( 'Unable to resolve notification partial view.' ) ; } $ return = [ ] ; foreach ( $ items as $ item ) { $ return [ ] = $ this -> item ( $ item , $ view ) ; } return $ return ; }
Decorates notifications of alerts
9,633
public function item ( Model $ item , $ view ) { $ content = $ this -> getVariablesAdapter ( ) -> get ( $ item -> content [ 0 ] -> content , ( array ) $ item -> variables ) ; return view ( $ view , [ 'id' => $ item -> id , 'author' => $ item -> author , 'title' => $ item -> content [ 0 ] -> title , 'value' => $ content , 'priority' => priority_label ( $ item -> notification -> severity -> name ) , 'created_at' => $ item -> created_at ] ) -> render ( ) ; }
Decorates single item
9,634
public function switchAction ( Request $ request , string $ currency ) : RedirectResponse { $ result = $ this -> get ( 'currency.repository' ) -> findOneBy ( [ 'code' => $ currency ] ) ; if ( null !== $ result ) { $ request -> getSession ( ) -> set ( '_currency' , $ currency ) ; } return new RedirectResponse ( $ request -> headers -> get ( 'referer' ) ) ; }
Sets new session currency
9,635
private function sanitize ( $ st ) { $ st = trim ( ( string ) $ st ) ; if ( strpos ( $ st , ';' ) !== false ) { return '' ; } if ( strpos ( $ st , '<' ) !== false ) { return '' ; } if ( strpos ( $ st , '"' ) !== false ) { return '' ; } if ( strpos ( $ st , "'" ) !== false ) { return '' ; } return $ st ; }
This function is used to sanitize the strings which are given as parameters
9,636
private function process_parameters ( $ param ) { foreach ( $ param as $ key => $ val ) { if ( \ is_array ( $ val ) ) { $ param [ $ key ] = $ this -> process_parameters ( $ val ) ; } else { $ param [ $ key ] = $ this -> sanitize ( $ val ) ; } } return $ param ; }
Sanitize each parameter
9,637
public function get_args ( $ name ) { if ( $ this -> checked ) { $ cmd_name = str_replace ( '_' , '-' , $ name ) ; return isset ( $ this -> commands [ $ cmd_name ] , $ this -> commands [ $ cmd_name ] [ 'args' ] ) ? $ this -> commands [ $ cmd_name ] [ 'args' ] : [ ] ; } }
Returns the arguments description of a given command
9,638
public function generate ( $ command ) { $ perl_cmd = str_replace ( '_' , '-' , $ command ) ; if ( isset ( $ this -> commands [ $ perl_cmd ] ) ) { $ cmd = $ this -> commands [ $ perl_cmd ] ; $ st = '$vm->' . $ command . '([' . PHP_EOL ; foreach ( $ cmd [ 'args' ] as $ k => $ v ) { $ st .= "'$k' => " . ( $ v [ 'binary' ] ? '0' : "''" ) . PHP_EOL ; } $ st .= ']);' ; return $ st ; } return false ; }
Returns a string of PHP code for executing a given command with all its possible parameters pre - populated
9,639
public function openFiscalReceipt ( $ tipo_ticket ) { $ tipo_ticket = $ this -> arrayMapTipoTicket [ $ tipo_ticket ] ; return "@" . $ this -> cm ( 'FS' ) . $ tipo_ticket . $ this -> cm ( 'FS' ) . "T" ; }
Me abre un documento fiscal
9,640
public function printFiscalText ( $ texto , $ doble_ancho = false , $ display = 0 ) { $ texto = substr ( $ texto , 0 , 30 ) ; if ( $ doble_ancho ) { $ texto = $ this -> cm ( 'DOBLE_ANCHO' ) . $ texto ; } return "A" . $ this -> cm ( 'FS' ) . $ texto . $ this -> cm ( 'FS' ) . $ display ; }
Imprime texto fiscal que se muestra por lo general antes de los articulos . No puede contener la palabra TOTAL porque se puede bloquear la impresora
9,641
public function setDateTime ( $ fecha = 'now' , $ hora = 'now' ) { $ ymd = date ( "ymd" , strtotime ( $ fecha ) ) ; $ his = date ( "His" , strtotime ( $ hora ) ) ; return "X" . $ this -> cm ( 'FS' ) . $ ymd . $ this -> cm ( 'FS' ) . $ his ; }
Setea fecha y hora
9,642
public function setHeaderTrailer ( $ numero_de_linea , $ texto = "-" , $ doble_ancho = false ) { $ texto = substr ( $ texto , 0 , 45 ) ; if ( $ numero_de_linea > - 3 && $ numero_de_linea <= 0 ) { $ comando = "]" . $ this -> cm ( 'FS' ) . $ numero_de_linea ; } if ( $ numero_de_linea > 0 && $ numero_de_linea < 21 ) { if ( $ doble_ancho ) { $ texto = $ this -> cm ( 'DOBLE_ANCHO' ) . $ texto ; } $ comando = "]" . $ this -> cm ( 'FS' ) . $ numero_de_linea . $ this -> cm ( 'FS' ) . $ texto ; } else { $ comando = false ; } return $ comando ; }
Setea el encabezado y el pie de pagina
9,643
public function setTrailer ( $ linea , $ texto , $ doble_ancho = false ) { $ texto = substr ( $ texto , 0 , 45 ) ; $ comando = '' ; if ( $ linea > - 1 && $ linea < 10 ) { if ( $ doble_ancho ) { $ texto = $ this -> cm ( 'DOBLE_ANCHO' ) . $ texto ; } $ numero_de_linea = 11 + $ linea ; $ comando = "]" . $ this -> cm ( 'FS' ) . $ numero_de_linea . $ this -> cm ( 'FS' ) . $ texto ; } return $ comando ; }
Setea el pie de pagina
9,644
public function addView ( View $ view ) { $ name = $ view -> getName ( ) ; $ path = $ view -> getPath ( ) ; if ( ! is_object ( $ path ) ) { if ( $ path ) { $ path = ltrim ( str_replace ( base_path ( ) , '' , realpath ( $ path ) ) , '/' ) ; } if ( substr ( $ path , - 10 ) == '.blade.php' ) { $ type = 'blade' ; } else { $ type = pathinfo ( $ path , PATHINFO_EXTENSION ) ; } } else { $ type = get_class ( $ view ) ; $ path = '' ; } if ( ! $ this -> collect_data ) { $ params = array_keys ( $ view -> getData ( ) ) ; } else { $ data = [ ] ; foreach ( $ view -> getData ( ) as $ key => $ value ) { $ data [ $ key ] = $ this -> exporter -> exportValue ( $ value ) ; } $ params = $ data ; } $ this -> templates [ ] = [ 'name' => $ path ? sprintf ( '%s (%s)' , $ name , $ path ) : $ name , 'param_count' => count ( $ params ) , 'params' => $ params , 'type' => $ type , ] ; }
Add a View instance to the Collector
9,645
protected function getSummaryColumns ( ) { $ columns = [ ] ; $ model = $ this -> getSampleModel ( ) ; $ columnName = $ model -> getLabelColumnName ( ) ; if ( $ columnName != "" ) { $ columns [ ] = $ columnName ; } return $ columns ; }
Override to control the columns returned in HEAD requests
9,646
protected function get_field ( \ WP_Post $ post ) { $ field = parent :: get_field ( $ post ) ; $ automatic = $ this -> original_callback ? ' original' : '' ; $ geocder = $ this -> show_geocoder ? $ this -> geocoder ( ) : '' ; return <<<HTML {$field} <div id="{$this->name}-map" class="wpametu-map{$automatic}"></div> {$geocder}HTML ; }
Add map canvas
9,647
protected function geocoder ( ) { $ helper = $ this -> __ ( 'Input address' ) ; $ btn = $ this -> __ ( 'Move point' ) ; $ fail = esc_attr ( $ this -> __ ( 'Sorry, but nothing found with input address' ) ) ; return <<<HTML <p> <input type="text" class="gmap-geocoder regular-text" placeholder="{$helper}" /> <a class="button gmap-geocoder-btn" href="#" data-failure="{$fail}">{$btn}</a> </p>HTML ; }
Get GeoCoder input
9,648
public function channel ( $ channel ) { $ channel = $ this -> client -> get ( config ( 'twitch-api.api_url' ) . '/kraken/channels/' . $ channel ) ; return $ channel -> json ( ) ; }
Returns a channel object .
9,649
public function getGeneratorSettings ( $ generator ) { return $ this -> settings -> getOptional ( "generators" , $ generator , fphp \ Generator \ Settings :: emptyInstance ( ) ) ; }
Returns the product line s settings for a generator .
9,650
public function getProduct ( $ configuration = null ) { if ( ! $ configuration ) $ configuration = $ this -> getDefaultConfiguration ( ) ; return new Product ( $ this , $ configuration ) ; }
Returns a product of the product line for a configuration . If the configuration is omitted the default configuration is used .
9,651
public function trace ( $ artifact ) { $ featureName = str_replace ( "\"" , "&quot;" , $ artifact -> getFeature ( ) -> getName ( ) ) ; $ xmlConfiguration = fphp \ Model \ XmlConfiguration :: fromString ( '<configuration><feature name="' . $ featureName . '" automatic="undefined" manual="selected"/></configuration>' ) ; $ configuration = new fphp \ Model \ Configuration ( $ this -> getModel ( ) , $ xmlConfiguration ) ; $ product = new Product ( $ this , $ configuration , true ) ; return $ product -> trace ( ) ; }
Returns tracing links for an artifact .
9,652
public function renderTracingLinkAnalysis ( $ artifact , $ textOnly = false ) { return ( new fphp \ Artifact \ TracingLinkRenderer ( $ this -> trace ( $ artifact ) ) ) -> render ( $ textOnly ) ; }
Analyzes an artifact s tracing links by returning a web page .
9,653
public function initializeObject ( ) { $ this -> queue = new \ SplQueue ( ) ; $ this -> synchronousEventMap = $ this -> cache -> get ( 'DispatcherConfiguration_Synchronous' ) ; $ this -> asynchronousEventMap = $ this -> cache -> get ( 'DispatcherConfiguration_Asynchronous' ) ; if ( FALSE === ( $ this -> synchronousEventMap || $ this -> asynchronousEventMap ) ) { $ this -> buildEventMap ( ) ; $ this -> cache -> set ( 'DispatcherConfiguration_Asynchronous' , $ this -> asynchronousEventMap ) ; $ this -> cache -> set ( 'DispatcherConfiguration_Synchronous' , $ this -> synchronousEventMap ) ; } }
Initializes the broker . Loads the dispatching configuration from cache or builds it .
9,654
public function queueEvent ( $ event ) { $ this -> queue -> enqueue ( $ event ) ; $ class = get_class ( $ event ) ; foreach ( $ this -> synchronousEventMap -> getListenersForEvent ( $ class ) as $ listener ) { $ this -> invokeListener ( $ listener , $ event ) ; } }
Enqueues an arbitrary event .
9,655
public function flush ( ) { $ this -> queue -> setIteratorMode ( \ SplQueue :: IT_MODE_DELETE ) ; foreach ( $ this -> queue as $ event ) { $ class = get_class ( $ event ) ; foreach ( $ this -> asynchronousEventMap -> getListenersForEvent ( $ class ) as $ listener ) { $ this -> invokeListener ( $ listener , $ event ) ; } } }
Publishes queued events .
9,656
private function invokeListener ( $ listener , $ event ) { if ( is_array ( $ listener ) ) { list ( $ listenerClass , $ method ) = $ listener ; $ listenerInstance = $ this -> objectManager -> get ( $ listenerClass ) ; $ listenerInstance -> { $ method } ( $ event ) ; } else { call_user_func ( $ listener , $ event ) ; } }
Invokes a listener for an event .
9,657
private function buildEventMap ( ) { $ this -> synchronousEventMap = new EventMapping ( ) ; $ this -> asynchronousEventMap = new EventMapping ( ) ; $ eventMap = NULL ; $ annotationName = 'Helmich\\EventBroker\\Annotations\\Listener' ; $ classes = $ this -> reflectionService -> getClassesContainingMethodsAnnotatedWith ( $ annotationName ) ; foreach ( $ classes as $ class ) { $ classReflection = new ClassReflection ( $ class ) ; foreach ( $ classReflection -> getMethods ( ) as $ method ) { if ( $ this -> reflectionService -> isMethodAnnotatedWith ( $ class , $ method -> getName ( ) , $ annotationName ) ) { $ annotation = $ this -> reflectionService -> getMethodAnnotation ( $ class , $ method -> getName ( ) , $ annotationName ) ; $ event = $ annotation -> event ; $ this -> getEventMap ( $ annotation -> synchronous ) -> addListenerForEvent ( $ event , [ $ class , $ method -> getName ( ) ] ) ; } } } }
Builds the event dispatching configuration .
9,658
protected function create_regObjects ( ) { $ this -> working_node = $ this -> oai_pmh -> addChild ( $ this -> working_node , 'lom:lom' ) ; $ this -> working_node -> setAttribute ( 'xmlns:lom' , "http://ltsc.ieee.org/xsd/LOM" ) ; $ this -> working_node -> setAttribute ( 'xmlns:dc' , "http://purl.org/dc/elements/1.1/" ) ; }
Override create registry objects to use oai_lom as holder
9,659
public function generate_metadata ( $ lom_identifier , $ res ) { debug_message ( '****** In ' . __FILE__ . ' function ' . __FUNCTION__ . ' was called.' ) ; $ lom_data = new LOM_DataHolder ( ) ; $ lom_data -> setIdentifiers ( $ lom_identifier , $ this -> def_catalog ) ; $ res -> setFetchMode ( \ PDO :: FETCH_CLASS , LOM_DataHolder :: getKlass ( ) ) ; while ( $ row = $ res -> fetch ( ) ) { $ lom_data -> combine ( $ row ) ; } $ res -> closeCursor ( ) ; $ this -> write_xml_meta ( $ lom_data -> to_array ( ) ) ; }
Generates metadata xml
9,660
public function combine ( $ another ) { debug_message ( __CLASS__ . '.' . __FUNCTION__ . " LLOM_DataHolder class is " . LOM_DataHolder :: getKlass ( ) ) ; debug_message ( __CLASS__ . '.' . __FUNCTION__ . " another is " . get_class ( $ another ) ) ; if ( is_a ( $ another , LOM_DataHolder :: getKlass ( ) ) ) { debug_message ( 'entering function ' . __FUNCTION__ . ' in ' . __CLASS__ ) ; if ( empty ( $ this -> identifier ) ) { debug_message ( "LOM_DataHolder::identifier should not be empty!!" ) ; $ this -> identifier = $ another -> identifier ; } elseif ( strcmp ( substr ( $ this -> identifier , - strlen ( $ another -> identifier ) ) , $ another -> identifier ) !== 0 ) { error_log ( "found a different identifier for this element " . $ this -> identifier . " != " . $ another -> identifier ) ; return ; } debug_message ( "Identity ok. Adding elements" ) ; $ this -> addElement ( 'contributor' , $ another ) ; $ this -> addElement ( 'coverage' , $ another ) ; $ this -> addElement ( 'creator' , $ another ) ; $ this -> addElement ( 'date_' , $ another ) ; $ this -> addElement ( 'description' , $ another ) ; $ this -> addElement ( 'format_' , $ another ) ; $ this -> addElement ( 'language' , $ another ) ; $ this -> addElement ( 'publisher' , $ another ) ; $ this -> addElement ( 'relation' , $ another ) ; $ this -> addElement ( 'rights' , $ another ) ; $ this -> addElement ( 'source' , $ another ) ; $ this -> addElement ( 'subject' , $ another ) ; $ this -> addElement ( 'title' , $ another ) ; $ this -> addElement ( 'type_' , $ another ) ; $ this -> addElement ( 'thumbnail' , $ another ) ; } }
Combines this object with another LOM_DataHolder object
9,661
private function addElement ( $ elem , $ to_add ) { if ( isset ( $ to_add -> $ elem ) && ! empty ( $ to_add -> $ elem ) && $ to_add -> $ elem != ' ' ) { $ elem_to_add = str_replace ( '&' , '-and-' , $ to_add -> $ elem ) ; if ( ! in_array ( $ elem_to_add , $ this -> $ elem ) ) { array_push ( $ this -> $ elem , $ elem_to_add ) ; } } }
adds a db element only if it is new
9,662
private function asVcard ( $ name ) { $ name = preg_replace ( '/\s\s+/i' , '' , $ name ) ; $ name = preg_replace ( '/[^A-Za-z0-9\x{002D}\x{002E}\x{00C0}-\x{00FF} -]/' , '' , $ name ) ; $ name = trim ( $ name ) ; $ nm_expl = explode ( ' ' , $ name ) ; $ head = '' ; if ( in_array ( $ nm_expl [ 0 ] , array ( 'Prof.' , 'Professor' , 'Dr.' , 'Doutor' ) ) ) { $ head = array_shift ( $ nm_expl ) ; } $ lastnm = array_pop ( $ nm_expl ) ; $ n = $ lastnm . ';' . implode ( ' ' , $ nm_expl ) . ';' . $ head . ';' ; return "BEGIN:VCARD\nVERSION:4.0\nN:$n\nFN:$name\nEND:VCARD" ; }
turns the elements into a string formatted for VCard
9,663
public function get ( array $ data = null ) { if ( $ this -> check ( ) ) { if ( \ is_null ( $ this -> content ) ) { $ this -> content = file_get_contents ( $ this -> file ) ; } if ( empty ( $ this -> content ) ) { return '' ; } if ( $ this -> checkers ) { $ st = '' ; foreach ( $ this -> checkers as $ chk ) { $ st .= file_get_contents ( $ chk ) ; } $ this -> content = $ st . $ this -> content ; } switch ( $ this -> ext ) { case 'js' : if ( ! empty ( $ this -> lang_file ) ) { $ tmp = json_decode ( file_get_contents ( $ this -> lang_file ) , true ) ; $ path = $ this -> plugin ? substr ( $ this -> path , \ strlen ( $ this -> plugin ) + 1 ) : $ this -> path ; if ( $ translations = $ tmp [ 'mvc/' . $ path ] ?? ( $ tmp [ 'components/' . $ path ] ?? null ) ) { $ json = json_encode ( $ translations ) ; $ tmp = <<<JAVASCRIPT(data) => { bbn.fn.autoExtend("lng", $json)};JAVASCRIPT ; $ this -> content = $ tmp . $ this -> content ; } unset ( $ tmp , $ translations ) ; } return $ this -> content ; case 'coffee' : return $ this -> content ; case 'css' : return $ this -> content ; case 'less' : $ less = new \ lessc ( ) ; return $ less -> compile ( $ this -> content ) ; case 'scss' : $ scss = new \ Leafo \ ScssPhp \ Compiler ( ) ; return $ scss -> compile ( $ this -> content ) ; case 'html' : return empty ( $ data ) ? $ this -> content : bbn \ tpl :: render ( $ this -> content , $ data ) ; case 'php' : $ dir = getcwd ( ) ; chdir ( dirname ( $ this -> file ) ) ; $ r = bbn \ mvc :: include_php_view ( $ this -> file , $ this -> content , $ data ? : [ ] ) ; chdir ( $ dir ) ; return $ r ; } } return false ; }
Processes the controller and checks whether it has been routed or not .
9,664
public function setSessionValue ( $ name , $ value ) { if ( method_exists ( $ this -> session , 'driver' ) && $ this -> session -> driver ( ) instanceof \ Illuminate \ Contracts \ Session \ Session ) { $ this -> session -> put ( $ name , $ value ) ; return ; } $ this -> session -> set ( $ name , $ value ) ; }
Sets a value in the session
9,665
public function getCmsCategories ( ) { $ categories = array ( '' => 'No category' ) ; $ results = $ this -> getEventManager ( ) -> trigger ( __FUNCTION__ , $ this , array ( 'categories' => $ categories ) ) -> last ( ) ; if ( $ results ) { $ categories = $ results ; } return $ categories ; }
An event is triggered so that the modules wishing to associate a category to a CMS page can add their own categories without adherence between the 2 modules
9,666
static public function createNewTable ( $ fields , $ indexes ) { self :: initOptions ( ) ; $ className = ezcDbSchema :: $ options -> tableClassName ; return new $ className ( $ fields , $ indexes ) ; }
Returns an object to represent a table in the schema .
9,667
protected function getPaths ( ContextInterface $ context ) { if ( $ this -> pathProvider instanceof ContextAwareInterface ) { $ this -> pathProvider -> setContext ( $ context ) ; } return $ this -> pathProvider -> getPaths ( [ ] ) ; }
Return paths that comes from provider and returns array of resource files
9,668
public static function get ( $ url , array $ params = [ ] , array $ headers = [ ] ) { if ( $ params ) { $ url .= ( strpos ( $ url , '?' ) ? '&' : '?' ) . http_build_query ( $ params ) ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; return self :: execute ( $ ch ) ; }
send GET request
9,669
public static function post ( $ url , array $ data = [ ] , array $ headers = [ ] ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ data ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; return self :: execute ( $ ch ) ; }
send POST request
9,670
public function marketRequest ( $ segment , array $ parameters = [ ] ) { $ baseUrl = $ this -> market_url ; return $ this -> privateRequest ( $ baseUrl , $ segment , $ parameters ) ; }
Execute a market API request
9,671
public function accountRequest ( $ segment , array $ parameters = [ ] ) { $ baseUrl = $ this -> account_url ; return $ this -> privateRequest ( $ baseUrl , $ segment , $ parameters ) ; }
Execute an account API request
9,672
private function _curlConnection ( $ request ) { $ curl = curl_init ( ) ; $ method = $ request -> getRequestMethod ( ) ; $ headers = array ( 'Expect:' ) ; foreach ( $ request -> getHeaders ( ) as $ header ) { $ headers [ ] = rtrim ( $ header -> __toString ( ) ) ; } curl_setopt ( $ curl , CURLOPT_URL , $ request -> getUrl ( ) ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_HEADER , true ) ; curl_setopt ( $ curl , CURLOPT_VERBOSE , false ) ; curl_setopt ( $ curl , CURLOPT_TIMEOUT_MS , $ this -> _timeout * 1000 ) ; curl_setopt ( $ curl , CURLOPT_CONNECTTIMEOUT_MS , $ this -> _connectTimeoutMs ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYHOST , false ) ; curl_setopt ( $ curl , CURLOPT_PROTOCOLS , ( CURLPROTO_HTTP | CURLPROTO_HTTPS ) ) ; curl_setopt ( $ curl , CURLOPT_REDIR_PROTOCOLS , ( CURLPROTO_HTTP | CURLPROTO_HTTPS ) ) ; curl_setopt ( $ curl , CURLOPT_NOSIGNAL , 1 ) ; if ( isset ( $ this -> _ipFamily ) ) { curl_setopt ( $ curl , CURLOPT_IPRESOLVE , $ this -> _ipFamily ) ; } if ( isset ( $ this -> _proxy ) ) { curl_setopt ( $ curl , CURLOPT_PROXY , $ this -> _proxy ) ; } if ( isset ( $ this -> _auth ) ) { curl_setopt ( $ curl , CURLOPT_USERPWD , $ this -> _auth ) ; curl_setopt ( $ curl , CURLOPT_HTTPAUTH , CURLAUTH_BASIC ) ; } if ( $ method == 'PUT' || $ method == 'POST' ) { $ headers [ ] = 'Content-Length: ' . strlen ( $ request -> getBody ( ) ) ; curl_setopt ( $ curl , CURLOPT_CUSTOMREQUEST , $ method ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ request -> getBody ( ) ) ; } elseif ( $ method == 'DELETE' ) { curl_setopt ( $ curl , CURLOPT_CUSTOMREQUEST , $ method ) ; } curl_setopt ( $ curl , CURLOPT_HTTPHEADER , $ headers ) ; return $ curl ; }
Initializes the curl connection
9,673
private function _buildResponse ( $ response ) { $ sections = explode ( "\r\n\r\n" , $ response , 2 ) ; $ body = isset ( $ sections [ 1 ] ) ? $ sections [ 1 ] : NULL ; $ headers = array ( ) ; $ headerlines = explode ( "\n" , $ sections [ 0 ] ) ; list ( $ http , $ code , $ message ) = explode ( ' ' , $ headerlines [ 0 ] , 3 ) ; foreach ( array_slice ( $ headerlines , 1 ) as $ headerline ) { $ headers [ ] = HeaderField :: fromString ( $ headerline ) ; } $ response = new Response ( $ code , $ headers , $ body ) ; return $ response ; }
Parses a response into headers and a body
9,674
public function addCustomer ( AddCustomerToCustomerGroupEvent $ event ) { ( new CustomerCustomerGroupQuery ( ) ) -> filterByCustomerId ( $ event -> getCustomerId ( ) ) -> filterByCustomerGroupId ( $ event -> getCustomerGroupId ( ) ) -> findOneOrCreate ( ) -> save ( ) ; }
Add a customer to a customer group .
9,675
public function compare ( $ date , $ comparator ) { if ( $ date instanceof $ this ) { $ tmp = $ date ; } else { $ tmp = new \ bbn \ time ( $ date ) ; } switch ( $ comparator ) { case $ comparator === '>' : return $ this -> get_time ( ) > $ tmp -> get_time ( ) ; break ; case $ comparator === '>=' : return $ this -> get_time ( ) >= $ tmp -> get_time ( ) ; break ; case $ comparator === '<' : return $ this -> get_time ( ) < $ tmp -> get_time ( ) ; break ; case $ comparator === '<=' : return $ this -> get_time ( ) <= $ tmp -> get_time ( ) ; break ; case $ comparator === '=' : return $ this -> get_time ( ) == $ tmp -> get_time ( ) ; break ; } }
Compares two dates
9,676
public function write ( $ sessionId , $ data ) { $ this -> cache -> save ( $ this -> prefix . $ sessionId , $ data , $ this -> lifetime ) ; }
Writes the data to the table
9,677
public function destroy ( $ session_id = null ) { @ session_unset ( ) ; if ( $ session_id === null ) { $ session_id = $ this -> getId ( ) ; } return $ this -> cache -> delete ( $ this -> prefix . $ session_id ) ; }
Destroyes the session
9,678
public function text ( $ ele ) { if ( isset ( $ ele -> parentNode ) && isset ( $ ele -> parentNode -> tagName ) && HTML5_Elements :: isA ( $ ele -> parentNode -> localName , HTML5_Elements :: TEXT_RAW ) ) { $ this -> wr ( $ ele -> data ) ; return ; } $ this -> wr ( $ this -> enc ( $ ele -> data ) ) ; }
Write a text node .
9,679
protected function namespaceAttrs ( $ ele ) { if ( ! $ this -> xpath || $ this -> xpath -> document !== $ ele -> ownerDocument ) { $ this -> xpath = new \ DOMXPath ( $ ele -> ownerDocument ) ; } foreach ( $ this -> xpath -> query ( 'namespace::*[not(.=../../namespace::*)]' , $ ele ) as $ nsNode ) { if ( ! in_array ( $ nsNode -> nodeValue , $ this -> implicitNamespaces ) ) { $ this -> wr ( ' ' ) -> wr ( $ nsNode -> nodeName ) -> wr ( '="' ) -> wr ( $ nsNode -> nodeValue ) -> wr ( '"' ) ; } } }
Write the namespace attributes
9,680
protected function closeTag ( $ ele ) { if ( $ this -> outputMode == static :: IM_IN_HTML || $ ele -> hasChildNodes ( ) ) { $ this -> wr ( '</' ) -> wr ( $ this -> traverser -> isLocalElement ( $ ele ) ? $ ele -> localName : $ ele -> tagName ) -> wr ( '>' ) ; } }
Write the closing tag .
9,681
protected function enc ( $ text , $ attribute = false ) { if ( ! $ this -> encode ) { return $ this -> escape ( $ text , $ attribute ) ; } if ( $ this -> hasHTML5 ) { return htmlentities ( $ text , ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES , 'UTF-8' , false ) ; } else { return strtr ( $ text , HTML5_Serializer_HTML5Entities :: $ map ) ; } }
Encode text .
9,682
protected function padText ( $ text , $ mode , $ blockSize , $ paddingType ) { $ paddingSize = 0 ; $ padding = '' ; if ( $ mode === 'cbc' || $ mode === 'ecb' ) { $ paddingSize = $ blockSize - ( strlen ( $ text ) % $ blockSize ) ; if ( $ paddingSize >= 256 ) { throw new InvalidArgumentException ( "Block size [$blockSize] is bigger than 256" ) ; } switch ( $ paddingType ) { case self :: PADDING_ANSI_X_923 : $ padding = str_repeat ( chr ( 0 ) , $ paddingSize - 1 ) . chr ( $ paddingSize ) ; break ; case self :: PADDING_PKCS7 : $ padding = str_repeat ( chr ( $ paddingSize ) , $ paddingSize ) ; break ; case self :: PADDING_ISO_10126 : $ padding = '' ; foreach ( range ( 0 , $ paddingSize - 2 ) as $ i ) { $ padding .= chr ( rand ( ) ) ; } $ padding .= chr ( $ paddingSize ) ; break ; case self :: PADDING_ISO_IEC_7816_4 : $ padding = chr ( 0x80 ) . str_repeat ( chr ( 0 ) , $ paddingSize - 1 ) ; break ; case self :: PADDING_ZERO : $ padding = str_repeat ( chr ( 0 ) , $ paddingSize ) ; break ; case self :: PADDING_SPACE : $ padding = str_repeat ( ' ' , $ paddingSize ) ; break ; default : $ paddingSize = 0 ; break ; } } if ( ! $ paddingSize ) { return $ text ; } if ( $ paddingSize > $ blockSize ) { throw new InvalidArgumentException ( "Invalid padding size [$paddingSize]" ) ; } return $ text . substr ( $ padding , 0 , $ paddingSize ) ; }
Pads texts before encryption
9,683
public function encryptBase64 ( $ text , $ key = null , $ safe = false ) { if ( $ safe === true ) { return strtr ( base64_encode ( $ this -> encrypt ( $ text , $ key ) ) , '+/' , '-_' ) ; } return base64_encode ( $ this -> encrypt ( $ text , $ key ) ) ; }
Encrypts a text returning the result as a base64 string
9,684
public function decryptBase64 ( $ text , $ key = null , $ safe = false ) { if ( $ safe === true ) { return $ this -> decrypt ( base64_decode ( strtr ( $ text , '-_' , '+/' ) ) , $ key ) ; } return $ this -> decrypt ( base64_decode ( $ text ) , $ key ) ; }
Decrypt a text that is coded as a base64 string
9,685
public function getListItems ( ) { $ item_arr = [ ] ; foreach ( $ this -> items as $ item ) { $ item_arr [ $ item -> id ] = $ item -> title ; } return $ item_arr ; }
For special widget
9,686
protected function createArgumentDescriptor ( $ functionDescriptor , $ argument ) { $ params = $ functionDescriptor -> getTags ( ) -> get ( 'param' , array ( ) ) ; if ( ! $ this -> argumentAssembler -> getBuilder ( ) ) { $ this -> argumentAssembler -> setBuilder ( $ this -> builder ) ; } return $ this -> argumentAssembler -> create ( $ argument , $ params ) ; }
Creates a new ArgumentDescriptor from the given Reflector and Param .
9,687
private function createCallbackFromString ( $ callFunc , $ params ) { if ( is_string ( $ callFunc ) ) { $ callFunc = function ( ) use ( $ callFunc , $ params ) { $ controllerParts = explode ( '@' , $ callFunc ) ; $ controllerParts [ 0 ] = explode ( '\\' , $ controllerParts [ 0 ] ) ; $ hmvc = '' ; $ controllerPaths = count ( $ controllerParts [ 0 ] ) ; if ( $ controllerPaths > 1 ) { foreach ( $ controllerParts [ 0 ] as $ idx => $ controllerPart ) { if ( $ idx == ( $ controllerPaths - 1 ) ) { break ; } $ hmvc .= '\\' . $ controllerPart ; } } $ controller = $ hmvc . '\\Controllers\\' . $ controllerParts [ 0 ] [ $ controllerPaths - 1 ] ; $ c = new \ ReflectionClass ( $ controller ) ; $ c = $ c -> newInstanceArgs ( $ params ) ; return call_user_func_array ( array ( $ c , $ controllerParts [ 1 ] ) , $ this -> route -> getParams ( ) ) ; } ; return $ callFunc ; } return $ callFunc ; }
Create Callback from string
9,688
public function get ( ) { $ this -> RoutedStatus = FALSE ; if ( ! $ this -> route -> isGet ( ) ) { return $ this ; } if ( is_callable ( $ this -> callable ) ) { return $ this ; } $ this -> middleware = array ( 'before' => array ( ) , 'after' => array ( ) ) ; self :: $ FullRender = '' ; $ args = func_get_args ( ) ; if ( ! empty ( self :: $ group ) ) { if ( $ args [ 0 ] == '/' ) { $ args [ 0 ] = substr ( self :: $ group , 0 , - 1 ) ; } else { $ args [ 0 ] = self :: $ group . $ args [ 0 ] ; } } array_push ( Route :: $ list , $ args [ 0 ] ) ; $ this -> setCallable ( $ args ) ; return $ this ; }
Set route for Get Method request
9,689
public function group ( ) { if ( is_callable ( $ this -> callable ) ) { return $ this ; } self :: $ FullRender = '' ; $ args = func_get_args ( ) ; self :: $ group .= $ args [ 0 ] . '/' ; if ( is_callable ( $ args [ 1 ] ) ) { $ this -> GroupFunc = Closure :: bind ( $ args [ 1 ] , $ this , get_class ( ) ) ; call_user_func_array ( $ this -> GroupFunc , array ( ) ) ; } self :: $ group = '' ; }
Set of Group route
9,690
public function template ( $ template , $ replace = FALSE ) { if ( $ this -> RoutedStatus || $ replace === TRUE ) { self :: $ FullRender = $ template ; } return $ this ; }
Set template before render
9,691
public function header ( $ code = 200 ) { if ( ! is_array ( $ code ) ) { $ code = array ( $ code ) ; } self :: $ header = array ( ) ; foreach ( $ code as $ value ) { if ( is_int ( $ value ) ) { self :: $ header [ ] = $ _SERVER [ "SERVER_PROTOCOL" ] . ' ' . Route :: $ HttpResponse [ $ value ] ; } else { self :: $ header [ ] = $ value ; } } }
Set Header Response
9,692
private function createMyCnf ( array $ db_info , $ path ) { $ this -> db_info = $ db_info ; $ data = array ( 'head' => '[client]' , 'user' => 'user = ' . $ this -> db_info [ 'user' ] , 'password' => 'password = ' . $ this -> db_info [ 'password' ] , 'host' => 'host = ' . $ this -> db_info [ 'host' ] ) ; $ content = implode ( PHP_EOL , $ data ) ; $ path = $ path . DIRECTORY_SEPARATOR . 'my.cnf' ; $ fp = fopen ( $ path , "wb" ) ; fwrite ( $ fp , $ content ) ; fclose ( $ fp ) ; return $ path ; }
Creates the my . cnf file for
9,693
public function run ( ) { $ result = $ this -> getCommand ( ) -> run ( ) ; if ( $ result -> getExitCode ( ) != 0 ) { throw new \ RuntimeException ( sprintf ( 'Command failed. Exit code %d, output %s' , $ result -> getExitCode ( ) , $ result -> getStdErr ( ) ) ) ; } return $ this -> parse ( $ result -> getStdOut ( ) ) ; }
Run configured command
9,694
protected function parse ( $ output ) { $ lines = explode ( PHP_EOL , $ output ) ; $ stats = array ( ) ; foreach ( $ lines as $ line ) { $ data = explode ( ' ' , $ line ) ; array_walk ( $ data , 'trim' ) ; $ stats [ ] = array_values ( array_filter ( $ data , function ( $ value ) { return strlen ( $ value ) > 0 ; } ) ) ; } return $ stats ; }
Parse top utility command output
9,695
protected function buildCommand ( ) { $ command = new Command ( \ Tivie \ Command \ ESCAPE ) ; $ command -> setCommand ( 'top' ) -> addArgument ( new Argument ( '-b' ) ) -> addArgument ( new Argument ( '-n' , 1 ) ) ; return $ command ; }
Build commit command
9,696
public function resolve ( $ name , $ declaringClass ) { if ( strpos ( $ name , '\\' ) !== false ) { return $ name ; } $ imports = $ this -> cache -> get ( '_PHX.imports.' . $ declaringClass ) ; if ( ! isset ( $ imports ) ) { $ imports = ClassHelper :: getImports ( $ declaringClass ) ; $ this -> cache -> save ( '_PHX.imports.' . $ declaringClass , $ imports ) ; } if ( isset ( $ imports [ $ name ] ) ) { return $ imports [ $ name ] ; } $ class = ClassHelper :: getNamespaceName ( $ declaringClass ) . $ name ; if ( class_exists ( $ class ) ) { return $ class ; } }
Gets full class name
9,697
public function add ( $ tag , ... $ arguments ) { $ tag = strtolower ( $ tag ) ; $ text = '' ; $ attributes = [ ] ; for ( $ i = 0 ; $ i <= 1 ; $ i ++ ) { if ( array_has ( $ arguments , $ i ) ) { if ( is_array ( array_get ( $ arguments , $ i ) ) ) { $ attributes = array_get ( $ arguments , $ i ) ; } elseif ( is_string ( array_get ( $ arguments , $ i ) ) || is_object ( array_get ( $ arguments , $ i ) ) ) { $ text = array_get ( $ arguments , $ i ) ; } } } if ( $ this -> tag === 'tag' || empty ( $ this -> allowed_tags ) || in_array ( $ tag , $ this -> allowed_tags ) || in_array ( $ tag , self :: $ special_tags ) ) { if ( in_array ( $ tag , self :: $ special_tags ) ) { $ tag_object = Html :: createElement ( $ tag , $ text , $ attributes ) ; $ tag_object -> text ( $ text ) -> addAttributes ( $ attributes ) ; self :: $ tag_registry [ ] = & $ tag_object ; $ this -> child_nodes [ ] = & $ tag_object ; return $ tag_object ; } $ class_name = 'Bluora\\LaravelHtmlBuilder\\Tag\\' . ucfirst ( $ tag ) ; if ( class_exists ( $ class_name ) ) { $ tag_object = ( new $ class_name ( ) ) -> setAttributes ( $ attributes ) -> setText ( $ text ) ; self :: $ tag_registry [ ] = & $ tag_object ; $ this -> child_nodes [ ] = & $ tag_object ; $ tag_object -> setParent ( $ tag_object ) ; return $ tag_object ; } throw new \ Exception ( $ tag . ' does not exist.' ) ; } throw new \ Exception ( $ this -> tag . ' does permit ' . $ tag ) ; }
Add a child node to this tag .
9,698
public function setTag ( $ tag ) { if ( in_array ( $ tag , $ this -> getParent ( ) -> allowed_tags ) ) { throw new \ Exception ( $ tag . ' can not be changed as it is not allowed under ' . $ this -> getParent ( ) -> getTag ( ) . '.' ) ; } $ this -> tag = $ tag ; return $ this ; }
Set the tag name .
9,699
public function setText ( $ value ) { $ this -> text = $ value ; if ( is_object ( $ value ) && stripos ( get_class ( $ value ) , 'HtmlGenerator\\Html' ) ) { $ this -> text = ( string ) $ value ; } return $ this ; }
Set the text for this tag .