idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
2,000
public function render ( Response $ response ) : void { $ i = 0 ; foreach ( $ response -> getViewHelpers ( ) as $ name => $ view_helper ) { if ( is_a ( $ view_helper , ViewHelperInterface :: class ) ) { if ( null !== $ view_helper -> getParent ( ) && ! is_null ( $ response -> getViewHelper ( $ view_helper -> getParent ...
Loads the view helpers and outputs the response in an appropriate format .
2,001
public function createURL ( $ route_name , $ variables = [ ] ) { if ( ! isset ( $ this -> routes ) ) { $ this -> routes = Core :: i ( ) -> config -> getConfiguration ( 'routes' ) ; } if ( ! isset ( $ this -> routes [ $ route_name ] ) ) { throw new \ Exception ( 'The specified route, ' . $ route_name . ', was not define...
Create a url based on a route . Passed variables will replace placeholders in the route . If the variable is not part of the route the variable will be appended as a query string .
2,002
public function createLink ( $ path , $ include_locale = false ) { $ protocol = ( \ Framework :: i ( ) -> isSecure ( ) ) ? 'https:' : 'http:' ; $ base = $ this -> getBaseURL ( $ include_locale ) ; return $ protocol . $ base . $ path ; }
Create an absolute path for use in links to use in place of relative links that can be affected by locale information .
2,003
public function getBaseURL ( $ include_locale = true ) { $ base = '//' . $ _SERVER [ 'HTTP_HOST' ] . str_replace ( 'index.php' , '' , $ _SERVER [ 'URL' ] ) ; if ( $ include_locale && \ Framework :: i ( ) -> locale_set ) { $ base .= $ this -> getLinkLocale ( \ Framework :: i ( ) -> locale ) . '/' ; } return $ base ; }
Calculates and returns the base URL for the site . This is used in the base HREF tag and can also be used for generating internal links to resources that don t correspond to Framework 2 paths .
2,004
public static function Ee00b ( $ date1 , $ date2 ) { $ dpsipr ; $ depspr ; $ epsa ; $ dpsi ; $ deps ; $ ee ; IAU :: Pr00 ( $ date1 , $ date2 , $ dpsipr , $ depspr ) ; $ epsa = IAU :: Obl80 ( $ date1 , $ date2 ) + $ depspr ; IAU :: Nut00b ( $ date1 , $ date2 , $ dpsi , $ deps ) ; $ ee = IAU :: Ee00 ( $ date1 , $ date2 ,...
- - - - - - - - - i a u E e 0 0 b - - - - - - - - -
2,005
protected static function checkVersion ( ) { if ( self :: $ checked === true ) { return true ; } $ process = new \ SystemProcess \ SystemProcess ( 'bzr' ) ; $ process -> nonZeroExitCodeException = true ; $ process -> argument ( '--version' ) -> execute ( ) ; if ( ! preg_match ( '/\Bazaar \(bzr\) ([0-9.]*)/' , $ process...
Verify bzr version
2,006
public function countMethodAnnotations ( ) { $ counter = 0 ; foreach ( $ this -> methodAnnotations as $ method ) { if ( count ( $ method ) == 0 ) { return 0 ; } foreach ( $ method as $ annotationToken ) { $ counter = $ counter + count ( $ annotationToken ) ; } } return $ counter ; }
Count the filtered annotation lines in all method the class have .
2,007
public function cssAction ( ) { $ pygmentize = $ this -> get ( 'cypress.pygments_elephant.pygmentize' ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'content-type' , 'text/css' ) ; $ response -> setContent ( $ pygmentize -> generateCss ( ) ) ; return $ response ; }
css for pygments
2,008
public function findFile ( $ class ) { if ( ! function_exists ( 'drupal_get_path' ) ) { return ; } $ class = ltrim ( $ class , '\\' ) ; $ expl = explode ( '\\' , $ class ) ; $ module = strtolower ( preg_replace ( '/(?<=\\w)(?=[A-Z])/' , '_$1' , reset ( $ expl ) ) ) ; if ( 2 === count ( $ expl ) ) { foreach ( array ( $ ...
Tries to locate the file where the class is defined .
2,009
public static function create ( $ className ) { $ bestLoggerConfiguration = LoggerManager :: findBestLoggerConfigurationForClass ( $ className ) ; if ( ! isset ( $ bestLoggerConfiguration ) ) { return new Logger ( $ className ) ; } $ logger = new Logger ( $ className ) ; $ logger -> _targetClassName = $ bestLoggerConfi...
Create and return a Logger
2,010
public function emergency ( $ messageOrException , $ contextOrException = null , array $ context = array ( ) ) { $ this -> log ( LogLevel :: EMERGENCY , $ messageOrException , $ contextOrException , $ context ) ; }
System is unusable
2,011
public function alert ( $ messageOrException , $ contextOrException = null , array $ context = array ( ) ) { $ this -> log ( LogLevel :: ALERT , $ messageOrException , $ contextOrException , $ context ) ; }
Action must be taken immediately
2,012
public function error ( $ messageOrException , $ contextOrException = null , array $ context = array ( ) ) { $ this -> log ( LogLevel :: ERROR , $ messageOrException , $ contextOrException , $ context ) ; }
Runtime errors that do not require immediate action but should typically be logged and monitored
2,013
public function warning ( $ messageOrException , $ contextOrException = null , array $ context = array ( ) ) { $ this -> log ( LogLevel :: WARNING , $ messageOrException , $ contextOrException , $ context ) ; }
Exceptional occurrences that are not errors
2,014
public function notice ( $ messageOrException , $ contextOrException = null , array $ context = array ( ) ) { $ this -> log ( LogLevel :: NOTICE , $ messageOrException , $ contextOrException , $ context ) ; }
Normal but significant events
2,015
public function debug ( $ messageOrException , $ contextOrException = null , array $ context = array ( ) ) { $ this -> log ( LogLevel :: DEBUG , $ messageOrException , $ contextOrException , $ context ) ; }
Detailed debug information
2,016
public static function split ( $ delimiter , $ value , $ limit = null ) { if ( $ delimiter == '' ) { return $ value ; } if ( $ limit == null ) { return explode ( $ delimiter , $ value ) ; } else { return explode ( $ delimiter , $ value , $ limit ) ; } }
Returns an array of strings each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter .
2,017
public static function regexResult ( $ reg , $ str , $ match = 1 ) { preg_match_all ( $ reg , $ str , $ matches ) ; return $ matches [ $ match ] ; }
Obtain matches from a Regex expression .
2,018
public function searchTweets ( $ query , $ count = 10 ) { if ( $ this -> bearer_token == null ) { throw new \ Exception ( 'Incorrect token. You need to obtain correct Bearer token in order to make calls to the API. Check if your API keys are correct.' ) ; } $ this -> makeRequest ( $ query , $ count ) ; }
Pull tweets from API
2,019
public function makeRequest ( $ query , $ count ) { try { $ response = $ this -> client -> request ( 'GET' , self :: $ api_base . '1.1/search/tweets.json' , [ 'query' => [ 'q' => $ query , 'count' => $ count ] , 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> bearer_token ] ] ) ; $ this -> setStatusCode ( $ res...
Get raw Twitter response
2,020
public function isBearer ( $ response ) { if ( ! isset ( $ response -> token_type ) ) { return false ; } if ( $ response -> token_type == 'bearer' ) { return $ response -> access_token ; } }
Validate the initial response to check if the response has a bearer token
2,021
public static function cache ( $ key , $ value ) { $ key = static :: createCacheKey ( $ key ) ; if ( $ cache = static :: getCache ( $ key ) ) { return $ cache ; } if ( $ value instanceof Closure ) { $ value = call_user_func ( $ value ) ; } return static :: setCache ( $ key , $ value ) ; }
Dynamically read and write from the cache at once . If the cache exists with the key return it else execute and save the result . If the value happens to be a closure evaluate the closure and save the result .
2,022
private function hasPermission ( AuthenticatedUserInterface $ user , string $ uri ) { $ permissions = $ this -> getParameterByKey ( "permissions" ) ; foreach ( $ permissions as $ permissionPath => $ acceptableRoles ) { if ( $ permissionPath [ 0 ] !== "/" ) { $ permissionPath = "/" . $ permissionPath ; } if ( substr ( $...
Checks that the user has permission to get response for the request .
2,023
public function isEmpty ( ) { if ( parent :: isEmpty ( ) ) { return true ; } if ( null === $ this -> read ( ) ) { $ this -> clear ( ) ; return true ; } return false ; }
Returns true if and only if storage is empty .
2,024
public function read ( ) { $ identity = $ this -> identity ; if ( null === $ identity ) { $ identity = parent :: read ( ) ; $ this -> identity = $ identity ; } return $ identity ; }
Returns the contents of storage . Behavior is undefined when storage is empty .
2,025
protected function scanAddonDefinition ( $ definitionFile ) { if ( ! file_exists ( $ definitionFile ) ) { throw new \ Exception ( "missing definition file" ) ; } $ definition = [ 'path' => dirname ( $ definitionFile ) , 'requires' => [ ] ] ; $ definitionData = json_decode ( file_get_contents ( $ definitionFile ) , true...
Scan an addon definition file
2,026
protected function scanClasses ( $ dir , $ depth = 2 ) { if ( $ depth < 0 ) { return [ ] ; } $ paths = scandir ( $ dir ) ; $ classes = [ ] ; foreach ( $ paths as $ path ) { if ( in_array ( $ path , [ '.' , '..' ] ) ) { continue ; } $ full = paths ( $ dir , $ path ) ; if ( is_dir ( $ full ) ) { if ( $ depth > 0 ) { $ cl...
Scan a directory for addon classes
2,027
public function autoload ( $ class ) { $ classKey = strtolower ( $ class ) ; if ( isset ( $ this -> classes [ $ classKey ] ) ) { list ( $ _ , $ path ) = $ this -> classes [ $ classKey ] ; include_once $ path ; } }
Autoload this addon s classes
2,028
public function getRequestHeaders ( ) { $ headers = parent :: getRequestHeaders ( ) ; if ( ! is_null ( $ this -> modifiedSince ) ) { $ headers [ 'If-Modified-Since' ] = $ this -> modifiedSince -> format ( 'r' ) ; } return $ headers ; }
Returns array of request headers .
2,029
public function setData ( $ data ) { $ this -> data = [ ] ; $ data = self :: normalizeArray ( $ data ) ; foreach ( $ data as $ offset => $ value ) $ this -> offsetSet ( $ offset , $ value ) ; return $ this ; }
Overwrite internal data array
2,030
public static function findPostsByFlag ( $ flag , $ post_type = PostTypes :: ANY ) { return Post :: findByExactMeta ( $ flag , Checkbox :: ON , $ post_type ) ; }
Finds one or more posts that have the given flag enabled
2,031
public function connect ( Array $ config ) { $ dsn = $ this -> getDSN ( $ config ) ; $ options = $ this -> getOptions ( $ config ) ; $ connection = $ this -> createConnection ( $ dsn , $ config , $ options ) ; if ( isset ( $ config [ 'charset' ] ) ) { $ connection -> prepare ( "set names '" . $ config [ 'charset' ] . "...
Create the actual connection .
2,032
protected function getDSN ( Array $ config ) { $ dsn = "pgsql:host={$config['host']};dbname={$config['dbname']}" ; if ( isset ( $ config [ 'port' ] ) ) { $ dsn .= ";port={$config['port']}" ; } if ( isset ( $ config [ 'sslmode' ] ) ) { $ dsn .= ";sslmode={$config['sslmode']}" ; } return $ dsn ; }
Return the base DSN for the connection .
2,033
public function attachmentUrlFilter ( $ key , $ filter = null ) { if ( empty ( $ key ) ) { return '' ; } try { $ url = $ this -> attachmentHandler -> getFileUrl ( $ key ) ; } catch ( AttachmentException $ e ) { return '' ; } if ( null === $ filter ) { return $ url ; } return $ this -> cacheManager -> getBrowserPath ( $...
Fetch attachment url and pass through liip_imagine filter if the url is not null and filter name is given .
2,034
public function attachmentImageFilter ( $ key , $ filter , $ title = '' , $ altImageUrl = null ) { $ url = $ this -> attachmentUrlFilter ( $ key , $ filter ) ; if ( '' == $ url && null === $ altImageUrl ) { return '' ; } return '<img src="' . ( '' != $ url ? $ url : $ altImageUrl ) . '" title="' . htmlspecialchars ( $ ...
Filters attachment url passes it through liip_imagine and provides a ready to use img tag that is marked as safe . If the url is empty no image tag will be generated . Use this if you want to quickly output attachment images and not care if the attachment was set or not .
2,035
public function CheckForSpam ( $ Type ) { $ Session = Gdn :: Session ( ) ; $ SpamCheckEnabled = GetValue ( 'SpamCheck' , $ this , TRUE ) ; if ( $ SpamCheckEnabled === FALSE || $ Session -> User -> Admin || $ Session -> CheckPermission ( 'Garden.Moderation.Manage' ) ) return FALSE ; $ Spam = FALSE ; if ( ! in_array ( $ ...
Checks to see if the user is spamming . Returns TRUE if the user is spamming .
2,036
public function redirect ( $ path , $ query = [ ] , $ http_response_code = 302 ) { $ url = $ this -> create ( $ path , $ query , true , '&' ) ; header ( 'Location: ' . $ url , true , $ http_response_code ) ; die ( '' ) ; }
Does a clean redirect .
2,037
public function create ( $ path = '' , $ query = [ ] , $ absolute = false , $ separator = '&amp;' ) { if ( empty ( $ path ) ) $ path = $ this -> _fullpath ; $ parts = $ this -> parse ( $ path ) ; parse_str ( $ parts [ 'query' ] , $ parts [ 'query' ] ) ; $ parts [ 'query' ] = array_merge ( $ parts [ 'query' ] , $ query ...
Creates a URL for use with Morrow . It handles automatically languages in the URL .
2,038
public function getBasehref ( ) { $ script_name = dirname ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; $ script_name = str_replace ( '\\' , '/' , $ script_name ) ; $ path = '/' . trim ( $ script_name , '/' ) . '/' ; if ( $ path == '//' ) $ path = '/' ; $ scheme = isset ( $ _SERVER [ 'HTTPS' ] ) || isset ( $ _SERVER [ 'HTTP_X_SSL_...
To get the base href for the actual Morrow installation .
2,039
public function patch ( $ userId , $ dataSourceId , Fitness_DataSource $ postBody , $ optParams = array ( ) ) { $ params = array ( 'userId' => $ userId , 'dataSourceId' => $ dataSourceId , 'postBody' => $ postBody ) ; $ params = array_merge ( $ params , $ optParams ) ; return $ this -> call ( 'patch' , array ( $ params...
Updates a given data source . It is an error to modify the data source s data stream ID data type type stream name or device information apart from the device version . Changing these fields would require a new unique data stream ID and separate data source .
2,040
protected function addSelectsToQuery ( Builder $ query , array $ selects ) { if ( ! empty ( $ selects ) ) { $ query -> selectRaw ( 'max(' . implode ( ' + ' , $ selects ) . ') as relevance' , $ this -> searchBindings ) ; } }
Puts all the select clauses to the main query .
2,041
protected function filterQueryWithRelevance ( Builder $ query , array $ selects , $ relevance_count ) { $ comparator = $ this -> getDatabaseDriver ( ) != 'mysql' ? implode ( ' + ' , $ selects ) : 'relevance' ; $ relevance_count = number_format ( $ relevance_count , 2 , '.' , '' ) ; if ( $ this -> getDatabaseDriver ( ) ...
Adds the relevance filter to the query .
2,042
public function & __get ( $ property ) { $ value = null ; if ( ! empty ( $ property ) ) { $ call = "getter_" . $ property ; if ( method_exists ( $ this , $ call ) ) $ value = $ this -> { $ call } ( ) ; } return $ value ; }
Handler method for accessing virtual properties .
2,043
public function definition ( $ concrete = null , array $ args = [ ] ) { $ definition = new Definition ( $ this , $ concrete , $ args ) ; return $ definition ; }
Instantiate a new Definition
2,044
public function get ( $ abstract ) { if ( ! isset ( $ this -> definitions [ $ abstract ] ) ) { $ this -> definitions [ $ abstract ] = new Definition ( $ this ) ; } return $ this -> definitions [ $ abstract ] ; }
Return a bound definition if set or bind a new definition and return it .
2,045
public function bind ( $ abstract , $ concrete = null , array $ args = [ ] ) { if ( is_null ( $ concrete ) ) { $ concrete = $ abstract ; } if ( isset ( $ this -> definitions [ $ abstract ] ) ) { $ definition = $ this -> definitions [ $ abstract ] ; $ definition -> setClass ( $ concrete ) ; $ definition -> withArgs ( $ ...
Bind a new definition or if it s already set set the concrete class of the bound definition .
2,046
public function readDirRecursive ( $ dir , $ pattern ) { $ sub_dirs = glob ( $ dir . '/*' , \ GLOB_ONLYDIR ) ; $ files = array ( ) ; if ( ! empty ( $ sub_dirs ) ) { foreach ( $ sub_dirs as $ sub_dir ) { $ files = array_merge ( $ files , $ this -> readDirRecursive ( $ sub_dir , $ pattern ) ) ; } } $ files = array_merge ...
read the subdirectory recursive and catch all files with the given pattern
2,047
protected function getSession ( ServerRequestInterface $ request ) : SessionInterface { if ( $ this -> session === null ) { $ this -> session = $ request -> getAttribute ( SessionMiddleware :: SESSION_ATTRIBUTE ) ; if ( ! $ this -> session instanceof SessionInterface ) { throw MissingSessionContainerException :: create...
Fetch session from request attributes
2,048
protected function parsevalue ( $ value ) { if ( ! is_array ( $ value ) && ! $ value instanceof \ ArrayAccess && ! is_object ( $ value ) ) { return false ; } return $ this -> rParseValue ( $ value ) ; }
Parse the value into a type map
2,049
protected function rParseValue ( $ parsableValue ) { $ ret = array ( ) ; foreach ( $ parsableValue as $ key => $ value ) { if ( is_array ( $ value ) || $ value instanceof \ ArrayAccess || is_object ( $ value ) ) { $ ret [ $ key ] = $ this -> rParseValue ( $ value ) ; continue ; } $ ret [ $ key ] = $ this -> normalizeTy...
Recursive value type parser
2,050
protected function issetInObjectOrArray ( $ actValue , $ key ) { if ( is_object ( $ actValue ) && property_exists ( $ actValue , $ key ) ) { return $ actValue -> $ key ; } if ( isset ( $ actValue [ $ key ] ) ) { return $ actValue [ $ key ] ; } return false ; }
Test if key isset in either Object or Array
2,051
public static function generateUrl ( $ name , array $ tokens = [ ] ) { if ( $ name === null ) { return ; } if ( isset ( static :: $ routes [ $ name ] ) ) { $ route = static :: $ routes [ $ name ] ; } else { foreach ( static :: $ routes as $ r ) { if ( $ r -> name === $ name ) { $ route = $ r ; } } } if ( isset ( $ rout...
Returns compiled path for the route .
2,052
public static function root ( $ to = null ) { static :: $ routes [ 'root' ] = new Route ( 'root' , 'root' ) ; if ( $ to ) { static :: $ routes [ 'root' ] -> to ( $ to ) ; } return static :: $ routes [ 'root' ] ; }
Sets the root route .
2,053
public static function resources ( $ resource , $ controller ) { $ uri = strtolower ( Inflector :: controllerise ( $ resource ) ) ; static :: get ( "/{$uri}" ) -> to ( "{$controller}::index" ) ; static :: get ( "/{$uri}/:id" ) -> to ( "{$controller}::show" ) ; static :: get ( "/{$uri}/new" ) -> to ( "{$controller}::new...
Shortcut for setting up the routes for a resource .
2,054
public static function route ( $ route , $ name = null ) { if ( $ route == '404' ) { return static :: $ routes [ '404' ] = new Route ( '404' , '404' ) ; } if ( $ name ) { return static :: $ routes [ $ name ] = new Route ( $ route , $ name ) ; } else { return static :: $ routes [ ] = new Route ( $ route ) ; } }
Adds a new route .
2,055
public static function process ( Request $ request ) { $ uri = "/" . trim ( $ request -> pathInfo ( ) , '/' ) ; if ( isset ( static :: $ routes [ 'root' ] ) and $ request -> pathInfo ( ) == '/' ) { return static :: setRoute ( static :: $ routes [ 'root' ] ) ; } foreach ( static :: $ routes as $ route ) { $ route -> rou...
Routes the request to the controller .
2,056
public static function set404 ( ) { if ( ! isset ( static :: $ routes [ '404' ] ) ) { throw new Exception ( "There is no 404 route set." ) ; } $ match = preg_match ( "#(?<extension>" . implode ( '|' , static :: $ extensions ) . ")?$#" , Request :: $ requestUri , $ params ) ; if ( isset ( $ params [ 'extension' ] ) ) { ...
Sets the route info to that of the 404 route .
2,057
public function format ( ) { switch ( $ this -> displayFormat ) { case self :: FORMAT_CANADA : if ( preg_match ( $ this -> displayFormat , $ this -> postalCode , $ matches ) && count ( $ matches ) === 3 ) { return strtoupper ( sprintf ( '%s %s' , $ matches [ 1 ] , $ matches [ 2 ] ) ) ; } return $ this -> postalCode ; b...
Get formatted phone number for display This assumes a flattened format like 12345 or S4P0H0
2,058
public function InsertRelation ( \ rstoetter \ libsqlphp \ cKEY_COLUMN_USAGE_Entry $ obj ) { if ( is_null ( $ obj -> m_TABLE_NAME ) ) { die ( "\n cKEY_COLUMN_USAGE_Entry mit is_null( m_TABLE_NAME ) " ) ; } $ obj_found = $ this -> SearchByKey ( $ obj -> m_TABLE_NAME ) ; if ( $ obj_found === false ) { $ obj_new = new cKe...
Insert a new item into the tree
2,059
public static function getTypeError ( $ type ) { $ data = [ Type :: TEXT => static :: TEXT , Type :: INTEGER => static :: INTEGER , Type :: FLOAT => static :: FLOAT , Type :: BOOLEAN => static :: BOOLEAN , Type :: TIMESTAMP => static :: TIMESTAMP , Type :: DATETIME => static :: DATETIME , Type :: DATE => static :: DATE...
Return the correct error constant for a specified type .
2,060
protected function _errorhandler_file ( $ errstr , $ backtrace , $ errortype ) { $ body = '############################## ' . $ errortype . "\n" ; $ body .= 'Datum: ' . date ( "d.m.Y - H:i:s" ) . "\n" ; if ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) { $ body .= 'URL: ' . $ _SERVER [ 'REQUEST_URI' ] . "\n" ; $...
Writes an error to a logfile .
2,061
protected function _errorhandler_output ( $ errstr , $ backtrace , $ errortype ) { $ error = '<div class="dp_container">' ; $ error .= '<div class="skyline">' . $ errortype . '</div>' ; $ error .= '<h1 class="exception">' . htmlspecialchars ( $ errstr , ENT_QUOTES , 'UTF-8' ) . '</h1>' ; $ count = 0 ; foreach ( $ backt...
Outputs an error to the screen .
2,062
public function errorhandler ( $ exception ) { $ errstr = $ exception -> getMessage ( ) ; $ errcode = $ exception -> getCode ( ) ; $ backtrace = $ exception -> getTrace ( ) ; if ( $ errstr == $ this -> lasterror ) return ; $ this -> lasterror = $ errstr ; $ this -> errorcounter ++ ; if ( $ exception instanceof ErrorExc...
This method is called when an exception occurs
2,063
protected function _getContent ( $ errfile_or_string , $ errline , $ file_or_string = 'file' ) { $ show_lines = 10 ; if ( $ file_or_string === 'file' ) $ file = highlight_file ( $ errfile_or_string , true ) ; else $ file = highlight_string ( $ errfile_or_string , true ) ; $ file = explode ( "<br />" , $ file ) ; foreac...
Retrieves a code excerpt from a file .
2,064
protected function _dump ( $ args ) { $ backtrace = debug_backtrace ( ) ; $ backtrace = $ backtrace [ 1 ] ; if ( isset ( $ backtrace [ 'file' ] ) ) { $ file = file ( $ backtrace [ 'file' ] ) ; $ function = trim ( $ file [ $ backtrace [ 'line' ] - 1 ] ) ; } $ output = '' ; foreach ( $ args as $ arg ) { $ this -> errorco...
Returns the HTML for dumped variables .
2,065
protected function _dump_php ( & $ var ) { $ scope = false ; $ prefix = 'unique' ; $ suffix = 'value' ; if ( $ scope ) $ vals = $ scope ; else $ vals = $ GLOBALS ; $ old = $ var ; $ var = $ new = $ prefix . rand ( ) . $ suffix ; $ vname = false ; foreach ( $ vals as $ key => $ val ) { if ( $ val === $ new ) $ vname = $...
Returns the HTML for the args of dumped variables .
2,066
public function init ( array $ initVars ) { if ( filter_var ( $ initVars [ 'url' ] , FILTER_VALIDATE_URL ) ) { $ this -> handle = curl_init ( $ initVars [ 'url' ] ) ; if ( isset ( $ initVars [ 'headers' ] ) ) { $ this -> setOpt ( CURLOPT_HTTPHEADER , $ initVars [ 'headers' ] ) ; } switch ( $ initVars [ 'method' ] ) { c...
Initalises the cURL handle and sets some defaults
2,067
public function __async_add ( ) { $ parent = dbQuery ( '\samson\cms\CMSMaterial' ) -> id ( $ _POST [ 'parent_id' ] ) -> first ( ) ; $ fields_array_temp = array ( ) ; $ fields_array = array ( ) ; foreach ( $ parent -> cmsnavs ( ) as $ structure ) { if ( $ structure -> type == 1 ) { $ fields_array_temp = array_merge ( $ ...
Creating new related material
2,068
public function __async_table ( $ parentID ) { $ form = new Form ( $ parentID ) ; $ tab = new RelatedTabLocalized ( $ form ) ; $ content = $ tab -> getContent ( ) ; return array ( 'status' => 1 , 'table' => $ content ) ; }
Async updating related table
2,069
public function saveFieldHandler ( $ dbObject , $ param , $ value ) { if ( $ dbObject instanceof \ samson \ activerecord \ materialfield ) { $ material = dbQuery ( 'material' ) -> id ( $ dbObject -> MaterialID ) -> first ( ) ; if ( $ material -> type == 1 && $ material -> parent_id == 0 ) { $ children = dbQuery ( 'mate...
External handler called on samson . cms . input . change event
2,070
public function write ( $ path , Iterator $ data , $ threshold = null , $ flags = 0 ) { $ asObject = $ this -> isAsObject ( $ data , $ flags ) ; $ pretty = $ flags & self :: FLAG_PRETTY_PRINT ; $ jsonFlags = $ pretty ? JSON_PRETTY_PRINT : 0 ; $ ord = isset ( $ threshold ) ? 1 : null ; $ file = $ this -> open ( $ path ,...
Writes data to a JSON file .
2,071
public function setAttributeNS ( $ namespaceURI , $ qualifiedName , $ value ) : void { if ( $ this -> ownerDocument && $ namespaceURI === XliffFile :: XLIFF_NS && $ this -> ownerDocument -> isDefaultNamespace ( XliffFile :: XLIFF_NS ) ) { \ call_user_func_array ( [ 'parent' , 'setAttribute' ] , \ array_slice ( \ func_g...
Adds new attribute .
2,072
public function getAttributeNS ( $ namespaceURI , $ localName ) : ? string { if ( $ this -> ownerDocument && $ namespaceURI === XliffFile :: XLIFF_NS && $ this -> ownerDocument -> isDefaultNamespace ( XliffFile :: XLIFF_NS ) ) { return \ call_user_func_array ( [ 'parent' , 'getAttribute' ] , \ array_slice ( \ func_get_...
Returns value of attribute
2,073
public function format ( $ level , $ message , array $ context = array ( ) ) { if ( ! is_object ( $ message ) ) { return $ this -> formatter -> format ( '' , $ message , $ context ) ; } $ this -> _processed [ ] = $ message ; $ object_as_array = array ( ) ; $ object_as_array [ ' class_name' ] = get_class ( $ message ) ;...
Format objects into JSON objects
2,074
protected function formatObjectHandleArray ( $ value , array $ context ) { if ( is_array ( $ value ) ) { $ objs = array ( ) ; foreach ( $ value as $ key => $ value2 ) { $ objs [ $ key ] = $ this -> format ( '' , $ value2 , $ context ) ; } return $ objs ; } else { return $ this -> format ( '' , $ value , $ context ) ; }...
Prosesses array values
2,075
protected function getPropertyKey ( ReflectionProperty $ property ) { $ static = $ property -> isStatic ( ) ? ' static' : '' ; if ( $ property -> isPublic ( ) ) { return 'public' . $ static . ' ' . $ property -> getName ( ) ; } if ( $ property -> isProtected ( ) ) { return 'protected' . $ static . ' ' . $ property -> g...
Return description string of object property
2,076
public static function isOn ( $ exception = false ) { if ( isset ( $ _SESSION ) ) { return true ; } exception_if ( $ exception , SessionSurfaceIsOffException :: class ) ; return false ; }
Check if session is started .
2,077
protected static function load ( ) { if ( ! static :: isOn ( ) ) { return false ; } elseif ( ! array_has ( $ _SESSION , static :: $ register_name ) ) { $ _SESSION [ static :: $ register_name ] = [ ] ; } static :: $ register = $ _SESSION [ static :: $ register_name ] ; return true ; }
Load the session register .
2,078
public static function put ( $ name , $ object , $ lifetime = null ) { static :: isOn ( true ) ; if ( is_null ( $ lifetime ) ) { $ lifetime = config ( 'storage.session_lifetime' ) ; } if ( $ lifetime > 0 ) { $ lifetime = time ( ) + $ lifetime ; } $ item = [ 'name' => $ name , 'object' => $ object , 'lifetime' => $ life...
Set new session variable .
2,079
public static function prolong ( $ name , $ lifetime ) { $ item = static :: reach ( $ name ) ; if ( $ item [ 'lifetime' ] > 0 ) { $ item [ 'lifetime' ] += $ lifetime ; } elseif ( $ item [ 'lifetime' ] == 0 ) { $ item [ 'lifetime' ] = time ( ) + $ lifetime ; } static :: $ register [ $ name ] = $ item ; static :: save ( ...
Prolong a session variable lang time .
2,080
public static function get ( $ name ) { static :: isOn ( true ) ; $ item = static :: reach ( $ name ) ; if ( ( $ item [ 'lifetime' ] < time ( ) && $ item [ 'lifetime' ] > 0 ) ) { static :: remove ( $ name ) ; exception ( SessionKeyNotFoundException :: class , $ name ) ; } else { return $ item [ 'object' ] ; } }
Get a seesion variable .
2,081
public static function exists ( $ name ) { static :: isOn ( true ) ; if ( ! isset ( static :: $ register [ $ name ] ) ) { return false ; } else { $ item = static :: $ register [ $ name ] ; return $ item [ 'lifetime' ] > time ( ) || $ item [ 'lifetime' ] == 0 ; } }
Check if a session variable is existe .
2,082
public static function remove ( $ name ) { exception_if ( ! static :: exists ( $ name ) , SessionKeyNotFoundException :: class , $ name ) ; static :: $ register [ $ name ] = null ; static :: save ( ) ; return true ; }
Forget and remove a session variable .
2,083
public static function token ( ) { $ name = config ( 'security.key1' ) ; $ token = '' ; if ( static :: exists ( $ name ) ) { $ token = static :: get ( $ name ) ; } else { $ token = Hash :: token ( ) ; static :: put ( $ name , $ token ) ; } return $ token ; }
Set and get the session token variable .
2,084
static function supprimer_argument_balise ( $ pos , $ p ) { if ( ! isset ( $ p -> param [ 0 ] ) ) { return null ; } if ( ! isset ( $ p -> param [ 0 ] [ $ pos ] ) ) { return null ; } if ( $ pos == 0 ) { array_shift ( $ p -> param [ 0 ] ) ; } else { $ debut = array_slice ( $ p -> param [ 0 ] , 0 , $ pos ) ; $ fin = array...
Supprime un argument de balise
2,085
static function recuperer_et_supprimer_argument_balise ( $ pos , & $ p ) { $ arg = Pile :: recuperer_argument_balise ( $ pos , $ p ) ; $ p = Pile :: supprimer_argument_balise ( $ pos , $ p ) ; return $ arg ; }
Retourne un argument de balise et le supprime de la liste des arguments
2,086
static function ajouter_argument_balise ( $ element , $ p ) { if ( ! isset ( $ p -> param [ 0 ] [ 0 ] ) ) { if ( ! isset ( $ p -> param [ 0 ] ) ) { $ p -> param [ 0 ] = array ( ) ; } $ p -> param [ 0 ] [ 0 ] = '' ; } $ zero = array_shift ( $ p -> param [ 0 ] ) ; array_unshift ( $ p -> param [ 0 ] , $ element ) ; array_...
Ajoute un argument de balise
2,087
public static function fromResponse ( Response $ httpResponse ) { $ content = json_decode ( $ httpResponse -> getBody ( ) -> getContents ( ) , true ) ; $ status = isset ( $ content [ 'status' ] ) ? $ content [ 'status' ] : '' ; if ( $ status == Status :: OK ) { $ htmlAttributes = isset ( $ content [ 'html_attributes' ]...
Create response from http response .
2,088
public function toAssocArray ( $ ident ) { $ nodes = ( func_num_args ( ) > 1 ) ? $ this -> toArray ( 1 ) : $ this -> toArray ( ) ; $ array = array ( ) ; foreach ( $ nodes as $ node ) { if ( array_key_exists ( $ ident , $ node ) ) { $ array [ ( is_object ( $ node [ $ ident ] ) ) ? $ node [ $ ident ] -> toString ( ) : $ ...
Returns a multi - dimensional assoc array containing the reply splitted in multiple rows and columns . The identifier specified by key will be used while indexing the array .
2,089
public function setData ( $ key , $ value ) { $ data = $ this -> findData ( $ key ) ; if ( ! isset ( $ data ) ) { $ data = $ this -> createData ( $ key ) ; } $ data -> setValue ( $ value ) ; }
Sets the value of an already existing data or creates a new one
2,090
public function removeData ( $ key ) { $ data = $ this -> findData ( $ key ) ; if ( isset ( $ data ) ) { $ this -> data -> removeElement ( $ data ) ; return true ; } return false ; }
Removes data if set previously
2,091
protected function findData ( $ key ) { $ criteria = Criteria :: create ( ) -> where ( Criteria :: expr ( ) -> eq ( 'key' , $ key ) ) ; $ result = $ this -> data -> matching ( $ criteria ) ; if ( is_array ( $ result ) ) { $ result = reset ( $ result ) ; return $ result ; } }
Finds a data entity
2,092
public function onDeleteNode ( NodeInterface $ node ) { $ textNode = $ this -> textNodeManager -> findTextNodeByNode ( $ node ) ; if ( null !== $ textNode ) { $ this -> textNodeManager -> remove ( $ textNode ) ; $ this -> textManager -> remove ( $ textNode -> getText ( ) ) ; } }
On delete node .
2,093
public function newCommit ( NewCommitEvent $ event ) { $ commit = $ event -> getCommit ( ) ; $ related = $ this -> matcher -> getRelatedIssues ( $ commit ) ; $ commit -> setIssuesRelated ( $ related ) ; $ this -> repository -> persist ( $ commit ) ; }
Fills the commit with related issues matched by CommitMatcher .
2,094
private function _setDefaultHeadersCompression ( ehough_shortstop_api_HttpRequest $ request ) { if ( $ this -> _isDebugEnabled ) { $ this -> _logger -> debug ( 'Determining if HTTP compression is available...' ) ; } $ header = $ this -> _httpContentDecoder -> getAcceptEncodingHeaderValue ( ) ; if ( $ header !== null ) ...
Sets compression headers .
2,095
private function _setDefaultHeadersBasic ( ehough_shortstop_api_HttpRequest $ request ) { $ map = array ( ehough_shortstop_api_HttpRequest :: HTTP_HEADER_USER_AGENT => 'shortstop; https://github.com/ehough/shortstop' , ehough_shortstop_api_HttpRequest :: HTTP_HEADER_HTTP_VERSION => 'HTTP/1.0' , ) ; foreach ( $ map as $...
Sets things like user agent and HTTP version .
2,096
public function find ( $ key ) { return array_key_exists ( ( $ key = strtolower ( trim ( $ key ) ) ) , $ this -> Hashes ) ? $ this -> Hashes [ $ key ] : false ; }
Try to find value for a key .
2,097
public function index ( $ builder = null ) { $ models = $ this -> repository -> all ( [ ] , true ) ; return response ( ) -> json ( $ models , 200 ) ; }
List resources .
2,098
public function addOption ( $ value , $ display = null ) { if ( null === $ display ) $ display = $ value ; $ this -> _options [ ] = array ( $ value , $ display ) ; return $ this ; }
Adds an option to the field . Once added you cannot edit or delete the options .
2,099
public function loadFile ( $ path , $ fieldsTerminator = ',' , $ fieldsEncloser = '"' , $ linesTerminator = "\n" ) { debug_enforce_string ( $ path ) ; debug_enforce_string ( $ fieldsTerminator ) ; debug_enforce_string ( $ fieldsEncloser ) ; debug_enforce_string ( $ linesTerminator ) ; $ sql = $ this -> getSql ( ) ; $ d...
Load results as CSV - like file on database server .