idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
5,300
|
public function addRemoteHistoryContao ( RemoteHistoryContao $ l ) { if ( $ this -> collRemoteHistoryContaos === null ) { $ this -> initRemoteHistoryContaos ( ) ; $ this -> collRemoteHistoryContaosPartial = true ; } if ( ! in_array ( $ l , $ this -> collRemoteHistoryContaos -> getArrayCopy ( ) , true ) ) { $ this -> doAddRemoteHistoryContao ( $ l ) ; if ( $ this -> remoteHistoryContaosScheduledForDeletion and $ this -> remoteHistoryContaosScheduledForDeletion -> contains ( $ l ) ) { $ this -> remoteHistoryContaosScheduledForDeletion -> remove ( $ this -> remoteHistoryContaosScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; }
|
Method called to associate a RemoteHistoryContao object to this object through the RemoteHistoryContao foreign key attribute .
|
5,301
|
public function actionImportLeagues ( ) { $ client = new Client ( [ 'apiKey' => $ this -> apiKey ] ) ; $ leagues = $ client -> getAllLeagues ( ) ; $ count = 0 ; foreach ( $ leagues as $ league ) { $ dbLeague = Yii :: createObject ( [ 'class' => $ this -> leagueClass , 'interface_id' => ArrayHelper :: getValue ( $ league , 'Id' ) , 'name' => ArrayHelper :: getValue ( $ league , 'Name' ) , 'country' => ArrayHelper :: getValue ( $ league , 'Country' ) , 'historical_data' => constant ( '\drsdre\yii\xmlsoccer\models\League::HISTORICAL_DATA_' . strtoupper ( ArrayHelper :: getValue ( $ league , 'Historical_Data' , 'no' ) ) ) , 'fixtures' => filter_var ( strtolower ( ArrayHelper :: getValue ( $ league , 'Fixtures' , 'no' ) ) , FILTER_VALIDATE_BOOLEAN ) , 'livescore' => filter_var ( strtolower ( ArrayHelper :: getValue ( $ league , 'Livescore' , 'no' ) ) , FILTER_VALIDATE_BOOLEAN ) , 'number_of_matches' => ArrayHelper :: getValue ( $ league , 'NumberOfMatches' , 0 ) , 'latest_match' => ArrayHelper :: getValue ( $ league , 'LatestMatch' ) , 'is_cup' => filter_var ( strtolower ( ArrayHelper :: getValue ( $ league , 'IsCup' , 'no' ) ) , FILTER_VALIDATE_BOOLEAN ) ] ) ; if ( ! $ dbLeague -> save ( ) ) { $ this -> stderr ( "Failed to import league '{$dbLeague->name}': " , Console :: FG_RED ) ; $ this -> stderr ( "\n" ) ; foreach ( $ dbLeague -> errors as $ attribute => $ errors ) { foreach ( $ errors as $ error ) { $ this -> stderr ( "$attribute: $error" , Console :: BG_YELLOW , Console :: FG_BLACK ) ; $ this -> stderr ( "\n" ) ; } } $ this -> stderr ( "\n" ) ; } else { $ count ++ ; $ this -> stdout ( "League '{$dbLeague->name}' inserted\n" ) ; } } $ this -> stdout ( "\n" ) ; $ this -> stdout ( "$count leagues imported" , Console :: FG_GREEN ) ; $ this -> stdout ( "\n" ) ; return ExitCode :: OK ; }
|
Import all leagues from XMLSoccer interface
|
5,302
|
public function actionShowLeagues ( ) { $ leagues = call_user_func ( [ $ this -> leagueClass , 'find' ] ) ; if ( ! $ leagues -> count ( 'id' ) ) { $ this -> stdout ( "No leagues found. Import by " ) ; $ this -> stdout ( "{$this->id}/import-leagues" , Console :: BOLD ) ; $ this -> stdout ( "\n" ) ; return ExitCode :: OK ; } $ first = $ leagues -> one ( ) ; $ headers = [ ] ; $ rows = [ ] ; $ attributes = [ ] ; foreach ( $ first -> toArray ( ) as $ attribute => $ value ) { $ attributes [ ] = $ attribute ; $ headers [ ] = $ first -> generateAttributeLabel ( $ attribute ) ; } foreach ( $ leagues -> all ( ) as $ league ) { $ rows [ ] = array_values ( $ league -> toArray ( $ attributes ) ) ; } echo Table :: widget ( [ 'headers' => $ headers , 'rows' => $ rows ] ) ; return ExitCode :: OK ; }
|
Show all leagues
|
5,303
|
private static function get_timestamped_url ( $ file , $ type ) { $ search = [ '{{root_dir}}' , '{{type}}' ] ; $ replace = [ self :: $ root_dir , $ type ] ; $ base_path = str_replace ( $ search , $ replace , self :: $ base_path ) ; $ base_url = str_replace ( $ search , $ replace , self :: $ base_url ) ; $ file = trim ( $ file ) ; $ absolute = ( $ file [ 0 ] == '/' ) ; $ file = ( $ absolute ) ? $ file : $ base_url . $ file ; $ full_path = $ base_path . $ file . '.' . $ type ; if ( file_exists ( $ full_path ) == false ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'can not find ' . $ type . ' resource ' . $ file ) ; } $ timestamp = filemtime ( $ full_path ) ; $ full_url = $ file . '.' . $ timestamp . '.' . $ type ; return $ full_url ; }
|
adds a modification timestamp to a file path
|
5,304
|
public function toHTML ( $ pretty_print = TRUE ) { $ this -> out = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ this -> out -> formatOutput = $ pretty_print ; $ field = $ this -> doc -> getElementsByTagName ( 'xlf:group' ) -> item ( 0 ) ; foreach ( $ field -> childNodes as $ child ) { if ( $ output = $ this -> convert ( $ child ) ) { $ this -> out -> appendChild ( $ output ) ; } } return html_entity_decode ( $ this -> out -> saveHTML ( ) , ENT_QUOTES , 'UTF-8' ) ; }
|
Converts XML to the corresponding HTML representation .
|
5,305
|
public function set ( $ key , $ value , $ param = null ) { CCArr :: set ( $ key , $ value , $ this -> _data ) ; }
|
set data to the object .
|
5,306
|
public function getTimelineHTML ( $ context , array $ args , $ page = 0 , $ number = 20 ) { $ query = $ this -> buildUnionQuery ( $ context , $ args , $ page , $ number ) ; $ fetched = $ this -> runQuery ( $ query ) ; $ entitiesByKey = $ this -> getEntities ( $ fetched , $ context ) ; return $ this -> render ( $ fetched , $ entitiesByKey , $ context , $ args ) ; }
|
return an HTML string with timeline
|
5,307
|
public function getProvidersByContext ( $ context ) { $ providers = array ( ) ; foreach ( $ this -> providers [ $ context ] as $ providerId ) { $ providers [ ] = $ this -> container -> get ( $ providerId ) ; } return $ providers ; }
|
Get providers by context
|
5,308
|
private function buildUnionQuery ( $ context , array $ args , $ page , $ number ) { if ( ! array_key_exists ( $ context , $ this -> providers ) ) { throw new \ LogicException ( sprintf ( 'No builders have been defined for "%s"' . ' context' , $ context ) ) ; } $ union = '' ; foreach ( $ this -> getProvidersByContext ( $ context ) as $ provider ) { $ select = $ this -> buildSelectQuery ( $ provider , $ context , $ args ) ; $ append = ( $ union === '' ) ? $ select : ' UNION ' . $ select ; $ union .= $ append ; } $ union .= sprintf ( ' ORDER BY date DESC LIMIT %d OFFSET %d' , $ number , $ page * $ number ) ; return $ union ; }
|
build the UNION query with all providers
|
5,309
|
private function buildSelectQuery ( TimelineProviderInterface $ provider , $ context , array $ args ) { $ data = $ provider -> fetchQuery ( $ context , $ args ) ; return sprintf ( 'SELECT %s AS id, ' . '%s AS "date", ' . "'%s' AS type " . 'FROM %s ' . 'WHERE %s' , $ data [ 'id' ] , $ data [ 'date' ] , $ data [ 'type' ] , $ data [ 'FROM' ] , $ data [ 'WHERE' ] ) ; }
|
return the SQL SELECT query as a string
|
5,310
|
private function runQuery ( $ query ) { $ resultSetMapping = ( new ResultSetMapping ( ) ) -> addScalarResult ( 'id' , 'id' ) -> addScalarResult ( 'type' , 'type' ) -> addScalarResult ( 'date' , 'date' ) ; return $ this -> em -> createNativeQuery ( $ query , $ resultSetMapping ) -> getArrayResult ( ) ; }
|
run the UNION query and return result as an array
|
5,311
|
private function render ( array $ fetched , array $ entitiesByType , $ context , array $ args ) { $ timelineEntries = array ( ) ; foreach ( $ fetched as $ result ) { $ data = $ this -> getTemplateData ( $ result [ 'type' ] , $ entitiesByType [ $ result [ 'type' ] ] [ $ result [ 'id' ] ] , $ context , $ args ) ; $ timelineEntry [ 'date' ] = new \ DateTime ( $ result [ 'date' ] ) ; $ timelineEntry [ 'template' ] = $ data [ 'template' ] ; $ timelineEntry [ 'template_data' ] = $ data [ 'template_data' ] ; $ timelineEntries [ ] = $ timelineEntry ; } return $ this -> container -> get ( 'templating' ) -> render ( 'ChillMainBundle:Timeline:index.html.twig' , array ( 'results' => $ timelineEntries ) ) ; }
|
render the timeline as HTML
|
5,312
|
private function getTemplateData ( $ type , $ entity , $ context , array $ args ) { foreach ( $ this -> getProvidersByContext ( $ context ) as $ provider ) { if ( $ provider -> supportsType ( $ type ) ) { return $ provider -> getEntityTemplate ( $ entity , $ context , $ args ) ; } } }
|
get the template data from the provider for the given entity by type .
|
5,313
|
public static function panel ( $ content , $ htmlOptions = array ( ) ) { ArrayHelper :: addValue ( 'class' , Enum :: PANEL , $ htmlOptions ) ; return \ CHtml :: tag ( 'div' , $ htmlOptions , $ content ) ; }
|
Generates a panel
|
5,314
|
public static function callout ( $ content , $ htmlOptions = array ( ) ) { ArrayHelper :: addValue ( 'class' , Enum :: PANEL_CALLOUT , $ htmlOptions ) ; return static :: panel ( $ content , $ htmlOptions ) ; }
|
Generates a callout panel
|
5,315
|
public function action_security_key ( $ params ) { $ path = \ CCPath :: config ( 'main.config' . EXT ) ; if ( ! file_exists ( $ path ) ) { $ this -> error ( 'Could not find main configuration file.' ) ; return ; } $ data = \ CCFile :: read ( $ path ) ; if ( strpos ( $ data , '{{security salt here}}' ) === false ) { $ this -> error ( 'The key has already been generated or set.' ) ; return ; } $ data = str_replace ( '{{security salt here}}' , \ CCStr :: random ( 32 , 'password' ) , $ data ) ; \ CCFile :: write ( $ path , $ data ) ; $ this -> success ( 'The key has been generated.' ) ; }
|
Try to generate a security key in the main config file
|
5,316
|
public static function instance ( ) { if ( null === self :: $ _instance ) { $ capsule = new Capsule ; $ capsule -> addConnection ( self :: getConfig ( ) ) ; $ capsule -> setEventDispatcher ( new Dispatcher ( new Container ) ) ; $ capsule -> setAsGlobal ( ) ; self :: $ _instance = $ capsule ; } return self :: $ _instance ; }
|
Instantiate Eloquent ORM
|
5,317
|
public function get ( $ serviceId ) { if ( isset ( $ this -> services [ $ serviceId ] ) ) { return $ this -> services [ $ serviceId ] ; } if ( ! isset ( $ this -> instantiators [ $ serviceId ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'No instantiator has been registered for requested service "%s"' , $ serviceId ) ) ; } $ this -> services [ $ serviceId ] = $ this -> instantiators [ $ serviceId ] ( $ this ) ; return $ this -> services [ $ serviceId ] ; }
|
Instantiate and return the service with the given ID . Note that this method will return the same instance on subsequent calls .
|
5,318
|
public function getServiceIdsForTag ( $ tag ) { $ serviceIds = [ ] ; foreach ( $ this -> tags as $ serviceId => $ tags ) { if ( isset ( $ tags [ $ tag ] ) ) { $ serviceIds [ $ serviceId ] = $ tags [ $ tag ] ; } } return $ serviceIds ; }
|
Return services IDs for the given tag .
|
5,319
|
public function register ( $ serviceId , \ Closure $ instantiator , array $ tags = [ ] ) { if ( isset ( $ this -> instantiators [ $ serviceId ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Service with ID "%s" has already been registered' , $ serviceId ) ) ; } $ this -> instantiators [ $ serviceId ] = $ instantiator ; $ this -> tags [ $ serviceId ] = $ tags ; }
|
Register a service with the given ID and instantiator .
|
5,320
|
public function getParameter ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> config ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Parameter "%s" has not been registered' , $ name ) ) ; } return $ this -> config [ $ name ] ; }
|
Return the parameter with the given name .
|
5,321
|
public function escape_table ( & $ query ) { $ table = $ query -> table ; if ( is_array ( $ table ) ) { reset ( $ table ) ; $ table = key ( $ table ) . ' as ' . $ table [ key ( $ table ) ] ; } return $ this -> escape ( $ table ) ; }
|
Escape the table
|
5,322
|
public function parameterize ( $ params ) { foreach ( $ params as $ key => $ param ) { $ params [ $ key ] = $ this -> param ( $ param ) ; } return implode ( ', ' , $ params ) ; }
|
Convert data to parameters and bind them to the query
|
5,323
|
public function compile_insert ( & $ query ) { $ build = ( $ query -> ignore ? 'insert ignore' : 'insert' ) . ' into ' . $ this -> escape_table ( $ query ) . ' ' ; $ value_collection = $ query -> values ; $ build .= '(' . $ this -> escape_list ( array_keys ( reset ( $ value_collection ) ) ) . ') values ' ; foreach ( $ value_collection as $ values ) { $ build .= '(' . $ this -> parameterize ( $ values ) . '), ' ; } return substr ( $ build , 0 , - 2 ) ; }
|
Build an insert query
|
5,324
|
public function compile_update ( & $ query ) { $ build = 'update ' . $ this -> escape_table ( $ query ) . ' set ' ; foreach ( $ query -> values as $ key => $ value ) { $ build .= $ this -> escape ( $ key ) . ' = ' . $ this -> param ( $ value ) . ', ' ; } $ build = substr ( $ build , 0 , - 2 ) ; $ build .= $ this -> compile_where ( $ query ) ; $ build .= $ this -> compile_limit ( $ query ) ; return $ build ; }
|
Build an update query
|
5,325
|
public function compile_delete ( & $ query ) { $ build = 'delete from ' . $ this -> escape_table ( $ query ) ; $ build .= $ this -> compile_where ( $ query ) ; $ build .= $ this -> compile_limit ( $ query ) ; return $ build ; }
|
Build an delete query
|
5,326
|
public function compile_select ( & $ query ) { $ build = ( $ query -> distinct ? 'select distinct' : 'select' ) . ' ' ; if ( ! empty ( $ query -> fields ) ) { foreach ( $ query -> fields as $ key => $ field ) { if ( ! is_numeric ( $ key ) ) { $ build .= $ this -> escape ( $ key ) . ' as ' . $ this -> escape ( $ field ) ; } elseif ( is_array ( $ field ) ) { $ build .= $ this -> escape ( $ field [ 0 ] ) . ' as ' . $ this -> escape ( $ field [ 1 ] ) ; } else { $ build .= $ this -> escape ( $ field ) ; } $ build .= ', ' ; } $ build = substr ( $ build , 0 , - 2 ) ; } else { $ build .= '*' ; } $ build .= ' from ' . $ this -> escape_table ( $ query ) ; $ build .= $ this -> compile_where ( $ query ) ; $ build .= $ this -> compile_group ( $ query ) ; $ build .= $ this -> compile_order ( $ query ) ; $ build .= $ this -> compile_limit_with_offset ( $ query ) ; return $ build ; }
|
Build a select
|
5,327
|
public function compile_where ( & $ query ) { $ build = '' ; foreach ( $ query -> wheres as $ where ) { if ( ! isset ( $ where [ 2 ] ) && is_closure ( $ where [ 1 ] ) ) { $ sub_query = new Query ; call_user_func ( $ where [ 1 ] , $ sub_query ) ; $ build .= ' ' . $ where [ 0 ] . ' ( ' . substr ( $ this -> compile_where ( $ sub_query ) , 7 ) . ' )' ; continue ; } if ( is_array ( $ where [ 3 ] ) ) { $ where [ 3 ] = '(' . $ this -> parameterize ( $ where [ 3 ] ) . ')' ; } else { $ where [ 3 ] = $ this -> param ( $ where [ 3 ] ) ; } $ where [ 1 ] = $ this -> escape ( $ where [ 1 ] ) ; $ build .= ' ' . implode ( ' ' , $ where ) ; } return $ build ; }
|
Build the where part
|
5,328
|
public function compile_limit_with_offset ( & $ query ) { if ( is_null ( $ query -> limit ) ) { return "" ; } return ' limit ' . ( ( int ) $ query -> offset ) . ', ' . ( ( int ) $ query -> limit ) ; }
|
Build the limit and offset part
|
5,329
|
protected function newUserModel ( $ username , $ password , array $ options = [ ] ) { $ user = new User ( ) ; $ user -> username = $ username ; $ user -> password = $ password ; foreach ( $ options as $ key => $ value ) { $ user -> { $ key } = $ value ; } return $ user ; }
|
Create new user model instance
|
5,330
|
protected function createUserModel ( $ username , $ password , array $ options = [ ] ) { $ user = $ this -> newUserModel ( $ username , $ password , $ options ) ; $ user -> save ( ) ; return $ user ; }
|
Create and store in database new user model instance
|
5,331
|
protected function createUserRecord ( $ username , $ password , array $ options = [ ] ) { return [ User :: FIELD_USERNAME => $ username , User :: FIELD_PASSWORD => bcrypt ( $ password ) , User :: FIELD_EMAIL => array_key_exists ( User :: FIELD_EMAIL , $ options ) ? $ options [ User :: FIELD_EMAIL ] : $ username . '@local . com' , User :: FIELD_HOME => array_key_exists ( User :: FIELD_HOME , $ options ) ? $ options [ User :: FIELD_HOME ] : null , User :: FIELD_BLOCKED => array_key_exists ( User :: FIELD_BLOCKED , $ options ) ? $ options [ User :: FIELD_BLOCKED ] : false , User :: FIELD_STATIC => array_key_exists ( User :: FIELD_STATIC , $ options ) ? $ options [ User :: FIELD_STATIC ] : false , User :: FIELD_HIDDEN => array_key_exists ( User :: FIELD_HIDDEN , $ options ) ? $ options [ User :: FIELD_HIDDEN ] : false , ] ; }
|
Create single user record
|
5,332
|
protected function newGroupModel ( $ token , array $ options = [ ] ) { $ group = new Group ( ) ; $ group -> token = $ token ; foreach ( $ options as $ key => $ value ) { $ group -> { $ key } = $ value ; } return $ group ; }
|
Create new group model instance
|
5,333
|
protected function createGroupModel ( $ token , array $ options = [ ] ) { $ group = $ this -> newGroupModel ( $ token , $ options ) ; $ group -> save ( ) ; return $ group ; }
|
Create and store in database new group model instance
|
5,334
|
protected function newRoleModel ( $ token , array $ options = [ ] ) { $ role = new Role ( ) ; $ role -> token = $ token ; foreach ( $ options as $ key => $ value ) { $ role -> { $ key } = $ value ; } return $ role ; }
|
Create new role model instance
|
5,335
|
protected function createRoleModel ( $ token , array $ options = [ ] ) { $ role = $ this -> newRoleModel ( $ token , $ options ) ; $ role -> save ( ) ; return $ role ; }
|
Create and store in database new role model instance
|
5,336
|
protected function newPermissionModel ( $ token , array $ options = [ ] ) { $ permission = new Permission ( ) ; $ permission -> token = $ token ; foreach ( $ options as $ key => $ value ) { $ permission -> { $ key } = $ value ; } return $ permission ; }
|
Create new permission model instance
|
5,337
|
protected function createPermissionModel ( $ token , array $ options = [ ] ) { $ permission = $ this -> newPermissionModel ( $ token , $ options ) ; $ permission -> save ( ) ; return $ permission ; }
|
Create and store in database new permission model instance
|
5,338
|
public static function display ( $ tpl , $ variablesDefinitions = NULL , $ indent = NULL ) { $ html = self :: get ( $ tpl , $ variablesDefinitions , $ indent ) ; print $ html ; }
|
Inkludiert ein Template
|
5,339
|
public function load ( $ data , $ key = null ) { if ( $ key ) { if ( isset ( $ this -> data [ $ key ] ) ) { $ this -> data [ $ key ] = self :: array_merge_recursive_unique ( $ this -> data [ $ key ] , $ data ) ; } else { $ this -> data [ $ key ] = $ data ; } } else { if ( is_array ( $ data ) ) { $ this -> data = self :: array_merge_recursive_unique ( $ this -> data , $ data ) ; } } }
|
Load from array
|
5,340
|
public function add ( $ key , $ value ) { if ( isset ( $ this -> data [ $ key ] ) ) { throw new \ InvalidArgumentException ( "Key $key is already set" ) ; } $ this -> data [ $ key ] = $ value ; }
|
Add a new key value pairing .
|
5,341
|
public function get ( $ name = null ) { $ data = $ this -> data ; if ( $ name ) { $ names = explode ( '.' , $ name ) ; if ( $ names ) { foreach ( $ names as $ name ) { if ( is_array ( $ data ) && array_key_exists ( $ name , $ data ) ) { $ data = $ data [ $ name ] ; } else { return null ; } } } } return $ data ; }
|
Get the value for a key with the given name Can use dot notation for acessing nested keys
|
5,342
|
public function getConfig ( $ name ) { $ data = $ this -> get ( $ name ) ; if ( $ data === null ) { return null ; } if ( isset ( $ this -> data [ 'global' ] ) ) { $ data [ 'global' ] = $ this -> data [ 'global' ] ; } $ config = new self ( ) ; $ config -> load ( $ data ) ; return $ config ; }
|
Get the value at the given key and return it as a config object
|
5,343
|
public function set ( $ name , $ value ) { $ data = array ( ) ; $ dataPointer = & $ data ; $ parents = explode ( '.' , $ name ) ; $ name = array_pop ( $ parents ) ; foreach ( $ parents as $ parent ) { $ dataPointer [ $ parent ] = array ( ) ; $ dataPointer = & $ dataPointer [ $ parent ] ; } $ dataPointer [ $ name ] = $ value ; $ this -> load ( $ data ) ; }
|
Set a value in the config . If the value doesn t exist it will be created .
|
5,344
|
final public function getName ( ) { if ( ! $ this -> name ) { $ this -> name = get_class ( $ this ) ; list ( $ jfusion , $ plugins , $ name ) = explode ( '\\' , get_class ( $ this ) ) ; $ this -> name = $ name ; } return $ this -> name ; }
|
returns the name of this JFusion plugin using the namespace part of the plugin class
|
5,345
|
final public function isConfigured ( ) { $ jname = $ this -> getJname ( ) ; $ result = false ; if ( ! empty ( $ jname ) ) { if ( ! isset ( static :: $ status [ $ jname ] ) ) { $ db = Factory :: getDBO ( ) ; $ query = $ db -> getQuery ( true ) -> select ( 'status' ) -> from ( '#__jfusion' ) -> where ( 'name = ' . $ db -> quote ( $ jname ) ) ; $ db -> setQuery ( $ query ) ; $ result = $ db -> loadResult ( ) ; if ( $ result >= 1 ) { $ result = true ; } else { $ result = false ; } static :: $ status [ $ jname ] = $ result ; } else { $ result = static :: $ status [ $ jname ] ; } } return $ result ; }
|
Checks to see if the JFusion plugin is properly configured
|
5,346
|
function getPluginFile ( $ filename , & $ error , & $ reason ) { $ path = $ this -> params -> get ( 'source_path' ) ; if ( empty ( $ path ) ) { $ error = 1 ; $ reason = Text :: _ ( 'SET_PATH_FIRST' ) ; } $ mod_file = $ path . $ filename ; if ( ! file_exists ( $ mod_file ) && $ error == 0 ) { $ error = 1 ; $ reason = Text :: _ ( 'NO_FILE_FOUND' ) ; } return $ mod_file ; }
|
Function returns the path to the modfile
|
5,347
|
public static function callStatic ( $ object , $ name , $ arguments ) { $ className = self :: getAdapterClassName ( ) ; return $ className :: _callStatic ( $ object , $ name , $ arguments ) ; }
|
Allows exposure to privately defined static calls
|
5,348
|
public function getSessionManager ( ) : ? SessionManager { if ( ! $ this -> hasSessionManager ( ) ) { $ this -> setSessionManager ( $ this -> getDefaultSessionManager ( ) ) ; } return $ this -> sessionManager ; }
|
Get session manager
|
5,349
|
protected function handleSetClassAccessors ( $ property , $ value ) { $ property = $ this -> studly ( $ property ) ; if ( method_exists ( $ this , "set{$property}" ) ) { return $ this -> { "set{$property}" } ( $ value ) ; } }
|
Finds and invokes setters .
|
5,350
|
public static function json ( $ data = array ( ) , $ status = 200 , $ beautify = true ) { if ( ! is_array ( $ data ) ) { throw new CCException ( "CCResponse::json - first argument has to be an array." ) ; } $ response = new static ( CCJson :: encode ( $ data , $ beautify ) , $ status ) ; $ response -> header ( 'Content-Type' , 'text/json' ) ; return $ response ; }
|
json response you can pass an array of data wich will be converted to json
|
5,351
|
public static function download ( $ body , $ filename = null , $ status = 200 ) { return static :: create ( $ body , $ status ) -> as_download ( $ filename ) ; }
|
download response creates an respose that forces the browser to download as file
|
5,352
|
public function as_download ( $ filename = null ) { if ( is_null ( $ filename ) ) { $ filename = 'file.' . CCStr :: suffix ( $ this -> header ( 'Content-Type' ) , '/' ) ; } $ this -> header ( 'Content-Description' , 'File Transfer' ) ; $ this -> header ( 'Content-Disposition' , 'attachment; filename=' . $ filename ) ; $ this -> header ( 'Content-Transfer-Encoding' , 'binary' ) ; $ this -> header ( 'Expires' , '0' ) ; $ this -> header ( 'Cache-Control' , 'must-revalidate' ) ; $ this -> header ( 'Pragma' , 'public' ) ; $ this -> header ( 'Content-Length' , strlen ( $ this -> body ( ) ) ) ; return $ this ; }
|
modify the headers to force a download
|
5,353
|
public function send ( $ headers = false ) { if ( $ headers && headers_sent ( ) && ! CLI ) { throw new CCException ( "CCResponse::send - cannot send header, header has already been send." ) ; } if ( $ headers ) { header ( CCIn :: server ( 'SERVER_PROTOCOL' ) . ' ' . $ this -> _status . ' ' . CCResponse :: $ messages [ $ this -> _status ] ) ; if ( ! isset ( $ this -> _header [ 'Content-Type' ] ) ) { $ this -> header ( 'Content-Type' , 'text/html; charset=' . ClanCats :: $ config -> get ( 'charset' , 'utf-8' ) ) ; } $ this -> header ( 'X-Powered-By' , 'ClanCatsFramework version: ' . ClanCats :: VERSION ) ; foreach ( $ this -> _header as $ key => $ content ) { header ( $ key . ': ' . $ content ) ; } } CCProfiler :: check ( 'CCResponse - sending response' ) ; echo CCEvent :: pass ( 'response.output' , $ this -> body ( ) ) ; }
|
send response means printing the response and setting the headers if set
|
5,354
|
protected function normalize_date_time ( $ value ) { if ( $ value === '' || $ value === NULL ) { return $ value ; } if ( ! is_string ( $ value ) && ! is_int ( $ value ) && ! $ value instanceof DateTime ) { return $ value ; } if ( is_int ( $ value ) ) { $ value = new \ DateTime ( '@' . $ value ) ; } elseif ( ! $ value instanceof DateTime ) { $ value = new \ DateTime ( $ value ) ; } return $ value -> format ( $ this -> options [ 'format' ] ) ; }
|
Normalize the provided value to a formatted string .
|
5,355
|
public function setIngredients ( array $ ingredients ) { $ this -> ingredients = array_values ( array_filter ( $ ingredients , function ( $ ingredient ) : bool { return $ ingredient instanceof Ingredient ; } ) ) ; return $ this ; }
|
Sets the ingredients of the recipe .
|
5,356
|
public function setProducts ( array $ products ) { $ this -> products = array_values ( array_filter ( $ products , function ( $ product ) : bool { return $ product instanceof Product ; } ) ) ; return $ this ; }
|
Sets the products of the recipe .
|
5,357
|
public function actionIndex ( ) { $ searchModel = new OrderSearch ( ) ; $ queryParams = request ( ) -> queryParams ; $ queryParams [ 'OrderSearch' ] [ 'customer_username' ] = get_current_user_name ( ) ; $ dataProvider = $ searchModel -> search ( $ queryParams ) ; $ dataProvider -> sort -> defaultOrder = [ 'id' => SORT_DESC ] ; $ dataProvider = $ searchModel -> search ( request ( ) -> queryParams ) ; return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
|
Lists all Order models .
|
5,358
|
public function tzFormat ( $ format , $ tz = null ) { if ( isset ( $ tz ) ) { $ this -> setTimezone ( new DateTimeZone ( $ tz ) ) ; } return $ this -> format ( $ format ) ; }
|
Formatting by timezone
|
5,359
|
public function jsonSerialize ( ) { if ( $ tz = Norm :: options ( 'tz' ) ) { $ this -> setTimezone ( new DateTimeZone ( $ tz ) ) ; } return $ this -> format ( 'c' ) ; }
|
Perform serialization of this implementation .
|
5,360
|
public function render ( $ route , $ id = null , $ options = array ( ) , $ view = null ) { return $ this -> pagebar -> render ( $ route , $ id , $ options , $ view ) ; }
|
Renders the paginator
|
5,361
|
public function convert ( $ field , $ type , array $ options = [ ] ) { if ( ! isset ( $ this -> _defaults [ $ type ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Converter %s does not exist' , $ type ) ) ; } $ this -> _converters [ $ field ] = Hash :: merge ( [ 'encode' => true , 'decode' => true , 'type' => $ type , ] , $ this -> _defaults [ $ type ] , $ options ) ; return $ this ; }
|
Define a converter for a specific field .
|
5,362
|
public function preSave ( Event $ event , Query $ query , $ id , array & $ data ) { $ repo = $ this -> getRepository ( ) ; $ converters = $ this -> getConverters ( ) ; foreach ( $ data as $ key => $ value ) { if ( empty ( $ converters [ $ key ] ) ) { continue ; } $ converter = $ converters [ $ key ] ; if ( ! $ converter [ 'encode' ] ) { continue ; } switch ( $ converter [ 'type' ] ) { case self :: SERIALIZE : $ value = $ this -> toSerialize ( $ value , $ converter ) ; break ; case self :: JSON : $ value = $ this -> toJson ( $ value , $ converter ) ; break ; case self :: BASE64 : $ value = $ this -> toBase64 ( $ value , $ converter ) ; break ; case self :: CUSTOM : if ( method_exists ( $ repo , $ converter [ 'encode' ] ) ) { $ value = call_user_func_array ( [ $ repo , $ converter [ 'encode' ] ] , [ $ value , $ converter ] ) ; } break ; } $ data [ $ key ] = $ value ; } return true ; }
|
Apply the encoding converter before a record is saved .
|
5,363
|
public function postFind ( Event $ event , array & $ results , $ finder ) { if ( ! in_array ( $ finder , [ 'first' , 'all' ] ) ) { return ; } $ repo = $ this -> getRepository ( ) ; $ converters = $ this -> getConverters ( ) ; foreach ( $ results as $ i => $ result ) { foreach ( $ result as $ key => $ value ) { if ( empty ( $ converters [ $ key ] ) ) { continue ; } $ converter = $ converters [ $ key ] ; if ( ! $ converter [ 'decode' ] ) { continue ; } switch ( $ converter [ 'type' ] ) { case self :: SERIALIZE : $ value = $ this -> fromSerialize ( $ value , $ converter ) ; break ; case self :: JSON : $ value = $ this -> fromJson ( $ value , $ converter ) ; break ; case self :: BASE64 : $ value = $ this -> fromBase64 ( $ value , $ converter ) ; break ; case self :: CUSTOM : if ( method_exists ( $ repo , $ converter [ 'decode' ] ) ) { $ value = call_user_func_array ( [ $ repo , $ converter [ 'decode' ] ] , [ $ value , $ converter ] ) ; } break ; } $ results [ $ i ] [ $ key ] = $ value ; } } }
|
Apply the decoding converter after a record is retrieved .
|
5,364
|
public function getRootDir ( ) { static $ dir ; if ( empty ( $ dir ) ) { $ rc = new \ ReflectionClass ( get_class ( $ this ) ) ; $ dir = dirname ( dirname ( $ rc -> getFileName ( ) ) ) ; } return $ dir ; }
|
Get root directory .
|
5,365
|
public function getCacheDir ( ) { static $ dir ; if ( empty ( $ dir ) ) { $ dir = $ this -> getOpenDir ( ) . '/cache/' ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0755 , true ) ; } } return $ dir ; }
|
Get cache directory .
|
5,366
|
public function getLogDir ( ) { static $ dir ; if ( empty ( $ dir ) ) { $ dir = $ this -> getOpenDir ( ) . '/log/' ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0755 , true ) ; } } return $ dir ; }
|
Get log directory .
|
5,367
|
public function await ( $ timeout = 0 , TimeUnit $ unit = null ) { if ( null !== $ unit ) { $ timeout = $ unit -> toMicros ( $ timeout ) ; } $ timeoutAt = microtime ( true ) + ( $ timeout / 1000000 ) ; while ( 0 != $ this -> count ) { if ( $ timeout > 0 && ( microtime ( true ) > $ timeoutAt ) ) { return false ; } time_nanosleep ( 0 , 1 ) ; } return true ; }
|
Causes the current thread to wait until the latch has counted down to zero unless the thread is interrupted .
|
5,368
|
public static function getIndex ( ) { try { if ( ! DB :: table ( config ( 'center.db.users' ) ) -> count ( ) ) return view ( 'center::login.install' ) ; } catch ( \ Exception $ e ) { if ( $ e -> getCode ( ) == 2002 ) { trigger_error ( 'Center needs a valid database connection.' ) ; } } return view ( 'center::login.index' ) ; }
|
show login page if not logged in
|
5,369
|
public function postIndex ( Request $ request ) { if ( DB :: table ( config ( 'center.db.users' ) ) -> count ( ) ) { if ( Auth :: attempt ( [ 'email' => $ request -> input ( 'email' ) , 'password' => $ request -> input ( 'password' ) ] , true ) ) { DB :: table ( config ( 'center.db.users' ) ) -> where ( 'id' , Auth :: user ( ) -> id ) -> update ( [ 'last_login' => new DateTime ] ) ; return redirect ( ) -> intended ( action ( '\LeftRight\Center\Controllers\TableController@index' ) ) ; } return redirect ( ) -> action ( '\LeftRight\Center\Controllers\TableController@index' ) -> with ( 'error' , trans ( 'center::site.login_invalid' ) ) ; } $ user_id = DB :: table ( config ( 'center.db.users' ) ) -> insertGetId ( [ 'name' => $ request -> input ( 'name' ) , 'email' => $ request -> input ( 'email' ) , 'password' => Hash :: make ( $ request -> input ( 'password' ) ) , 'last_login' => new DateTime , 'updated_at' => new DateTime , 'updated_by' => 1 , ] ) ; Auth :: loginUsingId ( $ user_id , true ) ; return redirect ( ) -> action ( '\LeftRight\Center\Controllers\TableController@index' ) ; }
|
handle a post to the login or install form
|
5,370
|
public function getChange ( $ email , $ token ) { if ( ! $ user = DB :: table ( config ( 'center.db.users' ) ) -> whereNull ( 'deleted_at' ) -> where ( 'email' , $ email ) -> where ( 'token' , $ token ) -> first ( ) ) { return redirect ( ) -> action ( '\LeftRight\Center\Controllers\LoginController@getReset' ) -> with ( [ 'error' => trans ( 'center::site.password_change_error' ) ] ) ; } return view ( 'center::login.change' , [ 'email' => $ email , 'token' => $ token , ] ) ; }
|
reset password form
|
5,371
|
protected function _respond ( $ string ) { if ( is_null ( $ this -> view ) ) { $ this -> theme -> content = $ string ; } else { $ this -> theme -> content = $ this -> view -> render ( ) ; } if ( CCRequest :: current ( ) -> args -> force_modal || $ this -> modal ) { return CCResponse :: create ( $ this -> theme -> content , $ this -> status ) ; } return CCResponse :: create ( $ this -> theme -> render ( ) , $ this -> status ) ; }
|
When a controller gives us a string make a response out of it
|
5,372
|
protected function handle ( $ handler ) { $ handler_type = $ this -> get_handler_type ( $ handler ) ; if ( empty ( $ handler ) || empty ( $ handler_type ) ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'no route found' , response :: STATUS_NOT_FOUND ) ; } $ this -> { 'load_handler_as_' . $ handler_type } ( $ handler ) ; }
|
find someone else and let them handle the request
|
5,373
|
protected function find_handler_path ( $ filename ) { $ filename = strtolower ( $ filename ) ; if ( preg_match ( '{[^a-z0-9/_-]}' , $ filename ) ) { return false ; } $ base_path = \ alsvanzelf \ fem \ ROOT_DIR_APP . $ this -> handler_base_path . '/' ; $ full_path = $ base_path . $ filename . '.php' ; if ( file_exists ( $ full_path ) == false ) { return false ; } if ( strpos ( $ full_path , $ base_path ) !== 0 ) { return false ; } return $ full_path ; }
|
finds the handler s file
|
5,374
|
private function find_handler ( ) { $ handler = false ; if ( empty ( $ this -> url ) ) { return $ this -> default_handler ; } if ( $ this -> map_to_filesystem && $ this -> find_handler_path ( $ this -> url ) ) { return $ this -> url ; } if ( $ this -> map_to_filesystem == false ) { $ handler = $ this -> find_custom_handler ( ) ; } if ( empty ( $ handler ) && $ this -> fallback_to_default ) { return $ this -> default_handler ; } return $ handler ; }
|
find a handler for the requested url
|
5,375
|
private function find_custom_handler ( ) { $ routes = $ this -> get_custom_routes ( ) ; if ( empty ( $ routes ) || empty ( $ routes [ $ this -> method ] ) ) { return false ; } if ( isset ( $ routes [ $ this -> method ] [ $ this -> url ] ) ) { return $ routes [ $ this -> method ] [ $ this -> url ] ; } $ handler = false ; foreach ( $ routes [ $ this -> method ] as $ url_regex => $ possible_handler ) { if ( preg_match ( '{^' . $ url_regex . '$}' , $ this -> url , $ matches ) ) { $ handler = $ possible_handler ; if ( strpos ( $ url_regex , '?<' ) && count ( $ matches ) > 1 ) { $ this -> arguments = $ matches ; } break ; } } return $ handler ; }
|
matches the user defined routes
|
5,376
|
private function get_handler_type ( $ handler ) { if ( $ handler instanceof \ Closure ) { return 'function' ; } if ( is_string ( $ handler ) == false ) { return false ; } if ( strpos ( $ handler , '->' ) ) { return 'method' ; } if ( strpos ( $ handler , '::' ) ) { return 'static' ; } if ( $ handler && $ this -> find_handler_path ( $ handler ) ) { return 'file' ; } return false ; }
|
figure out how to run the given handler
|
5,377
|
private function load_handler_as_method ( $ handler ) { list ( $ class , $ method ) = explode ( '->' , $ handler ) ; $ object = new $ class ; $ object -> $ method ( $ this -> url , $ this -> method , $ this -> arguments ) ; }
|
instantiated method handler
|
5,378
|
private function load_handler_as_static ( $ handler ) { list ( $ class , $ method ) = explode ( '::' , $ handler ) ; $ class :: $ method ( $ this -> url , $ this -> method , $ this -> arguments ) ; }
|
static method handler
|
5,379
|
private function load_handler_as_file ( $ handler ) { $ path = $ this -> find_handler_path ( $ handler ) ; require_once $ path ; $ class_name = str_replace ( '/' , '\\' , $ handler ) ; if ( $ this -> auto_instantiation && is_callable ( $ class_name ) ) { new $ class_name ( $ this -> url , $ this -> method , $ this -> arguments ) ; } }
|
file reference handler
|
5,380
|
public function stop ( ) { $ time = microtime ( true ) ; $ this -> time += $ time - $ this -> start ; $ this -> start = $ time ; return $ this ; }
|
Stop the timer .
|
5,381
|
public function time ( ) { $ format = $ this -> format ; $ format = $ this -> replace ( 'u' , 6 , $ format ) ; $ format = $ this -> replace ( 'ms' , 3 , $ format ) ; return gmdate ( $ format , $ this -> time ) ; }
|
Return measured time .
|
5,382
|
private function replace ( $ pattern , $ precision , $ format ) { $ time = round ( $ this -> time , $ precision ) ; $ value = substr ( number_format ( $ time - floor ( $ time ) , $ precision ) , 2 ) ; return str_replace ( $ pattern , $ value , $ format ) ; }
|
Replace the date format with calculated values .
|
5,383
|
public function setAttributesValues ( Collection $ attributesValues ) { foreach ( $ attributesValues as $ attributeValue ) { $ this -> addAttributeValue ( $ attributeValue ) ; } return $ this ; }
|
Set the attribute values
|
5,384
|
public function addAttributeValue ( AttributeValueInterface $ attributeValue ) { if ( ! $ this -> attributeValues -> contains ( $ attributeValue ) ) { $ attributeValue -> setSubject ( $ this ) ; $ this -> attributeValues -> add ( $ attributeValue ) ; } return $ this ; }
|
Add an attribute value
|
5,385
|
public function removeAttributeValue ( AttributeValueInterface $ attributeValue ) { if ( $ this -> attributeValues -> contains ( $ attributeValue ) ) { $ attributeValue -> setSubject ( null ) ; $ this -> attributeValues -> removeElement ( $ attributeValue ) ; } return $ this ; }
|
Remove an attribute value
|
5,386
|
public function hasAttributeValueByName ( $ attributeValueName ) { foreach ( $ this -> attributeValues as $ attributeValue ) { if ( $ attributeValue -> getAttributeName ( ) == $ attributeValueName ) { return true ; } } return false ; }
|
Check if has an attribute value that matches a given name
|
5,387
|
public function getAttributeValueByName ( $ attributeValueName ) { foreach ( $ this -> attributeValues as $ attributeValue ) { if ( $ attributeValue -> getAttributeName ( ) == $ attributeValueName ) { return $ attributeValue ; } } return null ; }
|
Gets an attribute value if matches a given name or null instead
|
5,388
|
public static function cache_path ( $ view ) { if ( strpos ( $ view , '::' ) !== false ) { list ( $ package , $ view ) = explode ( '::' , $ view ) ; } else { $ package = 'app' ; } return \ CCStorage :: path ( 'views/' . $ package . '/' . $ view . EXT ) ; }
|
Get the cache path of a view
|
5,389
|
public function file ( $ file = null ) { if ( ! is_null ( $ file ) ) { return $ this -> _file = $ file ; } return $ this -> _file ; }
|
set or get the current file
|
5,390
|
public function set ( $ key , $ value , $ param = null ) { if ( $ param === true ) { $ value = CCStr :: htmlentities ( $ value ) ; } return CCArr :: set ( $ key , $ value , $ this -> _data ) ; }
|
custom setter with encode ability
|
5,391
|
public function capture ( $ key , $ callback ) { return $ this -> set ( $ key , CCStr :: capture ( $ callback , $ this ) ) ; }
|
just like set but it can captures all output in a closure and set that .
|
5,392
|
public function capture_append ( $ key , $ callback ) { return $ this -> set ( $ key , $ this -> get ( $ key , '' ) . CCStr :: capture ( $ callback , $ this ) ) ; }
|
just like capture but it appends
|
5,393
|
protected function view_path ( $ view ) { if ( isset ( static :: $ _view_paths [ $ view ] ) ) { return static :: $ _view_paths [ $ view ] ; } if ( is_null ( $ view ) ) { throw new CCException ( "CCView - cannot render view without a view file." ) ; } $ path = CCPath :: get ( $ view , CCDIR_VIEW , EXT ) ; if ( ! file_exists ( $ path ) ) { throw new CCException ( "CCView - could not find view: " . $ view . " at: {$path}." ) ; } if ( strpos ( $ view , '.' ) !== false ) { $ cache = static :: cache_path ( $ view ) ; if ( ! file_exists ( $ cache ) || filemtime ( $ cache ) < filemtime ( $ path ) ) { list ( $ view_name , $ builder ) = explode ( '.' , $ view ) ; $ this -> build_cache ( $ cache , $ builder , $ path ) ; } $ path = $ cache ; } return static :: $ _view_paths [ $ view ] = $ path ; }
|
Get the path to real view file
|
5,394
|
protected function build_cache ( $ path , $ builder , $ view_path ) { CCFile :: write ( $ path , CCView_Builder :: compile ( $ builder , $ view_path ) ) ; }
|
Build a view cache file
|
5,395
|
public function render ( $ file = null ) { if ( ! is_null ( $ file ) ) { $ this -> file ( $ file ) ; } $ path = $ this -> view_path ( $ this -> file ( ) ) ; extract ( $ this -> _data ) ; if ( ! empty ( static :: $ _globals ) ) { extract ( static :: $ _globals , EXTR_PREFIX_SAME , 'global' ) ; } ob_start ( ) ; require ( $ path ) ; return ob_get_clean ( ) ; }
|
Render the view and return the output .
|
5,396
|
protected function addExchanges ( array $ commandClassToHandlerMap ) { foreach ( $ commandClassToHandlerMap as $ messageClass => $ handler ) { $ this -> addExchange ( $ handler , $ messageClass ) ; } }
|
Allows you to add multiple exchanges at once .
|
5,397
|
public function removeAdjustment ( AdjustmentInterface $ adjustment ) { if ( $ this -> hasAdjustment ( $ adjustment ) ) { $ this -> adjustmentsTotal = null ; $ adjustment -> setAdjustable ( null ) ; $ this -> adjustments -> removeElement ( $ adjustment ) ; } return $ this ; }
|
Removes a given adjustment
|
5,398
|
public function removeAdjustmentByLabel ( $ adjustmentLabel ) { foreach ( $ this -> adjustments as $ adjustment ) { if ( $ adjustmentLabel == $ adjustment -> getLabel ( ) ) { $ this -> removeAdjustment ( $ adjustment ) ; return $ this ; } } return $ this ; }
|
Removes an adjustment by label
|
5,399
|
public function calculateAdjustmentsTotal ( ) { $ this -> adjustmentsTotal = 0 ; foreach ( $ this -> adjustments as $ adjustment ) { if ( ! $ adjustment -> isNeutral ( ) ) { $ this -> adjustmentsTotal += $ adjustment -> getAmount ( ) ; } } return $ this ; }
|
Recalculates the adjustment amount
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.