idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
8,900
|
protected function replaceStringVars ( $ string , $ first , $ curBlock = '' ) { $ pos = 0 ; if ( $ this -> debug ) echo 'STRING VAR REPLACEMENT : ' . $ string . '<br>' ; while ( ( $ pos = strpos ( $ string , '$' , $ pos ) ) !== false ) { $ prev = substr ( $ string , $ pos - 1 , 1 ) ; if ( $ prev === '\\' ) { $ pos ++ ; continue ; } $ var = $ this -> parse ( $ string , $ pos , null , false , ( $ curBlock === 'modifier' ? 'modifier' : ( $ prev === '`' ? 'delimited_string' : 'string' ) ) ) ; $ len = $ var [ 0 ] ; $ var = $ this -> parse ( str_replace ( '\\' . $ first , $ first , $ string ) , $ pos , null , false , ( $ curBlock === 'modifier' ? 'modifier' : ( $ prev === '`' ? 'delimited_string' : 'string' ) ) ) ; if ( $ prev === '`' && substr ( $ string , $ pos + $ len , 1 ) === '`' ) { $ string = substr_replace ( $ string , $ first . '.' . $ var [ 1 ] . '.' . $ first , $ pos - 1 , $ len + 2 ) ; } else { $ string = substr_replace ( $ string , $ first . '.' . $ var [ 1 ] . '.' . $ first , $ pos , $ len ) ; } $ pos += strlen ( $ var [ 1 ] ) + 2 ; if ( $ this -> debug ) echo 'STRING VAR REPLACEMENT DONE : ' . $ string . '<br>' ; } $ string = preg_replace_callback ( '#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i' , array ( $ this , 'replaceModifiers' ) , $ string ) ; if ( $ first === "'" ) { $ string = str_replace ( '\\$' , '$' , $ string ) ; } return $ string ; }
|
replaces variables within a parsed string
|
8,901
|
public function generateHeaders ( ) { if ( $ this -> from !== null ) { $ this -> setHeader ( "From" , ezcMailTools :: composeEmailAddress ( $ this -> from ) ) ; } if ( $ this -> to !== null ) { $ this -> setHeader ( "To" , ezcMailTools :: composeEmailAddresses ( $ this -> to ) ) ; } if ( count ( $ this -> cc ) ) { $ this -> setHeader ( "Cc" , ezcMailTools :: composeEmailAddresses ( $ this -> cc ) ) ; } if ( count ( $ this -> bcc ) && $ this -> options -> stripBccHeader === false ) { $ this -> setHeader ( "Bcc" , ezcMailTools :: composeEmailAddresses ( $ this -> bcc ) ) ; } $ this -> setHeader ( 'Subject' , $ this -> subject , $ this -> subjectCharset ) ; $ this -> setHeader ( 'MIME-Version' , '1.0' ) ; $ this -> setHeader ( 'User-Agent' , 'eZ Components' ) ; $ this -> setHeader ( 'Date' , date ( 'r' ) ) ; $ idhost = $ this -> from != null && $ this -> from -> email != '' ? $ this -> from -> email : 'localhost' ; if ( is_null ( $ this -> messageId ) ) { $ this -> setHeader ( 'Message-Id' , '<' . ezcMailTools :: generateMessageId ( $ idhost ) . '>' ) ; } else { $ this -> setHeader ( 'Message-Id' , $ this -> messageID ) ; } if ( is_subclass_of ( $ this -> body , "ezcMailPart" ) ) { return parent :: generateHeaders ( ) . $ this -> body -> generateHeaders ( ) ; } return parent :: generateHeaders ( ) ; }
|
Returns the generated headers for the mail .
|
8,902
|
public function fetchParts ( $ filter = null , $ includeDigests = false ) { $ context = new ezcMailPartWalkContext ( array ( __CLASS__ , 'collectPart' ) ) ; $ context -> includeDigests = $ includeDigests ; $ context -> filter = $ filter ; $ context -> level = 0 ; $ this -> walkParts ( $ context , $ this ) ; return $ context -> getParts ( ) ; }
|
Returns an array of mail parts from the current mail .
|
8,903
|
public function walkParts ( ezcMailPartWalkContext $ context , ezcMailPart $ mail ) { $ className = get_class ( $ mail ) ; $ context -> level ++ ; switch ( $ className ) { case 'ezcMail' : case 'ezcMailComposer' : if ( $ mail -> body !== null ) { $ this -> walkParts ( $ context , $ mail -> body ) ; } break ; case 'ezcMailMultipartMixed' : case 'ezcMailMultipartAlternative' : case 'ezcMailMultipartDigest' : case 'ezcMailMultipartReport' : foreach ( $ mail -> getParts ( ) as $ part ) { $ this -> walkParts ( $ context , $ part ) ; } break ; case 'ezcMailMultipartRelated' : $ this -> walkParts ( $ context , $ mail -> getMainPart ( ) ) ; foreach ( $ mail -> getRelatedParts ( ) as $ part ) { $ this -> walkParts ( $ context , $ part ) ; } break ; case 'ezcMailRfc822Digest' : if ( $ context -> includeDigests ) { $ this -> walkParts ( $ context , $ mail -> mail ) ; } elseif ( empty ( $ context -> filter ) || in_array ( $ className , $ context -> filter ) ) { call_user_func ( $ context -> callbackFunction , $ context , $ mail ) ; } break ; case 'ezcMailText' : case 'ezcMailFile' : case 'ezcMailDeliveryStatus' : if ( empty ( $ context -> filter ) || in_array ( $ className , $ context -> filter ) ) { call_user_func ( $ context -> callbackFunction , $ context , $ mail ) ; } break ; default : if ( in_array ( 'ezcMail' , class_parents ( $ className ) ) ) { if ( $ mail -> body !== null ) { $ this -> walkParts ( $ context , $ mail -> body ) ; } } if ( in_array ( 'ezcMailFile' , class_parents ( $ className ) ) ) { if ( empty ( $ context -> filter ) || in_array ( $ className , $ context -> filter ) ) { call_user_func ( $ context -> callbackFunction , $ context , $ mail ) ; } } } $ context -> level -- ; }
|
Walks recursively through the mail parts in the specified mail object .
|
8,904
|
public function parseBody ( $ origLine ) { if ( $ this -> parserState == self :: PARSE_STATE_POST_LAST ) { return ; } $ line = rtrim ( $ origLine , "\r\n" ) ; $ newPart = false ; $ endOfMultipart = false ; if ( strlen ( $ line ) > 0 && $ line [ 0 ] == "-" ) { if ( strcmp ( trim ( $ line ) , '--' . $ this -> boundary ) === 0 ) { $ newPart = true ; } else if ( strcmp ( trim ( $ line ) , '--' . $ this -> boundary . '--' ) === 0 ) { $ endOfMultipart = true ; } } if ( $ newPart || $ endOfMultipart ) { if ( $ this -> parserState != self :: PARSE_STATE_BODY ) { $ this -> currentPartParser = null ; $ this -> currentPartHeaders = new ezcMailHeadersHolder ( ) ; $ this -> parserState = $ newPart ? self :: PARSE_STATE_HEADERS : self :: PARSE_STATE_POST_LAST ; } else { if ( $ this -> currentPartParser !== null ) { $ part = $ this -> currentPartParser -> finish ( ) ; if ( $ part !== null ) { $ this -> partDone ( $ part ) ; } } $ this -> currentPartParser = null ; $ this -> parserState = self :: PARSE_STATE_POST_LAST ; if ( $ newPart ) { $ this -> parserState = self :: PARSE_STATE_HEADERS ; $ this -> currentPartHeaders = new ezcMailHeadersHolder ( ) ; } } } else { if ( $ this -> parserState == self :: PARSE_STATE_HEADERS && $ line == '' ) { $ this -> currentPartParser = self :: createPartParserForHeaders ( $ this -> currentPartHeaders ) ; $ this -> parserState = self :: PARSE_STATE_BODY ; } else if ( $ this -> parserState == self :: PARSE_STATE_HEADERS ) { $ this -> parseHeader ( $ line , $ this -> currentPartHeaders ) ; } else if ( $ this -> parserState == self :: PARSE_STATE_BODY ) { if ( $ this -> currentPartParser ) { $ this -> currentPartParser -> parseBody ( $ origLine ) ; } } } }
|
Parses a multipart body .
|
8,905
|
public function finish ( ) { if ( $ this -> parserState != self :: PARSE_STATE_POST_LAST ) { if ( $ this -> currentPartParser !== null ) { $ part = $ this -> currentPartParser -> finish ( ) ; $ this -> partDone ( $ part ) ; $ this -> currentPartParser = null ; } } $ multipart = $ this -> finishMultipart ( ) ; ezcMailPartParser :: parsePartHeaders ( $ this -> headers , $ multipart ) ; $ multipart -> boundary = $ this -> boundary ; return $ multipart ; }
|
Completes the parsing of the multipart and returns the corresponding part .
|
8,906
|
public function find ( string $ operation , string $ locale ) { $ model = $ this -> notifications -> first ( function ( $ value ) use ( $ operation , $ locale ) { return $ value -> code === $ locale && ( $ value -> title === $ operation || $ value -> name === $ operation ) ; } ) ; return $ model ? $ model -> content : false ; }
|
Finds notification content by title and locale .
|
8,907
|
public function connect ( ) { if ( ! is_callable ( 'pg_connect' ) ) { throw new Exceptions \ UnableToConnectException ( 'PostgreSQL PHP extension is not available. It probably has not ' . 'been installed. Please install and configure it in order to use ' . 'PostgreSQL.' ) ; } $ connectionType = $ this -> config [ 'PostgreSQL' ] [ 'connection_type' ] ; $ host = $ this -> config [ 'PostgreSQL' ] [ 'host' ] ; $ port = $ this -> config [ 'PostgreSQL' ] [ 'port' ] ; $ user = $ this -> config [ 'PostgreSQL' ] [ 'user' ] ; $ password = $ this -> config [ 'PostgreSQL' ] [ 'password' ] ; $ database = $ this -> config [ 'PostgreSQL' ] [ 'database' ] ; if ( ! $ this -> connected ) { if ( $ connectionType === 'host' ) { $ connectString = 'host=\'' . addslashes ( $ host ) . '\' port=\'' . addslashes ( $ port ) . '\' dbname=\'' . addslashes ( $ database ) . '\' user=\'' . addslashes ( $ user ) . '\' password=\'' . addslashes ( $ password ) . '\' connect_timeout=5' ; } else { $ connectString = 'dbname=\'' . addslashes ( $ database ) . '\' user=\'' . addslashes ( $ user ) . '\' password=\'' . addslashes ( $ password ) . '\' connect_timeout=5' ; } if ( $ this -> config [ 'PostgreSQL' ] [ 'allow_persistent' ] ) { $ this -> link = pg_connect ( $ connectString . ' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\'' ) ; } else { $ this -> link = pg_connect ( $ connectString . ' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\'' , PGSQL_CONNECT_FORCE_NEW ) ; } if ( $ this -> link ) { $ this -> connected = true ; } else { $ this -> connected = false ; if ( $ host === 'localhost' && $ user === 'nymph' && $ password === 'password' && $ database === 'nymph' && $ connectionType === 'host' ) { throw new Exceptions \ NotConfiguredException ( ) ; } else { throw new Exceptions \ UnableToConnectException ( 'Could not connect: ' . pg_last_error ( ) ) ; } } } return $ this -> connected ; }
|
Connect to the PostgreSQL database .
|
8,908
|
public function disconnect ( ) { if ( $ this -> connected ) { if ( is_resource ( $ this -> link ) ) { pg_close ( $ this -> link ) ; } $ this -> connected = false ; } return $ this -> connected ; }
|
Disconnect from the PostgreSQL database .
|
8,909
|
protected function getAsset ( $ assetData ) { try { $ Comet = \ CometPHP \ Comet :: getInstance ( ) ; } catch ( \ CometPHP \ Exceptions \ CometNotBooted $ e ) { return null ; } if ( ! is_array ( $ assetData ) ) { $ assetData = [ $ assetData ] ; } $ asset = $ Comet [ 'template' ] -> getFunction ( 'asset' ) -> call ( $ this -> template , $ assetData ) ; return $ asset ; }
|
base function to return assets
|
8,910
|
function array_listado ( $ categoria_id = 1 ) { $ array_categoria = array ( ) ; $ array_final = array ( ) ; $ this -> recursive = 1 ; $ this -> id = $ categoria_id ; $ array_categoria = $ this -> read ( ) ; if ( empty ( $ array_categoria ) ) { return array ( ) ; } $ array_final = $ array_categoria [ 'Categoria' ] ; $ array_final [ 'Producto' ] = $ array_categoria [ 'Producto' ] ; $ array_final [ 'Sabor' ] = $ array_categoria [ 'Sabor' ] ; $ resultado = $ this -> children ( $ categoria_id , 1 ) ; foreach ( $ resultado as $ r ) : $ hijos = $ this -> array_listado ( $ r [ 'Categoria' ] [ 'id' ] ) ; if ( count ( $ hijos ) > 0 ) { $ array_final [ 'Hijos' ] [ ] = $ hijos ; } endforeach ; if ( $ array_final == false ) { $ array_final = array ( ) ; } return $ array_final ; }
|
Me devuelve un array lindo con sub arrays para cada subarbol
|
8,911
|
protected function initMessages ( ) { if ( ! is_string ( $ this -> registerSuccessMessage ) ) { $ this -> registerSuccessMessage = Yii :: t ( 'user' , 'User Registered.' ) ; } if ( ! is_string ( $ this -> registerFailedMessage ) ) { $ this -> registerFailedMessage = Yii :: t ( 'user' , 'Register Failed.' ) ; } if ( ! is_string ( $ this -> deregisterSuccessMessage ) ) { $ this -> deregisterSuccessMessage = Yii :: t ( 'user' , 'User Deregistered.' ) ; } if ( ! is_string ( $ this -> deregisterFailedMessage ) ) { $ this -> deregisterFailedMessage = Yii :: t ( 'user' , 'Failed to Deregister User.' ) ; } if ( ! is_string ( $ this -> updateSuccessMessage ) ) { $ this -> updateSuccessMessage = Yii :: t ( 'user' , 'Updated.' ) ; } if ( ! is_string ( $ this -> updateFailedMessage ) ) { $ this -> updateFailedMessage = Yii :: t ( 'user' , 'Failed to Update.' ) ; } }
|
Initialize messages .
|
8,912
|
public function actionDeregister ( $ id ) { $ id = ( int ) $ id ; if ( Yii :: $ app -> user -> identity -> getID ( ) == $ id ) { throw new ForbiddenHttpException ( Yii :: t ( 'user' , 'You cannot deregister yourself.' ) ) ; } $ user = $ this -> getUser ( $ id ) ; try { $ result = $ user -> deregister ( ) ; if ( $ result instanceof \ Exception ) { throw $ result ; } } catch ( \ Exception $ ex ) { throw new ServerErrorHttpException ( $ ex -> getMessage ( ) ) ; } if ( $ result !== true ) { throw new ServerErrorHttpException ( Yii :: t ( 'user' , 'Failed to deregister user.' ) ) ; } Yii :: $ app -> session -> setFlash ( Module :: SESSION_KEY_RESULT , Module :: RESULT_SUCCESS ) ; Yii :: $ app -> session -> setFlash ( Module :: SESSION_KEY_MESSAGE , '(' . $ user -> getID ( ) . ') ' . $ this -> deregisterSuccessMessage ) ; return $ this -> redirect ( [ 'index' ] ) ; }
|
Deregister User .
|
8,913
|
public function swrite ( $ severity , $ message = '' ) { if ( $ severity <= LOG_ERR ) { fwrite ( STDERR , $ message . "\n" ) ; } else { fwrite ( STDOUT , $ message . "\n" ) ; } }
|
If severity is equal or lower than LOG_ERR then the message is written to STDERR otherwise STDOUT is used .
|
8,914
|
public function findBestCandidate ( $ packageName , $ targetPackageVersion = null ) { $ constraint = $ targetPackageVersion ? $ this -> getParser ( ) -> parseConstraints ( $ targetPackageVersion ) : null ; $ candidates = $ this -> pool -> whatProvides ( strtolower ( $ packageName ) , $ constraint , true ) ; if ( ! $ candidates ) { return false ; } $ package = reset ( $ candidates ) ; foreach ( $ candidates as $ candidate ) { if ( version_compare ( $ package -> getVersion ( ) , $ candidate -> getVersion ( ) , '<' ) ) { $ package = $ candidate ; } } return $ package ; }
|
Given a package name and optional version returns the latest PackageInterface that matches .
|
8,915
|
public function getActualAttributeName ( Entity $ entity , $ name , $ hint = '' , $ force = false ) { if ( $ entity -> hasAttributeByName ( $ name ) || $ force ) { if ( ! $ entity -> hasAttributeByName ( $ name . $ hint ) ) { return [ $ name , $ hint ] ; } $ append = 1 ; while ( $ entity -> hasAttributeByName ( $ name . $ append . $ hint ) ) { $ append ++ ; } return [ $ name . $ append , $ hint ] ; } return [ $ name , '' ] ; }
|
Sometimes the automatic name cannot be used because the entity already has an attribute with that name or because is linked many times . This method gives an actual final name that will be unique .
|
8,916
|
public function getModelFiles ( $ path ) { $ fileCollection = new FileCollection ( ) ; $ namespacePath = str_replace ( '\\' , '/' , $ path . $ this -> getNamespace ( ) . '/' ) ; $ targetPath = $ namespacePath ; foreach ( $ this -> getEntities ( ) as $ entity ) { if ( $ entity -> getRenderizable ( ) ) { if ( $ this -> getLanguage ( ) === 'php' ) { if ( $ entity -> getNamespace ( ) !== '' ) { $ targetPath = $ path . str_replace ( '\\' , '/' , $ entity -> getNamespace ( ) ) . '/' ; } } elseif ( $ this -> getLanguage ( ) === 'java' ) { if ( $ entity -> getModule ( ) !== '' ) { $ targetPath = $ path . '/' . $ this -> getAutocodeConfiguration ( 'package' ) . '/' . str_replace ( '.' , '/' , $ entity -> getModule ( ) ) . '/' ; } } foreach ( $ this -> getAutocodeEntityTemplates ( ) as $ template ) { $ fileCollection -> add ( $ this -> renderEntityTemplate ( $ template , $ entity , $ targetPath ) ) ; } } } if ( $ this -> getLanguage ( ) === 'php' ) { foreach ( $ this -> modules as $ module ) { $ targetPath = $ path . str_replace ( '\\' , '/' , $ this -> moduleNamespaces [ $ module ] ) . '/' ; foreach ( $ this -> getAutocodeModuleTemplates ( ) as $ template ) { $ fileCollection -> add ( $ this -> renderModuleTemplate ( $ this , $ template , $ module , $ targetPath ) ) ; } } } return $ fileCollection ; }
|
Returns a collection of files
|
8,917
|
public static function singlelise ( $ string ) { $ rules = [ 'ies' => 'y' , 'ves' => 'f' , 's' => '' , ] ; foreach ( $ rules as $ ending => $ replacement ) { if ( $ ending === substr ( $ string , - strlen ( $ ending ) ) ) { return substr ( $ string , 0 , - strlen ( $ ending ) ) . $ replacement ; } } return $ string . 'Single' ; }
|
Get the plural name from a singular
|
8,918
|
protected function getConfigurationsFromFile ( $ fileName , ContainerBuilder $ container , $ merge = true ) { $ configs = [ ] ; foreach ( $ this -> getFinder ( $ fileName , $ container ) as $ file ) { $ currentConfiguration = Yaml :: parse ( $ file -> getContents ( ) ) ; if ( empty ( $ currentConfiguration ) ) { continue ; } if ( $ merge ) { $ configs = array_merge_recursive ( $ configs , $ currentConfiguration ) ; } else { $ configs [ ] = reset ( $ currentConfiguration ) ; } } return $ configs ; }
|
Returns all configurations registered in the specific yaml file .
|
8,919
|
private function getFinder ( $ fileName , ContainerBuilder $ container ) { $ finder = ( new Finder ( ) ) -> files ( ) -> name ( $ fileName ) ; $ resourcesDir = 'Resources' . DIRECTORY_SEPARATOR . 'config' ; if ( self :: $ directoriesCache ) { return $ finder -> in ( self :: $ directoriesCache ) ; } foreach ( $ container -> getParameter ( 'kernel.bundles' ) as $ name => $ pathToBundle ) { try { $ reflector = new \ ReflectionClass ( $ pathToBundle ) ; } catch ( \ ReflectionException $ e ) { continue ; } $ fileName = $ reflector -> getFileName ( ) ; $ fileName = str_replace ( $ name . '.php' , $ resourcesDir , $ fileName ) ; try { $ finder -> in ( $ fileName ) ; self :: $ directoriesCache [ $ name ] = $ fileName ; } catch ( \ InvalidArgumentException $ e ) { unset ( self :: $ directoriesCache [ $ name ] ) ; } } return $ finder ; }
|
Build and return finder
|
8,920
|
protected function getPrefixedTableNames ( $ tableNames ) { if ( $ this -> db -> options && $ this -> db -> options -> tableNamePrefix ) { switch ( true ) { case is_string ( $ tableNames ) : $ tableNames = $ this -> db -> options -> tableNamePrefix . $ tableNames ; break ; case is_array ( $ tableNames ) : foreach ( $ tableNames as $ key => $ table ) $ tableNames [ $ key ] = $ this -> db -> options -> tableNamePrefix . $ table ; break ; } } return $ tableNames ; }
|
Returns prefixed table names if tableNamePrefix option not empty otherwise return untouched names
|
8,921
|
public function prepare ( ) { $ stmt = $ this -> db -> prepare ( $ this -> getQuery ( ) ) ; $ this -> doBind ( $ stmt ) ; return $ stmt ; }
|
Returns a prepared statement from this query which can be used for execution .
|
8,922
|
public function fix ( $ packageName , LinkConstraintInterface $ constraint = null ) { $ this -> addJob ( $ packageName , 'install' , $ constraint , true ) ; }
|
Mark an existing package as being installed and having to remain installed
|
8,923
|
protected function ajax_url ( ) { $ url = admin_url ( 'admin-ajax.php' ) ; if ( is_ssl ( ) ) { $ url = str_replace ( 'http://' , 'https://' , $ url ) ; } else { $ url = str_replace ( 'https://' , 'http://' , $ url ) ; } return $ url ; }
|
Returns Ajax endpoint
|
8,924
|
public function register ( ) { if ( $ this -> validate ( ) ) { $ class = $ this -> userClass ; $ user = new $ class ( [ 'password' => $ this -> password ] ) ; $ profile = $ user -> createProfile ( [ 'nickname' => $ this -> nickname , 'first_name' => $ this -> first_name , 'last_name' => $ this -> last_name , 'gender' => $ this -> gender ] ) ; $ models [ ] = $ profile ; if ( is_string ( $ this -> username ) ) { $ username = $ user -> createUsername ( $ this -> username ) ; $ models [ ] = $ username ; } $ result = $ user -> register ( $ models ) ; if ( $ result == true ) { $ this -> model = $ user ; } return $ result ; } return false ; }
|
Register user with current model .
|
8,925
|
protected function getThemesHierarchy ( $ themeName ) { $ hierarchy = [ ] ; while ( null !== $ themeName ) { $ theme = $ this -> themeManager -> getTheme ( $ themeName ) ; $ hierarchy [ ] = $ theme ; $ themeName = $ theme -> getParentTheme ( ) ; } return array_reverse ( $ hierarchy ) ; }
|
Returns theme inheritance hierarchy with root theme as first item
|
8,926
|
public function send ( $ command ) { $ string = $ command ; $ timer = microtime ( true ) ; while ( $ string ) { $ bytes = fwrite ( $ this -> socket , $ string ) ; if ( $ bytes === false ) { $ this -> close ( ) ; throw new HSException ( 'Cannot write to socket' ) ; } if ( $ bytes === 0 ) { return null ; } $ string = substr ( $ string , $ bytes ) ; } $ this -> logs [ ] = [ 'type' => 'sended' , 'time' => microtime ( true ) - $ timer , 'command' => $ command ] ; return $ this -> receive ( ) ; }
|
Send string command to server
|
8,927
|
public static function encode ( $ string ) { return is_null ( $ string ) ? self :: NULL : strtr ( $ string , self :: $ encodeMap ) ; }
|
Encode string for sending to server
|
8,928
|
public static function decode ( $ string ) { return ( $ string === self :: NULL ) ? null : strtr ( $ string , self :: $ decodeMap ) ; }
|
Decode string from server
|
8,929
|
public function open ( ) { $ this -> socket = stream_socket_client ( 'tcp://' . $ this -> address , $ errc , $ errs , STREAM_CLIENT_CONNECT ) ; if ( ! $ this -> socket ) { throw new HSException ( 'Connection to ' . $ this -> address . ' failed' ) ; } }
|
Open Handler Socket
|
8,930
|
private function receive ( ) { $ timer = microtime ( true ) ; $ str = fgets ( $ this -> socket ) ; if ( $ str === false ) { $ this -> close ( ) ; throw new HSException ( 'Cannot read from socket' ) ; } $ this -> logs [ ] = [ 'type' => 'receive' , 'time' => microtime ( true ) - $ timer , 'command' => $ str ] ; return substr ( $ str , 0 , - 1 ) ; }
|
Receive one string from server . String haven t trailing \ n
|
8,931
|
public function compilePath ( $ path = false ) { $ currentBasePath = $ this -> getManager ( ) -> getCurrent ( ) -> getPath ( ) ; $ path = str_replace ( $ currentBasePath , $ this -> getPath ( ) , $ path ) ; return $ path ; }
|
Compile path for this section from a given path of current section
|
8,932
|
public static function check ( $ permission ) { if ( static :: isAdministrator ( ) ) { return true ; } if ( is_array ( $ permission ) ) { collect ( $ permission ) -> each ( function ( $ permission ) { call_user_func ( [ Permission :: class , 'check' ] , $ permission ) ; } ) ; return ; } if ( Auth :: guard ( 'merchant' ) -> user ( ) -> cannot ( $ permission ) ) { static :: error ( ) ; } }
|
Check permission .
|
8,933
|
protected function fetchData ( $ identifier , $ object = false ) { $ data = $ this -> backend -> fetch ( $ identifier ) ; if ( is_object ( $ data ) && $ object === false ) { return $ data -> data ; } if ( is_object ( $ data ) && $ object !== false ) { return $ data ; } else { return false ; } }
|
Fetches data from the cache .
|
8,934
|
protected function prepareData ( $ data ) { if ( is_resource ( $ data ) ) { throw new ezcCacheInvalidDataException ( gettype ( $ data ) , array ( 'simple' , 'array' , 'object' ) ) ; } return new ezcCacheStorageMemoryDataStruct ( $ data , $ this -> properties [ 'location' ] ) ; }
|
Wraps the data in an ezcCacheStorageMemoryDataStruct structure in order to store it .
|
8,935
|
protected function findDisplayViewFile ( ) { foreach ( $ this -> getDirectoryIterator ( ) as $ file ) { $ name = $ file -> getFilename ( ) ; if ( $ this -> isDisplayViewFile ( $ name ) ) { return $ file -> getPathname ( ) ; } } throw new AlertDisplayViewException ( 'Could not locate the view file.' ) ; }
|
Track down the display view file .
|
8,936
|
public function open ( ) : Transaction { $ response = ( $ this -> fulfill ) ( new Request ( Url :: fromString ( '/db/data/transaction' ) , Method :: post ( ) , new ProtocolVersion ( 1 , 1 ) , $ this -> headers , $ this -> body ) ) ; $ body = Json :: decode ( ( string ) $ response -> body ( ) ) ; $ location = ( string ) $ response -> headers ( ) -> get ( 'Location' ) -> values ( ) -> current ( ) ; $ transaction = new Transaction ( Url :: fromString ( $ location ) , $ this -> clock -> at ( $ body [ 'transaction' ] [ 'expires' ] ) , Url :: fromString ( $ body [ 'commit' ] ) ) ; $ this -> transactions = $ this -> transactions -> add ( $ transaction ) ; return $ transaction ; }
|
Open a new transaction
|
8,937
|
public function commit ( ) : self { ( $ this -> fulfill ) ( new Request ( $ this -> current ( ) -> commitEndpoint ( ) , Method :: post ( ) , new ProtocolVersion ( 1 , 1 ) , $ this -> headers , $ this -> body ) ) ; $ this -> transactions = $ this -> transactions -> dropEnd ( 1 ) ; return $ this ; }
|
Commit the current transaction
|
8,938
|
public function rollback ( ) : self { ( $ this -> fulfill ) ( new Request ( $ this -> current ( ) -> endpoint ( ) , Method :: delete ( ) , new ProtocolVersion ( 1 , 1 ) ) ) ; $ this -> transactions = $ this -> transactions -> dropEnd ( 1 ) ; return $ this ; }
|
Rollback the current transaction
|
8,939
|
private function rem_dir_opt ( $ d ) { $ sub_files = bbn \ file \ dir :: scan ( $ d ) ; $ files = [ ] ; foreach ( $ sub_files as $ sub ) { if ( is_file ( $ sub ) ) { array_push ( $ files , $ this -> real_to_url ( $ sub ) ) ; $ this -> options -> remove ( $ this -> options -> from_code ( $ this -> real_to_id ( $ sub ) , $ this -> _files_pref ( ) ) ) ; } else { $ f = $ this -> rem_dir_opt ( $ sub ) ; if ( ! empty ( $ f ) ) { $ files = array_merge ( $ files , $ f ) ; } } } return $ files ; }
|
Deletes all files options of a folder and returns an array of these files .
|
8,940
|
private function superior_sctrl ( $ tab , $ path = '' ) { if ( ( $ pos = strpos ( $ tab , '_ctrl' ) ) ) { $ bits = explode ( '/' , $ path ) ; $ count = \ strlen ( substr ( $ tab , 0 , $ pos ) ) ; if ( ! empty ( $ bits ) ) { while ( $ count >= 0 ) { array_pop ( $ bits ) ; $ count -- ; } $ path = implode ( '/' , $ bits ) . ( ! empty ( $ bits ) ? '/' : '' ) ; } $ tab = '_ctrl' ; } return [ 'tab' => $ tab , 'path' => $ path ] ; }
|
Checks if the file is a superior super - controller and returns the corrected name and path
|
8,941
|
public function real_to_id ( $ file ) { $ timer = new bbn \ util \ timer ( ) ; $ timer -> start ( 'real_to_id' ) ; $ url = self :: real_to_url ( $ file ) ; $ dir = self :: dir ( self :: dir_from_url ( $ url ) ) ; if ( ! empty ( $ dir ) && \ defined ( $ dir [ 'bbn_path' ] ) ) { $ bbn_p = constant ( $ dir [ 'bbn_path' ] ) ; if ( strpos ( $ file , $ bbn_p ) === 0 ) { $ f = substr ( $ file , \ strlen ( $ bbn_p ) ) ; $ timer -> stop ( 'real_to_id' ) ; bbn \ x :: log ( $ timer -> results ( ) , "directories" ) ; return bbn \ str :: parse_path ( $ dir [ 'bbn_path' ] . '/' . $ f ) ; } } }
|
Returns the file s ID from the real file s path .
|
8,942
|
public function url_to_real ( $ url ) { if ( ( $ dn = $ this -> dir_from_url ( $ url ) ) && ( $ dir = $ this -> dir ( $ dn ) ) && ( $ res = $ this -> get_root_path ( $ dn ) ) ) { $ bits = explode ( '/' , substr ( $ url , \ strlen ( $ dn ) , \ strlen ( $ url ) ) ) ; if ( ! empty ( $ dir [ 'tabs' ] ) && ! empty ( $ bits ) ) { $ tab = array_pop ( $ bits ) ; $ fn = array_pop ( $ bits ) ; $ fp = implode ( '/' , $ bits ) . '/' ; $ ssc = $ this -> superior_sctrl ( $ tab , $ fp ) ; $ tab = $ ssc [ 'tab' ] ; $ fp = $ ssc [ 'path' ] ; if ( ! empty ( $ dir [ 'tabs' ] [ $ tab ] ) ) { $ tab = $ dir [ 'tabs' ] [ $ tab ] ; $ res .= $ tab [ 'path' ] ; if ( ! empty ( $ tab [ 'fixed' ] ) ) { $ res .= $ fp . $ tab [ 'fixed' ] ; } else { $ res .= $ fp . $ fn ; $ ext_ok = false ; foreach ( $ tab [ 'extensions' ] as $ e ) { $ ext = '.' . $ e [ 'ext' ] ; if ( is_file ( $ res . $ ext ) ) { $ res .= $ ext ; $ ext_ok = true ; break ; } } if ( empty ( $ ext_ok ) ) { $ res .= '.' . $ tab [ 'extensions' ] [ 0 ] [ 'ext' ] ; } } } else { return false ; } } else { if ( end ( $ bits ) === 'code' ) { array_pop ( $ bits ) ; } $ res .= implode ( '/' , $ bits ) ; } return bbn \ str :: parse_path ( $ res ) ; } return false ; }
|
Gets the real file s path from an URL
|
8,943
|
public function dir_from_url ( $ url ) { $ dir = false ; foreach ( $ this -> dirs ( ) as $ i => $ d ) { if ( ( strpos ( $ url , $ i ) === 0 ) && ( \ strlen ( $ i ) > \ strlen ( $ dir ) ) ) { $ dir = $ i ; break ; } } return $ dir ; }
|
Returns the dir s name from an URL
|
8,944
|
public function url_to_id ( $ url ) { if ( $ file = $ this -> url_to_real ( $ url ) ) { return $ this -> real_to_id ( $ file ) ; } return false ; }
|
Returns the file s ID from its URL
|
8,945
|
public function id_to_url ( $ id ) { if ( $ file = $ this -> id_to_real ( $ id ) ) { return $ this -> real_to_url ( $ file ) ; } return false ; }
|
Returns the file s URL from its ID
|
8,946
|
public function get_root_path ( $ code ) { $ dir = $ this -> dir ( $ code ) ; if ( $ dir ) { $ path = $ this -> decipher_path ( bbn \ str :: parse_path ( $ dir [ 'bbn_path' ] . ( ! empty ( $ dir [ 'path' ] ) ? '/' . $ dir [ 'path' ] : '' ) ) ) ; $ r = bbn \ str :: parse_path ( $ path . '/' ) ; return $ r ; } return false ; }
|
Gets the real root path from a directory s id as recorded in the options .
|
8,947
|
public function dirs ( $ code = false ) { $ all = $ this -> options -> full_soptions ( self :: _dev_path ( ) ) ; $ cats = [ ] ; $ r = [ ] ; foreach ( $ all as $ a ) { if ( \ defined ( $ a [ 'bbn_path' ] ) ) { $ k = $ a [ 'bbn_path' ] . '/' . ( $ a [ 'code' ] === '/' ? '' : $ a [ 'code' ] ) ; if ( ! isset ( $ cats [ $ a [ 'id_alias' ] ] ) ) { unset ( $ a [ 'alias' ] [ 'cfg' ] ) ; $ cats [ $ a [ 'id_alias' ] ] = $ a [ 'alias' ] ; } unset ( $ a [ 'cfg' ] ) ; unset ( $ a [ 'alias' ] ) ; $ r [ $ k ] = $ a ; $ r [ $ k ] [ 'title' ] = $ r [ $ k ] [ 'text' ] ; $ r [ $ k ] [ 'alias_code' ] = $ cats [ $ a [ 'id_alias' ] ] [ 'code' ] ; if ( ! empty ( $ cats [ $ a [ 'id_alias' ] ] [ 'tabs' ] ) ) { $ r [ $ k ] [ 'tabs' ] = $ cats [ $ a [ 'id_alias' ] ] [ 'tabs' ] ; } else { $ r [ $ k ] [ 'extensions' ] = $ cats [ $ a [ 'id_alias' ] ] [ 'extensions' ] ; } unset ( $ r [ $ k ] [ 'alias' ] ) ; } } if ( $ code ) { return isset ( $ r [ $ code ] ) ? $ r [ $ code ] : false ; } return $ r ; }
|
Make dirs configurations
|
8,948
|
public function set_preferences ( $ id_user , $ id_file , $ md5 , array $ cfg = null , bbn \ user \ preferences $ pref = null ) { if ( ! empty ( $ id_user ) && ! empty ( $ id_file ) && ! empty ( $ pref ) ) { $ change [ 'md5' ] = $ md5 ; if ( ! empty ( $ cfg [ 'selections' ] ) ) { $ change [ 'selections' ] = $ cfg [ 'selections' ] ; } if ( isset ( $ cfg , $ cfg [ 'marks' ] ) ) { $ change [ 'marks' ] = $ cfg [ 'marks' ] ; } if ( ! empty ( $ change ) ) { $ id_option = $ this -> option_id ( $ id_file ) ; if ( $ pref -> set ( $ id_option , $ change , $ id_user ) ) { return true ; } } } return false ; }
|
Sets user s preferences for a file .
|
8,949
|
public function change_ext ( $ ext , $ file ) { if ( ! empty ( $ ext ) && ! empty ( $ file ) && file_exists ( $ file ) ) { $ pi = pathinfo ( $ file ) ; $ new = $ pi [ 'dirname' ] . '/' . $ pi [ 'filename' ] . '.' . $ ext ; bbn \ file \ dir :: move ( $ file , $ new , true ) ; return [ 'file' => $ new , 'file_url' => $ this -> real_to_url ( $ new ) ] ; } $ this -> error ( "Error." ) ; }
|
Changes the extension to a file .
|
8,950
|
public function history ( $ url ) { if ( ! empty ( $ url ) && ( $ dir = $ this -> dir_from_url ( $ url ) ) && ( $ dir_cfg = $ this -> dir ( $ dir ) ) && \ defined ( 'BBN_USER_PATH' ) ) { $ res = [ ] ; $ all = [ ] ; $ path = BBN_USER_PATH . "ide/backup/$dir" ; $ file = substr ( $ url , \ strlen ( $ dir ) , \ strlen ( $ url ) ) ; if ( ! empty ( $ dir_cfg [ 'tabs' ] ) ) { foreach ( $ dir_cfg [ 'tabs' ] as $ t ) { if ( empty ( $ t [ 'fixed' ] ) ) { $ p = $ path . $ t [ 'path' ] . $ file . '/' ; $ all = self :: get_history ( $ p , $ t , $ all , true ) ; } } } else { $ p = $ path . $ file . '/' ; $ all = self :: get_history ( $ p , $ dir_cfg , $ all ) ; } if ( ! empty ( $ all ) ) { foreach ( $ all as $ i => $ a ) { if ( ! empty ( $ dir_cfg [ 'tabs' ] ) ) { $ tmp = [ ] ; foreach ( $ a as $ k => $ b ) { array_push ( $ tmp , [ 'text' => $ k , 'items' => $ b ] ) ; } } array_push ( $ res , [ 'text' => $ i , 'items' => ! empty ( $ tmp ) ? $ tmp : $ a ] ) ; } } return [ 'list' => $ res ] ; } }
|
Returns all backup history of a file .
|
8,951
|
public function payload ( array $ data ) { foreach ( $ data as $ key => $ value ) { $ this -> data -> { $ key } = $ value ; } return $ this ; }
|
Payload the request
|
8,952
|
public function toArray ( ) { $ this -> data -> id = $ this -> id ; return json_decode ( json_encode ( $ this -> data ) , true ) ; }
|
Get the request data
|
8,953
|
public static function fromRaw ( array $ response ) : self { $ data = $ response [ 'data' ] ?? [ ] ; return new self ( self :: buildNodes ( $ data ) , self :: buildRelationships ( $ data ) , self :: buildRows ( $ response ) ) ; }
|
Build a result object out of a standard neo4j rest api response
|
8,954
|
public function getList ( array $ query = [ ] ) { $ list = $ this -> pagination ( self :: DOMUSERP_API_OPERACIONAL . '/categorias/' . $ this -> categoryId . '/subcategorias' , $ query ) ; return $ list ; }
|
List of subcategories
|
8,955
|
public static function __convertLindoArray ( $ mesa ) { $ mesanew = $ mesa [ 'Mesa' ] ; unset ( $ mesa [ 'Mesa' ] ) ; foreach ( $ mesa as $ mkey => $ mvalue ) { $ mesanew [ $ mkey ] = $ mvalue ; } return $ mesanew ; }
|
Hace un array para que sea compatible con la versin anterior del ristorantino donde se enviaba un js con interval
|
8,956
|
public function getRelatedParts ( ) { if ( is_null ( $ this -> getMainPart ( ) ) ) { return array_slice ( $ this -> parts , 0 ) ; } return array_slice ( $ this -> parts , 1 ) ; }
|
Returns the mail parts associated with this multipart .
|
8,957
|
public function getRelatedPartByID ( $ cid ) { $ parts = $ this -> getRelatedParts ( ) ; foreach ( $ parts as $ part ) { if ( ( $ part -> getHeader ( 'Content-ID' ) !== '' ) && ( $ part -> getHeader ( 'Content-ID' ) == "<$cid>" ) ) { return $ part ; } } return false ; }
|
Returns the part associated with the passed Content - ID .
|
8,958
|
public function match ( Request $ request ) { foreach ( $ this -> firewalls as $ firewall ) { if ( $ firewall [ 'method' ] !== null && $ request -> getMethod ( ) !== $ firewall [ 'method' ] ) { continue ; } if ( $ firewall [ 'exact_match' ] ) { if ( $ request -> getPathInfo ( ) === $ firewall [ 'path' ] ) { return $ firewall ; } } elseif ( 0 === strpos ( $ request -> getPathInfo ( ) , $ firewall [ 'path' ] ) ) { return $ firewall ; } } return null ; }
|
Find the matching path
|
8,959
|
public static function map ( $ options = null ) { if ( empty ( self :: $ _google ) ) { self :: $ _google = new GoogleMapAPI ( ) ; self :: $ _google -> _minify_js = false ; if ( is_array ( $ options ) ) { foreach ( $ options as $ key => $ value ) { self :: $ _google -> $ key = $ value ; } } ; } return self :: $ _google ; }
|
Returns GoogleMaps instance to work with
|
8,960
|
public static function coordsByAddress ( $ searchString ) { $ result = false ; try { if ( self :: $ _googleTimeout != 0 ) { $ timeToWait = self :: $ _lastGoogleSearchTime + self :: $ _googleTimeout - time ( ) ; if ( $ timeToWait > 0 ) { sleep ( $ timeToWait ) ; } } $ searchResult = self :: map ( ) -> geoGetCoordsFull ( $ searchString ) ; self :: $ _lastGoogleSearchTime = time ( ) ; if ( $ searchResult && $ searchResult -> status == 'OK' ) { $ result = [ 'latitude' => $ searchResult -> results [ 0 ] -> geometry -> location -> lat , 'longitude' => $ searchResult -> results [ 0 ] -> geometry -> location -> lng , ] ; } } catch ( ErrorException $ e ) { \ Yii :: error ( 'Can\'t load coordinates from Google Maps API: ' . $ e -> getMessage ( ) ) ; } return $ result ; }
|
Search coordinates by address
|
8,961
|
public function callEvent ( $ event_name ) { $ classname = get_called_class ( ) ; if ( ! isset ( static :: $ callbacks [ $ classname ] [ $ event_name ] ) ) { return ; } foreach ( static :: $ callbacks [ $ classname ] [ $ event_name ] as $ callback ) { $ callback ( $ this ) ; } }
|
Call an event on this entity calling the registering callbacks .
|
8,962
|
public function getRelation ( $ name ) { if ( array_key_exists ( $ name , $ this -> relation_objects ) ) { return $ this -> relation_objects [ $ name ] ; } $ relation = self :: getRelationDefinition ( $ name ) ; $ this -> relation_objects [ $ name ] = $ this -> fetchRelation ( $ relation ) ; return $ this -> relation_objects [ $ name ] ; }
|
Get the named related object . If the database has not been queried it will be fetched automatically . If the database has been queried the original result will be returned .
|
8,963
|
protected function fetchRelation ( array $ relation ) { list ( $ type , $ foreign_class , $ foreign_column , $ column ) = $ relation ; switch ( $ type ) { case 'has_one' : return $ this -> fetchOneToOne ( $ foreign_class , $ foreign_column , $ column ) ; case 'belongs_to' : return $ this -> fetchOneToOne ( $ foreign_class , $ foreign_column , $ column ) ; case 'has_many' : return $ this -> fetchOneToMany ( $ foreign_class , $ foreign_column , $ column ) ; default : } }
|
Fetch a related entity from the database .
|
8,964
|
protected function fetchOneToOne ( $ foreign_class , $ foreign_column , $ column ) { return $ foreign_class :: selectOne ( $ this -> connection ) -> where ( $ foreign_column , '=' , $ this -> getRaw ( $ column ) ) -> execute ( ) ; }
|
Query the database for a one to one relationship .
|
8,965
|
protected function fetchOneToMany ( $ foreign_class , $ foreign_column , $ column ) { return $ foreign_class :: select ( $ this -> connection ) -> where ( $ foreign_column , '=' , $ this -> getRaw ( $ column ) ) -> execute ( ) ; }
|
Query the database for a one to many relationship .
|
8,966
|
public function getValues ( ) { $ return = array ( ) ; foreach ( $ this -> values as $ k => $ v ) { $ return [ $ k ] = $ this -> get ( $ k ) ; } return $ return ; }
|
Get all values . Getter methods will be called on the values .
|
8,967
|
public function setRelation ( $ name , $ related_object ) { if ( ! $ related_object ) { $ related_object = false ; } $ this -> relation_objects [ $ name ] = $ related_object ; }
|
Set the named related object .
|
8,968
|
public function unsetRelation ( $ name , $ value ) { list ( $ type , $ foreign_class , $ foreign_column , $ column ) = static :: getRelationDefinition ( $ name ) ; if ( $ type === 'belongs_to' ) { $ this -> setRaw ( $ column , $ value ) ; $ this -> relation_objects [ $ name ] = false ; return ; } $ related_object = $ this -> getRelation ( $ name ) ; if ( ! $ related_object ) { return ; } if ( $ type === 'has_one' ) { $ related_object -> setRaw ( $ foreign_column , $ value ) ; $ this -> relation_objects [ $ name ] = false ; } if ( $ type === 'has_many' ) { $ related_object -> setColumnRaw ( $ foreign_column , $ value ) ; $ this -> relation_objects [ $ name ] = $ foreign_class :: newCollection ( ) ; } return ; }
|
Unset a related object and assign the joining column a value . If the related object has not been fetched it will be fetched and the joining column changed .
|
8,969
|
public function setValues ( array $ values = array ( ) ) { foreach ( $ values as $ k => $ v ) { $ this -> set ( $ k , $ v ) ; } return $ this ; }
|
Set an array of values . Setter methods will be called if they exist .
|
8,970
|
public function setValuesRaw ( $ values = array ( ) ) { foreach ( $ values as $ key => $ value ) { $ this -> setRaw ( $ key , $ value ) ; } return $ this ; }
|
Set an array of values . Setter methods will not be called .
|
8,971
|
public function insert ( ) { if ( $ this -> stored ) { throw new \ LogicException ( "You may not insert an already stored entity" ) ; } $ this -> callEvent ( 'insert' ) ; if ( empty ( $ this -> modified ) ) { return ; } $ values = array_intersect_key ( $ this -> values , $ this -> modified ) ; $ this -> connection -> insert ( static :: $ table , $ values , static :: $ types ) ; $ this -> values [ static :: $ primary_key ] = $ this -> connection -> lastInsertId ( ) ; $ this -> setStored ( ) ; }
|
Persist this entity to the database using an insert query .
|
8,972
|
protected function getPrimaryKey ( ) { if ( ! isset ( $ this -> values [ static :: $ primary_key ] ) ) { throw new \ LogicException ( 'Primary key not set' ) ; } return $ this -> current_index ? : $ this -> values [ static :: $ primary_key ] ; }
|
Get the primary key for this entity as it is stored in the database . If the key has been updated but not saved the original value will be returned .
|
8,973
|
public function update ( ) { $ this -> callEvent ( 'update' ) ; if ( empty ( $ this -> modified ) ) { return ; } $ values = array_intersect_key ( $ this -> values , $ this -> modified ) ; $ where = [ static :: $ primary_key => $ this -> getPrimaryKey ( ) ] ; $ this -> connection -> update ( static :: $ table , $ values , $ where , static :: $ types ) ; $ this -> setStored ( ) ; }
|
Update this entity in the database .
|
8,974
|
public function setStored ( $ stored = true ) { $ this -> stored = ( bool ) $ stored ; $ this -> modified = $ stored ? [ ] : $ this -> values ; return $ this ; }
|
Set whether this entity is stored in the database or not .
|
8,975
|
public function delete ( ) { $ where = [ static :: $ primary_key => $ this -> getPrimaryKey ( ) ] ; $ this -> connection -> delete ( static :: $ table , $ where ) ; $ this -> setStored ( false ) ; return $ this ; }
|
Delete this entity from the database .
|
8,976
|
public static function create ( Connection $ connection , $ amount = 0 ) { $ entities = [ ] ; for ( $ i = 0 ; $ i < ( int ) $ amount ; $ i ++ ) { $ entities [ ] = new static ( $ connection ) ; } return static :: newCollection ( $ entities ) ; }
|
Create a new collection with an amount of empty entities .
|
8,977
|
public static function selectSQL ( Connection $ connection , $ sql , array $ parameters = [ ] , array $ field_mapping = [ ] ) { $ stmt = $ connection -> prepare ( $ sql ) ; $ stmt -> execute ( $ parameters ) ; $ results = array ( ) ; while ( $ result = $ stmt -> fetch ( ) ) { foreach ( $ field_mapping as $ result_column => $ entity_field ) { if ( ! isset ( $ result [ $ result_column ] ) ) { continue ; } $ result [ $ entity_field ] = $ result [ $ result_column ] ; unset ( $ result [ $ result_column ] ) ; } foreach ( static :: $ types as $ column => $ type ) { if ( isset ( $ result [ $ column ] ) ) { $ result [ $ column ] = $ connection -> convertToPHPValue ( $ result [ $ column ] , $ type ) ; } } $ obj = new static ( $ connection , $ result ) ; $ obj -> setStored ( ) ; $ results [ ] = $ obj ; } $ collection = static :: newCollection ( ) ; $ collection -> setEntities ( $ results ) ; return $ collection ; }
|
Select all entities matching an SQL query and return the results as a collection .
|
8,978
|
public static function selectOneSQL ( Connection $ connection , $ sql , array $ parameters = [ ] , array $ field_mapping = [ ] ) { $ stmt = $ connection -> prepare ( $ sql ) ; $ stmt -> execute ( $ parameters ) ; $ result = $ stmt -> fetch ( ) ; if ( $ result ) { foreach ( $ field_mapping as $ result_column => $ entity_field ) { if ( ! isset ( $ result [ $ result_column ] ) ) { continue ; } $ result [ $ entity_field ] = $ result [ $ result_column ] ; unset ( $ result [ $ result_column ] ) ; } foreach ( static :: $ types as $ column => $ type ) { if ( isset ( $ result [ $ column ] ) ) { $ result [ $ column ] = $ connection -> convertToPHPValue ( $ result [ $ column ] , $ type ) ; } } $ entity = new static ( $ connection , $ result ) ; return $ entity -> setStored ( ) ; } return null ; }
|
Select a single entity matching an SQL query . If more than one row is matched by the query only the first entity will be returned .
|
8,979
|
public static function select ( Connection $ connection ) { return new EntitySelector ( AbstractSelector :: fromConnection ( $ connection , static :: $ table , static :: $ types ) , get_called_class ( ) ) ; }
|
Select entities using an EntitySelector instance .
|
8,980
|
public static function selectOne ( Connection $ connection ) { $ selector = new EntitySelector ( AbstractSelector :: fromConnection ( $ connection , static :: $ table , static :: $ types ) , get_called_class ( ) ) ; return $ selector -> one ( ) ; }
|
Select a single entity using an EntitySelector instance .
|
8,981
|
public static function selectPrimaryKey ( Connection $ connection , $ primary_key ) { return static :: selectOne ( $ connection ) -> where ( static :: $ primary_key , $ primary_key ) -> execute ( ) ; }
|
Select a single entity matching a primary key .
|
8,982
|
public function mesas_abiertas ( $ microtime = 0 ) { $ lastAccess = null ; $ type = 'created' ; if ( $ microtime != 0 ) { $ type = 'modified' ; $ lastAccess = $ this -> Session -> read ( 'lastAccess' ) ; $ nowTime = date ( 'Y-m-d H:i:s' , strtotime ( 'now' ) ) ; $ this -> Session -> write ( 'lastAccess' , $ nowTime ) ; $ borradas = $ this -> Mozo -> mesasBorradas ( null , $ lastAccess ) ; if ( ! empty ( $ borradas ) ) { $ mesas [ 'borradas' ] = $ borradas ; } } $ mesas [ $ type ] = $ this -> Mozo -> mesasAbiertas ( null , $ lastAccess ) ; $ this -> set ( 'mesasLastUpdatedTime' , 1 ) ; $ this -> set ( 'modified' , $ lastAccess ) ; $ this -> set ( 'mesas' , $ mesas ) ; }
|
Me devuelve las mesas abiertas de cada mozo
|
8,983
|
public static function handle_error ( $ errno , $ errstr , $ errfile , $ errline ) { if ( ! ( error_reporting ( ) & $ errno ) ) return false ; self :: error ( sprintf ( "%s [%s] %s. Line: %s. File: %s" , human_error_code ( $ errno ) , $ errno , $ errstr , $ errline , $ errfile ) ) ; return true ; }
|
This function is called when a PHP error occurs . It is unadivsed to call this function manually .
|
8,984
|
private static function filament ( $ type , $ arguments ) { $ uniqId = md5 ( $ type . json_encode ( $ arguments ) ) ; if ( isset ( self :: $ log [ $ uniqId ] ) ) return ++ self :: $ log [ $ uniqId ] [ "count" ] ; self :: $ log [ $ uniqId ] = array ( "count" => 1 , "type" => $ type , "arguments" => $ arguments ) ; return true ; }
|
Add a log entry to the filament log . This log is sent to the filament server after script execution .
|
8,985
|
public function hyphen_to_camel ( $ string , $ upper_first = false ) { $ str = preg_replace_callback ( '/-(.)/u' , function ( $ match ) { return strtoupper ( $ match [ 1 ] ) ; } , strtolower ( $ string ) ) ; if ( $ upper_first ) { $ str = ucfirst ( $ str ) ; } return $ str ; }
|
Make hyphenated string to camel case
|
8,986
|
public function post_type_label ( $ singular_name , $ multiple_name = '' , $ as_object = false ) { if ( ! $ multiple_name ) { $ multiple_name = $ singular_name ; } $ labels = [ 'name' => $ multiple_name , 'singular_name' => $ singular_name , 'add_new' => $ this -> __ ( 'Add new' ) , 'add_new_item' => sprintf ( $ this -> __ ( 'Add new %s' ) , $ singular_name ) , 'edit_item' => sprintf ( $ this -> __ ( 'Edit %s' ) , $ singular_name ) , 'new_item' => sprintf ( $ this -> __ ( 'New %s' ) , $ singular_name ) , 'view_item' => sprintf ( $ this -> __ ( 'Vew %s' ) , $ singular_name ) , 'search_items' => sprintf ( $ this -> __ ( 'Search %s' ) , $ multiple_name ) , 'not_found' => sprintf ( $ this -> __ ( 'No %s found.' ) , $ multiple_name ) , 'not_found_in_trash' => sprintf ( $ this -> __ ( 'No %s in trash.' ) , $ singular_name ) , 'parent_item_colon' => sprintf ( $ this -> __ ( 'Parent %s:' ) , $ singular_name ) , 'all_items' => sprintf ( $ this -> __ ( 'All %s' ) , $ multiple_name ) , 'menu_name' => $ singular_name , 'name_admin_bar' => $ singular_name , ] ; return $ as_object ? ( object ) $ labels : $ labels ; }
|
Returns post type label shorthand .
|
8,987
|
public function get_taxonomy_label ( $ singular_name , $ multiple_name = '' , $ hierarchical = false , $ as_object = false ) { if ( ! $ multiple_name ) { $ multiple_name = $ singular_name ; } $ labels = [ 'name' => $ multiple_name , 'singular_name' => $ singular_name , 'search_items' => sprintf ( $ this -> __ ( 'Search %s' ) , $ singular_name ) , 'popular_items' => sprintf ( $ this -> __ ( 'Popular %s' ) , $ multiple_name ) , 'all_items' => sprintf ( $ this -> __ ( 'All %s' ) , $ multiple_name ) , 'parent_item' => $ hierarchical ? sprintf ( $ this -> __ ( 'Parent %s' ) , $ singular_name ) : null , 'parent_item_colon' => $ hierarchical ? sprintf ( $ this -> __ ( 'Parent %s:' ) , $ singular_name ) : null , 'edit_item' => sprintf ( $ this -> __ ( 'Edit %s' ) , $ singular_name ) , 'update_item' => sprintf ( $ this -> __ ( 'Update %s' ) , $ singular_name ) , 'add_new_item' => sprintf ( $ this -> __ ( 'Add New %s' ) , $ singular_name ) , 'new_item_name' => sprintf ( $ this -> __ ( 'New %s Name' ) , $ singular_name ) , 'separate_items_with_commas' => sprintf ( $ this -> __ ( 'Separate %s with commas' ) , $ multiple_name ) , 'add_or_remove_items' => sprintf ( $ this -> __ ( 'Add or remove %s' ) , $ multiple_name ) , 'choose_from_most_used' => sprintf ( $ this -> __ ( 'Choose from the most used %s' ) , $ multiple_name ) , 'not_found' => sprintf ( $ this -> __ ( 'No %s found.' ) , $ multiple_name ) , 'menu_name' => $ multiple_name , ] ; return $ as_object ? ( object ) $ labels : $ labels ; }
|
Returns taxonomy label shorthand .
|
8,988
|
public function extract_host ( $ url ) { $ string = ( string ) $ url ; if ( preg_match ( '@https?://([^/\?#]+)@u' , $ url , $ match ) ) { return $ match [ 1 ] ; } else { return $ url ; } }
|
Extract host value from url
|
8,989
|
public function getFeature ( $ featureName , $ permissive = false ) { $ feature = Feature :: findByName ( $ this -> features , $ featureName , $ permissive ) ; if ( ! $ feature ) throw new ModelException ( "the model has no feature named \"$featureName\"" ) ; return $ feature ; }
|
Returns a feature in the feature model with a given name .
|
8,990
|
public function prepare ( ) { if ( $ this -> fromString == null || $ this -> fromString == '' ) { $ this -> from ( $ this -> getDummyTableName ( ) ) ; } return parent :: prepare ( ) ; }
|
Handles preparing query .
|
8,991
|
public static function to_string ( \ DOMDocument $ dom ) { $ html5 = new HTML5 ( ) ; preg_match ( '/<body>(.*)<\/body>/s' , $ html5 -> saveHTML ( $ dom ) , $ match ) ; return $ match [ 1 ] ; }
|
Return body as string
|
8,992
|
public function refine ( $ role ) { $ fileSource = $ role -> getFileSpecification ( ) -> getSource ( ) ; $ parser = ( new fphp \ Helper \ PhpParser ( ) ) -> parseFile ( $ fileSource ) ; $ ast = $ parser -> getAst ( ) ; $ class = $ parser -> getExactlyOneClass ( $ fileSource ) ; if ( ! $ this -> targetClass ) { $ this -> targetClass = $ class -> name ; $ this -> mangleClassName ( $ class , $ role ) ; } else { if ( $ class -> name !== $ this -> targetClass ) throw new ClassComposerException ( "\"$fileSource\" refines \"$class->name\" (expected \"$this->targetClass\")" ) ; if ( $ class -> extends ) throw new ClassComposerException ( "refining role at \"$fileSource\" may not extend a class" ) ; $ this -> mangleClassName ( $ class , $ role ) ; $ this -> extendClass ( $ class ) ; } return new ClassComposer ( $ this -> targetClass , $ class -> name , array_merge ( $ this -> ast , $ ast ) ) ; }
|
Returns a new class composer containing a role s refinements .
|
8,993
|
public function getContent ( ) { $ class = new \ PhpParser \ Node \ Stmt \ Class_ ( $ this -> targetClass ) ; $ this -> extendClass ( $ class ) ; $ ast = array_merge ( $ this -> ast , array ( $ class ) ) ; $ code = fphp \ Helper \ PhpParser :: astToString ( $ ast ) ; return new fphp \ File \ TextFileContent ( $ code ) ; }
|
Returns the refined file s content .
|
8,994
|
protected function grabFile ( $ file , $ root ) { $ data = '' ; if ( is_file ( $ root . '/' . $ file ) ) { $ this -> loaded_files [ ] = $ file ; $ file = $ root . '/' . $ file ; $ data = file_get_contents ( $ file ) ; if ( ! strstr ( $ file , 'sb.js' ) ) { preg_match_all ( "~sb\.include\([\"'](.*?)[\"']~" , $ data , $ includes ) ; if ( $ includes [ 1 ] ) { $ precludes = '' ; foreach ( $ includes [ 1 ] as $ include ) { $ include = \ str_replace ( '.' , '/' , $ include ) . '.js' ; if ( ! \ in_array ( $ include , $ this -> loaded_files ) ) { $ precludes .= $ this -> grabFile ( $ include , $ root ) ; } } $ data = $ precludes . "\n" . $ data ; } } } else { echo "\nthrow('ERROR: " . $ file . " Surebert module \"" . \ basename ( $ file ) . "\" could not be located by /surebert/load ');" ; } return $ data ; }
|
Grabs a file
|
8,995
|
public function basic ( ) { if ( ! isset ( $ this -> request -> get [ 'noexpire' ] ) ) { header ( 'Expires: ' . gmdate ( 'D, d M Y H:i:s \G\M\T' , time ( ) + 259200 ) ) ; } header ( "Content-type: application/x-javascript" ) ; $ version = '' ; if ( isset ( $ this -> request -> get [ 'v' ] ) ) { if ( is_numeric ( $ this -> request -> get [ 'v' ] ) ) { $ version = $ this -> request -> get [ 'v' ] ; } } $ surebert = Array ( "sb" , "browser.\$_GET" , "math.rand" , "cookies" , "browser.removeSelection" , "browser.getScrollPosition" , "browser.scrollTo" , "Element.prototype.show" , "Element.prototype.hide" , "Element.prototype.toggle" , "Element.prototype.getDimensions" , "Element.prototype.mv" , "Element.prototype.getPosition" , "Element.prototype.getNextSibling" , "Element.prototype.getPreviousSibling" , "Element.prototype.isOrHasParentOfClassName" , "Element.prototype.containsElement" , "Element.prototype.isWithin" , "Element.prototype.getContaining" , "Element.prototype.cssTransition" , "css.rules" , "swf" , "css.styleSheet" , "events.observer" , "events.classListener" , "events.idListener" , "widget.notifier" , "json.rpc2" ) ; $ protocol = isset ( $ _SERVER [ 'SERVER_PORT' ] ) && $ _SERVER [ 'SERVER_PORT' ] == 443 ? 'https' : 'http' ; $ str = "if(!sbBase){var sbBase = '" . $ protocol . "://" . \ sb \ Gateway :: $ http_host . "/surebert/load/';}\n" ; $ surebert = \ array_merge ( $ surebert , $ this -> request -> args ) ; $ str .= $ this -> concatFiles ( $ surebert , $ version ) ; return $ str ; }
|
Serves out the most common surebert toolkit files
|
8,996
|
public static function detect_mime_type ( $ path ) { $ handle = finfo_open ( FILEINFO_MIME ) ; $ mime_type = finfo_file ( $ handle , $ path ) ; if ( strpos ( $ mime_type , ';' ) ) { $ mime_type = preg_replace ( '/;.*/' , ' ' , $ mime_type ) ; } return trim ( $ mime_type ) ; }
|
Get the mime_type of a file
|
8,997
|
public static function status ( $ orderId ) { $ url = static :: classUrl ( ) ; $ url = $ url . '/' . $ orderId . '/status' ; list ( $ ret ) = parent :: staticRequest ( 'get' , $ url , [ ] ) ; return $ ret ; }
|
Get status information about an order
|
8,998
|
public static function shipped ( $ orderId , $ shippedAt = 0 ) { $ url = static :: classUrl ( ) ; $ url = $ url . '/' . $ orderId . '/shipped' ; list ( $ ret , $ code ) = parent :: staticRequest ( 'post' , $ url , [ 'shippedAt' => date ( 'c' , $ shippedAt ? $ shippedAt : time ( ) ) , ] ) ; return ( object ) [ 'code' => $ code , 'status' => $ code === 204 ? 'success' : 'failed' ] ; }
|
Tell LeaseCloud that an order is shipped
|
8,999
|
public function getCarouselEditFields ( ) { if ( method_exists ( 'HtmlEditorConfig' , 'require_js' ) ) { HtmlEditorConfig :: require_js ( ) ; } $ fields = FieldList :: create ( ) ; $ fields -> push ( CarouselCaptionField :: create ( 'Content' , _t ( 'CarouselPage.Caption' ) ) ) ; return $ fields ; }
|
Retrieve the fields used by SortableUploadField internal form .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.