idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
231,300
protected function addGlobal ( string $ key , $ value ) { $ template = $ this -> getContext ( ) -> getTemplateEngine ( ) ; $ template -> addGlobal ( $ key , $ value ) ; }
Add a variable that will be globally accessible in the template
231,301
protected function getTemplateFile ( string $ action = null ) : string { $ path = '/controller/' . lcfirst ( $ this -> getControllerName ( ) ) . '/' ; return $ path . ( $ action ? $ action : $ this -> getActionName ( ) ) ; }
Returns the default template file
231,302
protected function isAjax ( ) : bool { $ header = $ this -> request -> getHeaders ( ) -> get ( 'X-Requested-With' ) ; if ( $ header === null ) { return false ; } return $ header -> getValue ( ) === 'XMLHttpRequest' ; }
Is the current request done with ajax?
231,303
protected function redirect ( $ controller = null , $ action = 'index' , array $ parameters = [ ] ) : Response { $ host = 'http://' . $ _SERVER [ 'HTTP_HOST' ] ; if ( $ controller === null ) { if ( $ action === 'index' ) { return $ this -> redirectUrl ( $ host ) ; } $ controller = $ this -> getControllerName ( ) ; } if...
Redirect to a controller
231,304
protected function hasPermission ( string $ permission , bool $ return = false ) { $ auth = $ this -> getContext ( ) -> getAuthentication ( ) ; $ user = $ auth -> getUser ( ) ; $ acl = $ this -> getContext ( ) -> getAccessControlList ( ) ; if ( ! $ acl -> hasAccess ( $ user , $ permission ) ) { if ( $ return ) { return...
Has the current user permission for the given action
231,305
public function createHttpClient ( $ name = '' , $ client = null ) { if ( empty ( $ name ) ) { return $ this -> createBestClient ( ) ; } if ( ! isset ( $ this -> classes [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The client "%s" is not registered.' , $ name ) ) ; } $ class = $ this -> classes [ ...
Generate the best http client according to the detected configuration
231,306
public function register ( $ name , $ class , $ requirement = '' , $ priority = false ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s is not a valid class name.' , $ class ) ) ; } $ definition = [ 'class' => $ class , 'requirement' => $ requirement ] ; if ( $ priority ) { $ ...
Register a new client that will be able to be use by the ApiFactory
231,307
private function connect ( Credentials $ credentials ) : PDO { if ( $ this -> pdo === null ) { $ this -> pdo = new PDO ( $ credentials -> getDSN ( ) , $ credentials -> getUsername ( ) , $ credentials -> getPassword ( ) ) ; } return $ this -> pdo ; }
Makes the actual connection to the database
231,308
public static function process ( ArrayResolver $ config ) { $ copy = $ config -> extract ( ) ; $ instances = $ config -> resolveArray ( 'apply-templates' , [ ] ) ; foreach ( $ instances as $ name => $ instance ) { self :: processTemplate ( $ config , $ copy , $ name , $ instance ) ; } return new ArrayResolver ( $ copy ...
Processes a configuration node to expand the templates it contains .
231,309
public function getIcon ( ? string $ extension ) : ? string { $ iconClass = $ this -> iconSet [ $ this -> getIconType ( $ extension ) ] ?? null ; return $ iconClass !== null ? $ this -> iconPrefix . ' ' . $ iconClass : null ; }
Returns suitable css class for icon by extension .
231,310
public function getIconType ( ? string $ extension ) : string { if ( $ extension !== null && $ extension !== '' ) { foreach ( self :: TYPE_TO_REGEX as $ type => $ regex ) { if ( $ regex === null ) { continue ; } if ( ( $ regex === $ extension && preg_match ( '/[a-z0-9]+/' , $ extension ) ) || preg_match ( "/$regex/" , ...
Searches icon type by it s extension
231,311
public static function createRedirectFromPostValues ( $ postValues ) { if ( isset ( $ postValues [ 'title' ] , $ postValues [ 'fromUrl' ] , $ postValues [ 'toUrl' ] ) ) { $ redirectObject = new \ stdClass ( ) ; $ redirectObject -> title = $ postValues [ 'title' ] ; $ redirectObject -> slug = StringUtil :: slugify ( $ p...
Create a new redirect object from postvalues
231,312
public function clear ( ) { $ lastQuery = $ this -> query ; $ this -> query = new Query ( $ this -> error , $ lastQuery -> getInitializer ( ) ) ; $ this -> query -> forceLimit ( $ lastQuery -> getLimit ( ) ) ; $ this -> query -> forceOffset ( $ lastQuery -> getOffset ( ) ) ; if ( ! is_array ( $ lastQuery -> getResultDa...
Clear and reset persistence query .
231,313
public function setSingleQuery ( $ query ) { if ( $ this -> executed ) { $ this -> clear ( ) ; } $ this -> query -> single ( ) -> setQuery ( $ query ) ; return $ this ; }
Set Query to single statement executable .
231,314
public function setQuery ( $ queries ) { if ( $ this -> executed ) { $ this -> clear ( ) ; } $ this -> query -> multiple ( ) -> setQuery ( $ queries ) ; return $ this ; }
Set Query to multiple statement on next call this method will attach or append new query .
231,315
public function getAvailableDrivers ( ) { $ config = $ this -> client ? $ this -> client : $ this -> config ; return $ config -> getAvailableDrivers ( ) ; }
Get list of available drivers .
231,316
public function getServerVersion ( ) { if ( $ this -> client ) { return $ this -> client -> getServerVersion ( ) ; } $ connection = new Connection ( $ this -> config ) ; return $ connection -> getAttribute ( \ PDO :: ATTR_SERVER_VERSION ) ; }
Get current version of database platform .
231,317
public function run ( ) { $ this -> executed = true ; if ( $ this -> client instanceof ClientInterface ) { $ this -> client -> sendRequest ( ) ; } else { $ connection = new Connection ( $ this -> config ) ; $ executor = new Executor ( $ connection ) ; $ executor -> execQuery ( $ this -> query ) ; } return $ this -> has...
Run and execute prepared sql queries .
231,318
public function getResult ( $ resultMode = 0 ) { switch ( $ resultMode ) { case self :: FETCH_ARRAY : return $ this -> query -> toArray ( ) ; break ; case self :: FETCH_JSON : $ result = json_encode ( $ this -> query -> toArray ( ) ) ; return $ result ; break ; case self :: FETCH_JSON_BEAUTIFY : $ result = json_encode ...
Get Result .
231,319
public static function createService ( $ serviceName ) { switch ( $ serviceName ) { case self :: SERVICE_REST : return new RestService ( ) ; break ; case self :: SERVICE_SOAP : return new SoapService ( ) ; break ; case self :: SERVICE_XMLRPC : return new XmlRpcService ( ) ; break ; } throw new \ Exception ( sprintf ( '...
Create Service .
231,320
protected function getMappingClasses ( ) : array { AnnotationRegistry :: registerLoader ( 'class_exists' ) ; $ mappingClasses = [ ] ; foreach ( $ this -> locator -> getMappingFiles ( ) as $ annotationFile ) { $ mappingClasses [ ] = $ this -> loadClassFromFile ( $ annotationFile ) ; } return \ array_map ( function ( str...
Get mapping classes .
231,321
protected function loadClassFromFile ( string $ annotationFile ) : string { $ tokens = \ token_get_all ( \ file_get_contents ( $ annotationFile ) ) ; $ hasClass = false ; $ class = null ; $ hasNamespace = false ; $ namespace = '' ; for ( $ i = 0 , $ length = \ count ( $ tokens ) ; $ i < $ length ; $ i ++ ) { $ token = ...
Load fully qualified class name from file .
231,322
public function logChange ( $ args ) { if ( ! isset ( $ args [ "code" ] ) || ! is_numeric ( $ args [ "code" ] ) ) { if ( isset ( $ this -> AUDIT_CODE ) ) { $ args [ "code" ] = $ this -> AUDIT_CODE ; } else { return false ; } } if ( ! isset ( $ args [ "data" ] ) || '[]' == $ args [ "data" ] ) { return false ; } $ query ...
Log an entity change
231,323
public function tempnam ( ) { $ sysTempDir = $ this -> _sysGetTempDir ( ) ; do { $ this -> _tempnamCounter ++ ; $ name = $ sysTempDir . "/" . $ this -> _tempnamCounter ; } while ( file_exists ( $ name ) ) ; return $ name ; }
Return unique filename
231,324
private function _sysGetTempDir ( $ create = true ) { if ( is_null ( $ this -> _systemTempDirectory ) && $ create ) { $ sysTmpDir = rtrim ( sys_get_temp_dir ( ) , "\\/" ) ; do { $ name = $ sysTmpDir . "/" . uniqid ( "fs" , true ) ; } while ( file_exists ( $ name ) ) ; mkdir ( $ name , 0777 ) ; $ this -> _systemTempDire...
Return path to own temp directory
231,325
public function constructFromTable ( $ table , $ data ) { $ this -> _database = $ table -> getDatabase ( ) ; $ this -> _table = $ table ; $ this -> _parseName ( $ data ) ; $ this -> _parseDatatype ( $ data ) ; $ this -> _parseNotnull ( $ data ) ; $ this -> _parseDefault ( $ data ) ; $ this -> _parseAutoIncrement ( $ da...
Internal method to set up the object from within a \ Nada \ Table \ AbstractTable object
231,326
public function toArray ( ) { return array ( 'name' => $ this -> _name , 'type' => $ this -> _datatype , 'length' => $ this -> _length , 'notnull' => $ this -> _notnull , 'default' => $ this -> _default , 'autoincrement' => $ this -> _autoIncrement , 'comment' => $ this -> _comment , ) ; }
Export column data to an associative array
231,327
protected function _parseNotnull ( $ data ) { switch ( $ data [ 'is_nullable' ] ) { case 'YES' : $ this -> _notnull = false ; break ; case 'NO' : $ this -> _notnull = true ; break ; default : throw new \ UnexpectedValueException ( 'Invalid yes/no type: ' . $ data [ 'is_nullable' ] ) ; } }
Extract NOT NULL constraint from column data
231,328
public function setName ( $ name ) { if ( strlen ( $ name ) == 0 ) { throw new \ InvalidArgumentException ( 'Column name must not be empty' ) ; } if ( $ this -> _table ) { $ this -> _table -> renameColumn ( $ this , $ name ) ; } $ this -> _name = $ name ; }
Change the column s name
231,329
protected function _setDefault ( ) { if ( $ this -> _default === null ) { $ this -> _table -> alter ( sprintf ( 'ALTER COLUMN %s DROP DEFAULT' , $ this -> _database -> prepareIdentifier ( $ this -> _name ) ) ) ; } else { $ this -> _table -> alter ( sprintf ( 'ALTER COLUMN %s SET DEFAULT %s' , $ this -> _database -> pre...
DBMS - specific implementation for setting a column s default value
231,330
public function setComment ( $ comment ) { if ( $ this -> _comment != $ comment ) { $ this -> _comment = $ comment ; if ( $ this -> _table ) { $ this -> _setComment ( $ comment ) ; } } }
Set Column comment
231,331
public function isDifferent ( array $ newSpec , array $ keys = null ) { $ oldSpec = $ this -> toArray ( ) ; if ( $ keys ) { $ keys = array_flip ( $ keys ) ; $ oldSpec = array_intersect_key ( $ oldSpec , $ keys ) ; $ newSpec = array_intersect_key ( $ newSpec , $ keys ) ; } return $ this -> _isDifferent ( $ oldSpec , $ n...
Compare with given specification
231,332
public function get ( $ id ) { foreach ( $ this -> getContainers ( ) as $ container ) { if ( $ container -> has ( $ id ) ) { return $ container -> get ( $ id ) ; } } throw new NotFoundException ( Message :: get ( Message :: SERVICE_ID_NOT_FOUND , $ id ) , Message :: SERVICE_ID_NOT_FOUND ) ; }
Get from the delegator
231,333
public function make ( ) { return new Response ( $ this -> code , $ this -> headers , $ this -> stream , $ this -> version ) ; }
Creates the response instance .
231,334
public function display ( $ message = null ) { if ( ! $ message ) { $ message = $ this -> message ; } $ message = Str :: replace ( root , '$DOCUMENT_ROOT' , $ message ) ; $ message = strip_tags ( $ message ) ; switch ( env_type ) { case 'html' : return $ this -> sendHTML ( $ message ) ; case 'json' : return $ this -> s...
Display native exception
231,335
private function AddLogLifetimeField ( ) { $ name = 'LogLifetime' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetLogLifetime ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , new Integer ( 0 , 730 ) ) ; $ this -> SetRequired ( $ name ) ; }
Adds the log lifetime field
231,336
private function AddChangeRequestLifetimeField ( ) { $ name = 'ChangeRequestLifetime' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetChangeRequestLifetime ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , new Integer ( 1 , 360 ) ) ; $ this -> SetRequired ( $ name ) ; }
Adds the change request lifetime field
231,337
private function AddMailFromEMailField ( ) { $ name = 'MailFromEMail' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetMailFromEMail ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , PhpFilter :: EMail ( ) ) ; }
Adds the smtp mail from e - mail field
231,338
private function AddMailFromNameField ( ) { $ name = 'MailFromName' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetMailFromName ( ) ) ; $ this -> AddField ( $ field ) ; }
Adds the mail from name field
231,339
private function AddSmtpHostField ( ) { $ name = 'SmtpHost' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpHost ( ) ) ; $ this -> AddField ( $ field ) ; }
Adds the smtp host field
231,340
private function AddSmtpPortField ( ) { $ name = 'SmtpPort' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpPort ( ) ) ; $ this -> AddField ( $ field ) ; $ this -> AddValidator ( $ name , new Integer ( 1 , 65535 ) ) ; }
Adds the smtp port field
231,341
private function AddSmtpUserField ( ) { $ name = 'SmtpUser' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpUser ( ) ) ; $ this -> AddField ( $ field ) ; }
Adds the smtp user field
231,342
private function AddSmtpPasswordField ( ) { $ name = 'SmtpPassword' ; $ field = Input :: Text ( $ name , $ this -> settings -> GetSmtpPassword ( ) ) ; $ this -> AddField ( $ field ) ; }
Adds the smtp password field
231,343
private function AddSmtpSecurityField ( ) { $ name = 'SmtpSecurity' ; $ field = new Select ( $ name , $ this -> settings -> GetSmtpSecurity ( ) ) ; $ values = SmtpSecurity :: AllowedValues ( ) ; foreach ( $ values as $ value ) { $ field -> AddOption ( $ value , Trans ( "Core.SettingsForm.SmtpSecurity.$value" ) ) ; } $ ...
Adds the smtp security field
231,344
protected function OnSuccess ( ) { $ this -> settings -> SetLogLifetime ( ( int ) $ this -> Value ( 'LogLifetime' ) ) ; $ this -> settings -> SetChangeRequestLifetime ( $ this -> Value ( 'ChangeRequestLifetime' ) ) ; $ this -> settings -> SetMailFromEMail ( $ this -> Value ( 'MailFromEMail' ) ) ; $ this -> settings -> ...
Saves the settings
231,345
public function getAll ( ) { $ comm = new Comm ( ) ; $ comm -> setDb ( $ this -> di -> get ( "db" ) ) ; return $ comm -> findAll ( ) ; }
Get details on all comments .
231,346
public function setField ( Field $ field , $ index = 0 ) { $ this -> field = $ field ; $ this -> valueIndex = $ index ; }
Set the value s parent field for use in validation
231,347
public function getError ( ) { $ error = new Error ( $ this -> getMessage ( ) ) ; $ error -> setValue ( $ this -> value ) ; if ( $ this -> field !== null ) { $ error -> setName ( $ this -> field -> getName ( ) ) ; } if ( $ this -> valueIndex !== null ) { $ error -> setIndex ( $ this -> valueIndex ) ; } return $ error ;...
Get an error instance
231,348
public static function camelCase ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return str_replace ( ' ' , '' , mb_convert_case ( str_replace ( array ( '_' , '-' ) , ' ' , preg_replace ( '/[^-_a-z0-9\s]+/i' , '' , $ string ) ) , MB_CASE_TITLE ) ) ; } ) ; }
Inflect a word to a camel case form with the first letter being capitalized .
231,349
public static function className ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return Inflector :: camelCase ( Inflector :: singularize ( $ string ) ) ; } ) ; }
Inflect a word to a class name . Singular camel cased form .
231,350
public static function fileName ( $ string , $ ext = 'php' , $ capitalize = true ) { if ( mb_strpos ( $ string , '.' ) !== false ) { $ string = mb_substr ( $ string , 0 , mb_strrpos ( $ string , '.' ) ) ; } $ path = static :: camelCase ( $ string ) ; if ( ! $ capitalize ) { $ path = lcfirst ( $ path ) ; } if ( mb_subst...
Inflect a word for a filename . Studly cased and capitalized .
231,351
public static function normalCase ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return ucfirst ( mb_strtolower ( str_replace ( '_' , ' ' , $ string ) ) ) ; } ) ; }
Inflect a word to a human readable string with only the first word capitalized and the rest lowercased .
231,352
public static function route ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return mb_strtolower ( Inflector :: hyphenate ( str_replace ( '_' , '-' , preg_replace ( '/[^-_a-z0-9\s\.]+/i' , '' , $ string ) ) ) ) ; } ) ; }
Inflect a word to a routeable format . All non - alphanumeric characters will be removed and any spaces or underscores will be changed to dashes .
231,353
public static function tableName ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return lcfirst ( Inflector :: camelCase ( Inflector :: pluralize ( $ string ) ) ) ; } ) ; }
Inflect a word for a database table name . Formatted as plural and camel case with the first letter lowercase .
231,354
public static function titleCase ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return mb_convert_case ( str_replace ( '_' , ' ' , $ string ) , MB_CASE_TITLE ) ; } ) ; }
Inflect a word to a human readable string with all words capitalized .
231,355
public static function underscore ( $ string ) { return static :: cache ( array ( __METHOD__ , $ string ) , function ( ) use ( $ string ) { return trim ( mb_strtolower ( str_replace ( '__' , '_' , preg_replace ( '/([A-Z]{1})/' , '_$1' , preg_replace ( '/[^_a-z0-9]+/i' , '' , preg_replace ( '/[\s]+/' , '_' , $ string ) ...
Inflect a word to an underscore form that strips all punctuation and special characters and converts spaces to underscores .
231,356
public static function variable ( $ string ) { $ string = preg_replace ( '/[^_a-z0-9]+/i' , '' , $ string ) ; if ( is_numeric ( mb_substr ( $ string , 0 , 1 ) ) ) { $ string = '_' . $ string ; } return $ string ; }
Inflect a word to be used as a PHP variable . Strip all but letters numbers and underscores . Add an underscore if the first letter is numeric .
231,357
public static function parse ( $ ua = NULL ) { self :: $ ua = $ ua ? $ ua : strip_tags ( $ _SERVER [ "HTTP_USER_AGENT" ] ) ; self :: $ accept = empty ( $ _SERVER [ "HTTP_ACCEPT" ] ) ? '' : strip_tags ( $ _SERVER [ "HTTP_ACCEPT" ] ) ; if ( empty ( self :: $ regexes ) ) { if ( file_exists ( __DIR__ . "/resources/regexes....
Sets up some standard variables as well as starts the user agent parsing process
231,358
private static function log ( $ data ) { if ( ! $ data ) { $ data = new \ stdClass ( ) ; $ data -> ua = self :: $ ua ; } $ jsonData = json_encode ( $ data ) ; echo $ jsonData . "\r\n" ; }
Logs the user agent info
231,359
public static function get ( ) { if ( $ data = @ file_get_contents ( "https://raw.github.com/tobie/ua-parser/master/regexes.yaml" ) ) { if ( file_exists ( __DIR__ . "/resources/regexes.yaml" ) ) { if ( ! self :: $ nobackup ) { if ( ! self :: $ silent ) { print ( "backing up old YAML file...\n" ) ; } if ( ! copy ( __DIR...
Gets the latest user agent . Back - ups the old version first . it will fail silently if something is wrong ...
231,360
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ func = $ this -> getFunction ( ) ; $ arguments = $ this -> getArguments ( ) ; $ args = array ( ) ; foreach ( $ arguments as $ arg ) $ args [ ] = $ params -> getDriver ( ) -> toSQL ( $ params , $ arg , false ) ; return $ func . '(' . implode ( ', ' ...
Write a function as SQL query syntax
231,361
public function current ( ) { $ current = parent :: current ( ) ; if ( null !== $ current ) { if ( false === is_string ( $ current ) && false === is_numeric ( $ current ) && true === $ this -> is_multidimensional ( $ current ) ) { if ( $ this -> convert !== self :: TYPE_ARRAY ) { return trigger_error ( sprintf ( 'Multi...
Converts current array element to entity when requested
231,362
public function pluck ( $ column ) { $ plucked = [ ] ; while ( parent :: valid ( ) ) { $ current = parent :: current ( ) ; if ( true === is_array ( $ column ) ) { $ tmp = $ current ; $ insert = true ; foreach ( $ column as $ index ) { if ( false === isset ( $ tmp [ $ index ] ) ) { $ insert = false ; break ; } $ tmp = $...
Plucks a column from a resultset
231,363
private function is_multidimensional ( $ array ) { if ( false === is_array ( $ array ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type Array, "%s" given' , __METHOD__ , gettype ( $ array ) ) , E_USER_ERROR ) ; } return ( count ( array_filter ( $ array , 'is_array' ) ) > 0 ) ; }
Returns if an Array is multidimensional
231,364
public static function init ( string $ handlerType , array $ resLocations ) : Container { switch ( strtolower ( $ handlerType ) ) { case Config :: PHP_CONFIG_HANDLER : $ handler = new PhpHandler ( $ resLocations ) ; break ; case Config :: XML_CONFIG_HANDLER : $ xml = new \ Desperado \ XmlBundle \ Model \ XmlReader ; $ ...
Instantiate Config class
231,365
public function determineCategory ( $ userAgent = null , $ defaultGrade = Grades :: UNSUPPORTED ) { $ logger = $ GLOBALS [ 'logger' ] ; $ app = $ GLOBALS [ 'app' ] ; $ parsedUA = UA :: parse ( $ userAgent ) ; if ( ! empty ( $ app ) && ! $ app -> getConfiguration ( ) -> isLocal ( ) ) { try { $ logger -> info ( 'Attempti...
Categorize Incoming Request
231,366
private function _lookupLocal ( $ ua , $ defaultGrade ) { $ logger = $ GLOBALS [ 'logger' ] ; $ browser = new Browser ( ) ; $ gradePrefix = 'X' ; $ gradeSuffix = Grades :: UNSUPPORTED ; if ( ( $ ua -> isMobile || $ ua -> isMobileDevice ) && $ ua -> isTablet ) { $ gradePrefix = DeviceTypes :: TABLET ; $ gradeSuffix == G...
Lookup Device Detection based on File .
231,367
private function _lookupDB ( $ ua ) { $ browser = new Browser ( ) ; $ browser -> setGrade ( Grades :: UNSUPPORTED ) ; $ conn = new \ Mongo ( 'mongodb://' . DeviceManager :: HOST ) ; $ collection = $ conn -> selectDB ( DeviceManager :: DB ) -> devices ; $ pattern = $ this -> _getMatchingRegex ( $ ua ) ; $ uaRegex = new ...
Finds closest match given the user agent
231,368
public static function random ( $ min , $ max = null ) { if ( String :: isEmpty ( $ max ) || $ max > getrandmax ( ) ) { $ max = getrandmax ( ) ; } return rand ( $ min , $ max ) ; }
Generate random number
231,369
public function postIdOfPostupdate ( $ id ) { $ record = DB :: table ( 'postupdates' ) -> select ( 'post_id' ) -> where ( 'id' , '=' , $ id ) -> first ( ) ; return $ record -> post_id ; }
What is the post_id of a given postupdate?
231,370
public function postupdateNotExist ( $ post_id ) { if ( $ this -> countPostUpdates ( $ post_id ) == 0 ) { DB :: table ( 'posts' ) -> where ( 'id' , '=' , $ post_id ) -> update ( [ 'postupdate' => 0 ] ) ; } }
When a post update is deleted and no more post updates exist for that post then update the POSTS table to indicate that no post updates for that post exist .
231,371
public function hasAppliedValue ( ) { $ customFunction = $ this -> getHasAppliedValueFunction ( ) ; if ( is_callable ( $ customFunction ) ) { $ result = call_user_func ( $ customFunction , $ this ) ; if ( ! is_bool ( $ result ) ) { throw new FilterException ( 'Returned value from callable function must be boolean.' ) ;...
Checks if the filter value was applied . Note that the converted value is used for checking .
231,372
public function setApplyFilterFunction ( callable $ function ) { $ validator = $ this -> getCallableValidatorApplyFilters ( ) ; $ validator -> setCallableFunction ( $ function ) ; if ( $ validator -> isValid ( ) === false ) { throw $ validator -> getException ( ) ; } $ this -> applyFilterFunction = $ function ; return ...
Sets custom apply filter function .
231,373
public function setAppendFormFieldsFunction ( callable $ function ) { $ validator = $ this -> getCallableValidatorAppendFormFields ( ) ; $ validator -> setCallableFunction ( $ function ) ; if ( $ validator -> isValid ( ) === false ) { throw $ validator -> getException ( ) ; } $ this -> appendFormFieldsFunction = $ func...
Sets custom append form fields function .
231,374
public function setConvertValueFunction ( callable $ function ) { $ validator = $ this -> getCallableValidatorConvertValue ( ) ; $ validator -> setCallableFunction ( $ function ) ; if ( $ validator -> isValid ( ) === false ) { throw $ validator -> getException ( ) ; } $ this -> convertValueFunction = $ function ; retur...
Sets custom convert value function .
231,375
public function setValuePropertyName ( $ valuePropertyName ) { if ( ! is_string ( $ valuePropertyName ) || $ valuePropertyName === '' ) { throw new InvalidArgumentException ( '"Value property name" argument must be a string and must not empty.' ) ; } if ( ! property_exists ( $ this , $ valuePropertyName ) ) { throw new...
Sets the name of the property which contains the raw value .
231,376
public function setFormFieldType ( $ formFieldType ) { if ( ! is_string ( $ formFieldType ) || $ formFieldType === '' ) { throw new InvalidArgumentException ( '"Form field type" argument must be a string and must not empty.' ) ; } $ this -> formFieldType = $ formFieldType ; return $ this ; }
Sets form field type .
231,377
public function process ( Response $ response ) { $ content = preg_replace ( '/<!\-\-.[^(\-\-\>)]*?\-\->/i' , '' , $ response -> getContent ( ) ) ; $ content = str_replace ( "\t" , " " , $ content ) ; $ content = preg_replace ( '/(\s)\/\/(.*)(\s)/' , '\\1/* \\2 */\\3' , $ content ) ; $ search = array ( '/(\s+)?(\<.+\>)...
Drop comments & compress response content
231,378
public function getQueryHintValue ( ) : SqlConversionInfo { if ( null === $ this -> whereClause ) { throw new BadMethodCallException ( 'Unable to get query-hint value for ConditionGenerator. Call getWhereClause() before calling this method.' ) ; } return new SqlConversionInfo ( $ this -> nativePlatform , $ this -> para...
Returns the Query - hint value for the query object .
231,379
public static function read ( $ key = false ) { if ( is_array ( $ key ) && ! empty ( $ key ) ) { $ _value_to_be_returned = self :: $ _config ; foreach ( array_values ( $ key ) as $ key => $ _val ) { $ _value_to_be_returned = $ _value_to_be_returned [ $ _val ] ; } return $ _value_to_be_returned ; } return isset ( self :...
This function returns the value of the key in the config .
231,380
public static function loadConfigFiles ( $ configPath = false ) { if ( ! is_dir ( $ configPath ) ) { throw new \ Exception ( "Config directory {$configPath} not found!" ) ; } $ filesToBeLoaded = scandir ( $ configPath ) ; foreach ( $ filesToBeLoaded as $ _file ) { if ( preg_match ( '/.*\.php/' , $ _file ) ) { include_o...
This function is loads all the files in a particular folder this is meant to the config folder .
231,381
protected function InitForm ( ) { $ this -> htmlCode = $ this -> LoadElement ( ) ; $ name = 'Code' ; $ this -> AddField ( new Textarea ( $ name , $ this -> htmlCode -> GetCode ( ) ) ) ; $ this -> SetRequired ( $ name ) ; $ this -> AddCssClassField ( ) ; $ this -> AddCssIDField ( ) ; $ this -> AddSubmit ( ) ; }
Initializes the html code content form
231,382
public function init ( $ config , $ global ) { $ this -> author = $ global [ 'comment' ] [ 'author' ] ; $ this -> version = $ global [ 'comment' ] [ 'version' ] ; $ this -> classname = $ config [ 'class' ] [ 'classname' ] ; $ this -> namespace = $ config [ 'class' ] [ 'namespace' ] ; $ this -> cacheName = $ config [ 'c...
Initialize config .
231,383
public function getValidations ( $ class = null ) { $ reflectionClass = $ class ? new \ ReflectionClass ( $ class ) : false ; if ( $ reflectionClass === false ) { return [ ] ; } $ result = $ this -> buildValidation ( $ class ) ; $ validations = [ ] ; foreach ( $ result as $ keyElement => $ element ) { if ( is_array ( $...
Gets the validations .
231,384
protected function buildValidation ( $ class = null ) { $ validations = [ ] ; $ metadata = $ this -> validator -> getMetadataFor ( $ class ) ; $ entityConstraints = [ ] ; foreach ( $ metadata -> getConstraints ( ) as $ constraint ) { $ class = new \ ReflectionClass ( $ constraint ) ; $ fields = $ constraint -> fields ;...
Parses and builds the validation .
231,385
protected function constraintMessages ( Constraint $ constraint ) { $ result = [ ] ; if ( isset ( $ constraint -> min ) && $ constraint -> min !== null ) { $ count = new Count ( [ 'min' => $ constraint -> min ] ) ; $ length = new Length ( [ 'min' => $ constraint -> min ] ) ; $ result [ ] = $ constraint -> minMessage ; ...
Parses the constraint message .
231,386
public function cmdGetCollectionItem ( ) { $ result = $ this -> getListCollectionItem ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableCollectionItem ( $ result ) ; $ this -> output ( ) ; }
Callback for collection - item - get command
231,387
public function cmdDeleteCollectionItem ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ condition = $ id ; if ( $ this -> getParam ( 'collection' ) ) { $ condition = array ( 'collection_id' => $ id ) ; } $ res...
Callback for collection - item - delete command
231,388
public function cmdUpdateCollectionItem ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } ...
Callback for collection - item - update command
231,389
protected function addCollectionItem ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> collection_item -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new collection item
231,390
protected function updateCollectionItem ( $ collection_item_id ) { if ( ! $ this -> isError ( ) && ! $ this -> collection_item -> update ( $ collection_item_id , $ this -> getSubmitted ( ) ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } }
Updates a collection item
231,391
protected function submitAddCollectionItem ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'collection_item' ) ; $ this -> addCollectionItem ( ) ; }
Add a new collection item at once
231,392
protected function wizardAddCollectionItem ( ) { $ this -> validatePrompt ( 'collection_id' , $ this -> text ( 'Collection ID' ) , 'collection_item' ) ; $ this -> validatePrompt ( 'entity_id' , $ this -> text ( 'Entity ID' ) , 'collection_item' ) ; $ this -> validatePrompt ( 'weight' , $ this -> text ( 'Weight' ) , 'co...
Add a collection item step by step
231,393
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( MediaTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ Attogram \ Share...
Performs a DELETE on the database given a Media or Criteria object OR a primary key value .
231,394
public function registerPostType ( ) { $ nameSingular = 'Shortlink' ; $ namePlural = 'Shortlinks' ; $ description = 'Create shortlinks to your posts or pages' ; $ labels = array ( 'name' => _x ( $ nameSingular , 'post type general name' , 'custom-short-links' ) , 'singular_name' => _x ( $ nameSingular , 'post type sing...
Register shortlinks posttype
231,395
public function simpleRedirect ( ) { global $ wp ; if ( ! $ request = $ wp -> request ) { return ; } $ currentSlug = add_query_arg ( array ( ) , $ request ) ; $ post = get_page_by_title ( $ currentSlug , 'OBJECT' , 'custom-short-link' ) ; if ( ! $ post ) { return ; } $ fields = get_fields ( $ post -> ID ) ; $ redirectT...
Make a simple PHP redirect to the target page
231,396
protected function validateUrlData ( $ urlData , $ i ) { $ part1 = isset ( $ urlData [ $ i ] ) ? explode ( '~' , $ urlData [ $ i ] ) : [ ] ; $ part2 = isset ( $ urlData [ $ i + 1 ] ) ? explode ( '~' , $ urlData [ $ i + 1 ] ) : [ ] ; $ part3 = isset ( $ urlData [ $ i + 2 ] ) ? explode ( '~' , $ urlData [ $ i + 2 ] ) : [...
This function check for duplicate of page It s need for SEO
231,397
public function getMimeTypeFromFile ( $ file ) { $ extension = strtolower ( pathinfo ( $ file , PATHINFO_EXTENSION ) ) ; if ( array_key_exists ( $ extension , $ this -> _alt_mime_types ) ) { return $ this -> _alt_mime_types [ $ extension ] ; } else { return ( new \ Finfo ( FILEINFO_MIME_TYPE ) ) -> file ( $ file ) ; } ...
Get mime - type from file . Checks extensions array first then attempts to get mime - type using Finfo
231,398
public function getFriend ( ) { $ userTable = CoreTables :: getTableName ( CoreTables :: TABLE_USER ) ; return $ this -> hasOne ( User :: class , [ 'id' => 'friendId' ] ) -> from ( "$userTable as friend" ) ; }
Return user who got friendship invite .
231,399
public function writeOutput ( $ str ) { if ( empty ( $ str ) ) { return $ this ; } $ this -> output [ ] = $ str ; if ( $ this -> consoleOutput ) { $ this -> consoleOutput -> writeln ( $ str ) ; } return $ this ; }
Writes output to the run .