idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
11,300
protected function checkUserClass ( ) { $ userClass = $ this -> userClass ; if ( ! class_exists ( $ userClass ) ) { throw new Exception ( 'User Class Invalid.' ) ; } if ( ! ( ( new $ userClass ( ) ) instanceof User ) ) { throw new Exception ( 'User Class(' . $ userClass . ') does not inherited from `\rhosocial\user\Use...
Check and get valid User .
11,301
protected function getUser ( $ user ) { $ userClass = $ this -> checkUserClass ( ) ; if ( is_numeric ( $ user ) ) { $ user = $ userClass :: find ( ) -> id ( $ user ) -> one ( ) ; } elseif ( is_string ( $ user ) && strlen ( $ user ) ) { $ user = $ userClass :: find ( ) -> guid ( $ user ) -> one ( ) ; } if ( ! $ user || ...
Get user from database .
11,302
public function actionRegister ( $ password , $ nickname = null , $ firstName = null , $ lastName = null ) { $ userClass = $ this -> checkUserClass ( ) ; $ user = new $ userClass ( [ 'password' => $ password ] ) ; $ profile = $ user -> createProfile ( [ 'nickname' => $ nickname , 'first_name' => $ firstName , 'last_nam...
Register new User .
11,303
public function actionDeregister ( $ user ) { $ user = $ this -> getUser ( $ user ) ; if ( $ user -> deregister ( ) ) { echo "User (" . $ user -> getID ( ) . ") Deregistered.\n" ; return static :: EXIT_CODE_NORMAL ; } return static :: EXIT_CODE_ERROR ; }
Deregister user .
11,304
public function actionShow ( $ user , $ guid = false , $ passHash = false , $ accessToken = false , $ authKey = false ) { $ user = $ this -> getUser ( $ user ) ; echo Yii :: t ( 'app' , 'User' ) . " (" . $ user -> getID ( ) . "), " . Yii :: t ( 'app' , 'registered at' ) . " (" . $ user -> getCreatedAt ( ) . ")" . ( $ u...
Show User Information .
11,305
public function actionStat ( $ user = null ) { if ( $ user === null ) { $ count = User :: find ( ) -> count ( ) ; echo "Total number of user(s): " . $ count . "\n" ; if ( $ count == 0 ) { return static :: EXIT_CODE_NORMAL ; } $ last = User :: find ( ) -> orderByCreatedAt ( SORT_DESC ) -> one ( ) ; echo "Latest user (" ...
Show statistics .
11,306
public function actionRole ( $ user , $ operation , $ role ) { $ user = $ this -> getUser ( $ user ) ; $ role = Yii :: $ app -> authManager -> getRole ( $ role ) ; if ( $ operation == 'assign' ) { try { $ assignment = Yii :: $ app -> authManager -> assign ( $ role , $ user ) ; } catch ( \ yii \ db \ IntegrityException ...
Assign a role to user or revoke a role .
11,307
public function actionPermission ( $ user , $ operation , $ permission ) { $ user = $ this -> getUser ( $ user ) ; $ permission = Yii :: $ app -> authManager -> getPermission ( $ permission ) ; if ( $ operation == 'assign' ) { try { $ assignment = Yii :: $ app -> authManager -> assign ( $ permission , $ user ) ; } catc...
Assign a permission to user or revoke a permission .
11,308
public function actionPassword ( $ user , $ password ) { $ user = $ this -> getUser ( $ user ) ; $ user -> applyForNewPassword ( ) ; $ result = $ user -> resetPassword ( $ password , $ user -> getPasswordResetToken ( ) ) ; if ( $ result ) { echo "Password changed.\n" ; } else { echo "Password not changed.\n" ; } return...
Change password directly .
11,309
public function actionConfirmPasswordHistory ( $ user , $ password ) { $ user = $ this -> getUser ( $ user ) ; $ passwordHistory = $ user -> passwordHistories ; $ passwordInHistory = 0 ; foreach ( $ passwordHistory as $ pass ) { if ( $ pass -> validatePassword ( $ password ) ) { $ passwordInHistory ++ ; echo "This pass...
Confirm password in history . This command will list all matching passwords in reverse order .
11,310
function debug ( $ str , $ TYPE = 0 , $ file = "" , $ line = 0 ) { if ( $ this -> debug ) { echo "<br>[$file:$line:" . ( $ this -> getDiffTime ( ) ) . "]$str" ; flush ( ) ; if ( $ TYPE == 1 ) { exit ; } } }
Show Debugging information
11,311
function Get32s ( $ val1 , $ val2 , $ val3 , $ val4 ) { $ val1 = ord ( $ val1 ) ; $ val2 = ord ( $ val2 ) ; $ val3 = ord ( $ val3 ) ; $ val4 = ord ( $ val4 ) ; if ( $ this -> MotorolaOrder ) { return ( ( $ val1 << 24 ) | ( $ val2 << 16 ) | ( $ val3 << 8 ) | ( $ val4 << 0 ) ) ; } else { return ( ( $ val4 << 24 ) | ( $ v...
Converts 4 - byte number into its equivalent integer
11,312
function get32u ( $ val1 , $ val2 , $ val3 , $ val4 ) { return ( $ this -> Get32s ( $ val1 , $ val2 , $ val3 , $ val4 ) & 0xffffffff ) ; }
Converts 4 - byte number into its equivalent integer with the help of Get32s
11,313
protected function setJobInstanceIfNecessary ( Job $ job , $ instance ) { if ( in_array ( InteractsWithQueue :: class , class_uses_recursive ( get_class ( $ instance ) ) ) ) { $ instance -> setJob ( $ job ) ; } return $ instance ; }
Set the job instance of the given class if necessary .
11,314
public function formatPrice ( float $ price , $ baseCurrency = null , $ targetCurrency = null , $ locale = null , $ quantity = 1 ) : string { return $ this -> helper -> convertAndFormat ( $ price , $ baseCurrency , $ targetCurrency , $ quantity , $ locale ) ; }
Formats the given amount
11,315
public function convertPrice ( float $ price , $ baseCurrency = null , $ targetCurrency = null , $ quantity = 1 ) : string { return $ this -> helper -> convert ( $ price , $ baseCurrency , $ targetCurrency , $ quantity ) ; }
Converts the given amount
11,316
public function getRelations ( ) : array { $ relations = array_unique ( array_merge ( $ this -> getAvailableIncludes ( ) , $ this -> relations ) ) ; return array_filter ( $ relations , function ( $ relation ) { return $ relation !== '*' ; } ) ; }
Get relations set on the transformer .
11,317
public function setRelations ( $ relations ) { $ this -> setAvailableIncludes ( array_unique ( array_merge ( $ this -> availableIncludes , ( array ) $ relations ) ) ) ; return $ this ; }
Set relations on the transformer .
11,318
protected function includePivot ( Pivot $ pivot ) { if ( ! method_exists ( $ this , 'transformPivot' ) ) { return false ; } return app ( Responder :: class ) -> transform ( $ pivot , function ( $ pivot ) { return $ this -> transformPivot ( $ pivot ) ; } ) -> getResource ( ) ; }
Include pivot table data to the response .
11,319
private function _set_cfg ( ) { if ( \ is_array ( $ this -> cfg ) ) { $ p = & $ this -> cfg [ 'params' ] ; $ components = false ; if ( ! empty ( $ p [ 'components' ] ) ) { $ components = explode ( ',' , $ p [ 'components' ] ) ; } $ this -> cfg = bbn \ x :: merge_arrays ( $ this -> cfg , [ 'test' => ! empty ( $ p [ 'tes...
Returns an array with all the - default or no - config parameters based on the sent ones
11,320
public function getPriority ( $ as_string = true ) { $ nodes = $ this -> doc -> getElementsByTagName ( 'priority' ) ; $ node = $ nodes -> item ( 0 ) ; if ( $ node ) { if ( $ as_string ) { return $ node -> nodeValue ; } else { return $ node ; } } else { return '' ; } }
Gets the priority value of a presence packet
11,321
public function setStatus ( $ status ) { $ node = $ this -> getStatus ( false ) ; if ( ! $ node ) { $ node = $ this -> createElement ( 'status' ) ; $ this -> doc -> appendChild ( $ node ) ; } $ node -> nodeValue = htmlspecialchars ( $ status ) ; }
Set the status of the presence packet
11,322
public function setShow ( $ show ) { if ( $ show == 'unavailable' ) { $ this -> setType ( $ show ) ; } $ node = $ this -> getShow ( false ) ; if ( ! $ node ) { $ node = $ this -> createElement ( 'show' ) ; $ this -> doc -> appendChild ( $ node ) ; } $ node -> nodeValue = htmlspecialchars ( $ show ) ; }
Shows the status of the bot
11,323
public function setPriority ( $ priority = 1 ) { $ node = $ this -> getPriority ( false ) ; if ( ! $ node ) { $ node = $ this -> createElement ( 'priority' ) ; $ this -> doc -> appendChild ( $ node ) ; } $ node -> nodeValue = htmlspecialchars ( $ priority ) ; }
Sets the priority of the presence
11,324
public function setType ( $ type ) { $ attr = $ this -> createAttribute ( 'type' ) ; $ this -> doc -> appendChild ( $ attr ) ; $ attr -> appendChild ( $ this -> createTextNode ( $ type ) ) ; }
Sets the presence type
11,325
public function createFailure ( string $ description ) { $ exception = new AssertionException ( $ description ) ; $ suiteClass = $ this -> suiteClass ; $ suiteClass :: current ( ) -> assert ( [ 'handler' => function ( ) use ( $ exception ) { throw $ exception ; } , 'type' => AssertionException :: class , ] ) ; }
Create a new assertion failure exception .
11,326
public static function encode ( $ data , $ prettyPrint = false , $ xmlVersion = '1.0' , $ encoding = 'utf-8' ) { $ domDocument = new DOMDocument ( $ xmlVersion , $ encoding ) ; $ domDocument = self :: loopEncode ( $ data , $ domDocument ) ; if ( $ prettyPrint ) { $ domDocument -> preserveWhiteSpace = false ; $ domDocum...
Encodes an array to xml strutcture
11,327
protected static function loopEncode ( $ data , $ domElement ) { if ( is_array ( $ data ) ) { foreach ( $ data as $ index => $ mixedElement ) { if ( is_int ( $ index ) ) { if ( $ index == 0 ) { $ node = $ domElement ; } else { $ node = new DOMElement ( $ domElement -> tagName ) ; $ domElement -> parentNode -> appendChi...
Lets loop through our data
11,328
protected static function loopDecode ( $ data ) { if ( is_array ( $ data ) ) { foreach ( $ data as & $ value ) { $ value = self :: loopDecode ( $ value ) ; } } elseif ( is_object ( $ data ) ) { return self :: loopDecode ( ( array ) $ data ) ; } return $ data ; }
Turns all the objects into arrays
11,329
public function read ( $ byte_count = null ) { $ this -> log ( 'read from socket' ) ; $ buffer = '' ; if ( ! is_null ( $ byte_count ) ) { $ buffer .= fgets ( $ this -> socket , 1024 ) ; } else { while ( ! feof ( $ this -> socket ) ) { $ buffer .= fgets ( $ this -> socket , 1024 ) ; } } return $ buffer ; }
Read data from the socket
11,330
public function import ( array $ classes ) { foreach ( $ classes as $ class => $ alias ) { if ( is_integer ( $ class ) ) { $ class = $ alias ; $ alias = ClassHelper :: getSimpleName ( $ class ) ; } if ( isset ( $ this -> imports [ $ alias ] ) ) { throw new \ RuntimeException ( "Alias $alias for $class exists, previous ...
Imports annotation classes
11,331
public function get ( $ class ) { $ annotations = $ this -> getCache ( ) -> get ( '_PHX.annotations.' . $ class ) ; if ( ! isset ( $ annotations ) ) { $ annotations = $ this -> getAnnotations ( $ class ) ; $ this -> getCache ( ) -> save ( '_PHX.annotations.' . $ class , $ annotations ) ; } return $ annotations ; }
Gets all annotations in the class
11,332
private function getAnnotations ( $ class ) { $ parsed = $ this -> getParser ( ) -> parse ( $ class ) ; if ( ! is_array ( $ parsed ) ) { return [ ] ; } $ context = [ 'class' => $ class , 'declaringClass' => $ class , 'type' => Context :: TYPE_CLASS , 'name' => $ class ] ; $ annotations = [ ] ; if ( ! empty ( $ parsed [...
parse all annotations from class
11,333
private function create ( $ annotation , $ context ) { $ logger = $ this -> getLogger ( ) ; $ name = $ annotation [ 'name' ] ; if ( ! $ this -> isValidName ( $ name ) ) { return null ; } $ annotationClass = $ this -> resolveClassName ( $ name , $ context [ 'declaringClass' ] ) ; if ( ! $ annotationClass ) { if ( isset ...
create annotation object
11,334
private function updateAddressFromComponent ( Address $ address , $ component ) : Address { foreach ( $ component -> types as $ type ) { switch ( $ type ) { case 'postal_code' : $ address -> setPostalCode ( $ component -> long_name ) ; break ; case 'locality' : case 'postal_town' : $ address -> setLocality ( $ componen...
update address from google address component
11,335
protected function clearDir ( $ dir ) { $ iterator = new \ DirectoryIterator ( $ dir ) ; foreach ( $ iterator as $ file ) { if ( $ file -> isDir ( ) && ! $ file -> isDot ( ) && ! preg_match ( "~\.~" , $ file ) ) { $ this -> clearDir ( $ file -> getPathname ( ) ) ; if ( ! \ rmdir ( $ file -> getPathname ( ) ) ) { return...
Clears out the contents of a cache directory
11,336
protected function catalogKeyDelete ( $ key ) { $ catalog = $ this -> fetch ( $ this -> catalog_key ) ; $ catalog = \ is_array ( $ catalog ) ? $ catalog : Array ( ) ; if ( isset ( $ catalog [ $ key ] ) ) { unset ( $ catalog [ $ key ] ) ; } ; return $ this -> store ( '/sb_Cache_Catalog' , $ catalog ) ; }
Deletes a key from the catalog
11,337
protected function listConfiguration ( array $ contents , array $ rawContents , OutputInterface $ output , $ k = null ) { $ origK = $ k ; foreach ( $ contents as $ key => $ value ) { if ( $ k === null && ! in_array ( $ key , array ( 'config' , 'repositories' ) ) ) { continue ; } $ rawVal = isset ( $ rawContents [ $ key...
Display the contents of the file in a pretty formatted way
11,338
public function set ( $ orig , $ dest = '' ) { if ( ! empty ( $ dest ) ) { copy ( $ orig , $ dest ) ; $ orig = $ dest ; } $ this -> path = $ orig ; $ this -> getInfo ( ) ; }
Sets the image being edited
11,339
public function getInfo ( ) { $ file_info = @ getimagesize ( $ this -> path ) ; $ this -> width [ 'orig' ] = $ file_info [ '0' ] ; $ this -> height [ 'orig' ] = $ file_info [ '1' ] ; switch ( $ file_info [ 2 ] ) { case "1" : $ this -> type = "gif" ; break ; case "2" : $ this -> type = "jpg" ; break ; case "3" : $ this ...
Gets the image file type width and height
11,340
public function resize ( $ width , $ height ) { if ( $ width == - 1 ) { $ this -> width [ 'dest' ] = ( $ height * $ this -> width [ 'orig' ] ) / $ this -> height [ 'orig' ] ; $ this -> height [ 'dest' ] = $ height ; } elseif ( $ height == - 1 ) { $ this -> width [ 'dest' ] = $ width ; $ this -> height [ 'dest' ] = ( $ ...
Resizes an the edited image to the specified width and height
11,341
public function toGrayscale ( ) { $ this -> getInfo ( ) ; $ this -> edited = imagecreate ( $ this -> width [ 'orig' ] , $ this -> height [ 'orig' ] ) ; for ( $ c = 0 ; $ c < 256 ; $ c ++ ) { $ palette [ $ c ] = imagecolorallocate ( $ this -> edited , $ c , $ c , $ c ) ; } for ( $ y = 0 ; $ y < $ this -> height [ 'orig'...
Converts the image being edited to grayscale
11,342
public function write ( $ text , $ params = array ( ) ) { $ color = ( isset ( $ params [ 'color' ] ) ) ? $ params [ 'color' ] : array ( 0 , 0 , 0 ) ; $ color = imagecolorallocate ( $ this -> edited , $ color [ 0 ] , $ color [ 1 ] , $ color [ 2 ] ) ; $ size = ( isset ( $ params [ 'size' ] ) ) ? $ params [ 'size' ] : 5 ;...
Write text onto an image
11,343
public function toFile ( ) { if ( $ this -> type == "jpg" ) { $ this -> toJpg ( ) ; } elseif ( $ this -> type == "png" ) { $ this -> toPng ( ) ; } elseif ( $ this -> type == "gif" ) { $ this -> toGif ( ) ; } }
Saves the edited image as a file based on the original images file type
11,344
public function display ( ) { if ( isset ( $ this -> edited ) ) { $ image = $ this -> edited ; } else { $ image = $ this -> original ; } if ( $ this -> type == "jpg" ) { header ( "Content-type: image/jpeg" ) ; imagejpeg ( $ image ) ; } elseif ( $ this -> type == "png" ) { header ( "Content-type: image/png" ) ; imagepng...
Displays the edited image to screen as a dynamic image file
11,345
public function forceDownload ( ) { if ( $ this -> type == "jpg" ) { $ this -> toJpg ( ) ; } elseif ( $ this -> type == "png" ) { $ this -> toPng ( ) ; } elseif ( $ this -> type == "gif" ) { $ this -> toGif ( ) ; } header ( 'Content-Description: File Transfer' ) ; header ( "Content-Type: application/octet-stream" ) ; h...
Forces the image being manipulated to the user as a force download
11,346
private function parseTexturesProperties ( $ propertiesArray ) { foreach ( $ propertiesArray as $ property ) { if ( $ property [ 'name' ] == 'textures' ) { $ texturesJSON = json_decode ( base64_decode ( $ property [ 'value' ] ) , true ) ; $ properties = new PlayerProperties ( $ texturesJSON [ 'timestamp' ] , $ textures...
Checks the array for a properties with name textures and creates a PlayerProperties for it
11,347
private function getResponse ( $ url , $ options , $ post ) { if ( $ post ) { $ response = $ this -> httpClient -> post ( $ url , $ options ) ; } else { $ response = $ this -> httpClient -> get ( $ url , $ options ) ; } if ( $ response -> getStatusCode ( ) != 200 ) { $ json = $ response -> json ( ) ; $ short = $ json [...
Get a response from the given subURL via POST with the given JSON data . Sets header Content - Type for JSON
11,348
public function get ( $ property ) { return isset ( $ this -> data [ $ property ] ) ? $ this -> data [ $ property ] : null ; }
Returns the value of a given property .
11,349
public function connect ( ) { if ( isset ( $ this -> _connection ) ) { $ this -> disconnect ( ) ; } $ function = $ this -> _config [ 'persistent' ] ? 'pfsockopen' : 'fsockopen' ; $ params = [ $ this -> _config [ 'host' ] , $ this -> _config [ 'port' ] , & $ errNum , & $ errStr ] ; if ( $ this -> _config [ 'timeout' ] )...
Initiates a socket connection to the beanstalk server . The resulting stream will not have any timeout set on it . Which means it can wait an unlimited amount of time until a packet becomes available . This is required for doing blocking reads .
11,350
public function delete ( $ id ) { $ this -> _write ( sprintf ( 'delete %d' , $ id ) ) ; $ status = $ this -> _read ( ) ; switch ( $ status ) { case 'DELETED' : return true ; case 'NOT_FOUND' : return false ; default : throw new ServerException ( 'Delete error: ' . $ status ) ; } }
Removes a job from the server entirely .
11,351
public function kickJob ( $ id ) { $ this -> _write ( sprintf ( 'kick-job %d' , $ id ) ) ; $ status = strtok ( $ this -> _read ( ) , ' ' ) ; switch ( $ status ) { case 'KICKED' : return true ; case 'NOT_FOUND' : return false ; default : throw new ServerException ( 'Kick error: ' . $ status ) ; } }
This is a variant of the kick command that operates with a single job identified by its job id . If the given job id exists and is in a buried or delayed state it will be moved to the ready queue of the the same tube where it currently belongs .
11,352
public function setType ( $ type = null ) { $ type = $ this -> calculateTypeValue ( $ type ) ; if ( ! is_int ( $ type ) || ( $ type < 0 ) || ( $ type > self :: ALL ) ) { throw new Exception \ InvalidArgumentException ( 'Unknown type' ) ; } $ this -> options [ 'type' ] = $ type ; return $ this ; }
Sets types of values that are to be considered empty .
11,353
public function addRules ( $ rules ) { if ( $ rules instanceof RiskyRulesAwareInterface && $ rules -> isRisky ( ) ) { $ this -> setRiskyAllowed ( true ) ; } if ( $ rules instanceof \ Traversable ) { $ rules = iterator_to_array ( $ rules ) ; } if ( ! is_array ( $ rules ) ) { throw new \ InvalidArgumentException ( 'Expec...
Add to the current rules . Overrides existing rules .
11,354
public function initialize ( Controller $ controller ) { if ( $ this -> settings [ 'isTest' ] ) { return ; } $ this -> user = $ this -> Session -> read ( "{$this->settings['path']}" ) ; $ this -> routes = Permit :: $ routes ; Permit :: $ user = $ this -> user ; $ this -> request = $ controller -> request ; foreach ( ar...
Initializes SanctionComponent for use in the controller
11,355
public function startup ( Controller $ controller ) { if ( $ this -> settings [ 'isTest' ] ) { return ; } foreach ( $ this -> routes as $ route ) { if ( ! $ this -> _parse ( $ route [ 'route' ] ) ) { continue ; } if ( ! $ this -> _execute ( $ route ) ) { break ; } $ this -> Session -> write ( 'Sanction.referer' , $ thi...
Main execution method . Handles redirecting of invalid users and saving of request url as Sanction . referer
11,356
protected function _parse ( $ route ) { if ( is_string ( $ route ) ) { $ this -> _ensureHere ( ) ; $ url = parse_url ( $ route ) ; $ _path = rtrim ( $ url [ 'path' ] , '/' ) ; if ( $ _path . '?' . Hash :: get ( $ url , 'query' ) === $ this -> _hereQuery ) { return true ; } if ( $ _path === $ this -> _here ) { return tr...
Parses a given Permit route to see if it matches the current request
11,357
protected function _execute ( $ route ) { Permit :: $ executed = $ this -> executed = $ route ; if ( empty ( $ route [ 'rules' ] ) ) { return false ; } if ( isset ( $ route [ 'rules' ] [ 'deny' ] ) ) { return $ route [ 'rules' ] [ 'deny' ] == true ; } if ( ! isset ( $ route [ 'rules' ] [ 'auth' ] ) ) { return false ; }...
Determines whether the given user is authorized to perform an action . The result of a failed request depends upon the options for the route
11,358
public function redirect ( Controller $ Controller , $ route ) { if ( $ route [ 'message' ] != null ) { $ message = $ route [ 'message' ] ; $ element = $ route [ 'element' ] ; $ params = $ route [ 'params' ] ; $ this -> Session -> write ( "Message.{$route['key']}" , compact ( 'message' , 'element' , 'params' ) ) ; } $ ...
Performs a redirect based upon a given route
11,359
public function setDefaultArguments ( $ default_settings ) { foreach ( $ default_settings as $ setting => $ val ) { if ( property_exists ( get_class ( ) , $ setting ) ) { $ this -> $ setting = $ val ; } } }
Overrides the default settings for all requests
11,360
public function setAuthentication ( $ uname = '' , $ pass = '' , $ type = 'basic' ) { $ this -> authentication [ 'uname' ] = $ uname ; $ this -> authentication [ 'pass' ] = $ pass ; $ this -> authentication [ 'type' ] = $ type ; }
Sets the authentication type used
11,361
public function runQueued ( InputInterface $ input , OutputInterface $ output ) { $ smileCrons = $ this -> listQueued ( ) ; $ crons = $ this -> getCrons ( ) ; $ cronAlias = array ( ) ; foreach ( $ crons as $ cron ) { $ cronAlias [ $ cron -> getAlias ( ) ] = $ cron ; } if ( $ smileCrons ) { foreach ( $ smileCrons as $ s...
List cron commands identified as queued
11,362
public function listCronsStatus ( ) { $ smileCrons = $ this -> repository -> listCrons ( ) ; $ crons = $ this -> getCrons ( ) ; $ cronAlias = array ( ) ; foreach ( $ crons as $ cron ) { $ cronAlias [ $ cron -> getAlias ( ) ] = $ cron ; } if ( $ smileCrons ) { foreach ( $ smileCrons as $ smileCron ) { if ( isset ( $ cro...
Return cron list and status
11,363
public function analyze_php ( string $ file ) : array { $ res = [ ] ; $ php = file_get_contents ( $ file ) ; if ( $ tmp = \ Gettext \ Translations :: fromPhpCodeString ( $ php , [ 'functions' => [ '_' => 'gettext' ] , 'file' => $ file ] ) ) { foreach ( $ tmp -> getIterator ( ) as $ r => $ tr ) { $ res [ ] = $ tr -> get...
Returns the strings contained in the given php file
11,364
public function analyze_js ( string $ file ) : array { $ res = [ ] ; $ js = file_get_contents ( $ file ) ; if ( $ tmp = \ Gettext \ Translations :: fromJsCodeString ( $ js , [ 'functions' => [ '_' => 'gettext' , 'bbn._' => 'gettext' ] , 'file' => $ file ] ) ) { foreach ( $ tmp -> getIterator ( ) as $ r => $ tr ) { $ re...
Returns the strings contained in the given js file
11,365
public function analyze_file ( string $ file ) : array { $ res = [ ] ; $ ext = bbn \ str :: file_ext ( $ file ) ; if ( \ in_array ( $ ext , self :: $ extensions , true ) && is_file ( $ file ) ) { switch ( $ ext ) { case 'html' : $ res = $ this -> analyze_php ( $ file ) ; break ; case 'php' : $ res = $ this -> analyze_p...
Returns the strings contained in the given file
11,366
public function analyze_folder ( string $ folder = '.' , bool $ deep = false ) : array { $ res = [ ] ; if ( \ is_dir ( $ folder ) ) { $ files = $ deep ? bbn \ file \ dir :: scan ( $ folder , 'file' ) : bbn \ file \ dir :: get_files ( $ folder ) ; foreach ( $ files as $ f ) { $ words = $ this -> analyze_file ( $ f ) ; f...
Returns an array containing the strings found in the given folder
11,367
public function get_id_project ( $ id_option , $ projects ) { foreach ( $ projects as $ i => $ p ) { foreach ( $ projects [ $ i ] [ 'path' ] as $ idx => $ pa ) { if ( $ projects [ $ i ] [ 'path' ] [ $ idx ] [ 'id_option' ] === $ id_option ) { return $ projects [ $ i ] [ 'id' ] ; } } } }
get the id of the project from the id_option of a path
11,368
public function get_primaries_langs ( ) { $ uid_languages = self :: get_appui_option_id ( 'languages' ) ; $ languages = options :: get_instance ( ) -> full_tree ( $ uid_languages ) ; $ primaries = array_values ( array_filter ( $ languages [ 'items' ] , function ( $ v ) { return ! empty ( $ v [ 'primary' ] ) ; } ) ) ; r...
Gets primaries langs from option
11,369
public function get_po_files ( $ id_option ) { if ( ! empty ( $ id_option ) && ( $ o = options :: get_instance ( ) -> option ( $ id_option ) ) && ( $ parent = options :: get_instance ( ) -> parent ( $ id_option ) ) && defined ( $ parent [ 'code' ] ) ) { $ tmp = [ ] ; $ to_explore = constant ( $ parent [ 'code' ] ) . $ ...
Returns an array containing the po files found for the id_option
11,370
public function count_translations_db ( $ id_option ) { $ count = [ ] ; $ po = $ this -> get_po_files ( $ id_option ) ; if ( ! empty ( $ po ) ) { foreach ( $ po as $ lang => $ file ) { $ fileHandler = new \ Sepia \ PoParser \ SourceHandler \ FileSystem ( $ file ) ; $ poParser = new \ Sepia \ PoParser \ Parser ( $ fileH...
Count how many of the strings contained in po files are already in database
11,371
function write ( $ text , $ format = 'r' ) { $ fw = Base :: instance ( ) ; $ fw -> write ( $ this -> file , date ( $ format ) . ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ? ( ' [' . $ _SERVER [ 'REMOTE_ADDR' ] . ']' ) : '' ) . ' ' . trim ( $ text ) . PHP_EOL , TRUE ) ; }
Write specified text to log file
11,372
public static function remove ( $ itemName ) { $ returnVar = true ; if ( ! is_dir ( $ itemName ) && file_exists ( $ itemName ) ) { unlink ( $ itemName ) ; return true ; } if ( ! file_exists ( $ itemName ) ) { return true ; } $ dir = dir ( $ itemName ) ; $ item = $ dir -> read ( ) ; while ( $ item !== false ) { if ( $ i...
Recursively removes a directory and its contents or a file .
11,373
protected function createOn ( $ meta , $ fromIndex , $ relatedMeta , $ toIndex ) { if ( ! isset ( $ meta -> indexes [ $ fromIndex ] ) ) { throw new Exception ( "Index $fromIndex does not exist on {$meta->id}" ) ; } if ( ! isset ( $ relatedMeta -> indexes [ $ toIndex ] ) ) { throw new Exception ( "Index $toIndex does no...
to be interfered with yet .
11,374
public function store ( $ id , $ data , $ attributes = array ( ) ) { $ filename = $ this -> properties [ 'location' ] . $ this -> generateIdentifier ( $ id , $ attributes ) ; if ( file_exists ( $ filename ) ) { if ( unlink ( $ filename ) === false ) { throw new ezcBaseFilePermissionException ( $ filename , ezcBaseFileE...
Store data to the cache storage . This method stores the given cache data into the cache assigning the ID given to it .
11,375
protected function storeRawData ( $ filename , $ data ) { if ( file_put_contents ( $ filename , $ data ) !== strlen ( $ data ) ) { throw new ezcBaseFileIoException ( $ filename , ezcBaseFileException :: WRITE , 'Could not write data to cache file.' ) ; } }
Actually stores the given data .
11,376
public function delete ( $ id = null , $ attributes = array ( ) , $ search = false ) { $ filename = $ this -> properties [ 'location' ] . $ this -> generateIdentifier ( $ id , $ attributes ) ; $ filesToDelete = array ( ) ; if ( file_exists ( $ filename ) ) { $ filesToDelete [ ] = $ filename ; } else if ( $ search === t...
Delete data from the cache . Purges the cached data for a given ID and or attributes . Using an ID purges only the cache data for just this ID .
11,377
public function purge ( $ limit = null ) { $ purgeCount = 0 ; return $ this -> purgeRecursive ( $ this -> properties [ 'location' ] , $ limit , $ purgeCount ) ; }
Purges the given number of cache items .
11,378
private function purgeRecursive ( $ dir , $ limit , & $ purgeCount ) { $ purgedIds = array ( ) ; if ( ( $ files = glob ( "{$dir}*{$this->properties['options']->extension}" ) ) === false ) { throw new ezcBaseFileNotFoundException ( $ dir , 'cache location' , 'Produced an error while globbing for files.' ) ; } foreach ( ...
Recursively purge cache items .
11,379
public function reset ( ) { $ files = glob ( "{$this->properties['location']}*" ) ; foreach ( $ files as $ file ) { if ( is_dir ( $ file ) ) { ezcBaseFile :: removeRecursive ( $ file ) ; } else { if ( @ unlink ( $ file ) === false ) { throw new ezcBaseFilePermissionException ( $ file , ezcBaseFileException :: REMOVE , ...
Resets the whole storage .
11,380
protected function search ( $ id = null , $ attributes = array ( ) ) { $ globArr = explode ( "-" , $ this -> generateIdentifier ( $ id , $ attributes ) , 2 ) ; if ( sizeof ( $ globArr ) > 1 ) { $ glob = $ globArr [ 0 ] . "-" . strtr ( $ globArr [ 1 ] , array ( '-' => '*' , '.' => '*' ) ) ; } else { $ glob = strtr ( $ g...
Search the storage for data .
11,381
protected function searchRecursive ( $ pattern , $ directory ) { $ itemArr = glob ( $ directory . $ pattern ) ; $ dirArr = glob ( $ directory . "*" , GLOB_ONLYDIR ) ; foreach ( $ dirArr as $ dirEntry ) { $ result = $ this -> searchRecursive ( $ pattern , "$dirEntry/" ) ; $ itemArr = array_merge ( $ itemArr , $ result )...
Search the storage for data recursively .
11,382
public function generateIdentifier ( $ id , $ attributes = null ) { $ filename = ( string ) $ id ; $ illegalFileNameChars = array ( ' ' => '_' , '/' => DIRECTORY_SEPARATOR , '\\' => DIRECTORY_SEPARATOR , ) ; $ filename = strtr ( $ filename , $ illegalFileNameChars ) ; $ illegalChars = array ( '-' => '#' , ' ' => '%' , ...
Generate the storage internal identifier from ID and attributes .
11,383
private function extractIdentifier ( $ filename ) { $ regex = '( (?:' . preg_quote ( $ this -> properties [ 'location' ] ) . ') (?P<id>.*) (?P<attr>(?:-[^-=]+=[^-]+)*) -? # This is added if no attributes are supplied. For whatever reason... (?P<ext>' . preg_quote (...
Extracts ID attributes and the file extension from a filename .
11,384
public static function initialize ( ) { if ( defined ( 'DACHI_KERNEL' ) ) return false ; define ( 'DACHI_KERNEL' , true ) ; require_once ( 'Kernel.functions.php' ) ; getExecutionTime ( ) ; date_default_timezone_set ( Configuration :: get ( 'dachi.timezone' ) ) ; error_reporting ( - 1 ) ; define ( 'WORKING_DIRECTORY' , ...
Initialize the Dachi kernel .
11,385
public static function getEnvironment ( $ forceCheck = false ) { if ( self :: $ environment && ! $ forceCheck ) return self :: $ environment ; self :: $ environment = "local" ; if ( file_exists ( "dachi_environment" ) ) self :: $ environment = trim ( file_get_contents ( "dachi_environment" ) ) ; return self :: $ enviro...
Get the current environment we are executing in .
11,386
public static function getGitHash ( $ forceCheck = false ) { if ( self :: $ git_hash && ! $ forceCheck ) return self :: $ git_hash ; self :: $ git_hash = "ffffff" ; if ( file_exists ( "dachi_git_hash" ) ) self :: $ git_hash = trim ( file_get_contents ( "dachi_git_hash" ) ) ; return self :: $ git_hash ; }
Get the current short git hash for the revision of code we are executing .
11,387
public static function getVersion ( $ fullVersion = false ) { return ( $ fullVersion ? ( "v" . self :: $ version . "." . self :: $ version_patch ) : self :: $ version ) ; }
Get the Dachi version .
11,388
protected function convertLogLevel ( $ level ) { $ map = [ Propel :: LOG_EMERG => LogLevel :: EMERGENCY , Propel :: LOG_ALERT => LogLevel :: ALERT , Propel :: LOG_CRIT => LogLevel :: CRITICAL , Propel :: LOG_ERR => LogLevel :: ERROR , Propel :: LOG_WARNING => LogLevel :: WARNING , Propel :: LOG_NOTICE => LogLevel :: NO...
Converts Propel log levels to PSR log levels
11,389
protected function parseAndLogSqlQuery ( $ message ) { $ parts = explode ( '|' , $ message , 4 ) ; $ sql = trim ( $ parts [ 3 ] ) ; $ duration = 0 ; if ( preg_match ( '/([0-9]+\.[0-9]+)/' , $ parts [ 1 ] , $ matches ) ) { $ duration = ( float ) $ matches [ 1 ] ; } $ memory = 0 ; if ( preg_match ( '/([0-9]+\.[0-9]+) ([A...
Parse a log line to extract query information
11,390
public function load ( $ templatePath , $ userConfigurationPath , $ class = 'phpDocumentor\Configuration' ) { $ userConfigFilePath = $ this -> fetchUserConfigFileFromCommandLineOptions ( ) ; if ( $ this -> isValidFile ( $ userConfigFilePath ) ) { chdir ( dirname ( $ userConfigFilePath ) ) ; } else { $ userConfigFilePat...
Loads the configuration from the provided paths and returns a populated configuration object .
11,391
private function createConfigurationObject ( $ templatePath , $ defaultUserConfigPath , $ customUserConfigPath , $ class ) { $ config = $ this -> serializer -> deserialize ( file_get_contents ( $ templatePath ) , $ class , 'xml' ) ; $ customUserConfigPath = $ customUserConfigPath ? : $ defaultUserConfigPath ; if ( $ cu...
Combines the given configuration files and serializes a new Configuration object from them .
11,392
public function render ( \ WP_Post $ post = null ) { $ required = $ this -> get_required ( $ post ) ; $ label = esc_html ( $ this -> label ) ; $ desc_str = $ this -> description ; $ desc = ! empty ( $ desc_str ) ? sprintf ( '<p class="description">%s</p>' , $ this -> description ) : '' ; $ input = $ this -> get_field (...
Render input field
11,393
public function update ( $ value , \ WP_Post $ post = null ) { if ( $ this -> validate ( $ value ) ) { $ this -> save ( $ value , $ post ) ; } }
Save data as value
11,394
public function setCustomerData ( $ nombre_cliente = " " , $ documento = " " , $ respo_iva = 'C' , $ tipo_documento = " " , $ domicilio = '-' ) { $ nombre_cliente = substr ( $ nombre_cliente , 0 , 45 ) ; $ respo_iva = strtoupper ( $ respo_iva ) ; $ tipo_documento = strtoupper ( $ tipo_documento ) ; if ( $ respo_iva == ...
Setea los datos del Cliente por lo general se usa para hacer factura A
11,395
public function getSingularForm ( $ root ) { $ singularForm = $ root ; if ( ! is_string ( $ root ) ) { throw new \ InvalidArgumentException ( 'The pluralizer expects a string.' ) ; } if ( ! in_array ( strtolower ( $ root ) , $ this -> uncountable ) ) { if ( null !== $ replacement = $ this -> checkIrregularForm ( $ root...
Generate a singular name based on the passed in root .
11,396
protected function getDeprecatedCounter ( ProjectDescriptor $ project ) { $ deprecatedCounter = 0 ; foreach ( $ project -> getIndexes ( ) -> get ( 'elements' ) as $ element ) { if ( $ element -> isDeprecated ( ) ) { $ deprecatedCounter += 1 ; } } return $ deprecatedCounter ; }
Get number of deprecated elements .
11,397
public function allowPhpFunction ( $ func ) { if ( is_array ( $ func ) ) foreach ( $ func as $ fname ) $ this -> allowedPhpFunctions [ strtolower ( $ fname ) ] = true ; else $ this -> allowedPhpFunctions [ strtolower ( $ func ) ] = true ; }
adds a php function to the allowed list
11,398
public function allowDirectory ( $ path ) { if ( is_array ( $ path ) ) foreach ( $ path as $ dir ) $ this -> allowedDirectories [ realpath ( $ dir ) ] = true ; else $ this -> allowedDirectories [ realpath ( $ path ) ] = true ; }
adds a directory to the safelist for includes and other file - access plugins
11,399
public function disallowDirectory ( $ path ) { if ( is_array ( $ path ) ) foreach ( $ path as $ dir ) unset ( $ this -> allowedDirectories [ realpath ( $ dir ) ] ) ; else unset ( $ this -> allowedDirectories [ realpath ( $ path ) ] ) ; }
removes a directory from the safelist