idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
8,400
|
public function casMember ( $ member , $ oldValue , $ newValue ) { $ set = false ; $ this -> lock ( ) ; if ( $ this [ $ member ] == $ oldValue ) { $ this [ $ member ] = $ newValue ; $ set = true ; } $ this -> unlock ( ) ; return $ set ; }
|
Performs a compare and swap operation on a class member
|
8,401
|
public function indexAction ( ) { $ id = $ this -> getUser ( ) -> getId ( ) ; $ oUser = UserQuery :: create ( ) -> findOneById ( $ id ) ; $ form = $ this -> createFormBuilder ( $ oUser ) -> setAction ( $ this -> generateUrl ( "notification_center_update" ) ) -> add ( 'notification_change' , 'checkbox' ) -> add ( 'notification_error' , 'checkbox' ) -> add ( 'save' , 'submit' , array ( 'label' => $ this -> get ( 'translator' ) -> trans ( 'notificationcenter.form.save' ) ) ) -> getForm ( ) ; return $ this -> render ( 'SlashworksAppBundle:NotificationCenter:index.html.twig' , array ( 'user' => $ oUser , 'form' => $ form -> createView ( ) ) ) ; }
|
Display form for notification settings
|
8,402
|
public function updateAction ( Request $ request ) { try { $ id = $ this -> getUser ( ) -> getId ( ) ; $ oUser = UserQuery :: create ( ) -> findOneById ( $ id ) ; if ( $ oUser === null ) { throw $ this -> createNotFoundException ( 'Unable to find User entity.' ) ; } $ aPost = $ request -> request -> get ( "form" ) ; $ nbUpdatedRows = UserQuery :: create ( ) -> filterById ( $ id ) -> update ( array ( 'NotificationError' => isset ( $ aPost [ 'notification_error' ] ) , 'NotificationChange' => isset ( $ aPost [ 'notification_change' ] ) ) ) ; $ aResult = array ( "success" => true , "message" => $ this -> get ( "translator" ) -> trans ( "notificationcenter.save.successful" ) ) ; } catch ( \ Exception $ e ) { $ aResult = array ( "success" => false , "message" => $ this -> get ( "translator" ) -> trans ( "notificationcenter.save.failed" ) . ":<br>" . $ e -> getMessage ( ) ) ; } $ sResult = json_encode ( $ aResult ) ; $ response = new Response ( $ sResult ) ; $ response -> headers -> set ( 'Content-Type' , 'application/json' ) ; return $ response ; }
|
Update notification settings
|
8,403
|
public function onControllerSetup ( Event $ event ) { $ controller = $ event -> getSubject ( ) ; $ isAdmin = ( $ controller -> request -> getParam ( 'prefix' ) === 'admin' ) ; $ plugins = Plugin :: loaded ( ) ; foreach ( $ plugins as $ plugin ) { $ path = Plugin :: path ( $ plugin ) ; $ menuFile = ( $ isAdmin ) ? 'admin_menu' : 'menu' ; $ navConf = $ path . 'config/' . $ menuFile . '.php' ; if ( FS :: isFile ( $ navConf ) ) { require_once $ navConf ; } } }
|
On controller setup .
|
8,404
|
public function getNewFormRequestMeta ( $ clone = TRUE ) { if ( ! isset ( $ this -> newFormRequestMeta ) ) { $ this -> newFormRequestMeta = new RequestMeta ( \ Psc \ Net \ HTTP \ Request :: GET , $ this -> constructUrl ( array ( $ this -> getEntityNamePlural ( ) , 'form' ) ) ) ; } if ( $ clone ) { return clone $ this -> newFormRequestMeta ; } else { return $ this -> newFormRequestMeta ; } }
|
Zeigt das Entity erstellen Formular an
|
8,405
|
public function getSearchRequestMeta ( Array $ query = NULL ) { if ( ! isset ( $ this -> searchRequestMeta ) ) { $ this -> searchRequestMeta = new RequestMeta ( \ Psc \ Net \ HTTP \ Request :: GET , $ this -> constructUrl ( array ( $ this -> getEntityNamePlural ( ) , '%s' ) ) , array ( RequestMeta :: QUERY ) ) ; } if ( isset ( $ query ) ) { $ meta = clone $ this -> searchRequestMeta ; return $ meta -> setInput ( $ query ) ; } return $ this -> searchRequestMeta ; }
|
Request zum Suchen von Entities und zur LowLevel Ausgabe
|
8,406
|
public function initTodo ( ) { $ todo = $ this -> getVar ( array ( 'todo' ) , 'GP' ) ; $ this -> assertTodo ( $ todo ) ; $ this -> setTodo ( $ todo ) ; if ( ! isset ( $ this -> todo ) ) $ this -> todo = $ this -> defaultTodo ; }
|
Initialisiert das Todo des Controllers
|
8,407
|
public function entity ( Entity $ entity , Array $ linkRelations = array ( ) ) { if ( ! isset ( $ this -> meta [ 'links' ] ) ) $ this -> meta [ 'links' ] = array ( ) ; foreach ( $ linkRelations as $ linkRelation ) { $ this -> meta [ 'links' ] [ ] = ( object ) array ( 'rel' => $ linkRelation -> getName ( ) , 'href' => $ linkRelation -> getHref ( ) ) ; } return $ this ; }
|
Adds metadata for the reponse from an Entity
|
8,408
|
public function get_accounts ( ) { static $ ga_accounts = null ; if ( ! is_null ( $ ga_accounts ) ) { return $ ga_accounts ; } $ ga_accounts = array ( ) ; if ( $ this -> ga ) { try { $ accounts = $ this -> ga -> management_accounts -> listManagementAccounts ( ) ; if ( count ( $ accounts -> getItems ( ) ) > 0 ) { $ ga_accounts = $ accounts ; } } catch ( \ Exception $ e ) { error_log ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } } return $ ga_accounts ; }
|
Get account list
|
8,409
|
public function get_properties ( $ account_id ) { $ result = array ( ) ; try { if ( $ this -> ga ) { $ properties = $ this -> ga -> management_webproperties -> listManagementWebproperties ( $ account_id ) ; $ result = $ properties -> getItems ( ) ; } } catch ( \ Exception $ e ) { error_log ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } return $ result ; }
|
Get Web Properties
|
8,410
|
public function getScopes ( ) { if ( $ this -> scopes === null ) { $ this -> scopes = $ this -> formatScopes ( $ this -> server -> getAccessTokenStorage ( ) -> getScopes ( $ this ) ) ; } return $ this -> scopes ; }
|
Return all scopes associated with the access token
|
8,411
|
public function render ( $ key , array $ items = [ ] , array $ options = [ ] , $ level = 1 ) { $ i = 0 ; $ output = [ ] ; $ options = Hash :: merge ( $ this -> _default , $ options ) ; $ sorted = Hash :: sort ( $ items , '{s}.weight' , 'ASC' ) ; $ itemCount = count ( $ sorted ) ; foreach ( $ sorted as $ item ) { $ i ++ ; $ item = $ this -> _setFirstLast ( $ i , $ itemCount , $ item ) ; $ children = false ; if ( count ( $ item [ 'children' ] ) > 0 ) { $ children = $ this -> render ( $ key , $ item [ 'children' ] , $ options , $ level + 1 ) ; } $ itemParams = [ 'options' => $ options , 'item' => $ item , 'count' => $ i , 'children' => $ children , 'level' => $ level , ] ; $ this -> _setItemParams ( $ itemParams ) ; if ( isset ( $ item [ 'callable' ] ) && is_callable ( $ item [ 'callable' ] ) ) { $ output [ ] = call_user_func_array ( $ item [ 'callable' ] , array_merge ( [ 'view' => $ this -> _View ] , $ itemParams ) ) ; } else { $ output [ ] = $ this -> _View -> element ( $ options [ 'itemElement' ] , $ itemParams ) ; } } $ element = $ this -> _getCurrentMenuElement ( $ options , $ level ) ; return $ this -> _View -> element ( $ element , [ 'content' => $ output , 'options' => $ options , ] ) ; }
|
Render menu .
|
8,412
|
protected function _getCurrentMenuElement ( array $ options = [ ] , $ level = 1 ) { if ( $ level > 1 ) { $ levelElement = $ this -> _getLevelElement ( $ options , $ level ) ; if ( $ this -> _View -> elementExists ( $ levelElement ) ) { return $ levelElement ; } return $ options [ 'childMenuAttr' ] [ 'element' ] ; } return $ options [ 'menuAttr' ] [ 'element' ] ; }
|
Get current menu element .
|
8,413
|
protected function _getLevelElement ( array $ options , $ level ) { $ levelElement = 'menu_child_' . $ level ; $ element = $ options [ 'childMenuAttr' ] [ 'element' ] ; list ( $ plugin , $ path ) = $ this -> _View -> pluginSplit ( $ element ) ; $ path = FS :: clean ( $ path , '/' ) ; $ details = explode ( '/' , $ path ) ; array_pop ( $ details ) ; $ path = implode ( '/' , $ details ) ; return $ plugin . '.' . $ path . '/' . $ levelElement ; }
|
Get current menu level element .
|
8,414
|
protected function _setFirstLast ( $ i , $ itemCount , array $ item = [ ] ) { $ item = array_merge ( [ 'last' => false , 'first' => false ] , $ item ) ; if ( $ i == 1 ) { $ item [ 'first' ] = true ; } if ( $ i == $ itemCount ) { $ item [ 'last' ] = true ; } return $ item ; }
|
Setup first last item params .
|
8,415
|
public function getLiAttr ( ) { $ params = self :: $ _itemParams ; $ attr = [ 'class' => 'li-item' ] ; if ( isset ( $ params [ 'item' ] [ 'liClass' ] ) ) { $ attr = $ this -> addClass ( $ attr , $ params [ 'item' ] [ 'liClass' ] ) ; } if ( $ params [ 'item' ] [ 'last' ] ) { $ attr = $ this -> addClass ( $ attr , 'last' ) ; } if ( $ params [ 'item' ] [ 'first' ] ) { $ attr = $ this -> addClass ( $ attr , 'first' ) ; } return $ this -> _setActive ( $ attr ) ; }
|
Get default li attributes .
|
8,416
|
protected function _setActive ( array $ attr = [ ] ) { if ( $ this -> Url -> build ( self :: $ _itemParams [ 'item' ] [ 'url' ] ) == env ( 'REQUEST_URI' ) ) { $ attr = $ this -> addClass ( $ attr , 'active' ) ; } return $ attr ; }
|
Set active item link .
|
8,417
|
public function getPolymorphicRelation ( ) { if ( $ this -> _cached !== null ) { return $ this -> _cached ; } $ className = $ this -> owner -> getAttribute ( $ this -> classAttribute ) ; if ( $ className == "" ) { return null ; } if ( ! class_exists ( $ className ) ) { Yii :: error ( "Underlying object class " . $ className . " not found!" ) ; return null ; } $ tableName = $ className :: tableName ( ) ; $ object = $ className :: find ( ) -> where ( [ $ tableName . '.id' => $ this -> owner -> getAttribute ( $ this -> pkAttribute ) ] ) -> one ( ) ; if ( $ object !== null && $ this -> validateUnderlyingObjectType ( $ object ) ) { $ this -> _cached = $ object ; return $ object ; } return null ; }
|
Returns the Underlying Object
|
8,418
|
private function validateUnderlyingObjectType ( $ object ) { if ( count ( $ this -> mustBeInstanceOf ) == 0 ) { return true ; } foreach ( $ this -> mustBeInstanceOf as $ instance ) { if ( $ object instanceof $ instance ) { return true ; } } Yii :: error ( 'Got invalid underlying object type! (' . $ object -> className ( ) . ')' ) ; return false ; }
|
Validates if given object is of allowed type
|
8,419
|
public static function ConvertEncoding ( $ value , $ to , $ from ) { if ( self :: getIsMbstringEnabled ( ) ) { $ value = mb_convert_encoding ( $ value , $ to , $ from ) ; return $ value ; } if ( self :: getIsIconvEnabled ( ) ) { $ value = iconv ( $ from , $ to , $ value ) ; return $ value ; } return $ value ; }
|
Convert string from one encoding to another . First try mbstring then iconv or no convertion
|
8,420
|
public static function CountCharacters ( $ value , $ enc = 'UTF-8' ) { if ( self :: getIsMbstringEnabled ( ) ) { $ count = mb_strlen ( $ value , $ enc ) ; return $ count ; } if ( self :: getIsIconvEnabled ( ) ) { $ count = iconv_strlen ( $ value , $ enc ) ; return $ count ; } $ count = strlen ( $ value ) ; return $ count ; }
|
Get character count . First try mbstring then iconv finally strlen
|
8,421
|
public function max ( $ table , $ inc = null ) { return $ this -> select ( $ table , [ 'MAX(id)' ] ) [ 0 ] [ 'MAX(id)' ] + ( isset ( $ inc ) ? $ inc : 0 ) ; }
|
Get Maximum ID of a table
|
8,422
|
public function fetch ( $ query ) { $ db = $ this -> connection ( ) ; if ( method_exists ( $ result = $ db -> query ( rtrim ( preg_replace ( '/\s\s/' , ' ' , $ query ) , ' ' ) ) , 'rowCount' ) ) { if ( $ result -> rowCount ( ) && $ result -> setFetchMode ( $ db :: FETCH_ASSOC ) ) { return $ result -> fetchAll ( ) ; } return false ; } }
|
Get Data from the table
|
8,423
|
public function file ( $ cut = true ) { if ( empty ( $ this -> file ) ) { return null ; } if ( $ cut ) { return str_replace ( CCROOT , '' , $ this -> file ) ; } return $ this -> file ; }
|
get file path
|
8,424
|
public function args_string ( ) { if ( ! isset ( $ this -> args ) || ! is_array ( $ this -> args ) ) { return null ; } $ args = $ this -> args ; foreach ( $ args as $ key => $ arg ) { if ( is_array ( $ arg ) ) { $ args [ $ key ] = 'Array' ; } else { $ args [ $ key ] = var_export ( $ arg , true ) ; } } return implode ( ', ' , $ args ) ; }
|
create an argument string
|
8,425
|
private function parse_source ( ) { if ( ! $ this -> file ( ) ) { return null ; } $ lines = file ( $ this -> file ) ; $ size = 10 ; $ start = $ this -> line - ( $ size / 2 ) ; $ end = $ this -> line + ( $ size / 2 ) ; while ( $ start > 0 && substr ( trim ( $ lines [ $ start - 1 ] ) , 0 , 1 ) === '*' ) { $ start -- ; } $ source = array ( ) ; for ( $ i = $ start - 1 ; $ i < $ end ; $ i ++ ) { if ( array_key_exists ( $ i , $ lines ) ) { $ source [ $ i ] = str_replace ( "\t" , ' ' , $ lines [ $ i ] ) ; } } $ this -> source = $ source ; }
|
parse the source file
|
8,426
|
public function reflection_file ( ) { if ( is_null ( $ this -> reflection_file ) ) { if ( is_null ( $ reflection = $ this -> reflection ( ) ) ) { return null ; } $ this -> reflection_file = file ( $ reflection -> getFileName ( ) ) ; } return $ this -> reflection_file ; }
|
get the source code of the reflected file
|
8,427
|
public function reflection_function_info ( $ function = null ) { if ( is_null ( $ lines = $ this -> reflection_file ( ) ) ) { return null ; } if ( is_null ( $ function ) ) { if ( is_null ( $ function = $ this -> function_name ( ) ) ) { return null ; } } $ info = array ( 'message' => '' , ) ; foreach ( $ lines as $ index => $ line ) { if ( strpos ( $ line , 'function ' . $ function ) !== false ) { if ( substr ( trim ( $ lines [ $ index - 1 ] ) , 0 , 1 ) === '*' ) { $ start = $ index - 1 ; $ comment = array ( ) ; while ( $ start > 0 && substr ( trim ( $ lines [ $ start - 1 ] ) , 0 , 1 ) === '*' ) { $ start -- ; array_unshift ( $ comment , substr ( trim ( trim ( $ lines [ $ start ] ) , "*" ) , 1 ) ) ; } $ in_quote = false ; foreach ( $ comment as $ line ) { if ( strpos ( $ line , '@' ) !== false ) { $ line = preg_replace ( "!\t+!" , "\t" , $ line ) ; $ line = str_replace ( "\t" , ' ' , $ line ) ; $ info [ trim ( substr ( $ line , 1 , strpos ( $ line , ' ' ) ) ) ] [ ] = trim ( substr ( $ line , strpos ( $ line , ' ' ) ) ) ; } else { $ line = str_replace ( "\t" , ' ' , $ line ) ; if ( substr ( $ line , 0 , 4 ) == ' ' && ! $ in_quote ) { $ info [ 'message' ] .= "<pre>" ; $ in_quote = true ; } elseif ( substr ( $ line , 0 , 4 ) != ' ' && $ in_quote ) { $ info [ 'message' ] .= "</pre>" ; $ in_quote = false ; } if ( $ in_quote ) { $ line = substr ( $ line , 4 ) ; } $ info [ 'message' ] .= $ line . "\n" ; } } $ info [ 'message' ] = trim ( $ info [ 'message' ] , "\n\r\t" ) ; return $ info ; } continue ; } } }
|
get the source code where the trace happend
|
8,428
|
public function setEmail ( $ email ) { require_once 'Zend/Validate/EmailAddress.php' ; $ validate = new Zend_Validate_EmailAddress ( ) ; if ( ! $ validate -> isValid ( $ email ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to set a valid email address into the email property" ) ; } $ this -> offsetSet ( 'email' , $ email ) ; return $ this ; }
|
Sets the author s email
|
8,429
|
public function setWebmaster ( $ webmaster ) { require_once 'Zend/Validate/EmailAddress.php' ; $ validate = new Zend_Validate_EmailAddress ( ) ; if ( ! $ validate -> isValid ( $ webmaster ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to set a valid email address into the webmaster property" ) ; } $ this -> offsetSet ( 'webmaster' , $ webmaster ) ; return $ this ; }
|
Email address for person responsible for technical issues Ignored if atom is used
|
8,430
|
public function setTtl ( $ ttl ) { require_once 'Zend/Validate/Int.php' ; $ validate = new Zend_Validate_Int ( ) ; if ( ! $ validate -> isValid ( $ ttl ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to set an integer value to the ttl property" ) ; } $ this -> offsetSet ( 'ttl' , $ ttl ) ; return $ this ; }
|
How long in minutes a feed can be cached before refreshing Ignored if atom is used
|
8,431
|
public function setCloud ( $ uri , $ procedure , $ protocol ) { if ( is_string ( $ uri ) && Zend_Uri_Http :: check ( $ uri ) ) { $ uri = Zend_Uri :: factory ( $ uri ) ; } if ( ! $ uri instanceof Zend_Uri_Http ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( 'Passed parameter is not a valid HTTP URI' ) ; } if ( ! $ uri -> getPort ( ) ) { $ uri -> setPort ( 80 ) ; } $ this -> offsetSet ( 'cloud' , array ( 'uri' => $ uri , 'procedure' => $ procedure , 'protocol' => $ protocol ) ) ; return $ this ; }
|
Cloud to be notified of updates of the feed Ignored if atom is used
|
8,432
|
public function setTextInput ( $ title , $ description , $ name , $ link ) { $ this -> offsetSet ( 'textInput' , array ( 'title' => $ title , 'description' => $ description , 'name' => $ name , 'link' => $ link ) ) ; return $ this ; }
|
A text input box that can be displayed with the feed Ignored if atom is used
|
8,433
|
public function setSkipHours ( array $ hours ) { if ( count ( $ hours ) > 24 ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you can not have more than 24 rows in the skipHours property" ) ; } foreach ( $ hours as $ hour ) { if ( $ hour < 0 || $ hour > 23 ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "$hour has te be between 0 and 23" ) ; } } $ this -> offsetSet ( 'skipHours' , $ hours ) ; return $ this ; }
|
Hint telling aggregators which hours they can skip Ignored if atom is used
|
8,434
|
public function setSkipDays ( array $ days ) { if ( count ( $ days ) > 7 ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you can not have more than 7 days in the skipDays property" ) ; } $ valid = array ( 'monday' , 'tuesday' , 'wednesday' , 'thursday' , 'friday' , 'saturday' , 'sunday' ) ; foreach ( $ days as $ day ) { if ( ! in_array ( strtolower ( $ day ) , $ valid ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "$day is not a valid day" ) ; } } $ this -> offsetSet ( 'skipDays' , $ days ) ; return $ this ; }
|
Hint telling aggregators which days they can skip Ignored if atom is used
|
8,435
|
public function store ( $ key , $ value , $ expiry = 0 ) { if ( $ expiry == 0 ) { $ expiry = $ this -> expiry ; } $ entry = new CacheItem ( ) ; $ entry -> value = serialize ( $ value ) ; $ entry -> expireAt = time ( ) + $ expiry ; $ data = serialize ( $ entry ) ; $ this -> store -> store ( $ key , $ data ) ; $ this -> items [ $ key ] = $ entry ; }
|
Cache an item
|
8,436
|
public function get ( $ key ) { $ entry = null ; if ( isset ( $ this -> items [ $ key ] ) ) { $ entry = $ this -> items [ $ key ] ; } else { $ data = $ this -> store -> get ( $ key ) ; if ( $ data ) { $ entry = unserialize ( $ data ) ; } } if ( ! $ entry ) { return $ entry ; } if ( $ entry -> expireAt > time ( ) ) { return unserialize ( $ entry -> value ) ; } $ this -> expire ( $ key ) ; return null ; }
|
Gets a cached value for a given key
|
8,437
|
public function buildForm ( FormBuilderInterface $ builder , $ exportAlias , array $ aggregatorAliases ) { $ builder -> add ( 'numerotation' , ChoiceType :: class , array ( 'choices' => array ( 'yes' => true , 'no' => false ) , 'expanded' => true , 'multiple' => false , 'label' => "Add a number on first column" , 'choices_as_values' => true , 'data' => true ) ) ; }
|
build a form which will be used to collect data required for the execution of this formatter .
|
8,438
|
public function getResponse ( $ result , $ formatterData , $ exportAlias , array $ exportData , array $ filtersData , array $ aggregatorsData ) { $ this -> result = $ result ; $ this -> exportAlias = $ exportAlias ; $ this -> exportData = $ exportData ; $ this -> formatterData = $ formatterData ; $ output = fopen ( 'php://output' , 'w' ) ; $ this -> prepareHeaders ( $ output ) ; $ i = 1 ; foreach ( $ result as $ row ) { $ line = array ( ) ; if ( $ this -> formatterData [ 'numerotation' ] === true ) { $ line [ ] = $ i ; } foreach ( $ row as $ key => $ value ) { $ line [ ] = $ this -> getLabel ( $ key , $ value ) ; } fputcsv ( $ output , $ line ) ; $ i ++ ; } $ csvContent = stream_get_contents ( $ output ) ; fclose ( $ output ) ; $ response = new Response ( ) ; $ response -> setStatusCode ( 200 ) ; $ response -> headers -> set ( 'Content-Type' , 'text/csv; charset=utf-8' ) ; $ response -> setContent ( $ csvContent ) ; return $ response ; }
|
Generate a response from the data collected on differents ExportElementInterface
|
8,439
|
protected function prepareHeaders ( $ output ) { $ keys = $ this -> exportManager -> getExport ( $ this -> exportAlias ) -> getQueryKeys ( $ this -> exportData ) ; $ first_row = count ( $ this -> result ) > 0 ? $ this -> result [ 0 ] : array ( ) ; $ header_line = array ( ) ; if ( $ this -> formatterData [ 'numerotation' ] === true ) { $ header_line [ ] = $ this -> translator -> trans ( 'Number' ) ; } foreach ( $ first_row as $ key => $ value ) { $ header_line [ ] = $ this -> getLabel ( $ key , '_header' ) ; } if ( count ( $ header_line ) > 0 ) { fputcsv ( $ output , $ header_line ) ; } }
|
add the headers to the csv file
|
8,440
|
protected function getLabel ( $ key , $ value ) { if ( $ this -> labelsCache === null ) { $ this -> prepareCacheLabels ( ) ; } return $ this -> labelsCache [ $ key ] ( $ value ) ; }
|
Give the label corresponding to the given key and value .
|
8,441
|
protected function prepareCacheLabels ( ) { $ export = $ this -> exportManager -> getExport ( $ this -> exportAlias ) ; $ keys = $ export -> getQueryKeys ( $ this -> exportData ) ; foreach ( $ keys as $ key ) { $ values = \ array_map ( function ( $ v ) use ( $ key ) { return $ v [ $ key ] ; } , $ this -> result ) ; $ this -> labelsCache [ $ key ] = $ export -> getLabels ( $ key , $ values , $ this -> exportData ) ; } }
|
Prepare the label cache which will be used by getLabel . This function should be called only once in the generation lifecycle .
|
8,442
|
public function hasFeature ( $ feature ) { $ feature = strtoupper ( $ feature ) ; if ( ! isset ( $ this -> features [ $ feature ] ) ) { return null ; } return $ this -> features [ $ feature ] ; }
|
Check if feature exists and enabled .
|
8,443
|
public function setEventEmitter ( $ emitter = null ) { if ( $ emitter === null ) { $ this -> eventEmitter = new Emitter ( ) ; } else { $ this -> eventEmitter = $ emitter ; } }
|
Set an event emitter
|
8,444
|
public function addEventListener ( $ eventName , callable $ listener , $ priority = Emitter :: P_NORMAL ) { $ this -> eventEmitter -> addListener ( $ eventName , $ listener , $ priority ) ; }
|
Add an event listener to the event emitter
|
8,445
|
public function setClientStorage ( ClientInterface $ storage ) { $ storage -> setServer ( $ this ) ; $ this -> clientStorage = $ storage ; return $ this ; }
|
Set the client storage
|
8,446
|
public function setSessionStorage ( SessionInterface $ storage ) { $ storage -> setServer ( $ this ) ; $ this -> sessionStorage = $ storage ; return $ this ; }
|
Set the session storage
|
8,447
|
public function setAccessTokenStorage ( AccessTokenInterface $ storage ) { $ storage -> setServer ( $ this ) ; $ this -> accessTokenStorage = $ storage ; return $ this ; }
|
Set the access token storage
|
8,448
|
public function setRefreshTokenStorage ( RefreshTokenInterface $ storage ) { $ storage -> setServer ( $ this ) ; $ this -> refreshTokenStorage = $ storage ; return $ this ; }
|
Set the refresh token storage
|
8,449
|
public function setAuthCodeStorage ( AuthCodeInterface $ storage ) { $ storage -> setServer ( $ this ) ; $ this -> authCodeStorage = $ storage ; return $ this ; }
|
Set the auth code storage
|
8,450
|
public function setScopeStorage ( ScopeInterface $ storage ) { $ storage -> setServer ( $ this ) ; $ this -> scopeStorage = $ storage ; return $ this ; }
|
Set the scope storage
|
8,451
|
public function actionDelete ( $ id ) { if ( Admin :: find ( ) -> count ( ) == 1 ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'yuncms' , 'This is the last administrator, delete can not manage the system, it can not be deleted!' ) ) ; return $ this -> redirect ( [ 'index' ] ) ; } $ this -> findModel ( $ id ) -> delete ( ) ; Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'yuncms' , 'Delete success.' ) ) ; return $ this -> redirect ( [ 'index' ] ) ; }
|
Deletes an existing Admin model . If deletion is successful the browser will be redirected to the index page .
|
8,452
|
public static function init ( array $ attributes ) { $ obj = new Attributes ; foreach ( $ attributes as $ attribute ) { $ obj -> { $ attribute -> key } = $ attribute ; } return $ obj ; }
|
Initialize from list of attributes .
|
8,453
|
protected function sessionUserId ( ) { $ userId = null ; $ request = $ this -> newRequest ( ) ; if ( $ request -> session ( ) -> started ( ) ) { $ userId = $ request -> session ( ) -> read ( $ this -> _config [ 'sessionUserIdKey' ] ) ; } else { $ this -> log ( 'The Session is not started. This typically means a User is not logged in. In this case there is no Session value for the currently active User and therefore we will set the `creator_id` and `modifier_id` to a null value. As a fallback, we are manually starting the session and reading the `$this->_config[sessionUserIdKey]` value, which is probably not correct.' , 'debug' ) ; try { $ request -> session ( ) -> start ( ) ; $ userId = $ request -> session ( ) -> read ( $ this -> _config [ 'sessionUserIdKey' ] ) ; } catch ( RuntimeException $ e ) { } } return $ userId ; }
|
Return the User . id grabbed from the Session information .
|
8,454
|
public static function importArray ( array $ data , $ format = 'atom' ) { $ obj = 'Zend_Feed_' . ucfirst ( strtolower ( $ format ) ) ; require_once 'Zend/Loader.php' ; Zend_Loader :: loadClass ( $ obj ) ; require_once 'Zend/Feed/Builder.php' ; return new $ obj ( null , null , new Zend_Feed_Builder ( $ data ) ) ; }
|
Construct a new Zend_Feed_Abstract object from a custom array
|
8,455
|
public static function importBuilder ( Zend_Feed_Builder_Interface $ builder , $ format = 'atom' ) { $ obj = 'Zend_Feed_' . ucfirst ( strtolower ( $ format ) ) ; require_once 'Zend/Loader.php' ; Zend_Loader :: loadClass ( $ obj ) ; return new $ obj ( null , null , $ builder ) ; }
|
Construct a new Zend_Feed_Abstract object from a Zend_Feed_Builder_Interface data source
|
8,456
|
public function asJsonP ( $ data ) : YiiResponse { $ response = Yii :: $ app -> getResponse ( ) ; $ response -> data = $ data ; $ response -> format = YiiResponse :: FORMAT_JSONP ; return $ response ; }
|
Sets the response format of the given data as JSONP .
|
8,457
|
public function asRaw ( $ data ) : YiiResponse { $ response = Yii :: $ app -> getResponse ( ) ; $ response -> data = $ data ; $ response -> format = YiiResponse :: FORMAT_RAW ; return $ response ; }
|
Sets the response format of the given data as RAW .
|
8,458
|
protected function setParam ( $ key , $ value ) { if ( ! array_key_exists ( $ key , $ this -> _params ) ) { if ( $ this -> _ignoreExisting || $ this -> arrayGet ( $ this -> _setup , 'suppress_errors' ) === true ) { return ; } throw new UnknownPropertyException ( "Unknown property: '{$key}'" ) ; } switch ( $ this -> _types [ $ key ] ) { case "boolean" : $ this -> _params [ $ key ] = ( bool ) $ value ; break ; case "integer" : $ this -> _params [ $ key ] = ( integer ) $ value ; break ; case "float" : $ this -> _params [ $ key ] = ( float ) $ value ; break ; case "string" : $ this -> _params [ $ key ] = ( string ) $ value ; break ; case "array" : $ this -> _params [ $ key ] = ( array ) $ value ; break ; default : $ this -> _params [ $ key ] = $ value ; break ; } }
|
Set a value in the parameter pool and cast it to the same type as the default value
|
8,459
|
protected function setDefaultDataTypes ( ) { foreach ( $ this -> _params as $ key => $ value ) { switch ( gettype ( $ value ) ) { case "boolean" : $ this -> _types [ $ key ] = 'boolean' ; break ; case "integer" : $ this -> _types [ $ key ] = 'integer' ; break ; case "double" : $ this -> _types [ $ key ] = 'float' ; break ; case "string" : $ this -> _types [ $ key ] = 'string' ; break ; case "array" : $ this -> _types [ $ key ] = 'array' ; break ; default : $ this -> _types [ $ key ] = null ; break ; } } }
|
Get the default data types
|
8,460
|
public function toArray ( $ protect = null ) { $ protect = is_array ( $ protect ) ? $ protect : $ this -> _protect ; if ( $ protect ) { $ new = $ this -> _params ; foreach ( $ protect as $ key ) { unset ( $ new [ $ key ] ) ; } return json_decode ( json_encode ( $ new ) , true , 512 ) ; } return json_decode ( json_encode ( $ this -> _params ) , true , 512 ) ; }
|
Return the params as array and remove the protected keys
|
8,461
|
public function date ( $ key , $ format = "F j, Y" ) { if ( is_numeric ( $ this -> _params [ $ key ] ) ) { return date ( $ format , $ this -> _params [ $ key ] ) ; } return date ( $ format , strtotime ( $ this -> _params [ $ key ] ) ) ; }
|
Return a parameter as a formatted date string
|
8,462
|
public static function make ( $ data = null , $ index = null , Closure $ modifier = null ) { if ( $ data instanceof Traversable ) { $ data = iterator_to_array ( $ data ) ; } if ( ! is_array ( $ data ) ) { return null ; } if ( count ( $ data ) < 1 ) { return [ ] ; } $ values = array_values ( $ data ) ; $ multi = array_key_exists ( 0 , $ values ) && is_array ( $ values [ 0 ] ) ; if ( $ multi ) { $ list = [ ] ; foreach ( $ data as $ item ) { if ( $ index && array_key_exists ( $ index , $ item ) ) { $ key = $ item [ $ index ] ; $ list [ $ key ] = static :: populate ( $ item , $ modifier ) ; continue ; } $ list [ ] = static :: populate ( $ item , $ modifier ) ; } return $ list ; } return static :: populate ( $ data , $ modifier ) ; }
|
Convert array to entities
|
8,463
|
protected function arrayGet ( & $ source , $ key , $ default = null ) { if ( ! $ key ) { return $ default ; } if ( array_key_exists ( $ key , $ source ) ) { return $ source [ $ key ] ; } $ current = & $ source ; foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! array_key_exists ( $ segment , $ current ) ) { return $ default ; } $ current = & $ current [ $ segment ] ; } return $ current ; }
|
Get a key value using dot notation
|
8,464
|
protected function arrayHasKey ( & $ source , $ key ) { if ( ! $ key || ! is_array ( $ source ) ) { return false ; } if ( array_key_exists ( $ key , $ source ) ) { return true ; } $ current = & $ source ; foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! array_key_exists ( $ segment , $ current ) ) { return false ; } $ current = & $ current [ $ segment ] ; } return true ; }
|
Check if a key exists using dot notation
|
8,465
|
public function join ( $ separator ) { return $ this -> reduce ( function ( $ joined , $ string ) use ( $ separator ) { return ( '' === $ joined ? '' : $ joined . $ separator ) . $ string ; } , '' ) ; }
|
Join all the strings in this map with the separator between them .
|
8,466
|
public function letter_frequency ( ) { return $ this -> transform ( function ( $ frequencies , $ word ) { foreach ( count_chars ( $ word , 1 ) as $ byte => $ frequency ) { $ letter = chr ( $ byte ) ; if ( $ frequencies -> has ( $ letter ) ) { $ frequencies -> set ( $ letter , $ frequencies -> get ( $ letter ) + 1 ) ; } else { $ frequencies -> set ( $ letter , 1 ) ; } } } , function ( Map $ original ) { return new MapOfInts ( ) ; } ) ; }
|
Calculate frequency of letters in all strings .
|
8,467
|
private static function buildRegex ( string $ expression , bool $ is_prefix = false ) : string { $ regex = self :: REGEX_DELIMITER . '^' ; $ regex .= preg_replace ( array_keys ( self :: $ datatypes ) , self :: $ datatypes , $ expression ) ; $ regex .= $ is_prefix ? '(.*)' : '' ; $ regex .= '$' . self :: REGEX_DELIMITER ; return $ regex ; }
|
Build a complete regular expression
|
8,468
|
private function getParsingMode ( string & $ route ) : int { if ( strpos ( $ route , 'R>' ) === 0 ) { $ route = str_replace ( 'R>' , '' , $ route ) ; return self :: MODE_REGEX ; } if ( strpos ( $ route , 'S>' ) === 0 ) { $ route = str_replace ( 'S>' , '' , $ route ) ; return self :: MODE_STRING ; } return self :: $ mode ; }
|
Detect route parsing mode for specific route
|
8,469
|
private function matchRoute ( string $ route , string $ url , & $ matches , $ value = null ) { switch ( $ this -> getParsingMode ( $ route ) ) { case self :: MODE_REGEX : $ matched = preg_match ( self :: buildRegex ( $ route , ! is_null ( $ value ) ) , $ url , $ matches ) ; array_shift ( $ matches ) ; break ; case self :: MODE_STRING : if ( is_null ( $ value ) ) { $ matched = $ route === $ url ; $ matches = [ ] ; } else { $ matched = empty ( $ route ) ? empty ( $ url ) : strpos ( $ url , $ route ) === 0 ; $ matches = [ str_replace ( $ route , '' , $ url ) ] ; } break ; } if ( is_null ( $ value ) ) { return $ matched ; } $ sub_routes = ! is_callable ( $ value ) && is_array ( $ value ) ; return $ matched && $ sub_routes ; }
|
Match url against route
|
8,470
|
private function route ( ) : void { $ parsed = $ this -> parseRoute ( ) ; if ( ! $ parsed && isset ( $ this -> error_controller ) ) { call_user_func ( $ this -> error_controller ) ; } }
|
Try to parse routes or call the error controller
|
8,471
|
public static function setDefaultMode ( int $ mode ) : void { if ( in_array ( $ mode , [ self :: MODE_REGEX , self :: MODE_STRING ] ) ) { self :: $ mode = $ mode ; return ; } throw new \ UnexpectedValueException ( 'Invalid route mode' ) ; }
|
Set the route parsing mode
|
8,472
|
public function addClassPath ( $ path ) { if ( ! is_array ( $ path ) ) { $ path = array ( $ path ) ; } foreach ( $ path as $ item ) { $ this -> classPaths [ ] = $ item ; } }
|
Adds a path to search in when looking for a class .
|
8,473
|
public function loadClass ( $ className ) { $ cache = $ this -> getCache ( ) ; $ entries = $ cache -> load ( $ this -> cacheKey ) ; if ( $ entries == false ) { $ entries = array ( ) ; } $ status = $ this -> tryAndLoadClass ( $ className , $ entries ) ; if ( $ status ) { return true ; } if ( preg_match ( $ this -> ignoreClassNamesRegexp , $ className ) ) { return false ; } foreach ( $ this -> classPaths as $ path ) { $ realPath = $ this -> searchForClassFile ( $ className , $ path ) ; if ( $ realPath !== false ) { $ entries [ $ className ] = $ realPath ; break ; } } $ cache -> save ( $ entries , $ this -> cacheKey ) ; $ status = $ this -> tryAndLoadClass ( $ className , $ entries ) ; return $ status ; }
|
Returns true if the class file was found and included false if not .
|
8,474
|
public function buildCreateIndex ( Query $ query ) { return $ this -> renderStatement ( Query :: CREATE_INDEX , [ 'index' => $ this -> formatTable ( $ query -> getAlias ( ) ) , 'table' => $ this -> formatTable ( $ query -> getTable ( ) ) , 'fields' => $ this -> formatFields ( $ query ) ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the CREATE INDEX query .
|
8,475
|
public function buildCreateTable ( Query $ query ) { $ schema = $ query -> getSchema ( ) ; if ( ! $ schema ) { throw new InvalidSchemaException ( 'Table creation requires a valid schema object' ) ; } return $ this -> renderStatement ( Query :: CREATE_TABLE , [ 'table' => $ this -> formatTable ( $ schema -> getTable ( ) ) , 'columns' => $ this -> formatColumns ( $ schema ) , 'keys' => $ this -> formatTableKeys ( $ schema ) , 'options' => $ this -> formatTableOptions ( $ schema -> getOptions ( ) ) ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the CREATE TABLE query . Requires a table schema object .
|
8,476
|
public function buildDelete ( Query $ query ) { return $ this -> renderStatement ( Query :: DELETE , [ 'table' => $ this -> formatTable ( $ query -> getTable ( ) , $ query -> getAlias ( ) ) , 'joins' => $ this -> formatJoins ( $ query -> getJoins ( ) ) , 'where' => $ this -> formatWhere ( $ query -> getWhere ( ) ) , 'orderBy' => $ this -> formatOrderBy ( $ query -> getOrderBy ( ) ) , 'limit' => $ this -> formatLimit ( $ query -> getLimit ( ) ) , ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the DELETE query .
|
8,477
|
public function buildDropIndex ( Query $ query ) { return $ this -> renderStatement ( Query :: DROP_INDEX , [ 'index' => $ this -> formatTable ( $ query -> getAlias ( ) ) , 'table' => $ this -> formatTable ( $ query -> getTable ( ) ) ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the DROP INDEX query .
|
8,478
|
public function buildDropTable ( Query $ query ) { return $ this -> renderStatement ( Query :: DROP_TABLE , [ 'table' => $ this -> formatTable ( $ query -> getTable ( ) ) ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the DROP TABLE query .
|
8,479
|
public function buildMultiInsert ( Query $ query ) { return $ this -> renderStatement ( Query :: INSERT , [ 'table' => $ this -> formatTable ( $ query -> getTable ( ) ) , 'fields' => $ this -> formatFields ( $ query ) , 'values' => $ this -> formatValues ( $ query ) ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the INSERT query with multiple record support .
|
8,480
|
public function buildSelect ( Query $ query ) { return $ this -> renderStatement ( Query :: SELECT , [ 'fields' => $ this -> formatFields ( $ query ) , 'table' => $ this -> formatTable ( $ query -> getTable ( ) , $ query -> getAlias ( ) ) , 'joins' => $ this -> formatJoins ( $ query -> getJoins ( ) ) , 'where' => $ this -> formatWhere ( $ query -> getWhere ( ) ) , 'groupBy' => $ this -> formatGroupBy ( $ query -> getGroupBy ( ) ) , 'having' => $ this -> formatHaving ( $ query -> getHaving ( ) ) , 'compounds' => $ this -> formatCompounds ( $ query -> getCompounds ( ) ) , 'orderBy' => $ this -> formatOrderBy ( $ query -> getOrderBy ( ) ) , 'limit' => $ this -> formatLimitOffset ( $ query -> getLimit ( ) , $ query -> getOffset ( ) ) , ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the SELECT query .
|
8,481
|
public function buildTruncate ( Query $ query ) { return $ this -> renderStatement ( Query :: TRUNCATE , [ 'table' => $ this -> formatTable ( $ query -> getTable ( ) ) ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the TRUNCATE query .
|
8,482
|
public function buildUpdate ( Query $ query ) { return $ this -> renderStatement ( Query :: UPDATE , [ 'fields' => $ this -> formatFields ( $ query ) , 'table' => $ this -> formatTable ( $ query -> getTable ( ) , $ query -> getAlias ( ) ) , 'joins' => $ this -> formatJoins ( $ query -> getJoins ( ) ) , 'where' => $ this -> formatWhere ( $ query -> getWhere ( ) ) , 'orderBy' => $ this -> formatOrderBy ( $ query -> getOrderBy ( ) ) , 'limit' => $ this -> formatLimit ( $ query -> getLimit ( ) ) , ] + $ this -> formatAttributes ( $ query -> getAttributes ( ) ) ) ; }
|
Build the UPDATE query .
|
8,483
|
public function extend ( $ template , $ data = [ ] , $ paramName = 'body' ) { $ this -> extendedTemplate = $ this -> resolveTemplatePath ( $ template ) ; if ( is_array ( $ data ) ) { $ this -> extendedData = $ data ; } if ( is_string ( $ paramName ) && $ paramName ) { $ this -> extendedParamName = $ paramName ; } }
|
Set extended template and data .
|
8,484
|
public function translate ( $ key , $ defaultValue = '' , $ locale = null ) { return $ this -> translation -> translate ( $ key , $ defaultValue , $ locale ) ; }
|
Helper function for translation .
|
8,485
|
protected function resolveTemplatePath ( $ path ) { switch ( $ path [ 0 ] ) { case '/' : break ; case '.' : $ path = realpath ( dirname ( $ this -> template ) . '/' . $ path . '.phtml' ) ; break ; default : $ path = realpath ( $ this -> pathService -> getTemplatesPath ( ) . '/' . $ path . '.phtml' ) ; break ; } if ( $ path === false ) { throw new NotFoundException ( $ this -> template . ' file not found' ) ; } return $ path ; }
|
Resolve template path .
|
8,486
|
protected function renderToHtml ( ) { extract ( $ this -> data , EXTR_SKIP ) ; ob_start ( ) ; set_error_handler ( [ $ this , 'handleError' ] ) ; include $ this -> template ; restore_error_handler ( ) ; $ html = ob_get_clean ( ) ; return $ html ; }
|
Render this block to HTML string .
|
8,487
|
protected function normalizeAlias ( $ alias ) { $ normalized = preg_replace ( '/[^a-zA-Z0-9]/' , ' ' , $ alias ) ; $ normalized = 'new' . str_replace ( ' ' , '' , ucwords ( $ normalized ) ) ; return $ normalized ; }
|
Normalize an alias to a new instance method name
|
8,488
|
public function addStyleId ( $ styleId ) { $ styleId = ( string ) $ styleId ; if ( ! in_array ( $ styleId , $ this -> styleIds ) ) { array_push ( $ this -> styleIds , $ styleId ) ; } return $ this ; }
|
Add style Id
|
8,489
|
public function addStyleClass ( $ styleClass ) { $ styleClass = ( string ) $ styleClass ; if ( ! in_array ( $ styleClass , $ this -> styleClasses ) ) { array_push ( $ this -> styleClasses , $ styleClass ) ; } return $ this ; }
|
Add style class
|
8,490
|
public function init ( Entity $ entity , Closure $ adder = NULL , Closure $ remover = NULL ) { parent :: init ( $ entity ) ; list ( $ add , $ remove ) = $ this -> getRelationInterface ( ) ; if ( ! $ adder ) { $ adder = function ( $ entity , $ toEntity , $ repository ) use ( $ add ) { $ repository -> persist ( $ toEntity ) ; $ entity -> $ add ( $ toEntity ) ; } ; } if ( ! $ remover ) { $ remover = function ( $ entity , $ fromEntity , $ repository ) use ( $ remove ) { $ repository -> persist ( $ fromEntity ) ; $ entity -> $ remove ( $ fromEntity ) ; } ; } $ repository = $ this -> collectionRepository ; $ this -> innerSynchronizer -> onInsert ( function ( $ toEntity ) use ( $ repository , $ entity , $ adder ) { $ adder ( $ entity , $ toEntity , $ repository ) ; } ) ; $ this -> innerSynchronizer -> onUpdate ( function ( $ toEntity ) use ( $ repository , $ entity , $ adder ) { $ adder ( $ entity , $ toEntity , $ repository , $ isUpdate = TRUE ) ; } ) ; $ this -> innerSynchronizer -> onDelete ( function ( Entity $ fromEntity ) use ( $ entity , $ remover , $ repository ) { $ remover ( $ entity , $ fromEntity , $ repository ) ; } ) ; return $ this ; }
|
Kompiliert den Synchronizer und initialisiert
|
8,491
|
function postPublicNotification ( $ message , $ link = null , $ iconStyle = null , $ iconSubstyle = null , $ titleIdString = null , $ mediaURL = null , $ group = null ) { $ n = new Notification ( ) ; $ n -> senderName = ( object ) array ( 'serverLogin' => $ this -> serverLogin ) ; $ n -> message = $ message ; $ n -> link = $ link ; $ n -> iconStyle = $ iconStyle ; $ n -> iconSubStyle = $ iconSubstyle ; $ n -> titleId = $ titleIdString ; $ n -> mediaURL = $ mediaURL ; $ n -> group = $ group ; return $ this -> execute ( 'POST' , '/maniahome/notification/public/' , array ( $ n ) ) ; }
|
Send a public notification to every player that bookmarked your server .
|
8,492
|
function postPrivateEvent ( $ message , $ eventDate , $ receiverName , $ link = null , $ titleIdString = null , $ mediaURL = null ) { $ e = new Event ( ) ; $ n -> senderName = ( object ) array ( 'serverLogin' => $ this -> serverLogin ) ; $ e -> message = $ message ; $ e -> link = $ link ; $ e -> receiverName = $ receiverName ; $ e -> eventDate = $ eventDate ; $ e -> isPrivate = true ; $ n -> titleId = $ titleIdString ; $ n -> mediaURL = $ mediaURL ; return $ this -> execute ( 'POST' , '/maniahome/event/private/' , array ( $ e ) ) ; }
|
Create an event visible only by the receivers . To create an event for many players just give an array of login as receiverName .
|
8,493
|
function postPublicEvent ( $ message , $ eventDate , $ link = null , $ titleIdString = null , $ mediaURL = null ) { $ e = new Event ( ) ; $ n -> senderName = ( object ) array ( 'serverLogin' => $ this -> serverLogin ) ; $ e -> message = $ message ; $ e -> link = $ link ; $ e -> eventDate = $ eventDate ; $ n -> titleId = $ titleIdString ; $ n -> mediaURL = $ mediaURL ; return $ this -> execute ( 'POST' , '/maniahome/event/public/' , array ( $ e ) ) ; }
|
Create an event visible by all players who bookmarked your server
|
8,494
|
public static function create ( string $ baseUri , array $ query = [ ] ) : string { if ( count ( $ query ) === 0 ) { return $ baseUri ; } return sprintf ( '%s/?%s' , $ baseUri , http_build_query ( $ query ) ) ; }
|
Create request url based on base uri and request parameters .
|
8,495
|
public function switcher ( $ fieldName , array $ options = [ ] ) { $ input = parent :: checkbox ( $ fieldName , $ options ) ; if ( $ this -> getConfig ( 'materializeCss' , false ) === false ) { return $ input ; } $ options += [ 'before' => __d ( 'backend' , 'Off' ) , 'after' => __d ( 'backend' , 'On' ) ] ; $ title = ( Arr :: key ( 'title' , $ options ) ) ? $ options [ 'title' ] : $ fieldName ; if ( ! empty ( $ title ) ) { $ title = $ this -> Html -> div ( 'switch-title' , $ title ) ; } $ content = $ this -> formatTemplate ( __FUNCTION__ , [ 'input' => $ input , 'title' => $ title , 'after' => $ options [ 'after' ] , 'before' => $ options [ 'before' ] , 'lever' => '<span class="lever"></span>' ] ) ; return $ content ; }
|
Form switcher .
|
8,496
|
public function create ( $ model = null , array $ options = [ ] ) { $ options += [ 'process' => false , 'jsForm' => false ] ; $ options = $ this -> addClass ( $ options , $ this -> _class ( 'form' ) ) ; $ isProcess = $ options [ 'process' ] ; if ( $ isProcess !== false ) { $ _options = [ 'url' => [ 'plugin' => $ this -> request -> getParam ( 'plugin' ) , 'controller' => $ this -> request -> getParam ( 'controller' ) , 'action' => 'process' ] ] ; $ options [ 'jsForm' ] = true ; $ options = Hash :: merge ( $ _options , $ options ) ; } $ isJsForm = $ options [ 'jsForm' ] ; if ( $ isJsForm ) { $ this -> _isJsForm = true ; $ options = $ this -> addClass ( $ options , 'jsForm' ) ; } unset ( $ options [ 'process' ] , $ options [ 'jsForm' ] ) ; return parent :: create ( $ model , $ options ) ; }
|
Create html form .
|
8,497
|
public function end ( array $ secureAttributes = [ ] ) { if ( $ this -> _isJsForm ) { return implode ( '' , [ $ this -> hidden ( 'action' , [ 'value' => '' , 'class' => 'jsFormAction' ] ) , parent :: end ( $ secureAttributes ) ] ) ; } return parent :: end ( $ secureAttributes ) ; }
|
End html form .
|
8,498
|
protected function _addDefaultContextProviders ( ) { $ this -> addContextProvider ( 'orm' , function ( $ request , $ data ) { if ( is_array ( $ data [ 'entity' ] ) || $ data [ 'entity' ] instanceof \ Traversable ) { $ pass = ( new Collection ( $ data [ 'entity' ] ) ) -> first ( ) !== null ; if ( $ pass ) { return new EntityContext ( $ request , $ data ) ; } } return $ this -> _addEntityContent ( $ request , $ data ) ; } ) ; $ this -> _addFormContextProvider ( ) ; $ this -> _addFormArrayProvider ( ) ; }
|
Add the default suite of context providers provided .
|
8,499
|
protected function _addEntityContent ( $ request , $ data ) { if ( $ data [ 'entity' ] instanceof EntityInterface ) { return new EntityContext ( $ request , $ data ) ; } if ( is_array ( $ data [ 'entity' ] ) && empty ( $ data [ 'entity' ] [ 'schema' ] ) ) { return new EntityContext ( $ request , $ data ) ; } }
|
Add the entity suite of context providers provided .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.