idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
233,900
public function hasFieldError ( $ field ) { foreach ( ( array ) $ this -> errors as $ err ) { if ( $ err instanceof FieldValidationError ) { $ tfield = $ err -> getFieldResolved ( ) ; if ( $ tfield == $ field ) return true ; } } return false ; }
Determines if an error has occurred for the supplied field already
233,901
public function getErrorsAsArray ( ) { $ errors = array ( ) ; $ errors [ 'HasErrors' ] = $ this -> hasErrors ( ) ; $ errors [ 'ErrorCount' ] = $ this -> getErrorCount ( ) ; $ errors [ 'Errors' ] = ( array ) $ this -> errors ; foreach ( ( array ) $ this -> errors as $ err ) { if ( $ err instanceof FieldValidationError )...
Extracts the errors from the collection as ValidationErrors into simple arrays
233,902
public function toString ( ) { $ errorString = '' ; foreach ( ( array ) $ this -> errors as $ err ) { $ errorString .= $ err -> getDefaultErrorMessage ( ) . ", " ; } return substr ( $ errorString , 0 , - 2 ) ; }
Returns a string that s a combination of all errors
233,903
public function rejectField ( $ errorCode , $ fieldResolved , $ fieldTitle , $ value , $ message = '' ) { $ this -> addFieldError ( $ errorCode , $ fieldResolved , 'field' , $ fieldTitle , $ value , $ message == '' ? "$fieldTitle is required." : $ message ) ; return $ this ; }
Adds a field error to the specified field
233,904
public function validateModelObject ( ModelObject $ model ) { $ fields = $ model -> getPersistentFields ( ) ; foreach ( $ fields as $ fieldName ) { $ value = $ model -> $ fieldName ; $ fieldResolved = get_class ( $ model ) . '.' . $ fieldName ; $ this -> rejectIfInvalid ( $ fieldResolved , 'field' , $ model -> getField...
Validates the model object rejecting the fields that fail validation
233,905
public static function wordsTokenized ( $ string ) { for ( $ tokens = array ( ) , $ nextToken = strtok ( $ string , ' ' ) ; $ nextToken !== false ; $ nextToken = strtok ( ' ' ) ) { if ( $ nextToken { 0 } == '"' ) $ nextToken = $ nextToken { strlen ( $ nextToken ) - 1 } == '"' ? '"' . substr ( $ nextToken , 1 , - 1 ) . ...
Splits a string into an array exploded by spaces . However it takes quoted strings into account will count them as a single item .
233,906
public static function smartSplit ( $ data , $ delimiter = ';' , $ quote = "'" , $ escape = "\\'" , $ limit = null ) { $ results = array ( ) ; $ lines = explode ( $ delimiter , $ data ) ; if ( empty ( $ lines ) ) return array ( ) ; $ broke = false ; for ( $ i = 0 ; $ i < count ( $ lines ) ; $ i ++ ) { $ line = $ lines ...
Split a string around a delimiter taking into account quoted substrings
233,907
public static function lineIsOpenQuoted ( $ line , $ quote , $ escape ) { $ pos = 0 ; $ quote_open = false ; $ esc_len = strlen ( $ escape ) ; for ( ; $ pos < strlen ( $ line ) ; ++ $ pos ) { $ char = $ line [ $ pos ] ; if ( substr ( $ line , $ pos , $ esc_len ) == $ escape ) { $ pos += $ esc_len - 1 ; continue ; } if ...
Determines if a line is open - quoted and continues to the next line .
233,908
public static function smartExplode ( $ string ) { if ( empty ( $ string ) ) return array ( ) ; if ( is_array ( $ string ) ) return $ string ; if ( ! is_array ( $ string ) ) { if ( strpos ( $ string , ';' ) !== false ) return explode ( ';' , trim ( $ string , ';' ) ) ; if ( strpos ( $ string , ',' ) !== false ) return ...
Explodes a string into an array split upon ; or characters
233,909
public static function pluralize ( $ word ) { $ plural = array ( '/(quiz)$/i' => '\1zes' , '/^(ox)$/i' => '\1en' , '/([m|l])ouse$/i' => '\1ice' , '/(matr|vert|ind)ix|ex$/i' => '\1ices' , '/(x|ch|ss|sh)$/i' => '\1es' , '/([^aeiouy]|qu)ies$/i' => '\1y' , '/([^aeiouy]|qu)y$/i' => '\1ies' , '/(hive)$/i' => '\1s' , '/(?:([^...
Takes a word and makes it plural .
233,910
public static function strToBool ( $ string ) { if ( is_bool ( $ string ) ) return $ string ; if ( in_array ( strtolower ( ( string ) $ string ) , array ( '1' , 'true' , 'on' , '+' , 'yes' , 'y' ) ) ) return true ; elseif ( in_array ( strtolower ( ( string ) $ string ) , array ( '' , '0' , 'false' , 'off' , '-' , 'no' ...
Translates the given string into a boolean value if it s in the proper format
233,911
public static function stripslashesDeep ( $ value ) { $ value = is_array ( $ value ) ? array_map ( array ( 'StringUtils' , 'stripslashesDeep' ) , $ value ) : stripslashes ( $ value ) ; return $ value ; }
Recursively strips slashes from all values in the array
233,912
public static function stripHtml ( $ value , $ tags = null , $ keepContent = false ) { $ content = '' ; if ( ! is_array ( $ tags ) ) { $ tags = ( strpos ( $ value , '>' ) !== false ? explode ( '>' , str_replace ( '<' , '' , $ tags ) ) : array ( $ tags ) ) ; if ( end ( $ tags ) == '' ) array_pop ( $ tags ) ; } foreach (...
Strips a string of HTML tags specified can strip content or just remove tags
233,913
public static function convertMetric ( $ value , $ from , $ to , $ precision = null ) { switch ( $ from . $ to ) { case 'incm' : $ value *= 2.54 ; break ; case 'inmm' : $ value *= 25.4 ; break ; case 'inpt' : $ value *= 72 ; break ; case 'cmin' : $ value /= 2.54 ; break ; case 'cmmm' : $ value *= 10 ; break ; case 'cmp...
convert value from one metric to another .
233,914
public function setValues ( $ values ) { if ( false === is_array ( $ values ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ values ) ) , E_USER_ERROR ) ; } $ this -> values = $ values ; return $ this ; }
Add one or multiple fields to combine them as one
233,915
public function setFieldnames ( $ fieldnames ) { if ( false === is_array ( $ fieldnames ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ fieldnames ) ) , E_USER_ERROR ) ; } $ this -> fieldnames = $ fieldnames ; }
Sets the fieldnames
233,916
public function glue ( $ glue ) { if ( false === is_string ( $ glue ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ glue ) ) , E_USER_ERROR ) ; } $ this -> glue = $ glue ; return $ this ; }
Joins the fieldnames with the glue string between each fieldname
233,917
public function format ( $ format ) { if ( false === is_string ( $ format ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ format ) ) , E_USER_ERROR ) ; } $ this -> format = $ format ; return $ this ; }
Converts the fieldname values to the specific given format
233,918
public function name ( $ name ) { if ( false === is_string ( $ name ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ name ) ) , E_USER_ERROR ) ; } $ this -> name = $ name ; return $ this ; }
Gives the combined fieldnames a new single name
233,919
public function combine ( ) { if ( count ( $ this -> values ) > 0 ) { if ( null !== $ this -> glue ) { return implode ( $ this -> glue , $ this -> values ) ; } return vsprintf ( $ this -> format , $ this -> values ) ; } }
Combine the values with the glue or format
233,920
protected function getRecursiveAncestry ( Collection $ all_results , $ ids ) { $ all_results -> merge ( $ results = DB :: table ( $ this -> hierarchyTable ) -> whereIn ( 'term_id' , $ ids ) -> get ( ) ) ; if ( count ( $ results ) ) { $ this -> getRecursiveAncestry ( $ all_results , Arr :: pluck ( $ results , 'parent_id...
Get the ancestry recursively
233,921
public function createManyToOne ( $ request , $ match ) { $ parent = Pluf_Shortcuts_GetObjectOr404 ( 'Tenant_Ticket' , $ match [ 'parentId' ] ) ; $ object = new Tenant_Comment ( ) ; $ form = Pluf_Shortcuts_GetFormForModel ( $ object , $ request -> REQUEST ) ; $ object = $ form -> save ( false ) ; $ object -> ticket_id ...
Create new comment
233,922
public function generateVersioned ( $ pathBase , $ pathAppend ) { $ pathAbsolute = $ pathBase . $ pathAppend ; if ( ! file_exists ( $ pathAbsolute ) ) { throw new \ Exception ( "cannot get cache busting path for file '$pathAbsolute'" ) ; } $ timeModified = filemtime ( $ pathAbsolute ) ; return $ this -> generate ( ) . ...
gets absolute path of a single file with cache busting powers!
233,923
public function actionError ( ) { $ error = array ( ) ; if ( ! empty ( Yii :: app ( ) -> errorHandler -> error ) ) $ error = Yii :: app ( ) -> errorHandler -> error ; $ this -> render ( 'error' , array ( 'error' => $ error ) ) ; }
Error Action The installer shouldn t error if this happens flat out die and blame the developer
233,924
public function actionIndex ( ) { $ model = new DatabaseForm ; if ( Cii :: get ( Yii :: app ( ) -> session [ 'dsn' ] ) != "" ) $ model -> attributes = Yii :: app ( ) -> session [ 'dsn' ] ; if ( Cii :: get ( $ _POST , 'DatabaseForm' ) ) { $ model -> attributes = $ _POST [ 'DatabaseForm' ] ; if ( $ model -> validateConne...
Initial action the user arrives to . Handles setting up the database connection
233,925
public function actionCreateAdmin ( ) { $ model = new UserForm ; if ( Cii :: get ( $ _POST , 'UserForm' ) != NULL ) { $ model -> attributes = Cii :: get ( $ _POST , 'UserForm' , array ( ) ) ; if ( $ model -> validate ( ) ) { $ response = $ this -> runInstaller ( $ model ) ; if ( file_exists ( Yii :: getPathOfAlias ( 'a...
This action enables us to create an admin user for CiiMS
233,926
public function actionRunMigrations ( ) { header ( 'Content-Type: application/json' ) ; $ response = $ this -> runMigrationTool ( ) ; $ data = array ( 'migrated' => false , 'details' => $ response ) ; if ( strpos ( $ response , 'Migrated up successfully.' ) || strpos ( $ response , 'Your system is up-to-date.' ) ) $ da...
Ajax comment to run CDbMigrations
233,927
private function runInstaller ( $ userModel ) { return $ this -> runCommand ( Yii :: app ( ) -> session [ 'dsn' ] , 'application.modules.install.InstallerCommand' , array ( 'yiic' , 'installer' , 'index' , '--dbHost=' . Yii :: app ( ) -> session [ 'dsn' ] [ 'host' ] , '--dbName=' . Yii :: app ( ) -> session [ 'dsn' ] [...
Runs the CLI installer which writes the config files and create the initial admin user
233,928
private function runCommand ( $ dsn , $ command , $ data ) { $ runner = new CConsoleCommandRunner ( ) ; $ runner -> commands = array ( 'migrate' => array ( 'class' => $ command , 'dsn' => $ dsn , 'interactive' => 0 , ) , 'db' => array ( 'class' => 'CDbConnection' , 'connectionString' => "mysql:host={$dsn['host']};dbnam...
Runs a given command
233,929
public function setDriver ( $ dsn , array $ config = [ ] , array $ options = [ ] ) { $ class = '\Micro\Db\Drivers\\' . ucfirst ( substr ( $ dsn , 0 , strpos ( $ dsn , ':' ) ) ) . 'Driver' ; if ( ! class_exists ( $ class ) ) { throw new Exception ( 'DB driver `' . $ class . '` not supported' ) ; } unset ( $ this -> driv...
Set active connection driver
233,930
public function hmget ( $ key , ... $ dictionary ) { if ( count ( $ dictionary ) == 1 ) { $ dictionary = $ dictionary [ 0 ] ; } return array_values ( $ this -> command ( 'hmget' , [ $ key , $ dictionary ] ) ) ; }
Get the value of the given hash fields .
233,931
public function eval ( $ script , $ numberOfKeys , ... $ arguments ) { return $ this -> client -> eval ( $ script , $ arguments , $ numberOfKeys ) ; }
Evaluate a script and retunr its result .
233,932
public function read ( $ entityName ) { return new ReadQuery ( $ this -> connection , $ this -> models -> get ( $ entityName ) , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; }
Sets read operation
233,933
public function readOne ( $ entityName ) { return new ReadOneQuery ( $ this -> connection , $ this -> models -> get ( $ entityName ) , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; }
Sets read one operation
233,934
public function write ( $ instance , $ entity = null ) { list ( $ instance , $ entity ) = $ this -> reassignEntity ( $ instance , $ entity ) ; return new WriteQuery ( $ this -> connection , $ instance , $ this -> models -> get ( $ entity ) , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; }
Sets write operation
233,935
public function update ( $ instance , $ entity = null ) { list ( $ instance , $ entity ) = $ this -> reassignEntity ( $ instance , $ entity ) ; return new UpdateQuery ( $ this -> connection , $ instance , $ this -> models -> get ( $ entity ) , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; }
Sets update operation
233,936
public function insert ( $ instance , $ entity = null ) { list ( $ instance , $ entity ) = $ this -> reassignEntity ( $ instance , $ entity ) ; return new InsertQuery ( $ this -> connection , $ instance , $ this -> models -> get ( $ entity ) , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; }
Sets insert operation
233,937
public function delete ( $ instance , $ entity = null ) { list ( $ instance , $ entity ) = $ this -> reassignEntity ( $ instance , $ entity ) ; return new DeleteQuery ( $ this -> connection , $ instance , $ this -> models -> get ( $ entity ) , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; }
Sets delete operation
233,938
public function _initBaseException ( $ message = null , $ code = null , RootException $ previous = null ) { $ message = is_null ( $ message ) ? '' : $ this -> _normalizeString ( $ message ) ; $ code = is_null ( $ code ) ? 0 : $ this -> _normalizeInt ( $ code ) ; $ this -> _initParent ( $ message , $ code , $ previous )...
Initializes the base exception .
233,939
public function dateTransform ( $ date_value , $ format_origin = 'd/m/Y H:i:s' , $ format_destiny = 'Y-m-d H:i:s' ) { $ date = \ DateTime :: createFromFormat ( $ format_origin , $ date_value ) ; return $ date !== false ? $ date -> format ( $ format_destiny ) : '' ; }
Transforma uma data de um formato para outro
233,940
public static function validate_distance ( $ distance ) { $ valid = filter_var ( $ distance , FILTER_VALIDATE_INT , array ( 'options' => array ( 'min_range' => 1 , 'max_range' => PHP_INT_MAX ) ) ) ; return false !== $ valid ? true : false ; }
Validate distance .
233,941
public function diff ( DateTimeBase $ other , bool $ absolute = false ) { return $ this -> dateTime -> diff ( $ other -> dateTime , $ absolute ) ; }
Returns a diff of the supplied date time .
233,942
public function equals ( DateTimeBase $ other ) : bool { $ dateTime = $ this -> dateTime ; $ otherDateTime = $ other -> dateTime ; return $ dateTime == $ otherDateTime && $ dateTime -> getTimezone ( ) -> getName ( ) === $ otherDateTime -> getTimezone ( ) -> getName ( ) ; }
Returns whether the DateTimeBase is equal to the supplied date .
233,943
protected function buildTasks ( array $ configuration ) { $ this -> io -> text ( '- Building tasks...' ) ; $ builder = new TaskBuilder ( $ this -> debug ) ; $ tasks = $ builder -> build ( $ configuration ) ; $ this -> io -> text ( '- Tasks build !' ) ; $ this -> io -> newLine ( ) ; return $ tasks ; }
Build tasks from the configuration array .
233,944
protected function buildFilters ( array $ configuration ) { $ this -> io -> text ( '- Building filters...' ) ; $ builder = new FilterBuilder ( $ this -> eventDispatcher ) ; $ filters = $ builder -> build ( $ configuration ) ; $ this -> io -> text ( '- Filters build !' ) ; $ this -> io -> newLine ( ) ; return $ filters ...
Build the filter according to the configuration array .
233,945
protected function loadConfigurationFile ( $ configurationFile ) { if ( ! file_exists ( $ configurationFile ) ) { throw new Exception ( 'The configuration yml file ' . $ configurationFile . ' was not found' ) ; } $ configuration = Yaml :: parse ( file_get_contents ( $ configurationFile ) ) ; if ( empty ( $ configuratio...
Load the configuration from a yml file .
233,946
protected function loadConfiguration ( InputInterface $ input ) { $ loader = new ConfigurationLoader ( ) ; if ( $ input -> hasOption ( 'config' ) && $ file = $ input -> getOption ( 'config' ) ) { $ configuration = $ loader -> loadFromFile ( $ file ) ; } else { if ( null === $ this -> container ) { throw new Exception (...
Load the configuration from a yml file or the container according to the given option .
233,947
public function setContainer ( ContainerInterface $ container = null ) { $ this -> container = $ container ; $ this -> eventDispatcher = $ this -> container -> get ( 'event_dispatcher' ) ; }
Sets the container .
233,948
protected function sort ( ) { if ( ! empty ( $ this -> _callback_list ) ) { $ priority_list = $ this -> _priority_list ; asort ( $ priority_list ) ; $ tmp = $ this -> _callback_list ; $ this -> _callback_list = [ ] ; foreach ( $ priority_list as $ index => $ _ ) { $ this -> _callback_list [ ] = $ tmp [ $ index ] ; } $ ...
Sort callbacks based on their priority
233,949
public function createLoginToken ( $ userID ) { $ user = $ this -> getFind ( $ userID ) ; $ user -> login_token = hash_hmac ( 'sha256' , Str :: random ( 40 ) , 'secret' ) ; $ user -> login_token_created_at = Carbon :: now ( ) ; return $ user -> save ( ) ; }
UPDATE the users table with a login token
233,950
public function isLoginTokenExpired ( $ user ) { $ startTime = strtotime ( $ user -> login_token_created_at ) ; $ now = strtotime ( Carbon :: now ( ) ) ; $ timeDiff = ( $ now - $ startTime ) / 60 ; $ minutes2faFormIsLive = config ( 'lasallecmstokenbasedlogin.token_login_minutes_token_is_live' ) ; if ( $ timeDiff > $ mi...
Has a login token expired?
233,951
public function deleteUserLoginTokenFields ( $ userID ) { $ user = $ this -> getFind ( $ userID ) ; $ user -> login_token = '' ; $ user -> login_token_created_at = '' ; return $ user -> save ( ) ; }
Remove the login_token and login_token_created_at fields .
233,952
public function index ( ) { $ this -> data [ 'page' ] -> title = APP_NAME . ' Blog' ; $ this -> data [ 'page' ] -> seo -> description = '' ; $ this -> data [ 'page' ] -> seo -> keywords = '' ; $ page = $ this -> uri -> rsegment ( 3 ) ; $ perPage = appSetting ( 'home_per_page' , 'blog-' . $ this -> oBlog -> id ) ; $ per...
Browse all posts
233,953
public function rss ( ) { if ( ! appSetting ( 'rss_enabled' , 'blog-' . $ this -> oBlog -> id ) ) { show404 ( ) ; } $ data = array ( ) ; $ data [ 'include_body' ] = true ; $ data [ 'include_gallery' ] = appSetting ( 'home_show_gallery' , 'blog-' . $ this -> oBlog -> id ) ; $ data [ 'sort' ] = array ( 'bp.published' , '...
RSS Feed for the blog
233,954
protected function fetchSidebarWidgets ( ) { $ this -> data [ 'widget' ] = new stdClass ( ) ; if ( appSetting ( 'sidebar_latest_posts' , 'blog-' . $ this -> oBlog -> id ) ) { $ this -> data [ 'widget' ] -> latest_posts = $ this -> blog_widget_model -> latestPosts ( $ this -> oBlog -> id ) ; } if ( appSetting ( 'sidebar...
Loads all the enabled sidebar widgets
233,955
private function loadView ( $ sView , $ aData = array ( ) ) { $ oView = Factory :: service ( 'View' ) ; $ sFile = $ this -> oSkin -> path . 'views/' . $ sView ; if ( is_file ( $ sFile . '.php' ) ) { $ oView -> load ( $ sFile , $ aData ) ; } elseif ( ! empty ( $ this -> oSkinParent ) ) { $ sFile = $ this -> oSkinParent ...
Loads a view from the skin falls back tot he parent view if there is one .
233,956
public function _remap ( ) { $ method = $ this -> uri -> rsegment ( 3 ) ? $ this -> uri -> rsegment ( 3 ) : 'index' ; if ( method_exists ( $ this , $ method ) && substr ( $ method , 0 , 1 ) != '_' && $ this -> input -> get ( 'id' ) ) { $ this -> single ( $ this -> input -> get ( 'id' ) ) ; } elseif ( method_exists ( $ ...
Routes the URL
233,957
public function cmdGetReview ( ) { $ result = $ this -> getListReview ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableReview ( $ result ) ; $ this -> output ( ) ; }
Callback for review - get command
233,958
protected function setStatusReview ( $ status ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( ! isset ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( isset ( $ id ) && ( empty ( $ id ) || ! is_numeric ( $ id ) ) ) { $ this -> err...
Sets status for one or several reviews
233,959
public function cmdUpdateReview ( ) { $ 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' ) ) ; } $ this -...
Callback for review - update command
233,960
protected function addReview ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> review -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } }
Add a new review
233,961
protected function submitAddReview ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'review' ) ; $ this -> addReview ( ) ; }
Add a new review at once
233,962
protected function wizardAddReview ( ) { $ this -> validatePrompt ( 'user_id' , $ this -> text ( 'User' ) , 'review' ) ; $ this -> validatePrompt ( 'product_id' , $ this -> text ( 'Product' ) , 'review' ) ; $ this -> validatePrompt ( 'text' , $ this -> text ( 'Text' ) , 'review' ) ; $ this -> validatePrompt ( 'status' ...
Add a new review step by step
233,963
protected static function getTypeFinfoExt ( $ file ) { $ type = ( new \ finfo ( FILEINFO_MIME_TYPE ) ) -> file ( $ file ) ; if ( $ type ) { return $ type ; } else { return self :: getTypeFileExtList ( $ file ) ; } }
Gets the Mime Type using the Fileinfo Extension . If the Extension returns nothing the extension list is used .
233,964
protected static function getTypeFileExtList ( $ file ) { $ info = pathinfo ( strtolower ( $ file ) ) ; if ( isset ( self :: $ extensionToMime [ $ info [ 'extension' ] ] ) ) { return self :: $ extensionToMime [ $ info [ 'extension' ] ] ; } else { return self :: DEFAULT_MIME_TYPE ; } }
extracts the file extension and checks the extension array for the extension . If it is found it returns the MIME type . If not it returns the the default MIME type .
233,965
public static function getDefaultFileExtension ( $ mime ) { if ( empty ( self :: $ mimeToExtension ) ) { self :: $ mimeToExtension = array_flip ( self :: $ extensionToMime ) ; } return isset ( self :: $ mimeToExtension [ $ mime ] ) ? self :: $ mimeToExtension [ $ mime ] : '' ; }
returns a default extension by a given MIME type
233,966
protected function configure ( IConfig $ config ) { $ configuration = $ config -> get ( 'container' ) ; foreach ( $ configuration as $ name => $ group ) { switch ( $ name ) { case 'parameters' : $ this -> configureParameters ( $ group ) ; break ; case 'shared' : $ this -> configureShared ( $ group ) ; break ; case 'def...
Configure container .
233,967
public function cmdLineAuth ( ) { $ authUrl = $ this -> client -> createAuthUrl ( ) ; print "Please visit:\n$authUrl\n\n" ; print "Please enter the auth code:\n" ; $ authCode = trim ( fgets ( STDIN ) ) ; $ accessToken = $ this -> client -> authenticate ( $ authCode ) ; $ this -> client -> setAccessToken ( $ accessToken...
Auth over command line
233,968
public function make ( string $ title = null , string $ text = null ) : Notification { if ( self :: $ newNotificationCache === null ) { self :: $ newNotificationCache = new Notification ( ) ; } $ notification = clone ( self :: $ newNotificationCache ) ; if ( $ title !== null ) { $ notification -> title = $ title ; } if...
Constructs a new notification and returns it .
233,969
public function send ( string $ recipientID , Notification $ notification ) : void { $ app = App :: get ( ) ; if ( $ notification -> id === null ) { $ notification -> id = 'n' . uniqid ( ) . 'x' . base_convert ( rand ( 0 , 999999999 ) , 10 , 16 ) ; } if ( $ notification -> dateCreated === null ) { $ notification -> dat...
Sends a notification .
233,970
public function setOptsByArray ( $ options ) { foreach ( self :: $ _setableOptions as $ optionKey ) { if ( isset ( $ options [ $ optionKey ] ) ) { $ this -> $ optionKey = $ options [ $ optionKey ] ; } } return $ this ; }
Retrieve an option array and set valid keys as instance variables .
233,971
public function getScope ( ) { $ calledHere = $ this -> backTrace [ $ this -> backTraceOffset + 1 ] ; if ( isset ( $ calledHere [ 'class' ] ) ) { return ( object ) array ( 'type' => 'Method' , 'name' => $ calledHere [ 'class' ] . $ calledHere [ 'type' ] . $ calledHere [ 'function' ] ) ; } elseif ( isset ( $ calledHere ...
Get the current function or method scope according to the backtraceOffset
233,972
public function getID ( ) { if ( ! isset ( $ this -> ID ) ) { $ this -> ID = md5 ( $ this -> file . $ this -> line ) ; } return $ this -> ID ; }
Generate a hash from the file and line
233,973
public function setLineAndFile ( ) { if ( isset ( $ this -> backTrace [ $ this -> backTraceOffset ] ) ) { $ this -> ID = null ; $ calledHere = $ this -> backTrace [ $ this -> backTraceOffset ] ; if ( isset ( $ calledHere [ 'line' ] ) ) { $ this -> line = $ calledHere [ 'line' ] ; } if ( isset ( $ calledHere [ 'file' ] ...
Use the backTraceOffset and find the file and line in which the debug was called
233,974
public function put ( ) { X \ THEDEBUG :: i ( ) -> doCallback ( 'beforePut' , array ( & $ this ) ) ; $ this -> doCallback ( 'beforePut' , array ( & $ this ) ) ; switch ( strtolower ( $ this -> modus ) ) { case 'firephp' : $ this -> putFirePHP ( ) ; break ; case 'chromephp' : $ this -> putChromePHP ( ) ; break ; default...
fire the appropriate output method for the current modus
233,975
public function putChromePHP ( ) { $ ChromePHP = X \ THEDEBUG :: getChromePHP ( ) ; $ ChromePHP -> backtrace = $ this -> file . ': ' . $ this -> line ; $ this -> _improveVar ( ) ; $ args = array ( ) ; if ( ! empty ( $ this -> name ) ) { $ args [ ] = $ this -> name . ':' ; } $ args [ ] = $ this -> variable ; call_user_f...
Pass the debug to ChromePHP
233,976
public function putFirePHP ( ) { $ FirePHP = X \ THEDEBUG :: getFirePHP ( ) ; $ this -> _improveVar ( ) ; call_user_func_array ( array ( $ FirePHP , $ this -> _getMethod ( ) ) , array ( $ this -> variable , $ this -> name , array ( 'File' => $ this -> file , 'Line' => $ this -> line ) ) ) ; }
Pass the debug to firePHP
233,977
private function _improveVar ( ) { switch ( $ this -> variableType ) { case 'boolean' : $ this -> variable = '(boolean) ' . ( $ this -> variable ? 'true' : 'false' ) ; break ; case 'NULL' : $ this -> variable = '(null) NULL' ; break ; case 'string' : $ this -> variable = '"' . $ this -> variable . '"' ; default : break...
Make our variable more understandable .
233,978
private function _allocateArgs ( $ arguments ) { if ( empty ( $ arguments ) ) { return ; } $ this -> variable = $ arguments [ 0 ] ; $ this -> variableType = gettype ( $ this -> variable ) ; for ( $ i = 1 ; $ i < 3 ; $ i ++ ) { if ( ! isset ( $ arguments [ $ i ] ) ) { return ; } if ( is_string ( $ arguments [ $ i ] ) ) ...
Check which arguments were passed and name them .
233,979
protected function _dereferenceTokens ( $ value ) { if ( is_scalar ( $ value ) && ! is_string ( $ value ) ) { return $ value ; } try { $ value = $ this -> _normalizeString ( $ value ) ; } catch ( InvalidArgumentException $ e ) { return $ value ; } $ container = $ this -> _getContainer ( ) ; $ tokenStart = $ this -> _ge...
Replaces tokens with their values .
233,980
public static function translate ( \ Exception $ e ) : \ Exception { if ( $ e instanceof \ Doctrine \ DBAL \ Exception \ ConnectionException ) { return new \ Caridea \ Dao \ Exception \ Unreachable ( "System unreachable or connection timed out" , $ e -> getCode ( ) , $ e ) ; } elseif ( $ e instanceof \ Doctrine \ ORM \...
Translates a Doctrine exception .
233,981
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ drv = $ params -> getDriver ( ) ; $ clauses = $ this -> getClauses ( ) ; $ strs = array ( ) ; foreach ( $ clauses as $ clause ) $ strs [ ] = $ drv -> toSQL ( $ params , $ clause ) ; if ( count ( $ strs ) === 0 ) return ; return "ORDER BY " . implod...
Write a order clause as SQL query syntax
233,982
protected function retrieveBundleInfoFromGeneratedFile ( SplFileInfo $ generatedFile , Inflector $ inflector ) { if ( $ generatedFile -> getExtension ( ) !== 'php' ) { throw new UnsupportedFileForContentModifierException ( sprintf ( 'This content modifier requires to be used on a PHP file, "%s" is not a PHP file.' , $ ...
Retrieve information of the Bundle which contains the given file .
233,983
public function createInvitationTimelineEntries ( EntityPublishedEvent $ published_event ) : void { $ event = $ published_event -> getObject ( ) ; if ( ! $ event instanceof Event ) { return ; } $ author = $ this -> user_provider -> loadUserByUsername ( $ event -> getAuthor ( ) ) ; $ event_component = $ this -> action_m...
Create invited timeline events .
233,984
public function createScheduleTimelineEntry ( EntityPublishedEvent $ event ) : void { $ schedule = $ event -> getObject ( ) ; if ( ! $ schedule instanceof Schedule ) { return ; } $ author = $ this -> user_provider -> loadUserByUsername ( $ schedule -> getAuthor ( ) ) ; $ schedule_component = $ this -> action_manager ->...
Create the schedule timeline entry .
233,985
public function normalisePropertyName ( $ propertyName ) { if ( ( strlen ( $ propertyName ) > 1 ) && ( ( ord ( $ propertyName [ 1 ] ) >= ord ( "a" ) ) || is_numeric ( $ propertyName [ 1 ] ) ) ) { $ propertyName = strtolower ( $ propertyName [ 0 ] ) . substr ( $ propertyName , 1 ) ; } return $ propertyName ; }
Normalise the property name using the standard rules we might expect .
233,986
public function select ( $ columns = "*" ) : QueryBuilder { $ this -> _query [ ] = "SELECT" ; if ( is_array ( $ columns ) ) { $ select_columns = "" ; $ size = sizeof ( $ columns ) ; for ( $ i = 0 ; $ i < $ size ; $ i ++ ) { if ( $ i > 0 ) { $ select_columns .= ', ' ; } $ select_columns .= '`' . $ this -> sanitize ( ( s...
Begins the select query .
233,987
public function insert ( string $ table ) : QueryBuilder { $ this -> _query [ ] = "INSERT INTO" ; $ this -> _query [ ] = "`" . $ this -> sanitize ( $ table ) . "`" ; return $ this ; }
Begins the insert query
233,988
public function update ( string $ table ) : QueryBuilder { $ this -> _query [ ] = "UPDATE" ; $ this -> _query [ ] = "`" . $ this -> sanitize ( $ table ) . "`" ; return $ this ; }
Begins the update query
233,989
public function delete ( string $ table ) : QueryBuilder { $ this -> _query [ ] = "DELETE FROM" ; $ this -> _query [ ] = "`" . $ this -> sanitize ( $ table ) . "`" ; return $ this ; }
Begins the delete query
233,990
public function from ( string $ tables ) : QueryBuilder { $ this -> _query [ ] = "FROM" ; $ this -> _query [ ] = '`' . $ this -> sanitize ( $ tables ) . '`' ; return $ this ; }
Begins the FORM part of the query
233,991
public function where ( array $ condition ) : QueryBuilder { $ this -> _query [ ] = "WHERE" ; foreach ( $ condition as $ key => $ value ) { $ this -> _query [ ] = $ this -> parseTags ( [ $ key , $ value ] ) ; } return $ this ; }
Begins the WHERE statement of the query
233,992
public function order ( string $ column , string $ method = "DESC" ) : QueryBuilder { $ this -> _query [ ] = "ORDER BY" ; $ this -> _query [ ] = "`" . $ this -> sanitize ( $ column ) . "`" ; $ this -> _query [ ] = ( strtoupper ( $ method ) === "DESC" ) ? "DESC" : "ASC" ; return $ this ; }
Begins the ORDER BY part of the query
233,993
public function limit ( $ limit ) : QueryBuilder { $ this -> _query [ ] = "LIMIT" ; if ( is_array ( $ limit ) ) { $ this -> _query [ ] = $ this -> getQuoted ( $ limit [ 0 ] ) . "," ; $ this -> _query [ ] = $ this -> getQuoted ( $ limit [ 1 ] ) ; return $ this ; } $ this -> _query [ ] = $ this -> getQuoted ( $ limit ) ;...
Begins the LIMIT part of the query
233,994
public function offset ( int $ offset ) : QueryBuilder { $ this -> _query [ ] = "OFFSET" ; $ this -> _query [ ] = $ offset ; return $ this ; }
Begins the OFFSET part of the query
233,995
public function set ( array $ values ) : QueryBuilder { $ this -> _query [ ] = "SET" ; $ set = [ ] ; foreach ( $ values as $ key => $ val ) { $ set [ ] = $ this -> parseTags ( [ $ key , $ val ] ) ; } $ this -> _query [ ] = implode ( ", " , $ set ) ; return $ this ; }
Begins the SET part of the query
233,996
public function values ( array $ values ) : QueryBuilder { $ args = func_get_args ( ) ; $ columns = [ ] ; $ _values = [ ] ; foreach ( $ values as $ key => $ value ) { preg_match ( "/\(JSON\)\s*([\w]+)/i" , $ key , $ jsonTag ) ; if ( is_array ( $ value ) || is_object ( $ value ) ) { if ( isset ( $ jsonTag [ 0 ] ) ) { $ ...
Begins the VALUES part of the query
233,997
public function sanitize ( string $ input ) : string { $ input = $ this -> _connection -> getConnection ( ) -> quote ( $ input ) ; return substr ( $ input , 1 , - 1 ) ; }
Sanitizes the input .
233,998
public function write ( Command $ command , Option $ option = NULL ) { $ output = PHP_EOL ; $ output .= '-----------------------------------------------------' . PHP_EOL ; $ output .= $ command -> name . ' ' . $ command -> version . PHP_EOL ; $ output .= '-----------------------------------------------------' . PHP_EOL...
This method writes the help to the console .
233,999
private function _getUsageExample ( Command $ command ) { $ name = strtolower ( str_replace ( 'Command' , '' , get_class ( $ command ) ) ) ; if ( FALSE !== strstr ( $ name , "\\" ) ) { $ pts = explode ( "\\" , $ name ) ; $ name = $ pts [ count ( $ pts ) - 1 ] ; } $ usage = './' . $ name . ' --' . $ command -> options [...
Prepares the command usage example .