idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
60,200
public function addPlaceholder ( $ name , $ value = null , $ recursive = false ) { list ( $ name , , $ template ) = $ this -> getParentPlaceholder ( $ name ) ; if ( ! isset ( $ template ) ) { $ template = $ this ; } if ( $ template === false ) { if ( $ this -> throwException ) { throw new TemplateException ( "Unknown s...
Adding placeholder .
60,201
public function addMultiPlaceholders ( array $ placeholders , $ recursive = false ) { foreach ( $ placeholders as $ name => $ placeholder ) { $ this -> addPlaceholder ( $ name , $ placeholder , $ recursive ) ; } }
Adding placeholders .
60,202
public function removePlaceholder ( $ name ) { if ( empty ( $ name ) ) { return ; } $ _name = $ name ; list ( $ name , , $ template ) = $ this -> getParentPlaceholder ( $ name ) ; if ( ! isset ( $ template ) ) { $ template = $ this ; } if ( $ template === false ) { if ( $ this -> throwException ) { throw new TemplateEx...
Removing placeholder .
60,203
public function removeAllPlaceholders ( $ parent = null ) { if ( isset ( $ parent ) ) { list ( , , $ template ) = $ this -> getParentPlaceholder ( $ parent ) ; } if ( ! isset ( $ template ) ) { $ template = $ this ; } if ( $ template === false ) { if ( $ this -> throwException ) { if ( is_array ( $ parent ) ) { $ paren...
Removing all placeholders
60,204
public function findPlaceholders ( array $ placeholders = [ ] , $ recursive = false ) { if ( empty ( $ placeholders ) ) { return [ ] ; } $ result = [ ] ; foreach ( $ placeholders as $ name => $ value ) { if ( is_int ( $ name ) ) { if ( $ this -> existsPlaceholder ( $ value ) ) { $ result [ $ this -> _prepareNamePlaceho...
Finds a placeholders .
60,205
public function addConst ( $ name , $ value = null , $ recursive = false , $ changeable = false ) { if ( $ this -> existsConst ( $ name ) && ! $ changeable ) { if ( is_array ( $ name ) ) { $ name = implode ( '.' , $ name ) ; } throw new TemplateException ( "Constant is defined: {$name}" ) ; } static :: $ constants [ $ ...
Adds a constant .
60,206
public function sanitize ( $ value , $ mode = null ) { if ( $ mode === null ) { $ mode = $ this -> sanitize ; } if ( is_array ( $ value ) ) { $ hash = md5 ( json_encode ( $ value ) ) ; if ( isset ( static :: $ _sanitizeCache [ $ hash ] ) ) { return static :: $ _sanitizeCache [ $ hash ] ; } return static :: $ _sanitizeC...
Sanitizing value .
60,207
public function getChunk ( $ path , array $ placeholders = [ ] ) { $ template = clone $ this ; $ template -> scopes [ spl_object_hash ( $ this ) ] = $ this ; $ template -> removeAllPlaceholders ( ) ; list ( $ cacheKey , $ cacheExpire , $ cacheTags ) = $ template -> calculateCacheParams ( $ placeholders ) ; if ( ( $ res...
Rendering chunk .
60,208
public function existsChunk ( $ path ) { $ path = Alias :: getAlias ( $ path , [ 'lang' => $ this -> locale ] ) ; if ( ! pathinfo ( $ path , PATHINFO_EXTENSION ) ) { $ path .= '.' . $ this -> defaultExtension ; } return file_exists ( $ path ) ; }
Exists chunk .
60,209
public function getSnippet ( $ snippet , array $ params = [ ] , $ sanitize = null ) { $ template = clone $ this ; $ template -> scopes [ spl_object_hash ( $ this ) ] = $ this ; $ template -> removeAllPlaceholders ( ) ; $ result = $ template -> getSnippetInternal ( $ snippet , $ params , $ sanitize ) ; $ this -> cachePl...
Returns a snippet by name .
60,210
public function getExtension ( $ name , array $ params = [ ] , $ sanitize = null ) { $ result = $ this -> _getExtensionInternal ( $ name , $ params ) ; if ( ! empty ( $ params ) ) { $ this -> removePlaceholder ( 'params' ) ; } return $ this -> sanitize ( $ result , $ sanitize ) ; }
Returns a extansion by name .
60,211
public function replaceByPrefix ( $ value , array $ placeholders = [ ] ) { $ dataPrefix = $ this -> getNamePrefix ( $ value ) ; if ( strtolower ( $ dataPrefix [ 'prefix' ] ) === 'inline' ) { $ template = clone $ this ; $ result = $ template -> replace ( $ dataPrefix [ 'value' ] , $ placeholders ) ; return $ result ; } ...
Replaces a inline tpl .
60,212
public function getNamePrefix ( $ value ) { if ( empty ( $ value ) ) { return null ; } preg_match ( '/(?:\@(?P<prefix>INLINE))?(?P<value>.+)/is' , $ value , $ matches ) ; return [ 'prefix' => Helper :: getValue ( $ matches [ 'prefix' ] ) , 'value' => Helper :: getValue ( $ matches [ 'value' ] ) ] ; }
Returns name of prefix .
60,213
protected function renderBodyBeginHtml ( ) { $ lines = [ $ this -> body ] ; if ( ! empty ( $ this -> jsFiles [ self :: POS_BEGIN ] ) ) { $ lines [ ] = implode ( "\n" , $ this -> jsFiles [ self :: POS_BEGIN ] ) ; } if ( ! empty ( $ this -> js [ self :: POS_BEGIN ] ) ) { $ lines [ ] = Html :: script ( implode ( "\n" , $ ...
Renders the content to be inserted at the beginning of the body section . The content is rendered using the registered JS code blocks and files .
60,214
public function registerMetaTag ( $ options , $ key = null ) { if ( $ key === null ) { $ this -> metaTags [ ] = $ this -> renderWrapperTag ( Html :: tag ( 'meta' , '' , $ options ) , $ options ) ; } else { $ this -> metaTags [ $ key ] = $ this -> renderWrapperTag ( Html :: tag ( 'meta' , '' , $ options ) , $ options ) ...
Registers a meta tag .
60,215
public function registerLinkTag ( $ options , $ key = null ) { if ( $ key === null ) { $ this -> linkTags [ ] = $ this -> renderWrapperTag ( Html :: tag ( 'link' , '' , $ options ) , $ options ) ; } else { $ this -> linkTags [ $ key ] = $ this -> renderWrapperTag ( Html :: tag ( 'link' , '' , $ options ) , $ options ) ...
Registers a link tag .
60,216
private function _searchParams ( $ value , array $ dataRecursive ) { preg_match_all ( '/ \? (?P<name>\\w+) # name param \\s*\=\\s* (?P<value>\{{3}\\d+\}{3}\\s*)* # value param [^\?\[\]]* # restriction: is n...
Search placeholders is variable of template .
60,217
protected function renderBodyEndHtml ( ) { $ lines = [ ] ; if ( ! empty ( $ this -> cssFiles [ self :: POS_END ] ) ) { $ lines [ ] = implode ( "\n" , $ this -> cssFiles [ self :: POS_END ] ) ; } if ( ! empty ( $ this -> jsFiles [ self :: POS_END ] ) ) { $ lines [ ] = implode ( "\n" , $ this -> jsFiles [ self :: POS_END...
Renders the content to be inserted at the end of the body section . The content is rendered using the registered JS code blocks and files .
60,218
protected function getCacheContent ( $ key = null ) { if ( ! $ this -> cache instanceof CacheInterface ) { return false ; } if ( isset ( $ key ) && ( $ result = $ this -> cache -> get ( $ key ) ) !== false ) { if ( is_array ( $ result ) && isset ( $ result [ 'placeholders' ] , $ result [ 'result' ] ) ) { $ this -> addM...
Returns the content from the cache .
60,219
protected function setCacheContent ( $ key = null , $ value = null , $ expire = 0 , array $ tags = [ ] ) { if ( $ this -> cache instanceof CacheInterface && isset ( $ key ) ) { if ( ! empty ( $ this -> cachePlaceholders ) ) { $ result = $ value ; $ value = [ ] ; $ value [ 'result' ] = $ result ; $ value [ 'placeholders...
Caching template .
60,220
protected function checkPath ( $ path ) { foreach ( $ this -> chroots as $ chroot ) { if ( StringHelper :: contains ( $ path , $ chroot ) ) { return true ; } } return false ; }
Check path to view .
60,221
protected function cleanFilters ( $ filters ) : array { if ( ! is_array ( $ filters ) ) { return array ( ) ; } array_walk_recursive ( $ filters , function ( & $ item , $ key ) { $ item = trim ( $ item ) ; } ) ; $ filters = array_filter ( $ filters , function ( & $ item ) { if ( is_array ( $ item ) ) { $ item = array_fi...
Clean filters values . Trim white chars and unset empty filters .
60,222
protected function getItemByHash ( $ hash ) { foreach ( $ this -> items as $ item ) { if ( $ item -> getHash ( ) === $ hash ) { return $ item ; } } return false ; }
Returns the item for the given hash or false if the hash is not available .
60,223
public function getLeftItems ( ) { if ( empty ( $ this -> leftItems ) && empty ( $ this -> rightItems ) ) { $ this -> transformItems ( ) ; } return $ this -> leftItems ; }
Returns the left items
60,224
public function getRightItems ( ) { if ( empty ( $ this -> leftItems ) && empty ( $ this -> rightItems ) ) { $ this -> transformItems ( ) ; } return $ this -> rightItems ; }
Returns the right items
60,225
protected function transformItems ( ) { $ this -> leftItems = array ( ) ; $ this -> rightItems = array ( ) ; foreach ( $ this -> items as $ hash => $ value ) { if ( array_search ( $ value -> getKey ( ) , $ this -> value ) !== false ) { $ this -> rightItems [ ] = $ value ; } else { $ this -> leftItems [ ] = $ value ; } ...
Assigns each item to one of the two lists .
60,226
public function Base_Render_Before ( $ Sender ) { if ( $ Sender -> Menu && Gdn :: Session ( ) -> IsValid ( ) ) { if ( C ( 'Plugins.AllViewed.ShowInMenu' , TRUE ) ) $ Sender -> Menu -> AddLink ( 'AllViewed' , T ( 'Mark All Viewed' ) , '/discussions/markallviewed' ) ; } }
Adds Mark All Viewed to main menu .
60,227
public function DiscussionsController_MarkCategoryViewed_Create ( $ Sender , $ CategoryID ) { if ( strlen ( $ CategoryID ) > 0 && ( int ) $ CategoryID > 0 ) { $ CategoryModel = new CategoryModel ( ) ; $ this -> MarkCategoryRead ( $ CategoryModel , $ CategoryID ) ; $ this -> RecursiveMarkCategoryRead ( $ CategoryModel ,...
Allows user to mark all discussions in a specified category as viewed .
60,228
private function RecursiveMarkCategoryRead ( $ CategoryModel , $ UnprocessedCategories , $ ParentIDs ) { $ CurrentUnprocessedCategories = array ( ) ; $ CurrentParentIDs = $ ParentIDs ; foreach ( $ UnprocessedCategories as $ Category ) { if ( in_array ( $ Category [ "ParentCategoryID" ] , $ ParentIDs ) ) { $ this -> Mar...
Helper function to recursively mark categories as read based on a Category s ParentID .
60,229
public function DiscussionsController_MarkAllViewed_Create ( $ Sender ) { $ CategoryModel = new CategoryModel ( ) ; $ this -> MarkCategoryRead ( $ CategoryModel , - 1 ) ; $ this -> RecursiveMarkCategoryRead ( $ CategoryModel , CategoryModel :: Categories ( ) , array ( - 1 ) ) ; Redirect ( $ _SERVER [ "HTTP_REFERER" ] )...
Allows user to mark all discussions as viewed .
60,230
public function GetCommentCountSince ( $ DiscussionID , $ DateAllViewed ) { if ( ! Gdn :: Session ( ) -> IsValid ( ) ) return ; $ DiscussionID = ( int ) $ DiscussionID ; if ( ! $ DiscussionID ) throw new Exception ( 'A valid DiscussionID is required in GetCommentCountSince.' ) ; return Gdn :: Database ( ) -> SQL ( ) ->...
Get the number of comments inserted since the given timestamp .
60,231
private function CheckDiscussionDate ( $ Discussion , $ DateAllViewed ) { if ( Gdn_Format :: ToTimestamp ( $ Discussion -> DateInserted ) > $ DateAllViewed ) { return ; } if ( Gdn_Format :: ToTimestamp ( $ Discussion -> DateLastComment ) <= $ DateAllViewed ) { $ Discussion -> CountUnreadComments = 0 ; } elseif ( Gdn_Fo...
Helper function to actually override a discussion s unread status
60,232
public function DiscussionModel_SetCalculatedFields_Handler ( $ Sender ) { if ( ! Gdn :: Session ( ) -> IsValid ( ) ) return ; $ Discussion = & $ Sender -> EventArguments [ 'Discussion' ] ; $ Category = CategoryModel :: Categories ( $ Discussion -> CategoryID ) ; $ CategoryLastDate = Gdn_Format :: ToTimestamp ( $ Categ...
Modify CountUnreadComments to account for DateAllViewed .
60,233
public static function getCode ( $ path , $ line ) { $ snippet = 7 ; $ code = str_replace ( '>' , '&gt' , str_replace ( '<' , '&lt;' , file_get_contents ( $ path ) ) ) ; $ codesplit = explode ( "\n" , $ code ) ; $ lines = count ( $ codesplit ) ; $ from = $ line < $ snippet ? 0 : $ line - $ snippet ; $ to = $ lines < $ ...
Erzeugt einen Codeausschnitt einer Datei und hebt eine bestimmte Zeile hervor
60,234
public function addMenuItem ( $ options ) { foreach ( [ 'alias' , 'name' , 'priority' ] as $ attr ) { if ( ! isset ( $ options [ $ attr ] ) || ( isset ( $ options [ $ attr ] ) && $ options [ $ attr ] === '' ) ) { throw new Exception ( '$options[\'' . $ attr . '\'] is missing.' ) ; } } $ menuItem = [ 'alias' => $ option...
Add a new menu item
60,235
public function getOrderedArray ( $ items = [ ] ) { $ ordered = [ ] ; if ( empty ( $ items ) ) { $ items = $ this -> _menuItems ; } foreach ( $ items as $ item ) { $ ordered [ ] = $ item ; } $ ordered = Hash :: sort ( $ ordered , '{n}.priority' , 'ASC' ) ; foreach ( $ ordered as & $ item ) { if ( isset ( $ item [ 'chil...
Create and return an array clone of menu items ordered by their priority .
60,236
public function withProtocolVersion ( $ version ) { Validator :: checkProtocolVersion ( $ version ) ; $ instance = clone $ this ; $ instance -> protocol = $ version ; return $ instance ; }
Return an instance with the specified HTTP protocol version
60,237
public function withHeader ( $ name , $ value ) { $ instance = clone $ this ; $ instance -> headers -> set ( $ name , $ value ) ; return $ instance ; }
Return an instance with the provided value replacing the specified header
60,238
public function withAddedHeader ( $ name , $ value ) { $ instance = clone $ this ; $ instance -> headers -> add ( $ name , $ value ) ; return $ instance ; }
Return an instance with the specified header appended with the given value
60,239
public function withoutHeader ( $ name ) { $ instance = clone $ this ; $ instance -> headers -> remove ( $ name , $ value ) ; return $ instance ; }
Return an instance without the specified header
60,240
public function getRenderedTemplate ( ) { $ template = PO_PATH_TEMPLATES . DS . $ this -> _template [ 'folder' ] . DS . $ this -> _template [ 'name' ] . '.phtml' ; $ layout = $ this -> _layout ? PO_PATH_TEMPLATES . DS . 'layout' . DS . $ this -> _layout . '.phtml' : NULL ; return $ this -> render ( $ template , $ layou...
Renderiza la plantilla actual
60,241
public function getCoreRenderedTemplate ( $ template , $ layout = NULL ) { return $ this -> render ( POWERON_ROOT . DS . $ template , $ layout ? POWERON_ROOT . DS . $ layout : NULL ) ; }
Devuelve una plantilla renderizada del framework
60,242
private function render ( $ template , $ layout ) { if ( ! is_file ( $ template ) ) { throw new \ InvalidArgumentException ( sprintf ( 'No se encuentra la plantilla cargar en (%s).' , $ template ) ) ; } if ( $ layout && ! is_file ( $ layout ) ) { throw new \ InvalidArgumentException ( sprintf ( 'No se encuentra la plan...
Renderiza y devuelve el contenido de la plantilla indicada
60,243
private function handleBuffer ( $ buffer ) { $ error = error_get_last ( ) ; if ( $ error ) { $ matches = [ ] ; preg_match ( '/\: (.*) in /' , $ error [ 'message' ] , $ matches ) ; $ message = key_exists ( 1 , $ matches ) ? $ matches [ 1 ] : $ error [ 'message' ] ; $ response = $ this -> _container [ 'Response' ] ; if (...
Controla el flujo de una plantilla y procesa los errores en caso de encontrarlos
60,244
public function setLayout ( $ name ) { if ( ! $ name ) { return FALSE ; } $ path_layout = PO_PATH_TEMPLATES . DS . 'layout' . DS . $ name . '.phtml' ; if ( ! is_file ( $ path_layout ) ) { throw new LogicException ( sprintf ( 'No existe la plantilla principal (%s) en (%s).' , $ name , $ path_layout ) ) ; } $ this -> _la...
Establece una plantilla principal a utilizar
60,245
private function _setDbPrefix ( ) { if ( ! Agl :: isInitialized ( ) ) { return $ this ; } $ dbPrefix = Agl :: app ( ) -> getConfig ( 'main/db/prefix' ) ; if ( $ dbPrefix ) { $ this -> _dbPrefix = $ dbPrefix ; } return $ this ; }
Set the database prefix from configuration .
60,246
private static function preg_replace_query ( $ sql , $ values ) { return preg_replace_callback ( '~{(\w+)(?::(.*))?}~U' , function ( $ matches ) use ( $ values ) { return isset ( $ values [ $ matches [ 1 ] ] ) ? $ values [ $ matches [ 1 ] ] : ( isset ( $ matches [ 2 ] ) ? $ matches [ 2 ] : null ) ; } , $ sql ) ; }
helper functions for the build scripts!
60,247
function fetch_callback ( $ sql , callable $ callback ) { $ result = null ; $ rs = $ this -> query ( $ sql , MYSQLI_USE_RESULT ) ; while ( $ row = $ rs -> fetch_assoc ( ) ) { if ( $ callback ( $ row , $ result ) === false ) break ; } $ rs -> free_result ( ) ; return $ result ; }
optionally return false ; in callback to stop processing
60,248
function get_object ( $ sql , $ class_name = 'stdClass' , array $ params = null ) { $ rs = $ this -> query ( $ sql , MYSQLI_USE_RESULT ) ; $ obj = is_null ( $ params ) ? $ rs -> fetch_object ( $ class_name ) : $ rs -> fetch_object ( $ class_name , $ params ) ; $ rs -> free_result ( ) ; return $ obj ; }
The params don t seem to be passed to the constructor so not sure what that s about
60,249
protected function escapeIdentifier ( $ word , $ escapeChar = '`' ) { if ( is_array ( $ word ) || is_object ( $ word ) || is_numeric ( $ word ) ) { return '' ; } $ spaces = explode ( ' ' , $ word ) ; foreach ( $ spaces as & $ space ) { if ( strtolower ( $ space ) == 'as' ) { $ space = 'AS' ; } else { $ periods = explod...
Escapes potentially reserved keywords in identifiers by wrapping them with the escape character as necessary .
60,250
protected function parameterizeValues ( array $ values ) { foreach ( $ values as & $ value ) { $ value = $ this -> parameterize ( $ value ) ; } return '(' . implode ( ',' , $ values ) . ')' ; }
Parameterizes a list of values .
60,251
public function setLocales ( array $ locales ) { $ this -> locales = [ ] ; foreach ( $ locales as $ loc ) $ this -> addLocale ( $ loc ) ; }
Set a list of locales
60,252
private function setupProps ( $ amntStore , $ storeId ) { $ this -> uiIsWalletUsed = true ; $ amntWallet = $ this -> hlpWalletCur -> storeToWallet ( $ amntStore , $ storeId ) ; $ this -> uiAmountStore = $ this -> hlpFormat -> toNumber ( round ( $ amntStore , 2 ) ) ; $ this -> uiAmountWallet = $ this -> hlpFormat -> toN...
Setup block s UI properties if wallet payment is used .
60,253
public function sendRequest ( \ TYPO3 \ Flow \ Http \ Request $ request ) { $ responses = $ this -> sendRequests ( array ( $ request ) ) ; if ( isset ( $ responses [ 0 ] ) ) { return $ responses [ 0 ] ; } else { return NULL ; } }
Sends a single HTTP request
60,254
public function read ( $ length ) { $ buffer = $ this -> socket -> read ( $ length ) ; if ( $ this -> state < self :: STATE_OPEN ) { $ this -> handshakeBuffer .= $ buffer ; $ headerPos = mb_strpos ( $ this -> handshakeBuffer , "\r\n\r\n" , 0 , '8bit' ) ; if ( $ headerPos !== false ) { $ data = mb_substr ( $ this -> han...
Reads data from this connection
60,255
protected function handleFrame ( Net_Notifier_WebSocket_Frame $ frame ) { switch ( $ frame -> getOpcode ( ) ) { case Net_Notifier_WebSocket_Frame :: TYPE_BINARY : $ this -> binaryBuffer .= $ frame -> getUnmaskedData ( ) ; if ( $ frame -> isFinal ( ) ) { $ this -> binaryMessages [ ] = $ this -> binaryBuffer ; $ this -> ...
Handles a completed received frame
60,256
public function writeBinary ( $ message ) { $ final = false ; $ pos = 0 ; $ totalLength = mb_strlen ( $ message , '8bit' ) ; while ( ! $ final ) { $ data = mb_substr ( $ message , $ pos , self :: FRAME_SIZE , '8bit' ) ; $ dataLength = mb_strlen ( $ data , '8bit' ) ; $ pos += $ dataLength ; $ final = ( $ pos === $ total...
Writes a binary message to this connection s socket
60,257
public function writeText ( $ message ) { if ( ! $ this -> isValidUTF8 ( $ message ) ) { throw new Net_Notifier_WebSocket_UTF8EncodingException ( 'Can not write text message that is invalid UTF8.' , 0 , $ message ) ; } $ final = false ; $ pos = 0 ; $ totalLength = mb_strlen ( $ message , '8bit' ) ; while ( ! $ final ) ...
Writes a text message to this connection s socket
60,258
protected function handleHandshake ( $ data ) { $ handshake = new Net_Notifier_WebSocket_Handshake ( ) ; try { $ response = $ handshake -> receive ( $ data , $ this -> handshakeNonce , array ( Net_Notifier_WebSocket :: PROTOCOL ) ) ; if ( $ response !== null ) { $ this -> send ( $ response ) ; } $ this -> state = self ...
Performs a WebSocket handshake step for this client connection
60,259
public function startHandshake ( $ host , $ port , $ resource = '/' , array $ protocols = array ( ) ) { $ this -> handshakeNonce = $ this -> getNonce ( ) ; $ handshake = new Net_Notifier_WebSocket_Handshake ( ) ; $ request = $ handshake -> start ( $ host , $ port , $ this -> handshakeNonce , $ resource , $ protocols ) ...
Initiates a WebSocket handshake for this client connection
60,260
public function startClose ( $ code = self :: CLOSE_NORMAL , $ reason = '' ) { if ( $ this -> state < self :: STATE_CLOSING ) { $ code = intval ( $ code ) ; $ data = pack ( 's' , $ code ) . $ reason ; $ frame = new Net_Notifier_WebSocket_Frame ( $ data , Net_Notifier_WebSocket_Frame :: TYPE_CLOSE ) ; $ this -> send ( $...
Initiates the WebSocket closing handshake
60,261
public function pong ( $ message ) { $ frame = new Net_Notifier_WebSocket_Frame ( $ message , Net_Notifier_WebSocket_Frame :: TYPE_PONG ) ; $ this -> send ( $ frame -> __toString ( ) ) ; }
Sends a pong frame
60,262
protected function getNonce ( ) { $ nonce = '' ; for ( $ i = 0 ; $ i < 16 ; $ i ++ ) { $ nonce .= chr ( mt_rand ( 0 , 255 ) ) ; } $ nonce = base64_encode ( $ nonce ) ; return $ nonce ; }
Gets a random 16 - byte base - 64 encoded value
60,263
public function jsonDecodeOptions ( bool $ assoc = false , int $ depth = 512 , $ options = 0 ) : Request { $ this -> _jsonOptions = array ( $ assoc , $ depth , $ options ) ; return $ this ; }
Set the JSON decode mode .
60,264
public function headers ( array $ headers ) : Request { $ this -> _defaultHeaders = array_merge ( $ this -> _defaultHeaders , $ headers ) ; return $ this ; }
Set default headers to send on every request
60,265
public function header ( string $ name , string $ value ) : Request { if ( \ is_null ( $ value ) || ! \ is_string ( $ value ) ) { unset ( $ this -> _defaultHeaders [ $ name ] ) ; } $ this -> _defaultHeaders [ $ name ] = $ value ; return $ this ; }
Set a new default header to send on every request
60,266
public function curlOpts ( array $ options ) : Request { $ this -> _curlOpts = \ array_merge ( $ this -> _curlOpts , $ options ) ; return $ this ; }
Set curl options to send on every request
60,267
public function auth ( string $ username = '' , string $ password = '' , $ method = \ CURLAUTH_BASIC ) : Request { $ this -> _auth [ 'user' ] = $ username ; $ this -> _auth [ 'pass' ] = $ password ; $ this -> _auth [ 'meth' ] = $ method ; return $ this ; }
Set authentication method to use .
60,268
public function proxy ( string $ address , int $ port = 1080 , $ type = \ CURLPROXY_HTTP , bool $ tunnel = false ) : Request { $ this -> _proxy [ 'type' ] = $ type ; $ this -> _proxy [ 'port' ] = $ port ; $ this -> _proxy [ 'tunnel' ] = $ tunnel ; $ this -> _proxy [ 'address' ] = $ address ; return $ this ; }
Set proxy to use .
60,269
protected function _FromForm ( ) { $ Form = new Gdn_Form ( ) ; $ Px = $ this -> Prefix ; $ Types = ( array ) $ Form -> GetFormValue ( $ Px . 'Type' , array ( ) ) ; $ PermissionFields = ( array ) $ Form -> GetFormValue ( $ Px . 'PermissionField' , array ( ) ) ; $ RoleFields = ( array ) $ Form -> GetFormValue ( $ Px . 'R...
Grab the values from the form into the conditions array .
60,270
public function formalize ( ) { $ this -> supports ( StorageType :: OUTBOX ( ) , function ( Settings $ s ) { FeatureSettingsExtensions :: enableFeatureByDefault ( InMemoryOutboxPersistenceFeature :: class , $ s ) ; } ) ; }
This is where subclasses declare what storage types they support together with the initializers for those types .
60,271
public function controllerList ( ) { $ names = $ this -> controllerManager -> getCanonicalNames ( ) ; $ controllers = array ( ) ; foreach ( $ names as $ name ) { try { $ controllers [ $ name ] = $ this -> controllerManager -> get ( $ name ) ; } catch ( \ Exception $ e ) { continue ; } } return $ controllers ; }
Returns a list of controller names and class names .
60,272
public function loadCachedConfig ( array & $ config ) { $ cacheFilePath = $ this -> config -> getCacheFile ( ) ; if ( ! file_exists ( $ cacheFilePath ) ) { return false ; } $ cachedConfig = include $ cacheFilePath ; if ( ! is_array ( $ cachedConfig ) ) { return false ; } if ( ! isset ( $ config [ 'routes' ] ) ) { $ con...
Attempt to use cache rather than annotations .
60,273
public function getRouteConfig ( array $ controllers ) { $ routeList = new ArrayObject ( ) ; foreach ( $ controllers as $ name => $ controller ) { $ routeList = $ this -> parser -> parseReflectedController ( $ name , $ this -> parser -> getReflectedController ( $ controller ) , $ routeList ) ; } return $ routeList -> g...
Returns the config fetched from the annotations
60,274
public function updateRouteConfig ( array & $ config ) { if ( $ this -> loadCachedConfig ( $ config ) ) { return ; } $ routeList = $ this -> getRouteConfig ( $ this -> controllerList ( ) ) ; if ( ! sizeof ( $ routeList ) ) { return ; } if ( ! isset ( $ config [ 'routes' ] ) ) { $ config [ 'routes' ] = array ( ) ; } $ t...
Parses the route annotations and updates the route stack .
60,275
public function exists ( ) { if ( ! $ this -> name ) { throw new UnexpectedValueException ( 'Cannot check for existing user without a name' ) ; } if ( ! $ this -> host ) { throw new UnexpectedValueException ( 'Cannot check for existing user without a host because the result could be ambiguous' ) ; } $ row = $ this -> c...
Test whether or not the user exists .
60,276
public function delete ( ) { if ( ! $ this -> name ) { throw new UnexpectedValueException ( 'Cannot delete a user with no name' ) ; } $ parts = array ( 'DROP USER :user' ) ; $ params = array ( ':user' => $ this -> name ) ; if ( $ this -> host ) { $ parts [ ] = '@:host' ; $ params [ ':host' ] = strtolower ( $ this -> ho...
Delete the user .
60,277
public function create ( ) { if ( ! $ this -> name ) { throw new UnexpectedValueException ( 'Cannot create a user with no name' ) ; } $ parts = array ( 'CREATE USER :user' ) ; $ params = array ( ':user' => $ this -> name ) ; if ( $ this -> host ) { $ parts [ ] = '@:host' ; $ params [ ':host' ] = strtolower ( $ this -> ...
Create the user .
60,278
public function grant ( ) { if ( ! $ this -> name ) { throw new UnexpectedValueException ( 'Cannot grant privileges to a user with no name' ) ; } if ( ! $ this -> grants ) { throw new UnexpectedValueException ( 'Cannot grant privileges without being told what privileges to grant' ) ; } if ( ! $ this -> grantLevel ) { t...
Grant privileges to the user .
60,279
public function removeRule ( $ ruleName ) { if ( isset ( $ this -> rules [ $ ruleName ] ) ) { unset ( $ this -> rules [ $ ruleName ] ) ; return true ; } return false ; }
Removes a single rule by name
60,280
public function check ( $ input ) { $ this -> lastValue = $ input ; $ anyFailed = false ; foreach ( $ this -> rules as $ ruleName => & $ rule ) { if ( $ rule -> check ( $ input ) ) { if ( $ this -> matchAny || $ rule -> isSufficient ( ) ) { return true ; } } elseif ( ! $ this -> matchAny ) { $ this -> failedRule = & $ ...
Check all rules of this attribyte against input
60,281
public function determineDependents ( $ input , array & $ required ) { if ( $ this -> hasError ( ) ) { return ; } $ this -> lastValue = $ input ; $ foundRequired = false ; foreach ( $ this -> dependent as $ onInput => $ requiredNames ) { if ( $ onInput === '*' ) { continue ; } elseif ( $ input === $ onInput ) { $ found...
Adds possible requireds to list if . Only if not have error .
60,282
public function getMissingText ( ) { $ missing = $ this -> missing ? : $ this -> dataFilter -> getMissingTemplate ( ) ; return U :: formatString ( $ missing , array ( 'attrib' => $ this -> name ) ) ; }
Returns formatted missing text
60,283
public function setHeaders ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ k => $ v ) { if ( is_string ( $ k ) ) { $ this -> setHeaders ( $ k , $ v ) ; } else { $ this -> setHeaders ( $ v , null ) ; } } } else { if ( $ value === null && ( strpos ( $ name , ':' ) > 0 ) ) { list ( $ name ...
Set one or more request headers
60,284
public function setCookie ( $ cookie , $ value = null ) { Zend_Loader :: loadClass ( 'Zend_Http_Cookie' ) ; if ( is_array ( $ cookie ) ) { foreach ( $ cookie as $ c => $ v ) { if ( is_string ( $ c ) ) { $ this -> setCookie ( $ c , $ v ) ; } else { $ this -> setCookie ( $ v ) ; } } return $ this ; } if ( $ value !== nul...
Add a cookie to the request . If the client has no Cookie Jar the cookies will be added directly to the headers array as Cookie headers .
60,285
protected function _openTempStream ( ) { $ this -> _stream_name = $ this -> config [ 'output_stream' ] ; if ( ! is_string ( $ this -> _stream_name ) ) { $ this -> _stream_name = tempnam ( isset ( $ this -> config [ 'stream_tmp_dir' ] ) ? $ this -> config [ 'stream_tmp_dir' ] : sys_get_temp_dir ( ) , 'Zend_Http_Client' ...
Create temporary stream
60,286
public static function _getUserIpAddr ( ) { $ ip = 'unknown.ip.address' ; if ( isset ( $ _SERVER ) ) { if ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } elseif ( ! empty ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; } } return $ ip ; }
Gets the current user s IP address
60,287
public function GetNew ( $ DiscussionID , $ LastCommentID = 0 ) { $ this -> SetData ( 'Discussion' , $ this -> DiscussionModel -> GetID ( $ DiscussionID ) , TRUE ) ; $ this -> Permission ( 'Vanilla.Discussions.View' , TRUE , 'Category' , $ this -> Discussion -> PermissionCategoryID ) ; $ this -> SetData ( 'CategoryID' ...
Display comments in a discussion since a particular CommentID .
60,288
public function Comment ( $ CommentID ) { $ Comment = $ this -> CommentModel -> GetID ( $ CommentID ) ; if ( ! $ Comment ) throw NotFoundException ( 'Comment' ) ; $ DiscussionID = $ Comment -> DiscussionID ; $ Offset = $ this -> CommentModel -> GetOffset ( $ Comment ) ; $ Limit = Gdn :: Config ( 'Vanilla.Comments.PerPa...
Display discussion page starting with a particular comment .
60,289
public function DismissAnnouncement ( $ DiscussionID = '' ) { if ( ! C ( 'Vanilla.Discussions.Dismiss' , 1 ) ) { throw PermissionException ( 'Vanilla.Discussions.Dismiss' ) ; } if ( ! $ this -> Request -> IsPostBack ( ) ) throw PermissionException ( 'Javascript' ) ; $ Session = Gdn :: Session ( ) ; if ( is_numeric ( $ ...
Allows user to remove announcement .
60,290
public function Bookmark ( $ DiscussionID ) { if ( ! $ this -> Request -> IsPostBack ( ) ) throw PermissionException ( 'Javascript' ) ; $ Session = Gdn :: Session ( ) ; if ( $ Session -> UserID == 0 ) throw PermissionException ( 'SignedIn' ) ; $ Discussion = $ this -> DiscussionModel -> GetID ( $ DiscussionID ) ; if ( ...
Allows user to bookmark or unbookmark a discussion .
60,291
public function Announce ( $ DiscussionID = '' , $ Target = '' ) { $ Discussion = $ this -> DiscussionModel -> GetID ( $ DiscussionID ) ; if ( ! $ Discussion ) throw NotFoundException ( 'Discussion' ) ; $ this -> Permission ( 'Vanilla.Discussions.Announce' , TRUE , 'Category' , $ Discussion -> PermissionCategoryID ) ; ...
Allows user to announce or unannounce a discussion .
60,292
public function Sink ( $ DiscussionID = '' , $ Sink = TRUE , $ From = 'list' ) { if ( ! $ this -> Request -> IsPostBack ( ) ) throw PermissionException ( 'Javascript' ) ; $ Discussion = $ this -> DiscussionModel -> GetID ( $ DiscussionID ) ; if ( ! $ Discussion ) throw NotFoundException ( 'Discussion' ) ; $ this -> Per...
Allows user to sink or unsink a discussion .
60,293
public function Close ( $ DiscussionID = '' , $ Close = TRUE , $ From = 'list' ) { if ( ! $ this -> Request -> IsPostBack ( ) ) throw PermissionException ( 'Javascript' ) ; $ Discussion = $ this -> DiscussionModel -> GetID ( $ DiscussionID ) ; if ( ! $ Discussion ) throw NotFoundException ( 'Discussion' ) ; $ this -> P...
Allows user to close or re - open a discussion .
60,294
public function Delete ( $ DiscussionID , $ Target = '' ) { $ Discussion = $ this -> DiscussionModel -> GetID ( $ DiscussionID ) ; if ( ! $ Discussion ) throw NotFoundException ( 'Discussion' ) ; $ this -> Permission ( 'Vanilla.Discussions.Delete' , TRUE , 'Category' , $ Discussion -> PermissionCategoryID ) ; if ( $ th...
Allows user to delete a discussion .
60,295
public function DeleteComment ( $ CommentID = '' , $ TransientKey = '' ) { $ Session = Gdn :: Session ( ) ; $ DefaultTarget = '/discussions/' ; $ ValidCommentID = is_numeric ( $ CommentID ) && $ CommentID > 0 ; $ ValidUser = $ Session -> UserID > 0 && $ Session -> ValidateTransientKey ( $ TransientKey ) ; if ( $ ValidC...
Allows user to delete a comment .
60,296
protected function RedirectDiscussion ( $ Discussion ) { $ Body = Gdn_Format :: To ( GetValue ( 'Body' , $ Discussion ) , GetValue ( 'Format' , $ Discussion ) ) ; if ( preg_match ( '`href="([^"]+)"`i' , $ Body , $ Matches ) ) { $ Url = $ Matches [ 1 ] ; Redirect ( $ Url , 301 ) ; } }
Redirect to the url specified by the discussion .
60,297
public function RefetchPageInfo ( $ DiscussionID ) { if ( ! $ this -> Request -> IsPostBack ( ) ) throw PermissionException ( 'Javascript' ) ; $ Discussion = $ this -> DiscussionModel -> GetID ( $ DiscussionID ) ; if ( ! $ Discussion ) throw NotFoundException ( 'Discussion' ) ; $ this -> Permission ( 'Vanilla.Discussio...
Re - fetch a discussion s content based on its foreign url .
60,298
public function build ( $ className ) { $ footprint = $ this -> _footprintRegistry -> get ( $ className ) ; $ parentClass = $ footprint -> getParent ( ) ; if ( ! $ parentClass ) { $ parentClass = $ this -> _baseClassRegistry -> find ( $ className ) ; } if ( $ footprint -> isInterface ( ) ) { $ generator = new Interface...
Generate class using any given references or traits
60,299
public function getMinValue ( ) { $ values = $ this -> values -> toArray ( ) ; uasort ( $ values , $ this -> cmpValues ( 'getName' ) ) ; return reset ( $ values ) ; }
Get minimum value