idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
8,100
public static function clearInstancePool ( $ and_clear_all_references = false ) { if ( $ and_clear_all_references ) { foreach ( RemoteAppPeer :: $ instances as $ instance ) { $ instance -> clearAllReferences ( true ) ; } } RemoteAppPeer :: $ instances = array ( ) ; }
Clear the instance pool .
8,101
protected function getParamKeyByExpr ( ExprInterface $ expr ) { return str_replace ( '.' , '' , $ expr -> getField ( ) ) . ucfirst ( $ expr -> getExpression ( ) ) . uniqid ( ) ; }
Get the parameter key that is used by doctrine to put the query parameter identifier .
8,102
public function addImageUrl ( $ imageUrl ) { if ( ! in_array ( $ imageUrl , $ this -> imageUrls ) ) { array_push ( $ this -> imageUrls , $ imageUrl ) ; } return $ this ; }
Add an Image Url to preload
8,103
public function toHtml ( $ context = null ) : string { return wp_kses ( $ this -> unsafeRender ( $ context ) , $ this -> allowedHtml ) ; }
Convert the view to safe HTML .
8,104
protected function generateTranslations ( $ bundle , $ entity , $ metadata , $ forceOverwrite ) { try { $ this -> getTranslationsGenerator ( $ bundle ) -> generate ( $ bundle , $ entity , $ metadata [ 0 ] , $ forceOverwrite ) ; } catch ( \ RuntimeException $ e ) { } }
Tries to generate translations if they don t exist yet and if we need write operations on entities .
8,105
public function createMethod ( $ name , $ params = array ( ) , $ body = NULL , $ modifiers = 256 ) { $ method = $ this -> class -> createMethod ( $ name , $ params , $ body , $ modifiers ) ; $ method -> setClassBuilder ( $ this ) ; return $ method ; }
Erstellt eine neue Methode
8,106
public function getRequest ( array $ requestPostData ) { $ requestProperties = array ( 'username' => $ requestPostData [ 1 ] , 'password' => $ requestPostData [ 2 ] , 'title' => $ requestPostData [ 3 ] [ 'title' ] , 'description' => $ requestPostData [ 3 ] [ 'description' ] , 'keywords' => $ requestPostData [ 3 ] [ 'mt_keywords' ] , 'status' => $ requestPostData [ 3 ] [ 'post_status' ] , ) ; return new Request ( $ requestProperties ) ; }
Creates an IFTTT Request from XML RPC post data
8,107
public static function getValue ( $ name ) { if ( array_key_exists ( $ name , $ _GET ) ) { return $ _GET [ $ name ] ; } if ( array_key_exists ( $ name , $ _POST ) ) { return $ _POST [ $ name ] ; } return null ; }
Get the submitted form value
8,108
public function toNanos ( $ d ) { $ v = $ this -> getValue ( ) ; return $ this -> x ( $ d , $ this -> { 'c' . $ v } / $ this -> c0 , PHP_INT_MAX / ( $ this -> { 'c' . $ v } / $ this -> c0 ) ) ; }
Convert to nanos
8,109
public function toMicros ( $ d ) { $ v = $ this -> getValue ( ) ; if ( $ v < self :: MICROSECONDS ) { return $ d / ( $ this -> c1 / $ this -> c0 ) ; } else { return $ this -> x ( $ d , $ this -> { 'c' . $ v } / $ this -> c1 , PHP_INT_MAX / ( $ this -> { 'c' . $ v } ) / $ this -> c1 ) ; } }
Convert to micros
8,110
public function toMillis ( $ d ) { $ v = $ this -> getValue ( ) ; if ( $ v < self :: MILLISECONDS ) { return $ d / ( $ this -> c2 / $ this -> { 'c' . $ v } ) ; } else { return $ this -> x ( $ d , $ this -> { 'c' . $ v } / $ this -> c2 , PHP_INT_MAX / ( $ this -> { 'c' . $ v } / $ this -> c2 ) ) ; } }
Convert to millies
8,111
public function toSeconds ( $ d ) { $ v = $ this -> getValue ( ) ; if ( $ v < self :: SECONDS ) { return $ d / ( $ this -> c3 / $ this -> { 'c' . $ v } ) ; } else { return $ this -> x ( $ d , $ this -> { 'c' . $ v } / $ this -> c3 , PHP_INT_MAX / ( $ this -> { 'c' . $ v } / $ this -> c3 ) ) ; } }
Convert to seconds
8,112
public function toMinutes ( $ d ) { $ v = $ this -> getValue ( ) ; if ( $ v < self :: MINUTES ) { return $ d / ( $ this -> c4 / $ this -> { 'c' . $ v } ) ; } else { return $ this -> x ( $ d , $ this -> { 'c' . $ v } / $ this -> c4 , PHP_INT_MAX / ( $ this -> { 'c' . $ v } / $ this -> c4 ) ) ; } }
Convert to minutes
8,113
public function toHours ( $ d ) { $ v = $ this -> getValue ( ) ; if ( $ v < self :: HOURS ) { return $ d / ( $ this -> c5 / $ this -> { 'c' . $ v } ) ; } else { return $ this -> x ( $ d , $ this -> { 'c' . $ v } / $ this -> c5 , PHP_INT_MAX / ( $ this -> { 'c' . $ v } / $ this -> c5 ) ) ; } }
Convert to hours
8,114
public function toDays ( $ d ) { $ v = $ this -> getValue ( ) ; return $ d / ( $ this -> c6 / $ this -> { 'c' . $ v } ) ; }
Convert to days
8,115
public function convert ( $ sourceDuration , TimeUnit $ sourceUnit ) { switch ( $ this -> getValue ( ) ) { case self :: NANOSECONDS : return $ sourceUnit -> toNanos ( $ sourceDuration ) ; case self :: MICROSECONDS : return $ sourceUnit -> toMicros ( $ sourceDuration ) ; case self :: MILLISECONDS : return $ sourceUnit -> toMillis ( $ sourceDuration ) ; case self :: SECONDS : return $ sourceUnit -> toSeconds ( $ sourceDuration ) ; case self :: MINUTES ; return $ sourceUnit -> toMinutes ( $ sourceDuration ) ; case self :: HOURS ; return $ sourceUnit -> toHours ( $ sourceDuration ) ; case self :: DAYS : return $ sourceUnit -> toDays ( $ sourceDuration ) ; } }
Convert the given time duration in the given unit to this unit . Conversions from finer to coarser granularities truncate so lose precision . For example converting 999 milliseconds to seconds results in 0 . Conversions from coarser to finer granularities with arguments that would numerically overflow saturate to - PHP_INT_MAX - 1 if negative or PHP_INT_MAX if positive .
8,116
private function x ( $ d , $ m , $ over ) { if ( $ d > $ over ) { return PHP_INT_MAX ; } if ( $ d < - $ over ) { return - PHP_INT_MAX - 1 ; } return $ d * $ m ; }
Scale d by m checking for overflow . This has a short name to make code more readable .
8,117
public function Link ( ) { $ link = '' ; switch ( $ this -> type ) { case 'Internal' : if ( $ this -> internal && ( $ page = SiteTree :: get ( ) -> byID ( $ this -> internal ) ) ) { $ link = $ page -> Link ( ) ; } break ; case 'External' : $ link = $ this -> external ; break ; case 'Email' : $ link = $ this -> email ? 'mailto:' . $ this -> email : '' ; break ; case 'File' : if ( $ this -> file ) { $ link = File :: get ( ) -> byID ( $ this -> file ) -> Filename ; } break ; case 'DataObject' : if ( $ do = $ this -> getDO ( ) ) { $ link = $ do -> Link ( ) ; } break ; } if ( $ this -> extra ) { if ( strpos ( $ this -> extra , '=' !== false && strpos ( $ this -> extra , '?' === false ) ) ) { $ link .= '?' ; } $ link .= $ this -> extra ; } if ( $ this -> anchor ) { $ link .= '#' . $ this -> anchor ; } return $ link ; }
Determines the link by the type and what is set
8,118
public function getDO ( ) { if ( ! empty ( $ this -> dataObject ) ) { list ( $ className , $ ID ) = explode ( '-' , $ this -> dataObject ) ; return DataList :: create ( $ className ) -> byID ( $ ID ) ; } return null ; }
Get the DataObject instance
8,119
public function addParentLocation ( $ parentLocation ) { $ locationObject = $ this -> convertToLocationObject ( $ parentLocation ) ; if ( ! isset ( $ locationObject -> data [ 'parent_location_id' ] ) || ( int ) $ locationObject -> data [ 'parent_location_id' ] < 1 ) { throw new InvalidDataStructureException ( 'Parent location id must be an integer of 2 or above.' ) ; } if ( ! isset ( $ locationObject -> data [ 'content_id' ] ) ) { if ( $ this -> getProperty ( 'id' ) ) { $ locationObject -> data [ 'content_id' ] = $ this -> getProperty ( 'id' ) ; } } $ this -> properties [ 'parent_locations' ] [ $ locationObject -> data [ 'parent_location_id' ] ] = $ locationObject ; }
Convert parameters to LocationCreateStruct and stores it on the ContentObject .
8,120
public function renderStandalone ( ) { $ domDocument = new \ DOMDocument ( "1.0" , "utf-8" ) ; $ domDocument -> xmlStandalone = true ; $ domElement = $ this -> render ( $ domDocument ) ; $ domDocument -> appendChild ( $ domElement ) ; return $ domDocument ; }
Render the Custom UI standalone
8,121
public function render ( \ DOMDocument $ domDocument ) { $ domElement = $ domDocument -> createElement ( "custom_ui" ) ; $ settings = $ this -> getSettings ( ) ; foreach ( $ settings as $ setting => $ value ) { if ( $ value === null ) { continue ; } $ settingDomElement = $ domDocument -> createElement ( $ setting ) ; $ settingDomElement -> setAttribute ( "visible" , ( $ value ? 1 : 0 ) ) ; $ domElement -> appendChild ( $ settingDomElement ) ; } return $ domElement ; }
Render the Custom UI
8,122
protected function getSettings ( ) { return array ( "global" => $ this -> globalVisible , "challenge_info" => $ this -> challengeInfoVisible , "chat" => $ this -> chatVisible , "checkpoint_list" => $ this -> checkpointListVisible , "net_infos" => $ this -> netInfosVisible , "notice" => $ this -> noticeVisible , "round_scores" => $ this -> roundScoresVisible , "scoretable" => $ this -> scoretableVisible ) ; }
Get associative array of all Custom UI settings
8,123
private function createLatteEngine ( ) { $ latte = new LatteEngine \ Engine ; $ latte -> setTempDirectory ( $ this -> temp ) ; $ latte -> onCompile [ ] = function ( $ latte ) { Bridges \ FormsLatte \ FormMacros :: install ( $ latte -> getCompiler ( ) ) ; } ; return $ latte ; }
Latte engine settings .
8,124
private function getBasePath ( ) { $ pathInfo = new Http \ RequestFactory ; $ basePath = rtrim ( $ pathInfo -> createHttpRequest ( ) -> url -> basePath , '/' ) ; return $ basePath ; }
Path to root .
8,125
public function render ( $ name , array $ params = [ ] ) { $ latte = $ this -> createLatteEngine ( ) ; $ basePath = [ 'basePath' => $ this -> getBasePath ( ) ] ; $ latte -> render ( $ name , $ params + $ basePath ) ; return $ latte ; }
Create a template and insert parameters .
8,126
public function bindCallback ( $ callback , $ argument = null ) { if ( $ callback instanceof Closure ) { call_user_func_array ( $ callback , [ $ this , $ argument ] ) ; } return $ this ; }
Bind a Closure callback to this query and execute it .
8,127
public function cache ( $ key , $ expires = null ) { if ( $ this -> getType ( ) !== self :: SELECT ) { return $ this ; } $ this -> _cacheKey = $ key ; $ this -> _cacheLength = $ expires ; return $ this ; }
Set the cache key and duration length .
8,128
public function count ( ) { $ repo = $ this -> getRepository ( ) ; return $ repo -> aggregate ( $ this -> limit ( 0 ) , __FUNCTION__ , $ repo -> getPrimaryKey ( ) ) ; }
Pass the query to the repository to interact with the database . Return the count of how many records exist .
8,129
public function data ( $ data ) { if ( $ data instanceof Arrayable ) { $ data = $ data -> toArray ( ) ; } else if ( ! is_array ( $ data ) ) { throw new InvalidArgumentException ( 'Data passed must be an array or extend the Titon\Type\Contract\Arrayable interface' ) ; } $ type = $ this -> getType ( ) ; if ( in_array ( $ type , [ self :: INSERT , self :: UPDATE , self :: MULTI_INSERT ] , true ) ) { $ binds = [ ] ; $ rows = $ data ; if ( $ type !== self :: MULTI_INSERT ) { $ rows = [ $ rows ] ; } foreach ( $ rows as $ row ) { foreach ( $ row as $ field => $ value ) { $ binds [ ] = [ 'field' => $ field , 'value' => $ value ] ; } } $ this -> setBindings ( $ binds ) ; } $ this -> _data = $ data ; return $ this ; }
Set the data to use in an update insert or create index statement . We should also extract data to later bind during a prepared statement .
8,130
public function except ( Query $ query , $ flag = null ) { if ( $ flag === Dialect :: ALL ) { $ query -> attribute ( 'flag' , $ flag ) ; } return $ this -> _addCompound ( Dialect :: EXCEPT , $ query ) ; }
Add a select query as an except .
8,131
public function getAlias ( ) { if ( $ this -> getJoins ( ) || $ this instanceof SubQuery || in_array ( $ this -> getType ( ) , [ self :: CREATE_INDEX , self :: DROP_INDEX ] ) ) { return $ this -> _alias ; } return null ; }
Only return the alias if joins have been set or this is a sub - query .
8,132
public function getFields ( ) { $ fields = $ this -> _fields ; if ( $ this -> getJoins ( ) && ! $ fields && $ this -> getType ( ) === self :: SELECT ) { return array_keys ( $ this -> getRepository ( ) -> getSchema ( ) -> getColumns ( ) ) ; } return $ fields ; }
Return the list of fields and or values . Return all table fields if a join exists and no fields were whitelisted .
8,133
public function groupBy ( ) { $ fields = func_get_args ( ) ; if ( is_array ( $ fields [ 0 ] ) ) { $ fields = $ fields [ 0 ] ; } $ this -> _groupBy = array_unique ( array_merge ( $ this -> _groupBy , $ fields ) ) ; return $ this ; }
Set what fields to group on .
8,134
public function having ( $ field , $ op = null , $ value = null ) { return $ this -> _modifyPredicate ( $ this -> _having , Predicate :: ALSO , $ field , $ op , $ value ) ; }
Will modify or create a having predicate using the AND conjunction .
8,135
public function innerJoin ( $ table , array $ fields = [ ] , array $ on = [ ] ) { return $ this -> _addJoin ( Join :: INNER , $ table , $ fields , $ on ) ; }
Add a new INNER join .
8,136
public function intersect ( Query $ query , $ flag = null ) { if ( $ flag === Dialect :: ALL ) { $ query -> attribute ( 'flag' , $ flag ) ; } return $ this -> _addCompound ( Dialect :: INTERSECT , $ query ) ; }
Add a select query as an intersect .
8,137
public function last ( array $ options = [ ] ) { if ( $ order = $ this -> getOrderBy ( ) ) { $ this -> _orderBy = [ ] ; foreach ( $ order as $ field => $ dir ) { if ( $ dir === 'asc' ) { $ dir = 'desc' ; } else if ( $ dir === 'desc' ) { $ dir = 'asc' ; } if ( is_numeric ( $ field ) ) { $ this -> orderBy ( $ dir ) ; } else { $ this -> orderBy ( $ field , $ dir ) ; } } } else { $ this -> orderBy ( $ this -> getRepository ( ) -> getPrimaryKey ( ) , 'desc' ) ; } return $ this -> limit ( 1 ) -> find ( 'first' , $ options ) ; }
Return the last record from the results . Reverse the direction of any order by declarations .
8,138
public function leftJoin ( $ table , array $ fields = [ ] , array $ on = [ ] ) { return $ this -> _addJoin ( Join :: LEFT , $ table , $ fields , $ on ) ; }
Add a new LEFT join .
8,139
public function lists ( $ value = null , $ key = null , array $ options = [ ] ) { $ repo = $ this -> getRepository ( ) ; $ key = $ key ? : $ repo -> getPrimaryKey ( ) ; $ value = $ value ? : $ repo -> getDisplayField ( ) ; $ options [ 'key' ] = $ key ; $ options [ 'value' ] = $ value ; return $ this -> fields ( [ $ key , $ value ] , true ) -> find ( 'list' , $ options ) ; }
Return all records as a key value list .
8,140
public function orderBy ( $ field , $ direction = self :: DESC ) { if ( is_array ( $ field ) ) { foreach ( $ field as $ key => $ dir ) { $ this -> orderBy ( $ key , $ dir ) ; } } else if ( $ field === 'RAND' ) { $ this -> _orderBy [ ] = $ this -> func ( 'RAND' ) ; } else if ( $ field instanceof Func ) { $ this -> _orderBy [ ] = $ field ; } else { $ direction = strtolower ( $ direction ) ; if ( $ direction != self :: ASC && $ direction != self :: DESC ) { throw new InvalidArgumentException ( sprintf ( 'Invalid order direction %s for field %s' , $ direction , $ field ) ) ; } $ this -> _orderBy [ $ field ] = $ direction ; } return $ this ; }
Set the fields and direction to order by .
8,141
public function orHaving ( $ field , $ op = null , $ value = null ) { return $ this -> _modifyPredicate ( $ this -> _having , Predicate :: EITHER , $ field , $ op , $ value ) ; }
Will modify or create a having predicate using the OR conjunction .
8,142
public function orWhere ( $ field , $ op = null , $ value = null ) { return $ this -> _modifyPredicate ( $ this -> _where , Predicate :: EITHER , $ field , $ op , $ value ) ; }
Will modify or create a where predicate using the OR conjunction .
8,143
public function outerJoin ( $ table , array $ fields = [ ] , array $ on = [ ] ) { return $ this -> _addJoin ( Join :: OUTER , $ table , $ fields , $ on ) ; }
Add a new OUTER join .
8,144
public function rightJoin ( $ table , array $ fields = [ ] , array $ on = [ ] ) { return $ this -> _addJoin ( Join :: RIGHT , $ table , $ fields , $ on ) ; }
Add a new RIGHT join .
8,145
public function save ( $ data = null , array $ options = [ ] ) { if ( $ data ) { $ this -> data ( $ data ) ; } return $ this -> getRepository ( ) -> save ( $ this , $ options ) ; }
Pass the query to the repository to interact with the database . Return the count of how many records were affected .
8,146
public function setType ( $ type ) { if ( ! in_array ( $ type , [ self :: INSERT , self :: MULTI_INSERT , self :: SELECT , self :: UPDATE , self :: DELETE , self :: TRUNCATE , self :: CREATE_TABLE , self :: CREATE_INDEX , self :: DROP_TABLE , self :: DROP_INDEX ] , true ) ) { throw new UnsupportedTypeException ( sprintf ( 'Invalid query type %s' , $ type ) ) ; } $ this -> _type = $ type ; $ this -> _data = [ ] ; $ this -> _bindings = [ ] ; return $ this ; }
Set the type of query .
8,147
public function straightJoin ( $ table , array $ fields , array $ on = [ ] ) { return $ this -> _addJoin ( Join :: STRAIGHT , $ table , $ fields , $ on ) ; }
Add a new STRAIGHT join .
8,148
public function subQuery ( ) { $ query = new SubQuery ( Query :: SELECT , $ this -> getRepository ( ) ) ; $ query -> fields ( func_get_args ( ) ) ; return $ query ; }
Instantiate a new query object that will be used for sub - queries .
8,149
public function union ( Query $ query , $ flag = null ) { if ( $ flag === Dialect :: ALL || $ flag === Dialect :: DISTINCT ) { $ query -> attribute ( 'flag' , $ flag ) ; } return $ this -> _addCompound ( Dialect :: UNION , $ query ) ; }
Add a select query as a union .
8,150
public function where ( $ field , $ op = null , $ value = null ) { return $ this -> _modifyPredicate ( $ this -> _where , Predicate :: ALSO , $ field , $ op , $ value ) ; }
Will modify or create a where predicate using the AND conjunction .
8,151
public function xorHaving ( $ field , $ op = null , $ value = null ) { return $ this -> _modifyPredicate ( $ this -> _having , Predicate :: MAYBE , $ field , $ op , $ value ) ; }
Will modify or create a having predicate using the XOR conjunction .
8,152
public function xorWhere ( $ field , $ op = null , $ value = null ) { return $ this -> _modifyPredicate ( $ this -> _where , Predicate :: MAYBE , $ field , $ op , $ value ) ; }
Will modify or create a where predicate using the XOR conjunction .
8,153
protected function _addCompound ( $ type , Query $ query ) { if ( $ query -> getType ( ) !== self :: SELECT ) { throw new InvalidQueryException ( sprintf ( 'Only a select query can be used with %s' , $ type ) ) ; } $ query -> attribute ( 'compound' , $ type ) ; $ this -> _compounds [ ] = $ query ; return $ this ; }
Add a new compound query . Only select queries can be used with compounds .
8,154
protected function _addJoin ( $ type , $ table , $ fields , $ on = [ ] ) { $ repo = $ this -> getRepository ( ) ; $ join = new Join ( $ type ) ; $ conditions = [ ] ; if ( is_array ( $ table ) ) { $ alias = $ table [ 1 ] ; $ table = $ table [ 0 ] ; } else { $ alias = $ table ; } foreach ( $ on as $ pfk => $ rfk ) { if ( strpos ( $ pfk , '.' ) === false ) { $ pfk = $ repo -> getAlias ( ) . '.' . $ pfk ; } if ( strpos ( $ rfk , '.' ) === false ) { $ rfk = $ alias . '.' . $ rfk ; } $ conditions [ $ pfk ] = $ rfk ; } $ this -> _joins [ ] = $ join -> from ( $ table , $ alias ) -> on ( $ conditions ) -> fields ( $ fields ) ; return $ this ; }
Add a new join type .
8,155
protected function _modifyPredicate ( & $ predicate , $ type , $ field , $ op , $ value ) { if ( ! $ predicate ) { $ predicate = new Predicate ( $ type ) ; } else if ( $ predicate -> getType ( ) !== $ type ) { throw new ExistingPredicateException ( sprintf ( 'Predicate clause already created using "%s" conjunction' , $ predicate -> getType ( ) ) ) ; } if ( $ field instanceof Closure ) { $ predicate -> bindCallback ( $ field , $ this ) ; } else if ( $ value !== null || in_array ( $ op , [ Expr :: NULL , Expr :: NOT_NULL ] , true ) ) { $ predicate -> add ( $ field , $ op , $ value ) ; } else if ( $ op === '!=' ) { $ predicate -> notEq ( $ field , $ value ) ; } else { $ predicate -> eq ( $ field , $ op ) ; } return $ this ; }
Modify a predicate by adding additional clauses .
8,156
public function register ( ) { add_action ( 'admin_head' , array ( $ this , 'add_filters' ) ) ; add_action ( 'wp_head' , array ( $ this , 'add_filters' ) ) ; if ( is_array ( $ this -> config [ 'callback' ] ) ) { foreach ( $ this -> config [ 'callback' ] as $ handle => $ callback ) { $ callback -> register ( $ this -> config [ 'slug' ] . '_' . $ handle ) ; } } else { $ this -> config [ 'callback' ] -> register ( $ this -> config [ 'slug' ] ) ; } }
Register the plugin to the TinyMCE plugin registry and add a form callback or callbacks .
8,157
public function add_filters ( ) { if ( get_user_option ( 'rich_editing' ) ) { add_filter ( 'mce_external_plugins' , array ( $ this , 'register_plugin' ) ) ; add_filter ( 'mce_buttons' . ( $ this -> config [ 'row' ] > 1 ? '_' . $ this -> config [ 'row' ] : '' ) , array ( $ this , 'register_button' ) ) ; } }
Add a button to the tinyMCE editor if the user has the required settings .
8,158
public function setEnabledDesign ( $ style , $ subStyle = null ) { if ( $ style instanceof CheckBoxDesign ) { $ this -> feature -> setEnabledDesign ( $ style ) ; } else { $ checkBoxDesign = new CheckBoxDesign ( $ style , $ subStyle ) ; $ this -> feature -> setEnabledDesign ( $ checkBoxDesign ) ; } return $ this ; }
Set the enabled design
8,159
public function setDisabledDesign ( $ style , $ subStyle = null ) { if ( $ style instanceof CheckBoxDesign ) { $ this -> feature -> setDisabledDesign ( $ style ) ; } else { $ checkBoxDesign = new CheckBoxDesign ( $ style , $ subStyle ) ; $ this -> feature -> setDisabledDesign ( $ checkBoxDesign ) ; } return $ this ; }
Set the disabled design
8,160
public static function read ( $ key = '' , $ default = null ) { if ( empty ( $ key ) ) { return self :: instance ( ) -> all ( ) ; } if ( ! self :: exists ( $ key ) ) { return $ default ; } return self :: instance ( ) -> get ( $ key ) ; }
Read configuration value
8,161
public function send ( $ title , $ content , $ flag ) { $ headers = [ ] ; $ query = [ 'title' => $ title , 'content' => $ content , 'flag' => $ flag , ] ; if ( is_null ( $ this -> webhook ) ) { throw new Exception ( "Missing webhook" , 1 ) ; } $ response = $ this -> curl :: post ( $ this -> webhook , $ headers , $ query ) ; if ( $ response -> code != 200 ) { $ this -> error ( 'Unable to message Mission Control, please confirm your webhook' ) ; } return true ; }
Send the data to Mission Control
8,162
public function filter ( $ value , array $ options = [ ] ) { if ( ! is_string ( $ value ) || empty ( trim ( $ value ) ) ) return $ value ; $ this -> checkOptions ( $ options ) ; list ( $ currentFormat , $ targetFormat ) = array_map ( 'trim' , $ options ) ; return DateTime :: createFromFormat ( $ currentFormat , $ value ) -> format ( $ targetFormat ) ; }
Format date of the given string .
8,163
public function add_filter_by_key ( FilterInterface $ filter , $ key ) { if ( ! is_scalar ( $ key ) ) { throw new Exception \ InvalidArgumentException ( 'key should be a scalar value.' ) ; } $ key = ( string ) $ key ; if ( ! isset ( $ this -> filters_by_key [ $ key ] ) ) { $ this -> filters_by_key [ $ key ] = [ ] ; } $ this -> filters_by_key [ $ key ] [ ] = $ filter ; return $ this ; }
Adding a filter grouped by array key .
8,164
protected function filter_by_key ( $ values ) { if ( count ( $ this -> filters_by_key ) < 1 ) { return $ values ; } foreach ( $ values as $ key => $ value ) { if ( ! is_scalar ( $ value ) || ! isset ( $ this -> filters_by_key [ $ key ] ) ) { continue ; } $ filters = $ this -> filters_by_key [ $ key ] ; foreach ( $ filters as $ filter ) { $ values [ $ key ] = $ filter -> filter ( $ value ) ; } } return $ values ; }
Filters all values by array - key .
8,165
public static function create ( $ maniaLinkId = null , $ version = null , $ name = null , array $ children = null ) { return new static ( $ maniaLinkId , $ version , $ name , $ children ) ; }
Create a new ManiaLink
8,166
public function setId ( $ maniaLinkId ) { $ this -> maniaLinkId = ( string ) $ maniaLinkId ; if ( $ this -> maniaLinkId && ! $ this -> name ) { $ this -> setName ( $ this -> maniaLinkId ) ; } return $ this ; }
Set the ID
8,167
public function getDico ( $ createIfEmpty = true ) { if ( ! $ this -> dico && $ createIfEmpty ) { $ this -> setDico ( new Dico ( ) ) ; } return $ this -> dico ; }
Get the Dictionary
8,168
public function getStylesheet ( $ createIfEmpty = true ) { if ( ! $ this -> stylesheet && $ createIfEmpty ) { return $ this -> createStylesheet ( ) ; } return $ this -> stylesheet ; }
Get the Stylesheet
8,169
public function createStylesheet ( ) { if ( $ this -> stylesheet ) { return $ this -> stylesheet ; } $ stylesheet = new Stylesheet ( ) ; $ this -> setStylesheet ( $ stylesheet ) ; return $ this -> stylesheet ; }
Create and assign a new Stylesheet if necessary
8,170
public function getScript ( $ createIfEmpty = true ) { if ( ! $ this -> script && $ createIfEmpty ) { return $ this -> createScript ( ) ; } return $ this -> script ; }
Get the Script
8,171
public function createScript ( ) { if ( $ this -> script ) { return $ this -> script ; } $ script = new Script ( ) ; $ this -> setScript ( $ script ) ; return $ this -> script ; }
Create and assign a new Script if necessary
8,172
public function render ( $ echo = false , $ domDocument = null ) { $ isChild = ( bool ) $ domDocument ; if ( ! $ isChild ) { $ domDocument = new \ DOMDocument ( "1.0" , "utf-8" ) ; $ domDocument -> xmlStandalone = true ; } $ maniaLink = $ domDocument -> createElement ( "manialink" ) ; if ( ! $ isChild ) { $ domDocument -> appendChild ( $ maniaLink ) ; } if ( $ this -> maniaLinkId ) { $ maniaLink -> setAttribute ( "id" , $ this -> maniaLinkId ) ; } if ( $ this -> version > 0 ) { $ maniaLink -> setAttribute ( "version" , $ this -> version ) ; } if ( $ this -> name ) { $ maniaLink -> setAttribute ( "name" , $ this -> name ) ; } if ( $ this -> background ) { $ maniaLink -> setAttribute ( "background" , $ this -> background ) ; } if ( ! $ this -> navigable3d ) { $ maniaLink -> setAttribute ( "navigable3d" , "0" ) ; } if ( $ this -> timeout ) { $ timeoutXml = $ domDocument -> createElement ( "timeout" , $ this -> timeout ) ; $ maniaLink -> appendChild ( $ timeoutXml ) ; } if ( $ this -> dico ) { $ dicoXml = $ this -> dico -> render ( $ domDocument ) ; $ maniaLink -> appendChild ( $ dicoXml ) ; } if ( $ this -> layer ) { $ maniaLink -> setAttribute ( "layer" , $ this -> layer ) ; } $ scriptFeatures = array ( ) ; foreach ( $ this -> children as $ child ) { $ childXml = $ child -> render ( $ domDocument ) ; $ maniaLink -> appendChild ( $ childXml ) ; if ( $ child instanceof ScriptFeatureable ) { $ scriptFeatures = array_merge ( $ scriptFeatures , $ child -> getScriptFeatures ( ) ) ; } } if ( $ this -> stylesheet ) { $ stylesheetXml = $ this -> stylesheet -> render ( $ domDocument ) ; $ maniaLink -> appendChild ( $ stylesheetXml ) ; } if ( $ scriptFeatures ) { $ this -> createScript ( ) -> loadFeatures ( $ scriptFeatures ) ; } if ( $ this -> script ) { if ( $ this -> script -> needsRendering ( ) ) { $ scriptXml = $ this -> script -> render ( $ domDocument ) ; $ maniaLink -> appendChild ( $ scriptXml ) ; } $ this -> script -> resetGenericScriptLabels ( ) ; } if ( $ isChild ) { return $ maniaLink ; } if ( $ echo ) { header ( "Content-Type: application/xml; charset=utf-8;" ) ; echo $ domDocument -> saveXML ( ) ; } return $ domDocument ; }
Render the ManiaLink
8,173
public function encrypt ( $ text , $ email ) { $ key = $ this -> hasher -> key ( $ email ) ; return $ this -> crypter -> encrypt ( $ text , $ key ) ; }
encrypts a given string with given hash
8,174
protected function _buildEntryCache ( ) { $ this -> _entries = array ( ) ; foreach ( $ this -> _element -> childNodes as $ child ) { if ( $ child -> localName == $ this -> _entryElementName ) { $ this -> _entries [ ] = $ child ; } } }
Cache the individual feed elements so they don t need to be searched for on every operation .
8,175
public function get_manager ( $ params ) { if ( array_key_exists ( 'm' , $ params ) ) { $ manager = $ params [ 'm' ] ; } else { $ manager = reset ( $ params ) ; } if ( $ manager ) { $ this -> info ( 'Using session manager: ' . $ manager ) ; } else { $ manager = null ; $ this -> info ( 'Using default session manager.' ) ; } return \ CCSession :: manager ( $ manager ) ; }
Get a manager instance
8,176
public function action_gc ( $ params ) { $ manager = $ this -> get_manager ( $ params ) ; $ manager -> gc ( ) ; $ this -> success ( 'Garbage collection executed successfully' ) ; }
Gabrage collect old sessions
8,177
protected function _mapAliases ( ) { return $ this -> cache ( __METHOD__ , function ( ) { $ query = $ this -> getQuery ( ) ; if ( ! $ query ) { return [ ] ; } $ alias = $ query -> getAlias ( ) ; $ map = [ $ query -> getTable ( ) => $ alias , strtolower ( $ alias ) => $ alias ] ; foreach ( $ query -> getJoins ( ) as $ join ) { $ joinAlias = $ join -> getAlias ( ) ; $ map [ $ join -> getTable ( ) ] = $ joinAlias ; $ map [ strtolower ( $ joinAlias ) ] = $ joinAlias ; } return $ map ; } ) ; }
Return a mapping of table to alias for the primary table and joins .
8,178
public function create ( Video $ video , $ waitForIngest = 0 ) { if ( is_null ( $ video ) ) { throw new VideoClientException ( "No video provided" ) ; } if ( is_null ( $ video -> sourceUrl ) || ! filter_var ( $ video -> sourceUrl , FILTER_VALIDATE_URL ) ) { throw new VideoClientException ( "Invalid source URL" ) ; } $ ingestedStatus = "INGESTED" ; try { $ videoResponse = $ this -> post ( $ this -> apiResourcePath , $ video ) ; if ( $ waitForIngest > 0 && ! $ ingestedStatus == $ videoResponse -> status ) { $ startTime = round ( microtime ( true ) * 1000 ) ; $ ingested = false ; while ( ! $ ingested && ( round ( microtime ( true ) * 1000 ) - $ startTime ) < $ waitForIngest ) { $ test = $ this -> find ( $ video -> key ) ; if ( $ ingestedStatus == $ videoResponse -> status ) { return $ test ; } sleep ( 3 ) ; } throw new VideoClientException ( "Timeout reached waiting for video to be ingested" ) ; } else { return $ videoResponse ; } } catch ( SafeStreamHttpException $ e ) { throw new VideoClientException ( $ e ) ; } }
Creates a new video allowing a specific timeout while waiting for the video to downloaded and encoded . If not timeout is set then the function will return immediately before the ingest is complete . The video cannot be watermarked until it has been ingested at which point the video status will be INGESTED .
8,179
public function find ( $ videoKey ) { if ( is_null ( $ videoKey ) || empty ( $ videoKey ) ) { throw new VideoClientException ( "A key is needed to fnd a video" ) ; } try { $ videos = $ this -> get ( sprintf ( "%s?key=%s" , $ this -> apiResourcePath , $ videoKey ) ) ; return $ videos [ 0 ] ; } catch ( SafeStreamHttpException $ e ) { throw new VideoClientException ( $ e ) ; } }
Gets an existing video by it s key .
8,180
public function shiftFirstEntry ( ContentStream $ cs , $ type , \ Closure $ withFilter = NULL ) { if ( ( $ entry = $ cs -> findFirst ( $ type , $ withFilter ) ) != NULL ) { $ vars = $ this -> convertEntryTemplateVariables ( $ entry , $ cs ) ; $ cs -> removeEntry ( $ entry ) ; return $ vars ; } return NULL ; }
Finds the first occurence of the entry removes it and returns the template Variables for it
8,181
public function convertUnserialized ( Array $ serialized , ContentStream $ contentStream = NULL ) { if ( isset ( $ contentStream ) ) { foreach ( $ serialized as $ serializedEntry ) { $ entry = $ this -> unserializeEntry ( ( object ) $ serializedEntry ) ; $ entry -> setContentStream ( $ contentStream ) ; } return $ contentStream ; } else { $ unserialized = array ( ) ; foreach ( $ serialized as $ serializedEntry ) { $ unserialized [ ] = $ this -> unserializeEntry ( $ serializedEntry ) ; } } return $ unserialized ; }
Convertes an serialized ContentStream to the real object structure
8,182
public function getContentManager ( ) { if ( $ this -> contentManager != null ) { return $ this -> contentManager ; } $ this -> contentManager = new ContentManager ( $ this -> options , $ this -> getContentService ( ) , $ this -> getContentTypeService ( ) , $ this -> getLocationService ( ) , $ this -> getLocationManager ( ) ) ; if ( $ this -> logger ) { $ this -> contentManager -> setLogger ( $ this -> logger ) ; } return $ this -> contentManager ; }
Returns content manager .
8,183
public function getLocationManager ( ) { if ( $ this -> locationManager != null ) { return $ this -> locationManager ; } $ this -> locationManager = new LocationManager ( $ this -> getLocationService ( ) , $ this -> getContentService ( ) ) ; if ( $ this -> logger ) { $ this -> locationManager -> setLogger ( $ this -> logger ) ; } return $ this -> locationManager ; }
Returns location manager .
8,184
public function getContentTypeManager ( ) { if ( $ this -> contentTypeManager != null ) { return $ this -> contentTypeManager ; } $ this -> contentTypeManager = new ContentTypeManager ( $ this -> getContentTypeService ( ) , $ this -> getLanguageManager ( ) , $ this -> getFieldDefinitionSubManager ( ) , $ this -> getContentTypeGroupSubManager ( ) ) ; if ( $ this -> logger ) { $ this -> contentTypeManager -> setLogger ( $ this -> logger ) ; } return $ this -> contentTypeManager ; }
Returns contenttype manager .
8,185
public function getLanguageManager ( ) { if ( $ this -> languageManager != null ) { return $ this -> languageManager ; } $ this -> languageManager = new LanguageManager ( $ this -> getLanguageService ( ) ) ; if ( $ this -> logger ) { $ this -> languageManager -> setLogger ( $ this -> logger ) ; } return $ this -> languageManager ; }
Returns language manager .
8,186
public function getUserGroupManager ( ) { if ( $ this -> userGroupManager != null ) { return $ this -> userGroupManager ; } $ this -> userGroupManager = new UserGroupManager ( $ this -> options , $ this -> getUserService ( ) , $ this -> getContentService ( ) , $ this -> getContentTypeService ( ) ) ; if ( $ this -> logger ) { $ this -> userGroupManager -> setLogger ( $ this -> logger ) ; } return $ this -> userGroupManager ; }
Returns user group manager .
8,187
public function getUserManager ( ) { if ( $ this -> userManager != null ) { return $ this -> userManager ; } $ this -> userManager = new UserManager ( $ this -> options , $ this -> getUserService ( ) , $ this -> getContentTypeService ( ) , $ this -> getUserGroupManager ( ) ) ; if ( $ this -> logger ) { $ this -> userManager -> setLogger ( $ this -> logger ) ; } return $ this -> userManager ; }
Returns user manager .
8,188
protected function prepareHeaders ( $ method , $ url , array $ params , array $ overrides = [ ] ) { $ oauth = array_merge ( [ 'oauth_consumer_key' => $ this -> consumerKey , 'oauth_nonce' => md5 ( uniqid ( rand ( ) , true ) ) , 'oauth_signature_method' => 'HMAC-SHA1' , 'oauth_timestamp' => time ( ) , 'oauth_version' => '1.0A' , 'oauth_token' => $ this -> oauthToken , ] , $ overrides ) ; foreach ( $ oauth as $ k => $ v ) { $ oauth [ $ k ] = rawurlencode ( $ v ) ; } foreach ( $ params as $ k => $ v ) { $ params [ $ k ] = rawurlencode ( $ v ) ; } $ sigParams = array_merge ( $ oauth , $ params ) ; ksort ( $ sigParams ) ; $ oauth [ 'oauth_signature' ] = rawurlencode ( $ this -> generateSignature ( $ method , $ url , $ sigParams ) ) ; return $ oauth ; }
Prepares oauth headers for a given request .
8,189
public function getPasswordBrokerFactory ( ) : ? PasswordBrokerFactory { if ( ! $ this -> hasPasswordBrokerFactory ( ) ) { $ this -> setPasswordBrokerFactory ( $ this -> getDefaultPasswordBrokerFactory ( ) ) ; } return $ this -> passwordBrokerFactory ; }
Get password broker factory
8,190
public function getDefaultBroadcast ( ) : ? Broadcaster { $ manager = Broadcast :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { return $ manager -> connection ( ) ; } return $ manager ; }
Get a default broadcast value if any is available
8,191
public function getExports ( $ whereUserIsGranted = true ) { foreach ( $ this -> exports as $ alias => $ export ) { if ( $ whereUserIsGranted ) { if ( $ this -> isGrantedForElement ( $ export , null , null ) ) { yield $ alias => $ export ; } } else { yield $ alias => $ export ; } } }
Return all exports . The exports s alias are the array s keys .
8,192
public function getExport ( $ alias ) { if ( ! array_key_exists ( $ alias , $ this -> exports ) ) { throw new \ RuntimeException ( "The export with alias $alias is not known." ) ; } return $ this -> exports [ $ alias ] ; }
Return an export by his alias
8,193
public function isGrantedForElement ( ExportElementInterface $ element , ExportInterface $ export = NULL , array $ centers = null ) { if ( $ element instanceof ExportInterface ) { $ role = $ element -> requiredRole ( ) ; } elseif ( $ element instanceof ModifierInterface ) { if ( is_null ( $ element -> addRole ( ) ) ) { if ( is_null ( $ export ) ) { throw new \ LogicException ( "The export should not be null: as the " . "ModifierInstance element is not an export, we should " . "be aware of the export to determine which role is required" ) ; } else { $ role = $ export -> requiredRole ( ) ; } } else { $ role = $ element -> addRole ( ) ; } } else { throw new \ LogicException ( "The element is not an ModifiersInterface or " . "an ExportInterface." ) ; } if ( $ centers === null ) { $ centers = $ this -> authorizationHelper -> getReachableCenters ( $ this -> user , $ role ) ; } if ( count ( $ centers ) === 0 ) { return false ; } foreach ( $ centers as $ center ) { if ( $ this -> authorizationChecker -> isGranted ( $ role -> getRole ( ) , $ center ) === false ) { $ this -> logger -> debug ( 'user has no access to element' , array ( 'method' => __METHOD__ , 'type' => get_class ( $ element ) , 'center' => $ center -> getName ( ) ) ) ; return false ; } } return true ; }
Return true if the current user has access to the ExportElement for every center false if the user hasn t access to element for at least one center .
8,194
public function & getAggregatorsApplyingOn ( ExportInterface $ export , array $ centers = null ) { foreach ( $ this -> aggregators as $ alias => $ aggregator ) { if ( in_array ( $ aggregator -> applyOn ( ) , $ export -> supportsModifiers ( ) ) && $ this -> isGrantedForElement ( $ aggregator , $ export , $ centers ) ) { yield $ alias => $ aggregator ; } } }
Return a \ Generator containing aggregators which support type
8,195
public function generate ( $ exportAlias , array $ pickedCentersData , array $ data , array $ formatterData ) { $ export = $ this -> getExport ( $ exportAlias ) ; $ centers = $ this -> getPickedCenters ( $ pickedCentersData ) ; $ query = $ export -> initiateQuery ( $ this -> retrieveUsedModifiers ( $ data ) , $ this -> buildCenterReachableScopes ( $ centers , $ export ) , $ data [ ExportType :: EXPORT_KEY ] ) ; if ( $ query instanceof \ Doctrine \ ORM \ NativeQuery ) { if ( count ( $ export -> supportsModifiers ( ) ) > 0 ) { throw new \ LogicException ( "The export with alias `$exportAlias` return " . "a `\Doctrine\ORM\NativeQuery` and supports modifiers, which is not " . "allowed. Either the method `supportsModifiers` should return an empty " . "array, or return a `Doctrine\ORM\QueryBuilder`" ) ; } } elseif ( $ query instanceof QueryBuilder ) { $ this -> handleFilters ( $ export , $ query , $ data [ ExportType :: FILTER_KEY ] , $ centers ) ; $ this -> handleAggregators ( $ export , $ query , $ data [ ExportType :: AGGREGATOR_KEY ] , $ centers ) ; $ this -> logger -> debug ( 'current query is ' . $ query -> getDQL ( ) , array ( 'class' => self :: class , 'function' => __FUNCTION__ ) ) ; } else { throw new \ UnexpectedValueException ( "The method `intiateQuery` should return " . "a `\Doctrine\ORM\NativeQuery` or a `Doctrine\ORM\QueryBuilder` " . "object." ) ; } $ result = $ export -> getResult ( $ query , $ data [ ExportType :: EXPORT_KEY ] ) ; if ( ! is_array ( $ result ) ) { throw new \ UnexpectedValueException ( sprintf ( 'The result of the export should be an array, %s given' , gettype ( $ result ) ) ) ; } $ formatter = $ this -> getFormatter ( $ this -> getFormatterAlias ( $ data ) ) ; $ filters = array ( ) ; $ aggregatorsData = array ( ) ; if ( $ query instanceof QueryBuilder ) { $ aggregators = $ this -> retrieveUsedAggregators ( $ data [ ExportType :: AGGREGATOR_KEY ] ) ; foreach ( $ aggregators as $ alias => $ aggregator ) { $ aggregatorsData [ $ alias ] = $ data [ ExportType :: AGGREGATOR_KEY ] [ $ alias ] [ 'form' ] ; } } return $ formatter -> getResponse ( $ result , $ formatterData , $ exportAlias , $ data [ ExportType :: EXPORT_KEY ] , $ filters , $ aggregatorsData ) ; }
Generate a response which contains the requested data .
8,196
private function buildCenterReachableScopes ( array $ centers , ExportElementInterface $ element ) { $ r = array ( ) ; foreach ( $ centers as $ center ) { $ r [ ] = array ( 'center' => $ center , 'circles' => $ this -> authorizationHelper -> getReachableScopes ( $ this -> user , $ element -> requiredRole ( ) , $ center ) ) ; } return $ r ; }
build the array required for defining centers and circles in the initiate queries of ExportElementsInterfaces
8,197
public function getUsedAggregatorsAliases ( array $ data ) { $ aggregators = $ this -> retrieveUsedAggregators ( $ data [ ExportType :: AGGREGATOR_KEY ] ) ; return array_keys ( iterator_to_array ( $ aggregators ) ) ; }
get the aggregators typse used in the form export data
8,198
private function retrieveUsedModifiers ( $ data ) { $ usedTypes = array_merge ( $ this -> retrieveUsedFiltersType ( $ data [ ExportType :: FILTER_KEY ] ) , $ this -> retrieveUsedAggregatorsType ( $ data [ ExportType :: AGGREGATOR_KEY ] ) ) ; $ this -> logger -> debug ( 'Required types are ' . implode ( ', ' , $ usedTypes ) , array ( 'class' => self :: class , 'function' => __FUNCTION__ ) ) ; return array_unique ( $ usedTypes ) ; }
parse the data to retrieve the used filters and aggregators
8,199
private function retrieveUsedFiltersType ( $ data ) { $ usedTypes = array ( ) ; foreach ( $ data as $ alias => $ filterData ) { if ( $ filterData [ 'enabled' ] == true ) { $ filter = $ this -> getFilter ( $ alias ) ; if ( ! in_array ( $ filter -> applyOn ( ) , $ usedTypes ) ) { array_push ( $ usedTypes , $ filter -> applyOn ( ) ) ; } } } return $ usedTypes ; }
Retrieve the filter used in this export .