idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
10,300
private function _get_value ( $ args ) { if ( $ this -> id ) { $ var = & $ this -> data ; foreach ( $ args as $ a ) { if ( ! isset ( $ var [ $ a ] ) ) { return null ; } $ var = & $ var [ $ a ] ; } return $ var ; } }
Gets a reference to the part of the data corresponding to an array of indexes
10,301
protected function compileBody ( Buffer $ buffer ) { $ buffer -> write ( 'return ' ) ; $ this -> expr -> compile ( $ buffer ) ; $ buffer -> raw ( ';' ) ; }
Compiles the definition body
10,302
public function useEncryption ( $ key ) { $ this -> encryptor = new \ sb \ Encryption \ ForTransmission ( $ key ) ; $ this -> encryption_key = $ key ; foreach ( \ sb \ Gateway :: $ cookie as $ k => $ v ) { \ sb \ Gateway :: $ cookie [ $ k ] = $ this -> encryptor -> decrypt ( $ v ) ; } }
Sets the key that data is encrypted with and turns on encryption the client must use the same key
10,303
public function getMethods ( $ html = true ) { $ arr = Array ( ) ; foreach ( $ this -> served_classes as $ class ) { foreach ( \ get_class_methods ( $ class ) as $ method ) { $ reflect = new \ ReflectionMethod ( $ class , $ method ) ; if ( $ reflect ) { if ( $ class == $ this ) { $ docs = $ reflect -> getDocComment ( ) ; $ servable = false ; if ( ! empty ( $ docs ) ) { if ( \ preg_match ( "~@servable (true|false)~" , $ docs , $ match ) ) { $ servable = $ match [ 1 ] == 'true' ? true : false ; } } } else if ( $ reflect -> isPublic ( ) ) { $ servable = true ; } if ( ! $ servable ) { continue ; } $ params = $ reflect -> getParameters ( ) ; $ ps = Array ( ) ; foreach ( $ params as $ param ) { $ ps [ ] = '$' . $ param -> getName ( ) ; } $ key = $ method . '(' . implode ( ', ' , $ ps ) . ')' ; $ arr [ $ key ] = $ reflect -> getDocComment ( ) ; } } } if ( $ html == false ) { return $ arr ; } else { return $ this -> methodsToHtml ( $ arr ) ; } }
Get the methods available for this \ sb \ JSON \ RPC2_Server instance
10,304
protected function getPhpdoc ( $ method ) { $ reflect = false ; foreach ( $ this -> served_classes as $ class ) { if ( \ method_exists ( $ class , $ method ) ) { $ reflect = new \ ReflectionMethod ( $ class , $ method ) ; break ; } } $ response = new \ stdClass ( ) ; if ( ! $ reflect ) { $ response -> error = new \ sb \ JSON \ RPC2 \ Error ( ) ; $ response -> error -> code = - 32602 ; $ response -> error -> message = "Invalid method parameters" ; return $ response ; } $ response -> phpdoc = $ reflect -> getDocComment ( ) ; if ( \ preg_match ( "~@return (.*?) (.*?)\*/$~s" , $ response -> phpdoc , $ match ) ) { $ response -> return_type = $ match [ 1 ] ; } else { $ response -> return_type = 'n/a' ; } return $ response ; }
Get php doc and return_type for method by name
10,305
protected function methodsToHtml ( $ methods ) { $ html = '<style type="text/css"> li{background-color:#c8c8d4;} h1{ font-size:1.0em; padding:3px 0 3px 10px; color:white; background-color:#8181bd; } pre{ color:#1d1d4d; } </style><ol>' ; ksort ( $ methods ) ; foreach ( $ methods as $ method => $ comments ) { $ html .= '<li><h1>$server->' . $ method . ';</h1><pre>' . str_repeat ( "&nbsp;" , 4 ) . $ comments . '</pre></li>' ; } $ html .= '</ol>' ; return $ html ; }
Coverts the methods served into an HTML string
10,306
public function getAcceptedTypes ( ) { return $ this -> getCachedProperty ( 'accept' , function ( ) { $ result = [ ] ; $ nodes = $ this -> query ( 'app:accept' ) ; foreach ( $ nodes as $ value ) { $ result [ ] = trim ( $ value -> textContent ) ; } return $ result ; } ) ; }
Return types of representations accepted by the Collection .
10,307
public function setAcceptedTypes ( array $ types ) { $ nodes = $ this -> query ( 'app:accept' ) ; foreach ( $ nodes as $ node ) { $ this -> getDomElement ( ) -> removeChild ( $ node ) ; } foreach ( $ types as $ type ) { $ element = $ this -> getDomElement ( ) -> ownerDocument -> createElementNS ( $ this -> ns ( ) , 'accept' , $ type ) ; $ this -> getDomElement ( ) -> appendChild ( $ element ) ; } $ this -> setCachedProperty ( 'accept' , $ types ) ; }
Set types of representations accepted by the Collection .
10,308
public function removeTrailingSlashAction ( Request $ request ) { $ pathInfo = $ request -> getPathInfo ( ) ; $ requestUri = $ request -> getRequestUri ( ) ; $ url = str_replace ( $ pathInfo , rtrim ( $ pathInfo , ' /' ) , $ requestUri ) ; return $ this -> redirect ( $ url , 301 ) ; }
Action used to remove trailing slash in url
10,309
public function edit ( $ eloquent , $ locale ) { $ this -> breadcrumb -> onEdit ( $ eloquent ) ; $ form = $ this -> getForm ( $ eloquent ) ; return $ this -> view ( 'edit' , compact ( 'form' ) ) ; }
shows form edit job
10,310
public function getForm ( $ eloquent , $ type = null ) { $ classname = $ eloquent -> classname ; $ model = $ eloquent -> contents -> first ( ) ; $ configuration = [ 'content' => $ model !== null ? $ model -> content : null , 'title' => $ model !== null ? $ model -> title : '' , 'type' => $ eloquent -> exists ? $ eloquent -> type -> name : '' , 'form_name' => $ eloquent -> name ] ; $ notification = app ( $ classname ? : Notification :: class ) ; $ fluent = new Fluent ( array_merge ( $ configuration , array_except ( $ eloquent -> toArray ( ) , [ 'type' ] ) ) ) ; if ( ! is_null ( $ fluent -> type ) && $ type ) { $ fluent -> type = $ type ; } return $ this -> form ( $ fluent , $ notification ) ; }
gets form instance
10,311
protected function form ( Fluent $ fluent , $ notification = null ) { publish ( 'notifications' , 'scripts.resources-default' ) ; Event :: fire ( 'antares.forms' , 'notification.' . $ fluent -> form_name ) ; $ fluent -> type = $ fluent -> type === '' ? 'email' : $ fluent -> type ; return new Form ( $ notification , $ fluent ) ; }
gets instance of command form
10,312
public function create ( Model $ model , $ type = null ) { $ this -> breadcrumb -> onCreate ( $ type ) ; $ form = $ this -> getForm ( $ model , $ type ) -> onCreate ( ) ; return $ this -> view ( 'create' , [ 'form' => $ form ] ) ; }
create new notification notification
10,313
public function edit ( $ id , $ locale , IndexListener $ listener ) { app ( 'antares.asset' ) -> container ( 'antares/foundation::application' ) -> add ( 'ckeditor' , '/packages/ckeditor/ckeditor.js' , [ 'webpack_forms_basic' ] ) ; $ model = $ this -> repository -> findByLocale ( $ id , $ locale ) ; if ( is_null ( $ model ) ) { throw new ModelNotFoundException ( 'Model not found' ) ; } return $ this -> presenter -> edit ( $ model , $ locale ) ; }
shows edit form
10,314
public function update ( IndexListener $ listener ) { $ id = Input :: get ( 'id' ) ; $ model = $ this -> repository -> find ( $ id ) ; $ form = $ this -> presenter -> getForm ( $ model ) ; if ( ! $ form -> isValid ( ) ) { return $ listener -> updateValidationFailed ( $ id , $ form -> getMessageBag ( ) ) ; } try { $ this -> repository -> updateNotification ( $ id , Input :: all ( ) ) ; } catch ( Exception $ ex ) { return $ listener -> updateFailed ( ) ; } return $ listener -> updateSuccess ( ) ; }
updates notification notification
10,315
public function preview ( ) { $ inputs = Input :: all ( ) ; $ content = str_replace ( "&#39;" , '"' , $ inputs [ 'content' ] ) ; $ content = $ this -> variablesAdapter -> get ( $ content ) ; if ( isset ( $ inputs [ 'subject' ] ) ) { $ subject = str_replace ( "&#39;" , '"' , $ inputs [ 'subject' ] ) ; $ subject = $ this -> variablesAdapter -> get ( $ subject ) ; array_set ( $ inputs , 'subject' , $ subject ) ; } preg_match_all ( '/\[\[(.*?)\]\]/' , $ content , $ matches ) ; $ view = str_replace ( $ matches [ 0 ] , $ matches [ 1 ] , $ content ) ; if ( array_get ( $ inputs , 'type' ) === 'email' ) { event ( 'antares.notifier.before_send_email' , [ & $ view ] ) ; } $ brandTemplate = BrandOptions :: query ( ) -> where ( 'brand_id' , brand_id ( ) ) -> first ( ) ; $ header = str_replace ( '</head>' , '<style>' . $ brandTemplate -> styles . '</style></head>' , $ brandTemplate -> header ) ; $ html = preg_replace ( "/<body[^>]*>(.*?)<\/body>/is" , '<body>' . $ view . '</body>' , $ header . $ brandTemplate -> footer ) ; array_set ( $ inputs , 'content' , $ html ) ; return $ this -> presenter -> preview ( $ inputs ) ; }
preview notification notification
10,316
public function changeStatus ( IndexListener $ listener , $ id ) { $ model = $ this -> repository -> find ( $ id ) ; if ( is_null ( $ model ) ) { return $ listener -> changeStatusFailed ( ) ; } $ model -> active = $ model -> active ? 0 : 1 ; $ model -> save ( ) ; return $ listener -> changeStatusSuccess ( ) ; }
change notification notification status
10,317
public function create ( $ type = null ) { app ( 'antares.asset' ) -> container ( 'antares/foundation::application' ) -> add ( 'ckeditor' , '/packages/ckeditor/ckeditor.js' , [ 'webpack_forms_basic' ] ) ; return $ this -> presenter -> create ( $ this -> repository -> makeModel ( ) -> getModel ( ) , $ type ) ; }
Create notification notification form
10,318
public function store ( IndexListener $ listener ) { $ model = $ this -> repository -> makeModel ( ) -> getModel ( ) ; $ form = $ this -> presenter -> getForm ( $ model ) -> onCreate ( ) ; if ( ! $ form -> isValid ( ) ) { return $ listener -> storeValidationFailed ( $ form -> getMessageBag ( ) ) ; } try { $ this -> repository -> store ( Input :: all ( ) ) ; } catch ( Exception $ ex ) { return $ listener -> createFailed ( ) ; } return $ listener -> createSuccess ( ) ; }
store new notification notification
10,319
public function delete ( $ id , IndexListener $ listener ) { try { $ model = $ this -> repository -> makeModel ( ) -> findOrFail ( $ id ) ; $ model -> delete ( ) ; return $ listener -> deleteSuccess ( ) ; } catch ( Exception $ ex ) { return $ listener -> deleteFailed ( ) ; } }
deletes custom notification
10,320
public function getExportFields ( ) { $ export_fields = Config :: inst ( ) -> get ( $ this -> modelClass , self :: EXPORT_FIELDS ) ; if ( isset ( $ export_fields ) && is_array ( $ export_fields ) ) { $ fields = $ export_fields ; } else { $ fields = parent :: getExportFields ( ) ; } $ this -> extend ( "updateExportFields" , $ fields ) ; return $ fields ; }
Get the default export fields for the current model .
10,321
public function getSearchSessionName ( ) { $ curr = $ this -> sanitiseClassName ( self :: class ) ; $ model = $ this -> sanitiseClassName ( $ this -> modelClass ) ; return $ curr . "." . $ model ; }
Get the name of the session to be useed by this model admin s search form .
10,322
public function getEditForm ( $ id = null , $ fields = null ) { $ form = parent :: getEditForm ( $ id , $ fields ) ; $ grid_field = $ form -> Fields ( ) -> fieldByName ( $ this -> sanitiseClassName ( $ this -> modelClass ) ) ; $ manager = new BulkManager ( ) ; $ manager -> removeBulkAction ( UnlinkHandler :: class ) ; $ config = $ grid_field -> getConfig ( ) ; $ config -> removeComponentsByType ( GridFieldPaginator :: class ) -> addComponent ( $ manager ) -> addComponent ( new GridFieldConfigurablePaginator ( ) ) ; $ config -> removeComponentsByType ( SSGridFieldFilterHeader :: class ) -> addComponent ( new GridFieldFilterHeader ( false , function ( $ context ) { $ this -> extend ( 'updateSearchContext' , $ context ) ; } , function ( $ form ) { $ this -> extend ( 'updateSearchForm' , $ form ) ; } ) ) ; if ( ! $ this -> showSearchForm || ( is_array ( $ this -> showSearchForm ) && ! in_array ( $ this -> modelClass , $ this -> showSearchForm ) ) ) { $ config -> removeComponentsByType ( GridFieldFilterHeader :: class ) ; } if ( $ this -> config ( ) -> auto_convert_dates ) { GridFieldDateFinder :: create ( $ grid_field ) -> convertDateFields ( ) ; } return $ form ; }
Add bulk editor to Edit Form
10,323
public function store ( $ key , $ data , $ lifetime = 0 ) { if ( $ lifetime != 0 ) { $ lifetime = \ time ( ) + $ lifetime ; } $ data = array ( $ lifetime , $ data ) ; $ this -> hash [ $ key ] = $ data ; if ( $ key != $ this -> catalog_key ) { $ this -> catalogKeyAdd ( $ key , $ lifetime ) ; } return true ; }
Store the cache data in memcache
10,324
public function fetch ( $ key ) { if ( ! \ array_key_exists ( $ key , $ this -> hash ) ) { return false ; } $ data = $ this -> hash [ $ key ] ; if ( $ data && ( $ data [ 0 ] == 0 || \ time ( ) <= $ data [ 0 ] ) ) { return $ data [ 1 ] ; } else { $ this -> delete ( $ key ) ; return false ; } }
Fetches the cache from memcache
10,325
public function delete ( $ key ) { $ deleted = false ; $ catalog = \ array_keys ( $ this -> getKeys ( ) ) ; foreach ( $ catalog as $ k ) { if ( $ k == $ key ) { unset ( $ this -> hash [ $ key ] ) ; if ( $ delete ) { $ this -> catalogKeyDelete ( $ k ) ; $ deleted = true ; } } } return $ deleted ; }
Deletes cache data
10,326
public function renderValue ( $ object , array $ options = [ ] ) : string { $ options = array_merge ( [ 'column' => $ this , 'object' => $ object ] , $ this -> getFormattingOptions ( ) , $ options ) ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; try { $ value = $ accessor -> getValue ( $ object , $ this -> getPropertyPath ( ) ) ; } catch ( UnexpectedTypeException $ e ) { return '' ; } return $ this -> getValueRenderer ( ) -> renderValue ( $ value , $ options ) ; }
Render column for a given result
10,327
protected function getLogPath ( $ log ) { $ dir = $ this -> log_root . '/' . $ log . '/' ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0777 , true ) ; } return $ dir ; }
Grabs the log path based on the type of log
10,328
protected function write ( $ data , $ log_type ) { return file_put_contents ( $ this -> getLogPath ( $ log_type ) . date ( 'Y_m_d' ) . '.log' , "\n\n" . \ date ( 'Y/m/d H:i:s' ) . "\t" . $ this -> agent_str . "\n" . $ data , \ FILE_APPEND ) ; }
Writes the data to file
10,329
function remove ( $ header ) { $ normalizer = new HeaderCaseNormalizer ( ) ; $ name = $ normalizer -> normalize ( $ header ) ; foreach ( $ this -> _headers as $ idx => $ header ) { if ( $ header -> getName ( ) == $ name ) unset ( $ this -> _headers [ $ idx ] ) ; } return $ this ; }
Remove a header by name
10,330
function value ( $ name , $ default = false ) { $ values = $ this -> values ( $ name ) ; return count ( $ values ) ? $ values [ 0 ] : $ default ; }
Gets a single header value
10,331
function values ( $ name ) { $ normalizer = new HeaderCaseNormalizer ( ) ; $ name = $ normalizer -> normalize ( $ name ) ; $ values = array ( ) ; foreach ( $ this -> _headers as $ header ) { if ( $ header -> getName ( ) == $ name ) { $ values [ ] = $ header -> getValue ( ) ; } } return $ values ; }
Gets an array of the values for a header
10,332
function toArray ( $ crlf = true ) { $ headers = array ( ) ; foreach ( $ this -> _headers as $ header ) { $ string = $ header -> __toString ( ) ; $ headers [ ] = $ crlf ? $ string : rtrim ( $ string ) ; } return $ headers ; }
Returns an array of the string versions of headers
10,333
public function has ( string $ key ) : bool { if ( isset ( $ this -> items [ $ key ] ) ) { return true ; } try { $ class = new \ ReflectionClass ( $ key ) ; } catch ( \ ReflectionException $ e ) { return false ; } $ classes = $ this -> reflectionTools -> getClassHierarchy ( $ class ) ; foreach ( $ classes as $ class ) { if ( $ this -> injectionPolicy -> isClassInjected ( $ class ) ) { $ this -> bind ( $ key ) ; return true ; } } return false ; }
Returns whether the container has the given key .
10,334
public function set ( string $ key , $ value ) : Container { $ this -> items [ $ key ] = $ value ; return $ this ; }
Sets a single value .
10,335
public function bind ( string $ key , $ target = null ) : BindingDefinition { return $ this -> items [ $ key ] = new BindingDefinition ( $ target ?? $ key ) ; }
Binds a key to a class name to be instantiated or to a closure to be invoked .
10,336
public function alias ( string $ key , string $ targetKey ) : AliasDefinition { return $ this -> items [ $ key ] = new AliasDefinition ( $ targetKey ) ; }
Creates an alias from one key to another .
10,337
private function addStoreToBuildQueue ( $ storeName , $ builderName , array $ options ) { if ( ! $ this -> factory -> getRegistry ( ) -> has ( $ builderName ) ) { throw new \ DomainException ( sprintf ( "Unknown builder: %s" , $ builderName ) ) ; } $ this -> buildQueue [ $ storeName ] = array ( $ builderName , $ options ) ; return $ this ; }
Queues a store to be built
10,338
private function getProjectProperties ( ) { $ r = '' ; $ projectOptions = ( array ) $ this -> xml -> xpath ( '/draggy/project' ) ; $ projectOptions = ( array ) $ projectOptions [ 0 ] ; $ this -> checkMandatoryAttributes ( 'Project' , $ projectOptions , [ 'language' , 'description' , 'orm' , 'framework' ] ) ; $ r .= 'Draggy.prototype.setLanguage(\'' . $ projectOptions [ 'language' ] . '\');' . PHP_EOL ; $ r .= 'Draggy.prototype.setDescription(\'' . str_replace ( '\'' , '\\\'' , $ projectOptions [ 'description' ] ) . '\');' . PHP_EOL ; $ r .= 'Draggy.prototype.setORM(\'' . $ projectOptions [ 'orm' ] . '\');' . PHP_EOL ; $ r .= 'Draggy.prototype.setFramework(\'' . $ projectOptions [ 'framework' ] . '\');' . PHP_EOL ; $ r .= 'Draggy.prototype.updateConfiguration();' . PHP_EOL ; return $ r ; }
Get the project properties from the saved file
10,339
private function getAutocodeProperties ( ) { $ r = '' ; $ autocode = ( array ) $ this -> xml -> xpath ( '/draggy/autocode' ) ; $ autocode = ( array ) $ autocode [ 0 ] ; $ autocodeProperties = ( array ) $ autocode [ 'properties' ] ; $ autocodeConfigurations = ( array ) $ autocode [ 'configurations' ] ; $ autocodeTemplates = ( array ) $ autocode [ 'templates' ] ; foreach ( $ autocodeProperties as $ propertyName => $ propertyValue ) { $ r .= 'Autocode.prototype.setProperty(\'' . $ propertyName . '\', true === ' . $ propertyValue . ');' . PHP_EOL ; } foreach ( $ autocodeConfigurations as $ configurationName => $ configurationValue ) { $ r .= 'Autocode.prototype.setConfiguration(\'' . $ configurationName . '\', \'' . str_replace ( '\\' , '\\\\' , $ configurationValue ) . '\');' . PHP_EOL ; } foreach ( $ autocodeTemplates as $ templateName => $ templateValue ) { $ r .= 'Autocode.prototype.setTemplate(\'' . $ templateName . '\', "' . str_replace ( '\\' , '\\\\' , $ templateValue ) . '");' . PHP_EOL ; } return $ r ; }
Get the project autocode properties from the saved file
10,340
private function getModules ( ) { $ modules = ( array ) $ this -> xml -> xpath ( '/draggy/module' ) ; $ r = '' ; foreach ( $ modules as $ module ) { $ moduleAttributes = ( array ) $ module ; $ moduleAttributes = ( array ) $ moduleAttributes [ '@attributes' ] ; $ this -> checkMandatoryAttributes ( 'Modules' , $ moduleAttributes , [ 'name' , 'left' , 'top' , 'width' , 'height' ] ) ; $ moduleName = $ moduleAttributes [ 'name' ] ; $ r .= 'var o = new Container(\'' . str_replace ( '\\' , '\\\\' , $ moduleName ) . '\');' . PHP_EOL ; $ r .= 'o.moveTo(\'' . ( $ moduleAttributes [ 'left' ] - 1 ) . 'px\',\'' . ( $ moduleAttributes [ 'top' ] - 1 ) . 'px\',\'' . $ moduleAttributes [ 'width' ] . 'px\',\'' . $ moduleAttributes [ 'height' ] . 'px\')' . PHP_EOL ; $ this -> modules [ ] = $ moduleName ; $ this -> insideClasses [ $ moduleName ] = [ ] ; $ this -> insideAbstracts [ $ moduleName ] = [ ] ; } return $ r ; }
Get the project modules
10,341
private function getInterfaces ( ) { $ r = '' ; foreach ( $ this -> modules as $ module ) { $ interfaces = ( array ) $ this -> xml -> xpath ( '/draggy/module[@name=\'' . $ module . '\']/interface' ) ; foreach ( $ interfaces as $ interface ) { $ interfaceAttributes = ( array ) $ interface ; $ interfaceAttributes = $ interfaceAttributes [ '@attributes' ] ; $ this -> checkMandatoryAttributes ( 'Interface in module ' . $ module , $ interfaceAttributes , [ 'name' ] ) ; $ className = $ interfaceAttributes [ 'name' ] ; $ this -> checkMandatoryAttributes ( 'Interface ' . $ className . ' in module ' . $ module , $ interfaceAttributes , [ 'left' , 'top' ] ) ; $ r .= 'var i = new Interface(\'' . $ interfaceAttributes [ 'name' ] . '\',\'' . str_replace ( '\\' , '\\\\' , $ module ) . '\');' . PHP_EOL ; $ r .= 'i.moveTo(\'' . ( $ interfaceAttributes [ 'left' ] ) . 'px\',\'' . ( $ interfaceAttributes [ 'top' ] ) . 'px\');' . PHP_EOL ; $ r .= $ this -> getInterfaceProperties ( $ interfaceAttributes , 'i' ) ; $ r .= 'i.setModule(Container.prototype.getContainerByName(\'' . str_replace ( '\\' , '\\\\' , $ module ) . '\').getId());' . PHP_EOL ; } } $ interfaces = ( array ) $ this -> xml -> xpath ( '/draggy/loose/interface' ) ; foreach ( $ interfaces as $ interface ) { $ interfaceAttributes = ( array ) $ interface ; $ interfaceAttributes = $ interfaceAttributes [ '@attributes' ] ; $ this -> checkMandatoryAttributes ( 'Loose interface' , $ interfaceAttributes , [ 'name' ] ) ; $ className = $ interfaceAttributes [ 'name' ] ; $ this -> checkMandatoryAttributes ( 'Loose interface ' . $ className , $ interfaceAttributes , [ 'left' , 'top' ] ) ; $ r .= 'var i = new Interface(\'' . $ className . '\');' . PHP_EOL ; $ r .= 'i.moveTo(\'' . ( $ interfaceAttributes [ 'left' ] ) . 'px\',\'' . ( $ interfaceAttributes [ 'top' ] ) . 'px\');' . PHP_EOL ; $ r .= $ this -> getInterfaceProperties ( $ interfaceAttributes , 'i' ) ; } return $ r ; }
Get the project interfaces
10,342
public function getLoaderJS ( ) { if ( $ this -> newFile ) { return '' ; } $ r = '' ; $ r .= $ this -> getProjectProperties ( ) ; $ r .= $ this -> getModules ( ) ; $ r .= $ this -> getClasses ( ) ; $ r .= $ this -> getAbstracts ( ) ; $ r .= $ this -> getInterfaces ( ) ; $ r .= $ this -> getAttributes ( ) ; $ r .= $ this -> getClassLikeAfterAttributesProperties ( ) ; $ r .= $ this -> getRelationships ( ) ; $ r .= $ this -> getAutocodeProperties ( ) ; $ r .= 'for (var i in Connectable.prototype.connectables) Connectable.prototype.connectables[i].reDraw();' . PHP_EOL ; $ r .= 'Link.prototype.reDrawLinks();' . PHP_EOL ; $ r .= 'System.prototype.runtime = true;' . PHP_EOL ; return $ r ; }
Returns all the JS code to load the project
10,343
public function toArray ( $ sheet = 0 ) { $ arr = array ( ) ; for ( $ row = 1 ; $ row <= $ this -> rowcount ( $ sheet ) ; $ row ++ ) { for ( $ col = 1 ; $ col <= $ this -> colcount ( $ sheet ) ; $ col ++ ) { $ arr [ $ row ] [ $ col ] = $ this -> val ( $ row , $ col , $ sheet ) ; } } return $ arr ; }
export to multi dimensional array
10,344
public function info ( $ row , $ col , $ type = '' , $ sheet = 0 ) { $ col = $ this -> getCol ( $ col ) ; if ( array_key_exists ( 'cellsInfo' , $ this -> sheets [ $ sheet ] ) && array_key_exists ( $ row , $ this -> sheets [ $ sheet ] [ 'cellsInfo' ] ) && array_key_exists ( $ col , $ this -> sheets [ $ sheet ] [ 'cellsInfo' ] [ $ row ] ) && array_key_exists ( $ type , $ this -> sheets [ $ sheet ] [ 'cellsInfo' ] [ $ row ] [ $ col ] ) ) { return $ this -> sheets [ $ sheet ] [ 'cellsInfo' ] [ $ row ] [ $ col ] [ $ type ] ; } return "" ; }
Gets info for a specifc cell of a specific sheet
10,345
public function mesasAbiertas ( $ mozo_id = null , $ lastAccess = null ) { $ conditions = array ( ) ; if ( ! empty ( $ mozo_id ) ) { $ conditions [ 'Mozo.id' ] = $ mozo_id ; } else { $ conditions [ 'Mozo.activo' ] = 1 ; } if ( Configure :: read ( 'Site.type' ) == SITE_TYPE_HOTEL ) { $ conditionsMesa = array ( 'Mesa.deleted' => 0 , 'Mesa.checkin >' => date ( 'Y-m-d' , strtotime ( '-1 month' ) ) , ) ; } else { $ conditionsMesa = array ( "Mesa.estado_id" => array ( MESA_ABIERTA , MESA_CERRADA , MESA_COBRADA ) , 'Mesa.deleted' => 0 , ) ; } if ( ! empty ( $ lastAccess ) ) { $ conditionsMesa [ 'Mesa.modified >=' ] = $ lastAccess ; } $ contain = $ this -> Mesa -> defaultContain ; $ contain [ 'conditions' ] = $ conditionsMesa ; unset ( $ contain [ 0 ] ) ; $ optionsCreated = array ( 'contain' => array ( 'Mesa' => $ contain ) , 'conditions' => $ conditions , ) ; $ mesasABM = $ this -> find ( 'all' , $ optionsCreated ) ; $ mozosMesa = array ( ) ; foreach ( $ mesasABM as $ abmMesas ) { $ abmMesas [ 'Mozo' ] [ 'mesas' ] = $ abmMesas [ 'Mesa' ] ; if ( ! empty ( $ lastAccess ) ) { if ( ! empty ( $ abmMesas [ 'Mesa' ] ) ) { $ mozosMesa [ 'mozos' ] [ ] = $ abmMesas [ 'Mozo' ] ; } } else { $ mozosMesa [ 'mozos' ] [ ] = $ abmMesas [ 'Mozo' ] ; } } return $ mozosMesa ; }
Para todos los mozos activos me trae sus mesas abiertas
10,346
public function mesasBorradas ( $ mozo_id = null , $ lastAccess = null ) { if ( empty ( $ lastAccess ) ) { return array ( ) ; } $ conditions = array ( ) ; if ( ! empty ( $ mozo_id ) ) { $ conditions [ 'Mozo.id' ] = $ mozo_id ; } else { $ conditions [ 'Mozo.activo' ] = 1 ; } $ conditionsMesa = array ( 'OR' => array ( array ( 'Mesa.deleted' => 1 , 'Mesa.deleted_date >=' => $ lastAccess , ) , array ( 'Mesa.estado_id' => MESA_CHECKOUT , 'Mesa.checkout >=' => $ lastAccess , ) ) ) ; $ contain = $ this -> Mesa -> defaultContain ; $ contain [ 'conditions' ] = $ conditionsMesa ; unset ( $ contain [ 0 ] ) ; $ optionsCreated = array ( 'contain' => array ( 'Mesa' => $ contain ) , 'conditions' => $ conditions , ) ; $ mesasABM = $ this -> find ( 'all' , $ optionsCreated ) ; $ mozosMesa = array ( ) ; foreach ( $ mesasABM as $ abmMesas ) { $ abmMesas [ 'Mozo' ] [ 'mesas' ] = $ abmMesas [ 'Mesa' ] ; if ( ! empty ( $ abmMesas [ 'Mesa' ] ) ) { $ mozosMesa [ 'mozos' ] [ ] = $ abmMesas [ 'Mozo' ] ; } } return $ mozosMesa ; }
Para todos los mozos activos me trae sus mesas eliminadas entre cada actualizacion de datos
10,347
protected function addInheritedFromTag ( \ DOMElement $ docBlock , $ descriptor ) { $ parentElement = $ descriptor -> getInheritedElement ( ) ; if ( ! $ parentElement instanceof $ descriptor ) { return ; } $ child = new \ DOMElement ( 'tag' ) ; $ docBlock -> appendChild ( $ child ) ; $ rule = $ this -> router -> match ( $ parentElement ) ; $ child -> setAttribute ( 'name' , 'inherited_from' ) ; $ child -> setAttribute ( 'description' , $ parentElement -> getFullyQualifiedStructuralElementName ( ) ) ; $ child -> setAttribute ( 'refers' , $ parentElement -> getFullyQualifiedStructuralElementName ( ) ) ; $ child -> setAttribute ( 'link' , $ rule ? $ rule -> generate ( $ parentElement ) : '' ) ; }
Adds the inherited_from tag when a Descriptor inherits from another Descriptor .
10,348
protected function _isuuidversion ( $ in , $ strict = true ) { if ( false !== $ strict ) { $ in = strtolower ( $ in ) ; $ alphanums = "a-f" ; } else { $ alphanums = "a-z" ; } if ( ! preg_match ( "/^[0-9$alphanums]{8}-[0-9$alphanums]{4}-(?<version>[0-9$alphanums]{1})[0-9$alphanums]{3}-[0-9$alphanums]{4}-[0-9$alphanums]{12}$/i" , $ in , $ matches ) ) return false ; $ version = $ matches [ 'version' ] ; if ( false !== $ strict && ( empty ( $ version ) || ! $ this -> _isint ( $ version ) || intval ( $ version ) < 1 || intval ( $ version ) > 6 ) ) return false ; return $ version ; }
returns UUID version or FALSE if no UUID format
10,349
protected function _ip2long ( $ ip , $ getVersion = TRUE ) { $ version = $ this -> _isip ( $ ip ) ; if ( $ getVersion === FALSE && $ version === FALSE ) return FALSE ; if ( $ getVersion === FALSE && $ version === 'ipv4' ) return $ this -> _ip2long_v4 ( $ ip ) ; if ( $ getVersion === FALSE && $ version === 'ipv6' ) return $ this -> _ip2long_v6 ( $ ip ) ; if ( $ getVersion === TRUE && $ version === FALSE ) return array ( 'version' => FALSE , 'int' => FALSE ) ; if ( $ getVersion === TRUE && $ version === 'ipv4' ) return array ( 'version' => $ version , 'int' => $ this -> _ip2long_v4 ( $ ip ) ) ; if ( $ getVersion === TRUE && $ version === 'ipv6' ) return array ( 'version' => $ version , 'int' => $ this -> _ip2long_v6 ( $ ip ) ) ; return trigger_error ( 'inalid argument getVersion in ipFormat::ip2long()!' , E_USER_ERROR ) ; }
IP Addresses ... - php . net
10,350
public static function save ( $ url , $ post_ID , $ featured = false ) { $ url = filter_var ( $ url , FILTER_VALIDATE_URL ) ; if ( false === $ url || false === get_post_status ( $ post_ID ) ) { return false ; } $ filename = basename ( $ url ) ; $ filepath = self :: upload ( $ url , $ filename ) ; $ attachment = [ 'post_mime_type' => wp_check_filetype ( $ filename , null ) [ 'type' ] , 'post_title' => sanitize_file_name ( $ filename ) , 'post_content' => '' , 'post_status' => 'inherit' , ] ; $ attach_id = wp_insert_attachment ( $ attachment , $ filepath , $ post_ID ) ; require_once ( ABSPATH . 'wp-admin/includes/image.php' ) ; $ attach_data = wp_generate_attachment_metadata ( $ attach_id , $ filepath ) ; wp_update_attachment_metadata ( $ attach_id , $ attach_data ) ; if ( $ featured ) { set_post_thumbnail ( $ post_ID , $ attach_id ) ; } return wp_get_attachment_url ( $ attach_id ) ; }
Save image and associate it with a specific post .
10,351
public static function upload ( $ url , $ filename ) { $ dir = wp_upload_dir ( ) ; if ( ! isset ( $ dir [ 'path' ] , $ dir [ 'basedir' ] ) ) { return false ; } $ path = wp_mkdir_p ( $ dir [ 'path' ] ) ? $ dir [ 'path' ] : $ dir [ 'basedir' ] ; $ path = rtrim ( $ path , '/' ) . '/' ; $ image_data = @ file_get_contents ( $ url ) ; if ( $ image_data ) { $ state = @ file_put_contents ( $ path . $ filename , $ image_data ) ; } return ( isset ( $ state ) && $ state ) ? $ path . $ filename : false ; }
Upload image to WordPress upload directory .
10,352
public static function delete_all_attachment ( $ post_ID , $ force = false ) { if ( get_post_status ( $ post_ID ) === false ) { return false ; } $ counter = 0 ; $ attachments = get_posts ( [ 'post_type' => 'attachment' , 'posts_per_page' => 100 , 'post_status' => 'any' , 'post_mime_type' => 'image/jpeg, image/png, image/gif' , 'post_parent' => $ post_ID , ] ) ; foreach ( $ attachments as $ attachment ) { if ( wp_delete_attachment ( $ attachment -> ID , $ force ) !== false ) { $ counter ++ ; } } return $ counter ; }
Deletes an attachment and all of its derivatives .
10,353
public function delete ( $ id ) { $ this -> fireEvent ( 'deleting' , [ $ id ] ) ; $ deleted = $ this -> model -> destroy ( $ id ) ; $ this -> fireEvent ( 'deleted' , [ $ id , $ deleted ] ) ; return $ deleted ; }
Find and delete a resource by ID .
10,354
public function store ( $ request ) { $ this -> fireEvent ( 'creating' , [ $ request ] ) ; $ created = $ this -> model -> create ( $ request ) ; $ this -> fireEvent ( 'created' , [ $ created ] ) ; return $ created ; }
Store a new resource .
10,355
public function with ( $ relationships ) { if ( ! is_array ( $ relationships ) ) { $ relationships = explode ( ', ' , $ relationships ) ; } if ( ! in_array ( $ relationships , $ this -> withRelationships ) ) { foreach ( $ relationships as $ with ) { $ this -> withRelationships [ ] = $ with ; } } return $ this ; }
Assign eager loading relationships .
10,356
protected function newQuery ( ) { $ query = $ this -> model -> newQuery ( ) ; foreach ( $ this -> withRelationships as $ relationship ) { $ query -> with ( $ relationship ) ; } return $ query ; }
Create a new newQuery instance with eager loaded relationships .
10,357
protected function fireEvent ( $ event , $ data ) { $ fireableEvent = isset ( $ this -> fireEvents [ $ event ] ) ? $ this -> fireEvents [ $ event ] : null ; if ( ! is_null ( $ fireableEvent ) ) { return $ this -> event -> fire ( $ fireableEvent , $ data ) ; } return null ; }
Fire off an event if one is defined .
10,358
private function wait ( ) { do { if ( empty ( $ this -> queries ) ) { break ; } $ links = $ errors = $ reject = [ ] ; foreach ( $ this -> queries as $ link ) { $ links [ ] = $ errors [ ] = $ reject [ ] = $ link [ 'l' ] ; } if ( ! mysqli_poll ( $ links , $ errors , $ reject , self :: $ sleep , self :: $ usleep ) ) { continue ; } foreach ( $ this -> queries as $ l => $ link ) { $ promise = $ this -> getPromise ( $ link ) ; $ cnx = $ this -> getConnection ( $ link ) ; try { $ result = $ cnx -> reap_async_query ( ) ; if ( $ result instanceof mysqli_result ) { $ promise -> resolve ( $ result ) ; } else { $ errNo = mysqli_errno ( $ cnx ) ; $ errStr = mysqli_error ( $ cnx ) ; if ( 0 !== $ errNo || 0 !== strlen ( $ errStr ) ) { throw new mysqli_sql_exception ( $ errStr , $ errNo ) ; } else { $ promise -> resolve ( $ cnx ) ; } } } catch ( mysqli_sql_exception $ e ) { $ promise -> reject ( $ e ) ; } $ this -> processed ++ ; unset ( $ this -> queries [ $ l ] ) ; } } while ( $ this -> processed < count ( $ this -> queries ) ) ; $ this -> reset ( ) ; }
Wait for pending queries to complete .
10,359
public function makeRoot ( $ runValidation = true , $ attributes = null ) { $ this -> operation = self :: OPERATION_MAKE_ROOT ; return $ this -> owner -> save ( $ runValidation , $ attributes ) ; }
Creates the root node if the active record is new or moves it as the root node .
10,360
public function prependTo ( $ node , $ runValidation = true , $ attributes = null ) { $ this -> operation = self :: OPERATION_PREPEND_TO ; $ this -> node = $ node ; return $ this -> owner -> save ( $ runValidation , $ attributes ) ; }
Creates a node as the first child of the target node if the active record is new or moves it as the first child of the target node .
10,361
public function appendTo ( $ node , $ runValidation = true , $ attributes = null ) { $ this -> operation = self :: OPERATION_APPEND_TO ; $ this -> node = $ node ; return $ this -> owner -> save ( $ runValidation , $ attributes ) ; }
Creates a node as the last child of the target node if the active record is new or moves it as the last child of the target node .
10,362
public function insertBefore ( $ node , $ runValidation = true , $ attributes = null ) { $ this -> operation = self :: OPERATION_INSERT_BEFORE ; $ this -> node = $ node ; return $ this -> owner -> save ( $ runValidation , $ attributes ) ; }
Creates a node as the previous sibling of the target node if the active record is new or moves it as the previous sibling of the target node .
10,363
public function insertAfter ( $ node , $ runValidation = true , $ attributes = null ) { $ this -> operation = self :: OPERATION_INSERT_AFTER ; $ this -> node = $ node ; return $ this -> owner -> save ( $ runValidation , $ attributes ) ; }
Creates a node as the next sibling of the target node if the active record is new or moves it as the next sibling of the target node .
10,364
public function parents ( $ depth = null ) { $ condition = [ 'and' , [ $ this -> leftAttribute => [ '$lt' => $ this -> owner -> getAttribute ( $ this -> leftAttribute ) ] ] , [ $ this -> rightAttribute => [ '$gt' => $ this -> owner -> getAttribute ( $ this -> rightAttribute ) ] ] , ] ; if ( $ depth !== null ) { $ condition [ ] = [ $ this -> depthAttribute => [ '$gte' => $ this -> owner -> getAttribute ( $ this -> depthAttribute ) - $ depth ] ] ; } $ this -> applyTreeAttributeCondition ( $ condition ) ; return $ this -> owner -> find ( ) -> andWhere ( $ condition ) -> addOrderBy ( [ $ this -> leftAttribute => SORT_ASC ] ) ; }
Gets the parents of the node .
10,365
public function leaves ( ) { $ condition = [ 'and' , [ $ this -> leftAttribute => [ '$gt' => $ this -> owner -> getAttribute ( $ this -> leftAttribute ) ] ] , [ $ this -> rightAttribute => [ '$lt' => $ this -> owner -> getAttribute ( $ this -> rightAttribute ) ] ] , [ '$where' => "this.{$this->rightAttribute} = this.{$this->leftAttribute} + 1" ] ] ; $ this -> applyTreeAttributeCondition ( $ condition ) ; return $ this -> owner -> find ( ) -> andWhere ( $ condition ) -> addOrderBy ( [ $ this -> leftAttribute => SORT_ASC ] ) ; }
Gets the leaves of the node .
10,366
public function prev ( ) { $ condition = [ $ this -> rightAttribute => $ this -> owner -> getAttribute ( $ this -> leftAttribute ) - 1 ] ; $ this -> applyTreeAttributeCondition ( $ condition ) ; return $ this -> owner -> find ( ) -> andWhere ( $ condition ) ; }
Gets the previous sibling of the node .
10,367
public function isChildOf ( $ node ) { $ result = $ this -> owner -> getAttribute ( $ this -> leftAttribute ) > $ node -> getAttribute ( $ this -> leftAttribute ) && $ this -> owner -> getAttribute ( $ this -> rightAttribute ) < $ node -> getAttribute ( $ this -> rightAttribute ) ; if ( $ result && $ this -> treeAttribute !== false ) { $ result = $ this -> owner -> getAttribute ( $ this -> treeAttribute ) === $ node -> getAttribute ( $ this -> treeAttribute ) ; } return $ result ; }
Determines whether the node is child of the parent node .
10,368
protected function fetchObject ( $ filename ) { $ data = $ this -> backend -> fetch ( $ filename ) ; return ( is_object ( $ data ) ) ? $ data : false ; }
Fetches the object from the cache .
10,369
public function store ( $ id , $ data , $ attributes = array ( ) ) { $ filename = $ this -> properties [ 'location' ] . $ this -> generateIdentifier ( $ id , $ attributes ) ; if ( isset ( $ this -> registry [ $ filename ] ) ) { unset ( $ this -> registry [ $ filename ] ) ; } if ( file_exists ( $ filename ) ) { if ( unlink ( $ filename ) === false ) { throw new ezcBaseFilePermissionException ( $ filename , ezcBaseFileException :: WRITE , 'Could not delete existing cache file.' ) ; } } $ this -> backend -> delete ( $ filename ) ; $ dataStr = $ this -> prepareData ( $ data ) ; $ dirname = dirname ( $ filename ) ; if ( ! is_dir ( $ dirname ) && ! mkdir ( $ dirname , 0777 , true ) ) { throw new ezcBaseFilePermissionException ( $ dirname , ezcBaseFileException :: WRITE , 'Could not create directory to store cache file.' ) ; } if ( @ file_put_contents ( $ filename , $ dataStr ) !== strlen ( $ dataStr ) ) { throw new ezcBaseFileIoException ( $ filename , ezcBaseFileException :: WRITE , 'Could not write data to cache file.' ) ; } if ( ezcBaseFeatures :: os ( ) !== "Windows" ) { chmod ( $ filename , $ this -> options -> permissions ) ; } $ dataObj = $ this -> prepareData ( $ data , true ) ; $ dataObj -> mtime = @ filemtime ( $ filename ) ; $ dataObj -> atime = time ( ) ; $ this -> registerIdentifier ( $ id , $ attributes , $ filename ) ; if ( ! $ this -> backend -> store ( $ filename , $ dataObj , $ this -> properties [ 'options' ] [ 'ttl' ] ) ) { throw new ezcCacheApcException ( "APC store failed." ) ; } return $ id ; }
Stores data to the cache storage .
10,370
protected function handleBasePath ( InputInterface $ input , OutputInterface $ output ) { $ path = realpath ( $ input -> getOption ( 'basepath' ) ) ; $ this -> writeln ( $ output , 'Joomla! installation expected in ' . $ path , OutputInterface :: VERBOSITY_DEBUG ) ; return $ path ; }
Read the base path from the options
10,371
private function ffprobe ( $ binary = null ) { if ( is_null ( $ binary ) ) { $ binary = static :: $ ffprobe ; } if ( ! isset ( $ this -> metadata ) ) { $ cmd = "{$binary} -v quiet -print_format json -show_format -show_streams {$this->file}" ; exec ( $ cmd , $ output , $ returnvalue ) ; $ json = json_decode ( implode ( "\n" , $ output ) , true ) ; if ( ! is_array ( $ json ) ) { $ json = false ; } $ this -> metadata = $ json ; if ( $ this -> ffprobeHasFormat ( ) ) { $ this -> formats = array_filter ( explode ( "," , $ json [ 'format' ] [ 'format_name' ] ) ) ; } } }
Runs an ffprobe on the file or returns cached information .
10,372
private function ffprobeFormat ( $ format ) { $ this -> ffprobe ( ) ; if ( count ( $ this -> formats ) > 0 ) { $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( in_array ( $ arg , $ this -> formats ) ) { return true ; } } return null ; } return false ; }
Checks requested format against what formats ffprobe returned .
10,373
private function ffprobeHasVideo ( ) { if ( isset ( $ this -> metadata [ 'streams' ] ) ) { foreach ( $ this -> metadata [ 'streams' ] as $ streamIndex => $ stream ) { if ( isset ( $ stream [ 'codec_type' ] ) && $ stream [ 'codec_type' ] === "video" && $ stream [ 'disposition' ] [ 'attached_pic' ] !== 1 ) { return $ streamIndex ; } } } return false ; }
Check our metadata for a video stream .
10,374
private function ffprobeHasAudio ( ) { if ( isset ( $ this -> metadata [ 'streams' ] ) ) { foreach ( $ this -> metadata [ 'streams' ] as $ streamIndex => $ stream ) { if ( isset ( $ stream [ 'codec_type' ] ) && $ stream [ 'codec_type' ] === "audio" ) { return $ streamIndex ; } } } return false ; }
Check our metadata for an audio stream .
10,375
protected function lead3GP ( ) { $ lead = $ this -> ffprobeFormat ( "3gp" ) ; if ( $ lead === true ) { return $ this -> closeCase ( "3gp" , "video/3gp" , $ this -> metadata ) ; } return null ; }
Checks if the file is a 3GP .
10,376
protected function leadAAC ( ) { $ lead = $ this -> ffprobeFormat ( "aac" ) ; if ( $ lead === true ) { return $ this -> closeCase ( "aac" , "audio/aac" , $ this -> metadata ) ; } return null ; }
Checks if the file is a AAC
10,377
protected function leadFLV ( ) { $ lead = $ this -> ffprobeFormat ( "flv" ) ; if ( $ lead === true ) { return $ this -> closeCase ( "flv" , "video/x-flv" , $ this -> metadata ) ; } return null ; }
Checks if the file is a FLV .
10,378
protected function leadMP3 ( ) { $ lead = $ this -> ffprobeFormat ( "mp1" , "mp2" , "mp3" , "mpg" , "mpeg" ) ; if ( $ lead === true ) { return $ this -> closeCase ( "mp3" , "audio/mpeg" , $ this -> metadata ) ; } return null ; }
Checks if the file is a MP3
10,379
protected function leadMP4 ( ) { $ lead = $ this -> ffprobeFormat ( "mp4" , "m4a" ) ; if ( $ lead === true ) { if ( $ this -> ffprobeHasVideo ( ) !== false ) { return $ this -> closeCase ( "mp4" , "video/mp4" , $ this -> metadata ) ; } else if ( $ this -> ffprobeHasAudio ( ) !== false ) { return $ this -> closeCase ( "mp4" , "audio/mp4" , $ this -> metadata ) ; } else { return false ; } } return null ; }
Checks if the file is a MP4 .
10,380
protected function leadMKA ( ) { $ lead = $ this -> ffprobeFormat ( "matroska" , "webm" ) ; if ( $ lead === true ) { if ( $ this -> ffprobeHasAudio ( ) !== false ) { return $ this -> closeCase ( "mka" , "audio/x-matroska" , $ this -> metadata ) ; } else { return false ; } } return null ; }
Checks if the file is a MKA .
10,381
protected function leadMKV ( ) { $ lead = $ this -> ffprobeFormat ( "matroska" , "webm" ) ; if ( $ lead === true ) { if ( $ this -> ffprobeHasVideo ( ) !== false ) { return $ this -> closeCase ( "mkv" , "video/x-matroska" , $ this -> metadata ) ; } else { return false ; } } return null ; }
Checks if the file is a MKV .
10,382
protected function leadWAV ( ) { $ lead = $ this -> ffprobeFormat ( "wav" ) ; if ( $ lead === true ) { return $ this -> closeCase ( "wav" , "audio/wave" , $ this -> metadata ) ; } return null ; }
Checks if the file is a WAV
10,383
public static function on ( ) { static :: fetchBinaries ( ) ; return ( empty ( static :: $ ffmpeg ) ? false : true ) && ( empty ( static :: $ ffprobe ) ? false : true ) ; }
Can the system run this Detective?
10,384
public function addMessage ( $ message , $ type ) { if ( ! is_string ( $ message ) ) { throw new \ InvalidArgumentException ( 'Message must be a string' ) ; } if ( ! $ message ) { throw new \ InvalidArgumentException ( 'Message can\'t be empty' ) ; } if ( ! is_string ( $ type ) ) { throw new \ InvalidArgumentException ( 'Type must be a string' ) ; } if ( ! $ type ) { throw new \ InvalidArgumentException ( 'Type can\'t be empty' ) ; } $ this -> messages [ $ type ] [ ] = $ message ; return $ this ; }
Add a message to this message bag .
10,385
public static function write ( $ message , $ nl = true , $ quit = false ) { if ( \ is_array ( $ message ) ) { $ message = implode ( $ nl ? PHP_EOL : '' , $ message ) ; } self :: stdout ( self :: renderColor ( $ message ) , $ nl , $ quit ) ; }
write message to console
10,386
public function invalidate ( $ namespaceId ) { $ namespace = $ this -> fetch ( $ namespaceId ) ; if ( false === $ namespace ) { return false ; } $ newNamespace = rand ( 0 , 10000 ) ; while ( $ namespace === $ newNamespace ) { $ newNamespace = rand ( 0 , 10000 ) ; } return $ this -> save ( $ namespaceId , $ namespaceId . '_' . $ newNamespace . '_' , 0 ) ; }
Invalidate a namespace .
10,387
public function findOrMakeAssetsFolder ( $ url , $ doWrite = true ) { $ owner = $ this -> owner ; $ dir = Folder :: find_or_make ( $ url ) ; $ owner -> AssetsFolderID = $ dir -> ID ; if ( $ doWrite ) { $ owner -> write ( ) ; } if ( $ owner -> ClassName == 'Subsite' ) { $ dir -> SubsiteID = $ owner -> ID ; $ dir -> write ( ) ; } return $ dir ; }
Find or make assets folder called from onBeforeWrite .
10,388
public function getAssetsFolderDirName ( ) { if ( $ this -> owner -> getField ( 'AssetsFolderID' ) != 0 ) { $ dirObj = $ this -> owner -> AssetsFolder ( ) ; $ dirName = str_replace ( 'assets/' , '' , $ dirObj -> Filename ) ; return $ dirName ; } }
Name of the associated assets folder .
10,389
protected function assignDefaultValues ( ) { foreach ( $ this -> defaultValues as $ key => $ value ) { $ this -> model [ $ key ] = $ value ; } return true ; }
Assign default values to model .
10,390
protected function getPackageVersions ( $ id ) { $ localPackage = $ this -> get ( 'package.repository' ) -> findOneById ( $ id ) ; $ remotePackage = $ this -> get ( 'package.helper' ) -> getPackage ( $ localPackage -> getFullName ( ) ) ; $ versions = $ remotePackage -> getVersions ( ) ; $ result = [ ] ; foreach ( $ versions as $ version ) { $ this -> getPackageInfo ( $ version , $ result ) ; } return $ result ; }
Returns version information for package
10,391
protected function getPackageInfo ( Version $ version , & $ result ) { $ date = new \ DateTime ( $ version -> getTime ( ) ) ; $ packageVersion = $ version -> getVersion ( ) ; if ( $ packageVersion === PackageHelperInterface :: DEFAULT_BRANCH_VERSION ) { $ result [ $ packageVersion ] = [ 'version' => $ packageVersion , 'date' => $ date -> format ( 'Y-m-d H:i:s' ) , 'authors' => $ version -> getAuthors ( ) , 'description' => $ version -> getDescription ( ) , 'homepage' => $ version -> getHomepage ( ) , 'license' => $ version -> getLicense ( ) , ] ; } }
Adds information about single version to result array
10,392
public static function create ( $ password ) { if ( function_exists ( 'random_bytes' ) ) { $ salt = random_bytes ( self :: $ salt_byte_size ) ; } else if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ salt = openssl_random_pseudo_bytes ( self :: $ salt_byte_size ) ; } else if ( function_exists ( 'mcrypt_create_iv' ) ) { $ salt = mcrypt_create_iv ( self :: $ salt_byte_size , MCRYPT_DEV_URANDOM ) ; } else { throw ( new Exception ( "You must have random_bytes, openssl_random_pseudo_bytes or mcrypt_create_iv function available to create salt" ) ) ; } $ salt = base64_encode ( $ salt ) ; return self :: $ hash_algorithm . ":" . self :: $ iterations . ":" . $ salt . ":" . base64_encode ( self :: calculate ( self :: $ hash_algorithm , $ password , $ salt , self :: $ iterations , self :: $ hash_byte_size , true ) ) ; }
Creates the password hash that you would store for comparison . Make sure to check the size of the output when creating database tables to store this hash . The defaults produce a 94 char string . Changing the public static properties may affect the size of the hash returned .
10,393
public static function validate ( $ password , $ hash ) { $ params = explode ( ":" , $ hash ) ; if ( count ( $ params ) < 4 ) return false ; $ pbkdf2 = base64_decode ( $ params [ self :: $ hash_pbkdf2_index ] ) ; return self :: slowEquals ( $ pbkdf2 , self :: calculate ( $ params [ self :: $ hash_alogrithm_index ] , $ password , $ params [ self :: $ hash_salt_index ] , ( int ) $ params [ self :: $ hash_iteration_index ] , strlen ( $ pbkdf2 ) , true ) ) ; }
Validates a password against its precalculated hash
10,394
public static function get ( $ name = null , $ default = null ) { $ queryParams = app ( ) -> request -> getQueryParams ( ) ; if ( is_null ( $ name ) ) { return $ queryParams ; } elseif ( isset ( $ queryParams [ $ name ] ) ) { return $ queryParams [ $ name ] ; } return $ default ; }
Retrieves GET parameter .
10,395
public static function delete ( $ name = null , $ default = null ) { $ parsedBody = app ( ) -> request -> getParsedBody ( ) ; if ( is_null ( $ name ) ) { return $ parsedBody ; } if ( isset ( $ parsedBody [ $ name ] ) ) { return $ parsedBody [ $ name ] ; } return $ default ; }
Retrieves DELETE parameter .
10,396
public static function files ( $ name = null ) { $ files = app ( ) -> request -> getUploadedFiles ( ) ; if ( is_null ( $ name ) ) { return $ files ; } if ( isset ( $ files [ $ name ] ) ) { return $ files [ $ name ] ; } return null ; }
Retrieves Uploaded Files .
10,397
protected function getStatsd ( InputInterface $ input ) { if ( null === $ this -> statsd ) { $ this -> statsdConnection = new UdpSocket ( $ input -> getOption ( 'statsd-host' ) , $ input -> getOption ( 'statsd-port' ) ) ; $ this -> statsd = new Client ( $ this -> statsdConnection , $ input -> getOption ( 'statsd-namespace' ) ) ; } return $ this -> statsd ; }
Statically cache statsd client and return a statsd client
10,398
protected function getGauges ( $ config ) { if ( null === $ this -> gauges ) { $ this -> gauges = array ( ) ; foreach ( $ config as $ path => $ details ) { $ className = $ details [ 'class' ] ; if ( class_exists ( $ className ) ) { $ reflection = new \ ReflectionClass ( $ className ) ; if ( $ reflection -> getConstructor ( ) ) { $ this -> gauges [ $ path ] = $ reflection -> newInstanceArgs ( $ details [ 'arguments' ] ? $ details [ 'arguments' ] : array ( ) ) ; } else { $ this -> gauges [ $ path ] = $ reflection -> newInstance ( ) ; } } else { throw new \ RuntimeException ( sprintf ( 'Class does not exists %s' ) , $ className ) ; } } if ( empty ( $ this -> gauges ) ) { throw new \ RuntimeException ( sprintf ( 'No gauges found for provided string %s' , $ input -> getArgument ( 'gauges-class' ) ) ) ; } } return $ this -> gauges ; }
Instantiate selected gauges
10,399
public function actionCheckname ( ) { $ request = \ Yii :: $ app -> request ; if ( $ request -> getIsOptions ( ) ) { return $ this -> ResponseOptions ( $ this -> verbs ( ) [ 'checkname' ] ) ; } $ model = new BizRule ( null ) ; $ mo = $ model -> find ( Yii :: $ app -> request -> post ( ) [ 'BizRule' ] [ 'name' ] ) ; if ( $ mo == null ) { return [ 'message' => true ] ; } else { return [ 'message' => false ] ; } }
check is a new item