idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
29,600
function addUser ( $ username , $ password , $ additional = "" ) { if ( function_exists ( $ this -> options [ 'cryptType' ] ) ) { $ cryptFunction = $ this -> options [ 'cryptType' ] ; } else { $ cryptFunction = 'md5' ; } $ additional_key = '' ; $ additional_value = '' ; if ( is_array ( $ additional ) ) { foreach ( $ additional as $ key => $ value ) { $ additional_key .= ', ' . $ key ; $ additional_value .= ", '" . $ value . "'" ; } } $ query = sprintf ( "INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)" , $ this -> options [ 'table' ] , $ this -> options [ 'usernamecol' ] , $ this -> options [ 'passwordcol' ] , $ additional_key , $ username , $ cryptFunction ( $ password ) , $ additional_value ) ; $ res = $ this -> query ( $ query ) ; if ( DB :: isError ( $ res ) ) { return PEAR :: raiseError ( $ res -> getMessage ( ) , $ res -> getCode ( ) ) ; } else { return true ; } }
Add user to the storage container
29,601
function removeUser ( $ username ) { $ query = sprintf ( "DELETE FROM %s WHERE %s = '%s'" , $ this -> options [ 'table' ] , $ this -> options [ 'usernamecol' ] , $ username ) ; $ res = $ this -> query ( $ query ) ; if ( DB :: isError ( $ res ) ) { return PEAR :: raiseError ( $ res -> getMessage ( ) , $ res -> getCode ( ) ) ; } else { return true ; } }
Remove user from the storage container
29,602
public function send ( SimpleHeaders $ headers = null , $ die_after = true ) { if ( $ headers === null ) { $ headers = $ this -> getHttpHeaders ( ) ; } ob_end_clean ( ) ; try { $ data = $ this -> getData ( ) ; } catch ( \ Exception $ e ) { throw $ e ; } $ headers -> outputHeaders ( $ replace = true ) ; echo $ data ; if ( $ die_after ) { die ( ) ; } }
Send the store data via http .
29,603
public function FullName ( ) { $ fullName = $ this -> Name ( ) ; if ( $ this -> prefix ) $ fullName = $ this -> escaper -> EscapeIdentifier ( $ this -> prefix ) . '.' . $ fullName ; return $ fullName ; }
SQL escaped name with prefix if given .
29,604
public static function handle ( Exception $ exception ) { $ debug = ( true === defined ( 'DOOZR_DEBUGGING' ) ) ? DOOZR_DEBUGGING : true ; if ( $ exception -> getCode ( ) < 100 || $ exception -> getCode ( ) > 599 ) { $ statusCode = 500 ; } else { $ statusCode = $ exception -> getCode ( ) ; } if ( true === $ debug ) { $ message = $ exception -> getMessage ( ) ; $ code = $ exception -> getCode ( ) ; } else { $ message = constant ( 'Doozr_Http::REASONPHRASE_' . $ statusCode ) ; $ code = $ statusCode ; } if ( Doozr_Kernel :: RUNTIME_ENVIRONMENT_WEB === DOOZR_RUNTIME_ENVIRONMENT ) { self :: handleHtml ( $ statusCode , $ code , $ message , $ exception -> getFile ( ) , $ exception -> getLine ( ) ) ; } else { self :: handleText ( $ code , $ message , $ exception -> getFile ( ) , $ exception -> getLine ( ) ) ; } }
Replacement for PHP s default internal exception handler . All Exceptions are forwarded to this method - we decide here what to do with it . We need this hook to stay informed about Doozr s state and to pipe the Exceptions to attached Logger - Subsystem .
29,605
protected static function handleHtml ( $ statusCode , $ code , $ message , $ file , $ line ) { $ file = '' ; $ line = '' ; if ( false === headers_sent ( $ file , $ line ) ) { header ( 'HTTP/' . Doozr_Http :: VERSION_1_1 . ' ' . $ statusCode . ' ' . $ message ) ; } echo sprintf ( '<h1>%s %s</h1>' , $ code , $ message ) ; }
Output of exception for HTML ready environments .
29,606
protected static function handleText ( $ code , $ message , $ file , $ line ) { echo sprintf ( '%s %s %s %s' , $ code , $ message , $ file , $ line ) ; }
Output of exception for text - only environments .
29,607
protected function replaceJquery ( array & $ data , Controller $ controller ) { if ( ! $ controller -> isCurrentTheme ( 'mobile' ) || empty ( $ data [ '_js_top' ] ) || $ controller -> isInternalRoute ( ) ) { return false ; } $ jquery = $ this -> library -> get ( 'jquery' ) ; foreach ( $ data [ '_js_top' ] as $ key => $ asset ) { if ( dirname ( $ asset [ 'file' ] ) === $ jquery [ 'basepath' ] ) { $ asset [ 'file' ] = __DIR__ . '/js/jquery.js' ; $ asset [ 'key' ] = $ asset [ 'asset' ] = gplcart_path_normalize ( gplcart_path_relative ( $ asset [ 'file' ] ) ) ; $ data [ '_js_top' ] [ $ asset [ 'key' ] ] = $ asset ; unset ( $ data [ '_js_top' ] [ $ key ] ) ; return true ; } } return false ; }
Downgrade jQuery Jquery Mobile 1 . 4 . 5 does not work correctly with Jquery 2 . 2 . 4
29,608
public function read ( $ key = null ) { try { $ value = $ this -> subject -> read ( $ key ) ; } catch ( Doozr_Base_Service_Exception $ exception ) { throw new Doozr_Form_Service_Exception ( sprintf ( 'The key "%s" does not exist in store.' , $ key ) , null , $ exception ) ; } return $ value ; }
Reads an entry from store .
29,609
public function addParam ( $ name , $ value ) { if ( ! empty ( $ name ) && ! empty ( $ value ) ) { $ this -> params [ stripslashes ( trim ( $ name ) ) ] = stripslashes ( trim ( $ value ) ) ; } }
Add a query parameter to the cURL request .
29,610
public function setAuth ( $ username , $ password ) { if ( ! empty ( $ username ) && ! empty ( $ password ) ) { $ this -> username = stripslashes ( trim ( $ username ) ) ; $ this -> password = stripslashes ( trim ( $ password ) ) ; } }
Set authentication to the cURL request .
29,611
public function setProxy ( $ host , $ port , $ type = CURLPROXY_HTTP ) { if ( ! empty ( $ host ) && ! empty ( $ port ) ) { $ this -> proxyHost = stripslashes ( trim ( $ host ) ) ; $ this -> proxyPort = intval ( $ port ) ; $ this -> proxyType = intval ( $ type ) ; } }
Set a HTTP proxy to tunnel requests through .
29,612
public function setProxyAuth ( $ username , $ password , $ authType = CURLAUTH_BASIC ) { if ( ! empty ( $ username ) && ! empty ( $ password ) ) { $ this -> proxyUsername = stripslashes ( trim ( $ username ) ) ; $ this -> proxyPassword = stripslashes ( trim ( $ password ) ) ; $ this -> proxyAuthType = intval ( $ authType ) ; } }
Set a HTTP proxy authentication .
29,613
public function setTimeout ( $ timeout ) { $ timeout = intval ( $ timeout ) ; if ( ! empty ( $ timeout ) ) { $ this -> timeout = $ timeout ; } }
Set the maximum number of seconds to allow cURL functions to execute .
29,614
public function setMaxRedirect ( $ maxRedirect ) { $ maxRedirect = intval ( $ maxRedirect ) ; if ( ! empty ( $ maxRedirect ) ) { $ this -> maxRedirect = $ maxRedirect ; } }
Set the maximum redirects allowed .
29,615
protected function getRequestClassForMethod ( string $ method ) : string { if ( in_array ( $ method , [ 'login' , 'logout' ] ) ) { return sprintf ( 'DMT\\WebservicesNl\\Client\\Request\\%sRequest' , ucfirst ( $ method ) ) ; } foreach ( $ this -> getInstalledServices ( ) as $ service ) { if ( stripos ( $ method , $ service ) !== 0 ) { continue ; } $ requestClass = sprintf ( 'DMT\\WebservicesNl\\%s\\Request\\%sRequest' , $ service , substr ( $ method , strlen ( $ service ) ) ) ; if ( class_exists ( $ requestClass ) ) { return $ requestClass ; } } throw new \ BadMethodCallException ( "Function `$method` is not a valid method for this service" ) ; }
Get the request that corresponds to the service method .
29,616
private function applyFilterToTd ( $ value , array $ fields ) { return [ 'template' => $ fields [ 'template' ] , 'style' => $ fields [ 'style' ] , 'class' => $ fields [ 'class' ] , 'format' => $ fields [ 'format' ] , 'value' => $ this -> getValueFrom ( $ fields [ 'format' ] , $ fields [ 'relation' ] , $ value ) ] ; }
Converte dados TD para uso no template table data
29,617
public function encrypt ( $ data , $ key = null , $ encode = true ) { if ( null !== $ key ) { $ this -> getContainer ( ) -> setKey ( $ key ) ; } $ data = $ this -> getContainer ( ) -> encrypt ( $ data ) ; if ( true === $ encode ) { $ data = $ this -> encode ( $ data ) ; } return $ data ; }
This method is intend to encrypt a given string with a given key or default key .
29,618
public function decrypt ( $ data , $ key = null , $ decode = true ) { if ( null !== $ key ) { $ this -> getContainer ( ) -> setKey ( $ key ) ; } if ( true === $ decode ) { $ data = $ this -> decode ( $ data ) ; } $ data = $ this -> getContainer ( ) -> decrypt ( $ data ) ; return $ data ; }
Decrypts an encrypted string .
29,619
protected function setCipher ( $ cipher ) { if ( false === in_array ( $ cipher , $ this -> getCipherAvailable ( ) ) ) { throw new Doozr_Crypt_Service_Exception ( sprintf ( 'Cipher "%s" not supported. Choose from: "%s".' , $ cipher , var_export ( $ this -> getCipherAvailable ( ) , true ) ) ) ; } if ( $ cipher !== $ this -> getCipher ( ) ) { $ this -> container ( $ this -> containerFactory ( $ cipher ) ) -> cipher ; self :: setRealObject ( $ this -> getContainer ( ) ) ; } }
Setter for cipher .
29,620
protected function setEncoding ( $ encoding ) { if ( false === in_array ( $ encoding , $ this -> getEncodingAvailable ( ) ) ) { throw new Doozr_Crypt_Service_Exception ( sprintf ( 'Encoding "%s" not supported. Choose from: "%s".' , $ encoding , var_export ( $ this -> getEncodingAvailable ( ) , true ) ) ) ; } $ this -> encoding = $ encoding ; }
Setter for encoding .
29,621
protected function containerFactory ( $ container , array $ containerOptions = [ ] ) { $ container = ucfirst ( strtolower ( $ container ) ) ; $ className = __CLASS__ . '_Container_' . $ container ; $ file = $ this -> getRegistry ( ) -> getPath ( ) -> get ( 'service' ) . str_replace ( '_' , DIRECTORY_SEPARATOR , $ className ) . '.php' ; if ( false === file_exists ( $ file ) ) { throw new Doozr_Crypt_Service_Exception ( sprintf ( 'Container "%s" is not loadable. File "%s" does not exist!' , $ container , $ file ) ) ; } include_once $ file ; return self :: instantiate ( $ className , $ containerOptions ) ; }
This method is intend to act as factory for container .
29,622
public function getHomeTemplate ( ) { $ templateName = 'home' ; if ( ! $ this -> hasTemplate ( $ templateName ) ) { $ templates = array_keys ( $ this -> templates ) ; sort ( $ templates ) ; $ templateName = $ templates [ 0 ] ; } return $ this -> templates [ $ templateName ] ; }
Returns the home template or the first one when the theme does not contains an home template
29,623
protected function hasComposerJson ( $ projectName ) { return is_dir ( $ this -> cwd . '/' . $ this -> projectsDir . '/' . $ projectName ) && file_exists ( $ this -> cwd . '/' . $ this -> projectsDir . '/' . $ projectName . '/composer.json' ) ; }
Test if project has composer . json file .
29,624
protected function getProjectPackageName ( $ projectName , $ repositoryUrl ) { $ packageName = null ; if ( $ this -> hasComposerJson ( $ projectName ) ) { $ packageName = $ this -> getPackageNameByComposerJson ( $ projectName ) ; } return $ packageName ? $ packageName : $ this -> getPackageNameByRepositoryUrl ( $ repositoryUrl ) ; }
Get project name by repository url .
29,625
public function error ( $ error , $ tokens = null ) { switch ( $ error ) { case '&require-package-or-repository' : $ message = 'Repository url or package name required.' ; break ; case '&require-package-or-project' : $ message = 'Package name or project name required, type \'php producer --help ${command}\'.' ; break ; case '&help-not-found' : $ message = 'Not found help for \'${command}\' command.' ; break ; case '&file-not-found' : $ message = 'File not found \'${file}\' during \'${command}\'.' ; break ; case '&json-syntax-error' : $ message = '[JSON] Syntax error on \'${file}\' during \'${command}\'.' ; break ; case '&project-not-found' : $ message = 'Project into directory \'' . $ this -> projectsDir . '/${project}\' not found.' ; break ; default : $ message = $ error ; } if ( is_array ( $ tokens ) && $ tokens ) { foreach ( $ tokens as $ token => $ value ) { $ message = str_replace ( '${' . $ token . '}' , $ value , $ message ) ; } } echo "> Producer: {$message}\n" ; return $ error ; }
Return error message .
29,626
protected function parseArgs ( $ args ) { if ( ! is_array ( $ args ) ) { return $ args ; } $ this -> silent = in_array ( '--silent' , $ args ) ; if ( $ this -> silent ) { $ args = array_values ( array_diff ( $ args , [ '--silent' ] ) ) ; } return $ args ; }
Get an info line .
29,627
protected function exec ( $ cmd , $ task , $ args = null ) { $ script = __DIR__ . '/../../exec/' . $ cmd . '/' . $ task . '.sh' ; if ( ! file_exists ( $ script ) ) { die ( 'Producer > INTERNAL ERROR MISSING SCRIPT' ) ; } $ params = '' ; if ( $ args && count ( $ args ) > 0 ) { foreach ( $ args as & $ value ) { $ value = $ this -> escapeParam ( $ value ) ; } $ params = implode ( ' ' , $ args ) ; } $ rawCommand = $ script . ' ' . $ this -> escapeParam ( $ this -> cwd ) . ' ' . $ this -> escapeParam ( $ this -> projectsDir ) . ' ' . $ params ; $ output = shell_exec ( $ rawCommand ) ; if ( ! $ this -> silent ) { echo $ output ; } }
Exec specific script .
29,628
public function getAllSubordinates ( $ guid = null , $ limit = CAKE_LDAP_SYNC_AD_LIMIT ) { $ result = [ ] ; $ conditions = [ ] ; $ contain = [ ] ; if ( ! empty ( $ guid ) ) { $ conditions [ $ this -> Employee -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_OBJECT_GUID ] = $ guid ; $ contain [ ] = 'Employee' ; } $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.parent_id' , $ this -> alias . '.lft' , $ this -> alias . '.rght' , $ this -> alias . '.name' , ] ; $ order = [ $ this -> alias . '.id' => 'asc' , ] ; $ result = $ this -> find ( 'all' , compact ( 'fields' , 'conditions' , 'order' , 'limit' , 'contain' ) ) ; return $ result ; }
Return array information of all subordinate employees
29,629
protected function _changeParentInfo ( $ data = null ) { if ( empty ( $ data ) ) { return false ; } $ result = true ; foreach ( $ data as $ dataItem ) { if ( ! isset ( $ dataItem [ $ this -> alias ] [ 'id' ] ) && empty ( $ dataItem [ $ this -> alias ] [ 'id' ] ) ) { $ result = false ; continue ; } $ this -> clear ( ) ; $ this -> recursive = - 1 ; $ savedInfo = $ this -> read ( null , $ dataItem [ $ this -> alias ] [ 'id' ] ) ; $ savedInfo [ $ this -> alias ] = $ dataItem [ $ this -> alias ] + $ savedInfo [ $ this -> alias ] ; if ( ! $ this -> save ( $ savedInfo ) ) { $ result = false ; } } return $ result ; }
Change parent of subordinate employees
29,630
protected function _getConditionsForEmployeeTreeInfo ( $ id = null , $ includeRoot = true , $ includeBlocked = false ) { $ result = [ ] ; if ( ! $ includeBlocked && $ this -> Employee -> hasField ( 'block' ) ) { $ result [ $ this -> Employee -> alias . '.block' ] = false ; } if ( empty ( $ id ) ) { return $ result ; } $ conditions = [ $ this -> alias . '.id' => $ id ] ; $ fields = [ $ this -> alias . '.parent_id' , $ this -> alias . '.lft' , $ this -> alias . '.rght' , ] ; $ this -> recursive = - 1 ; $ subordinateTreeInfo = $ this -> find ( 'first' , compact ( 'conditions' , 'fields' ) ) ; if ( empty ( $ subordinateTreeInfo ) ) { return false ; } $ conditionItem = '' ; if ( $ includeRoot ) { $ conditionItem = '=' ; } $ result [ $ this -> alias . '.lft >' . $ conditionItem ] = $ subordinateTreeInfo [ $ this -> alias ] [ 'lft' ] ; $ result [ $ this -> alias . '.rght <' . $ conditionItem ] = $ subordinateTreeInfo [ $ this -> alias ] [ 'rght' ] ; return $ result ; }
Return condition for build tree of subordinate employees
29,631
public function getListTreeEmployee ( $ id = null , $ includeRoot = true , $ includeBlocked = false ) { $ cachePath = 'employees_tree_list_' . md5 ( serialize ( func_get_args ( ) ) ) ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES ) ; if ( $ cached !== false ) { return $ cached ; } $ result = [ ] ; $ conditions = $ this -> _getConditionsForEmployeeTreeInfo ( $ id , $ includeRoot , $ includeBlocked ) ; if ( $ conditions === false ) { return $ result ; } $ keyPath = '{n}.' . $ this -> Employee -> alias . '.id' ; $ valuePath = '{n}.' . $ this -> Employee -> alias . '.' . $ this -> Employee -> displayField ; $ spacer = '--' ; $ recursive = 0 ; $ result = $ this -> generateTreeList ( $ conditions , $ keyPath , $ valuePath , $ spacer , $ recursive ) ; Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES ) ; return $ result ; }
Return tree of subordinate employees as list
29,632
public function getArrayTreeEmployee ( $ id = null , $ includeRoot = true , $ includeBlocked = false , $ includeFields = null ) { $ cachePath = 'employees_tree_arr_' . md5 ( serialize ( func_get_args ( ) ) ) ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES ) ; if ( $ cached !== false ) { return $ cached ; } $ result = [ ] ; $ conditions = $ this -> _getConditionsForEmployeeTreeInfo ( $ id , $ includeRoot , $ includeBlocked ) ; if ( $ conditions === false ) { return $ result ; } if ( empty ( $ includeFields ) ) { $ includeFields = [ ] ; } elseif ( ! is_array ( $ includeFields ) ) { $ includeFields = [ $ includeFields ] ; } $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.parent_id' , $ this -> alias . '.lft' , $ this -> alias . '.rght' , $ this -> Employee -> alias . '.id' , $ this -> Employee -> alias . '.' . $ this -> Employee -> displayField ] ; if ( $ this -> Employee -> hasField ( CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ) ) { $ fields [ ] = $ this -> Employee -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ; } if ( $ includeBlocked && $ this -> Employee -> hasField ( 'block' ) ) { $ fields [ ] = $ this -> Employee -> alias . '.block' ; } if ( ! empty ( $ includeFields ) ) { $ fields = array_values ( array_unique ( array_merge ( $ fields , $ includeFields ) ) ) ; } $ order = [ $ this -> alias . '.lft' => 'asc' ] ; $ contain = [ 'Employee' ] ; $ data = $ this -> find ( 'threaded' , compact ( 'conditions' , 'fields' , 'order' , 'contain' ) ) ; if ( $ data !== false ) { $ result = $ data ; } Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_TREE_EMPLOYEES ) ; return $ result ; }
Return tree of subordinate employees
29,633
public function reorderEmployeeTree ( $ verify = true ) { set_time_limit ( REORDER_TREE_EMPLOYEE_TIME_LIMIT ) ; if ( $ verify && ( $ this -> verify ( ) !== true ) ) { return false ; } $ dataSource = $ this -> getDataSource ( ) ; $ dataSource -> begin ( ) ; $ result = $ this -> reorder ( [ 'verify' => false ] ) ; if ( $ result ) { $ dataSource -> commit ( ) ; $ event = new CakeEvent ( 'Model.afterUpdateTree' , $ this ) ; $ this -> getEventManager ( ) -> dispatch ( $ event ) ; } else { $ dataSource -> rollback ( ) ; } return $ result ; }
Reorder tree of subordinate employees .
29,634
public function recoverEmployeeTree ( $ verify = true ) { set_time_limit ( RECOVER_TREE_EMPLOYEE_TIME_LIMIT ) ; if ( $ verify && ( $ this -> verify ( ) === true ) ) { return true ; } $ dataSource = $ this -> getDataSource ( ) ; $ dataSource -> begin ( ) ; $ result = $ this -> recover ( 'parent' ) ; if ( $ result ) { $ dataSource -> commit ( ) ; $ event = new CakeEvent ( 'Model.afterUpdateTree' , $ this ) ; $ this -> getEventManager ( ) -> dispatch ( $ event ) ; } else { $ dataSource -> rollback ( ) ; } return $ result ; }
Recover a corrupted tree
29,635
public function setData ( $ data = null , $ render = true ) { $ this -> data = $ data ; $ result = null ; if ( true === $ render ) { $ specificViewRenderer = '__render' . ucfirst ( $ this -> getRoute ( ) -> getPresenter ( ) ) ; if ( method_exists ( $ this , $ specificViewRenderer ) ) { $ result = $ this -> { $ specificViewRenderer } ( $ this -> data ) ; } elseif ( method_exists ( $ this , '__render' ) ) { $ result = $ this -> { '__render' } ( $ this -> data ) ; } } return $ result ; }
This method is the setter for the data to use in the action method .
29,636
protected function translateToTemplateFilename ( ) { $ presenter = ucfirst ( $ this -> getRoute ( ) -> getPresenter ( ) ) ; $ action = ucfirst ( $ this -> getRoute ( ) -> getAction ( ) ) ; return $ presenter . DIRECTORY_SEPARATOR . $ action ; }
This method is intend to encrypt the current object and action pair to a filename .
29,637
protected function generateFingerprint ( ) { $ fingerprint = '' ; $ headers = getallheaders ( ) ; $ arguments = func_get_args ( ) ; $ arguments [ ] = $ _SERVER [ 'REMOTE_ADDR' ] ; $ arguments [ ] = ( isset ( $ headers [ 'USER_AGENT' ] ) ) ? $ headers [ 'USER_AGENT' ] : null ; $ arguments [ ] = ( isset ( $ headers [ 'ACCEPT' ] ) ) ? $ headers [ 'ACCEPT' ] : null ; $ arguments [ ] = ( isset ( $ headers [ 'ACCEPT_LANGUAGE' ] ) ) ? $ headers [ 'ACCEPT_LANGUAGE' ] : null ; $ arguments [ ] = ( isset ( $ headers [ 'ACCEPT_ENCODING' ] ) ) ? $ headers [ 'ACCEPT_ENCODING' ] : null ; $ arguments [ ] = $ this -> translateToTemplateFilename ( ) ; foreach ( $ arguments as $ argument ) { $ fingerprint .= serialize ( $ argument ) ; } return md5 ( $ fingerprint ) ; }
Generates and returns fingerprint for the current instance & request .
29,638
public function getGateways ( ) { $ gateways = array ( ) ; foreach ( $ this -> getGatewayNamespaces ( ) as $ namespace ) { if ( strpos ( $ namespace , 'Omnipay' ) !== 0 ) { continue ; } $ matches = array ( ) ; preg_match ( '/Omnipay\\\(.+?)\\\/' , $ namespace , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { $ gateways [ ] = $ matches [ 1 ] ; } } return $ gateways ; }
Returns an array of gateways extracted from registered namespaces
29,639
public function getGatewayInstance ( $ gateway = null ) { require __DIR__ . '/vendor/autoload.php' ; foreach ( $ this -> getGateways ( ) as $ id ) { $ class = \ Omnipay \ Common \ Helper :: getGatewayClassName ( $ id ) ; if ( class_exists ( $ class ) ) { \ Omnipay \ Omnipay :: register ( $ id ) ; } } $ instances = array ( ) ; foreach ( \ Omnipay \ Omnipay :: find ( ) as $ id ) { $ instances [ $ id ] = \ Omnipay \ Omnipay :: create ( $ id ) ; } if ( isset ( $ gateway ) ) { return empty ( $ instances [ $ gateway ] ) ? null : $ instances [ $ gateway ] ; } return $ instances ; }
Returns an array of registered gateway instances
29,640
public static function getCredential ( $ user_id ) { $ sql = new Pluf_SQL ( 'login=%s' , array ( $ user_id ) ) ; return Pluf :: factory ( 'User_Account' ) -> getOne ( $ sql -> gen ( ) ) ; }
Returns credential data of given user if exist
29,641
static function ReplaceArgsUsing ( $ placeholder , Interfaces \ IRealizer $ realizer = null , array $ args = array ( ) ) { return self :: RetrieveRealizer ( $ realizer ) -> RealizeArgs ( $ placeholder , $ args ) ; }
Replaces the placeholder using the given realizer and arguments
29,642
static function HasReplacement ( $ placeholder , Interfaces \ IRealizer $ realizer = null ) { return self :: RetrieveRealizer ( $ realizer ) -> HasReplacement ( $ placeholder ) ; }
Checks if the placeholder has replacement text defined
29,643
static function ReplaceUsing ( $ placeholder , Interfaces \ IRealizer $ realizer = null ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; if ( count ( $ args ) >= 2 ) { array_shift ( $ args ) ; } return self :: ReplaceArgsUsing ( $ placeholder , $ realizer , $ args ) ; }
Replaces the placeholder using a given realizer and optional arguments
29,644
static function Replace ( $ placeholder ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; return self :: ReplaceArgsUsing ( $ placeholder , null , $ args ) ; }
Replaces the placeholder using the default wording realizer
29,645
public function _getRequiredParamsCount ( $ paramsDef ) { $ result = 0 ; if ( $ paramsDef ) { $ result = 1 ; $ commas = substr_count ( $ paramsDef , ',' ) ; $ equals = substr_count ( $ paramsDef , '=' ) ; $ result += ( $ commas - $ equals ) ; } return $ result ; }
Get count of the required parameters .
29,646
public function _processClassDocBlock ( $ block ) { $ result = [ ] ; if ( $ block instanceof \ Zend \ Code \ Reflection \ DocBlockReflection ) { $ docBlockLines = $ block -> getContents ( ) ; $ docBlockLines = explode ( "\n" , $ docBlockLines ) ; foreach ( $ docBlockLines as $ line ) { $ methodData = $ this -> _processClassDocLine ( $ line ) ; if ( $ methodData ) { $ name = $ methodData -> getName ( ) ; $ result [ $ name ] = $ methodData ; } } } return $ result ; }
Analyze class documentation block and extract annotated methods .
29,647
public function _processClassDocLine ( $ line ) { $ result = null ; if ( preg_match ( self :: PATTERN_METHOD , $ line , $ matches ) ) { $ isRequired = true ; $ returnType = $ matches [ 1 ] ; $ key = '|null' ; $ length = strlen ( $ key ) ; if ( substr ( $ returnType , - $ length , $ length ) == $ key ) { $ returnType = str_replace ( $ key , '' , $ returnType ) ; $ isRequired = false ; } $ methodName = lcfirst ( $ matches [ 2 ] ) ; $ paramsCount = $ this -> _getRequiredParamsCount ( $ matches [ 3 ] ) ; $ desc = $ matches [ 4 ] ?? '' ; $ desc = trim ( $ desc ) ; $ result = new \ Praxigento \ Core \ App \ Reflection \ Data \ Method ( ) ; $ result -> setName ( $ methodName ) ; $ result -> setIsRequired ( $ isRequired ) ; $ result -> setType ( $ returnType ) ; $ result -> setDescription ( $ desc ) ; $ result -> setParameterCount ( $ paramsCount ) ; } return $ result ; }
Analyze class level documentation line and extract method data .
29,648
protected function _getArgsListErrors ( $ args , $ spec ) { $ errors = [ ] ; foreach ( $ spec as $ _idx => $ _param ) { if ( ! ( $ _param instanceof ReflectionParameter ) ) { throw $ this -> _createOutOfRangeException ( $ this -> __ ( 'Parameter #%1$d of the specification is invalid' , [ $ _idx ] ) , null , null , $ _param ) ; } $ pos = $ _param -> getPosition ( ) ; $ isArgPresent = key_exists ( $ pos , $ args ) ; $ isNullable = $ _param -> allowsNull ( ) ; if ( ! $ _param -> isOptional ( ) && ! $ isArgPresent ) { $ errors [ ] = $ this -> __ ( 'Argument #%1$s is required' , [ $ pos ] ) ; continue ; } $ arg = $ isArgPresent ? $ args [ $ pos ] : null ; $ isNullOk = $ isNullable && $ isArgPresent && is_null ( $ arg ) ; if ( $ isNullOk ) { continue ; } if ( method_exists ( $ _param , 'hasType' ) && $ _param -> hasType ( ) ) { try { $ error = $ this -> _getValueTypeError ( $ arg , $ _param -> getType ( ) ) ; } catch ( InvalidArgumentException $ e ) { throw $ this -> _createOutOfRangeException ( $ this -> __ ( 'Problem validating type of argument #%1$d against spec criterion #%1$d' , [ $ pos , $ _idx ] ) , null , $ e , $ _param ) ; } if ( ! is_null ( $ error ) ) { $ errors [ ] = $ this -> __ ( 'Argument #%1$s is invalid: %2$s' , [ $ pos , $ this -> _normalizeString ( $ error ) ] ) ; } } } return $ errors ; }
Produces a list of reasons why an args list is invalid against a spec .
29,649
public function getEntry ( ) { return $ this -> getCachedProperty ( 'entry' , function ( ) { return $ this -> getExtensions ( ) -> parseElement ( $ this , $ this -> getDomDocument ( ) -> documentElement ) ; } ) ; }
Return entry .
29,650
function Realize ( $ placeholder ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; return $ this -> RealizeArgs ( $ placeholder , $ args ) ; }
Realizes a wording placeholder
29,651
function RealizeArgs ( $ placeholder , array $ args = array ( ) ) { $ result = $ this -> GetReplacement ( $ placeholder ) ; return System \ Str :: FormatArgs ( $ result , $ args ) ; }
Realizes a wording placeholder with formatting arguments as array
29,652
protected function respondRelatedPhones ( $ phoneableId , $ objectType ) { $ phones = Phone :: where ( 'phoneable_id' , $ phoneableId ) -> orderBy ( 'created_at' , 'desc' ) -> get ( ) ; return fractal ( $ phones , new PhoneTransformer ( ) ) -> withResourceName ( "{$objectType}Phone" ) -> respond ( ) ; }
Produce a list of Phones related to a selected object
29,653
private function hasError ( $ json ) : ? string { if ( ! isset ( $ json [ 'table_name' ] ) ) { return "missing [table_name] property in JSON payload" ; } if ( ! isset ( $ json [ 'group_id' ] ) ) { return "missing [group_id] property in JSON payload" ; } if ( ! isset ( $ json [ 'criteria' ] ) ) { return "missing [criteria] property in JSON payload" ; } if ( ! isset ( $ json [ 'criteria' ] [ 'version' ] ) || $ json [ 'criteria' ] [ 'version' ] !== '1' ) { return "missing or invalid [criteria.version] property in JSON payload" ; } return null ; }
hasError returns string error message if json is not valid or null otherwise .
29,654
public static function readAttributes ( $ object ) { if ( ! is_object ( $ object ) ) { throw self :: getInvalidArgumentException ( 1 , 'object' ) ; } $ reflector = new ReflectionObject ( $ object ) ; $ result = [ ] ; foreach ( $ reflector -> getProperties ( ) as $ attribute ) { $ attribute -> setAccessible ( true ) ; $ result [ $ attribute -> getName ( ) ] = $ attribute -> getValue ( $ object ) ; } return $ result ; }
Returns an associative array of all attributes of an object including those declared as protected or private .
29,655
public static function getInvalidArgumentException ( $ argument , $ type ) { $ stack = debug_backtrace ( false ) ; return new InvalidArgumentException ( sprintf ( 'Argument #%d of %s::%s() is no %s' , $ argument , $ stack [ 1 ] [ 'class' ] , $ stack [ 1 ] [ 'function' ] , $ type ) ) ; }
Only used internally .
29,656
public function getHandler ( $ name ) { if ( ! isset ( $ this -> instances [ $ name ] ) ) { $ handlerClass = __NAMESPACE__ . '\\' . $ name ; $ this -> instances [ $ name ] = new $ handlerClass ( $ this -> builder ) ; } return $ this -> instances [ $ name ] ; }
Returns the handler of the specified name .
29,657
public function getHandlerForEvent ( AbstractEvent $ event ) { $ parts = explode ( '\\' , get_class ( $ event ) ) ; $ class = end ( $ parts ) ; return $ this -> getHandler ( $ class ) ; }
Returns the event handler responsible for the specified event .
29,658
public function getAllControlHandlers ( ) { $ result = array ( ) ; foreach ( $ this -> instances as $ instance ) { if ( $ instance instanceof ControlHandler ) { $ result [ ] = $ instance ; } } return $ result ; }
Returns all ControlHandler instances currently known to the factory .
29,659
public function login ( ) { $ externalAuth = false ; if ( isset ( $ this -> Auth -> authenticate [ 'CakeLdap.Ldap' ] [ 'externalAuth' ] ) ) { $ externalAuth = $ this -> Auth -> authenticate [ 'CakeLdap.Ldap' ] [ 'externalAuth' ] ; } if ( $ this -> request -> is ( 'post' ) || ( $ externalAuth === true ) ) { if ( $ this -> Auth -> login ( ) ) { return $ this -> redirect ( $ this -> Auth -> redirectUrl ( ) ) ; } $ this -> Flash -> error ( __d ( 'cake_ldap' , 'Invalid username or password, try again' ) ) ; } $ this -> set ( 'pageTitle' , __d ( 'cake_ldap' , 'Login' ) ) ; }
Action login . Used to login user .
29,660
public static function get ( Composer $ composer ) : ? ProjectTypeInterface { $ rootDir = dirname ( $ composer -> getConfig ( ) -> getConfigSource ( ) -> getName ( ) ) ; $ classes = static :: getClasses ( $ composer ) ; $ composerProjectType = $ composer -> getPackage ( ) -> getExtra ( ) [ 'rikudou' ] [ 'installer' ] [ 'project-type' ] ?? null ; if ( $ composerProjectType && isset ( $ classes [ $ composerProjectType ] ) ) { $ class = $ classes [ $ composerProjectType ] ; return new $ class ; } foreach ( $ classes as $ class ) { $ instance = new $ class ; foreach ( $ instance -> getDirs ( ) as $ dir ) { if ( is_array ( $ dir ) ) { $ exists = true ; foreach ( $ dir as $ requiredDir ) { $ exists = $ exists && file_exists ( "{$rootDir}/{$requiredDir}" ) ; } if ( $ exists ) { return $ instance ; } } else { if ( file_exists ( "{$rootDir}/{$dir}" ) ) { return $ instance ; } } } } return null ; }
Returns the project type either from composer extra section or it tries to detect from file structure . Returns null if no project type is detected .
29,661
static function create ( $ left = null , $ right = null , $ operator = Query :: EQUAL , $ quote = null ) { return new self ( $ left , $ right , $ operator , $ quote ) ; }
Returns new instance of self by passing arguments directly to constructor .
29,662
function addAnd ( $ left , $ right = null , $ operator = Query :: EQUAL , $ quote = null ) { if ( null === $ left ) { return $ this ; } if ( is_array ( $ left ) ) { foreach ( $ left as $ key => & $ value ) { $ this -> addAnd ( $ key , $ value ) ; } return $ this ; } $ this -> conds [ ] = array ( 'AND' , func_get_args ( ) ) ; return $ this ; }
Adds an AND condition to the array of conditions .
29,663
public function initHeadScript ( ) { $ javascripts = $ this -> orderByPriority ( $ this -> options -> getJs ( ) -> getHead ( ) ) ; foreach ( $ javascripts as $ js ) { $ this -> setJavascript ( $ this -> headScript , $ js ) ; } return $ this ; }
Initializes the HeadScript element
29,664
public function initInlineScript ( ) { $ javascripts = $ this -> orderByPriority ( $ this -> options -> getJs ( ) -> getInline ( ) ) ; foreach ( $ javascripts as $ js ) { $ this -> setJavascript ( $ this -> inlineScript , $ js ) ; } return $ this ; }
Initializes the InlineScript element
29,665
public function initHeadLink ( ) { $ cssPath = $ this -> options -> getCss ( ) -> getPath ( ) ; $ stylesheets = $ this -> orderByPriority ( $ this -> options -> getCss ( ) -> getStylesheets ( ) ) ; foreach ( $ stylesheets as $ css ) { if ( isset ( $ css [ "media" ] ) ) { $ this -> headLink -> appendStylesheet ( $ cssPath . "/" . $ css [ "name" ] , $ css [ "media" ] , false , array ( ) ) ; } else { $ this -> headLink -> appendStylesheet ( $ cssPath . "/" . $ css [ "name" ] , 'screen' , false , array ( ) ) ; } } return $ this ; }
Initializes the HeadLink element
29,666
private function setJavascript ( HeadScript $ element , array $ js = array ( ) ) { $ jsPath = $ this -> options -> getJs ( ) -> getPath ( ) ; if ( isset ( $ js [ "options" ] ) ) { $ element -> appendFile ( $ jsPath . "/" . $ js [ "name" ] , "text/javascript" , $ js [ "options" ] ) ; } else { $ element -> appendFile ( $ jsPath . "/" . $ js [ "name" ] ) ; } }
Sets a javascript asset into the HeadScript or InlineScript
29,667
private function orderByPriority ( array $ elements ) { $ elements = array_values ( $ elements ) ; $ length = count ( $ elements ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { for ( $ j = $ i ; $ j < $ length ; $ j ++ ) { $ priorityFirst = isset ( $ elements [ $ i ] [ 'priority' ] ) ? ( int ) $ elements [ $ i ] [ 'priority' ] : 1 ; $ prioritySecond = isset ( $ elements [ $ j ] [ 'priority' ] ) ? ( int ) $ elements [ $ j ] [ 'priority' ] : 1 ; if ( $ priorityFirst < $ prioritySecond ) { $ aux = $ elements [ $ j ] ; $ elements [ $ j ] = $ elements [ $ i ] ; $ elements [ $ i ] = $ aux ; } } } return $ elements ; }
Gets provided array and orders it by priority
29,668
private function compileBlockOptions ( \ Twig_Compiler $ compiler , $ loopId = null ) { $ options = $ this -> getAttribute ( 'options' ) ; if ( null !== $ loopId ) { $ compiler -> raw ( 'array_merge(' ) -> subcompile ( $ options ) -> raw ( ', array(\'id\' => ' ) -> string ( $ loopId . '__' ) -> raw ( '.$key)' ) -> raw ( ')' ) ; } else { $ compiler -> subcompile ( $ options ) ; } }
Compile the block options .
29,669
private function buildLoopVariables ( ) { $ options = $ this -> getAttribute ( 'options' ) ; $ loop = $ this -> getAttribute ( 'loop' ) ; $ loopKey = '' ; $ loopId = null ; $ hasId = false ; if ( ! empty ( $ loop ) ) { foreach ( $ options -> getKeyValuePairs ( ) as $ val ) { $ key = $ val [ 'key' ] ; $ value = $ val [ 'value' ] ; if ( 'id' === $ key -> getAttribute ( 'value' ) ) { $ hasId = true ; if ( $ value instanceof \ Twig_Node_Expression_Constant ) { $ loopKey = ', $key' ; $ loopId = $ value -> getAttribute ( 'value' ) ; break ; } } } if ( ! $ hasId ) { $ loopKey = ', $key' ; $ loopId = $ this -> getAttribute ( 'name' ) ; } } return [ $ loopKey , $ loopId ] ; }
Build the loop key and loop id variables .
29,670
public function isExpired ( ) { $ now = new DateTime ( gmdate ( 'Y-m-d H:i:s' ) ) ; $ expire = new Datetime ( $ this -> expiry_dtime ) ; return $ now >= $ expire ; }
Check if the token is expired
29,671
private function getCommonType ( $ columnName , $ field ) { static $ types = [ SQLITE3_INTEGER => CommonTypes :: TINT , SQLITE3_FLOAT => CommonTypes :: TNUMBER , SQLITE3_TEXT => CommonTypes :: TTEXT , ] ; if ( isset ( $ this -> overrideTypes [ $ columnName ] ) ) { return $ this -> overrideTypes [ $ columnName ] ; } if ( false !== $ field && array_key_exists ( $ field , $ types ) ) { return $ types [ $ field ] ; } return CommonTypes :: TTEXT ; }
Private function to get the CommonType from the information of the field
29,672
protected function removeItem ( string $ key ) : bool { if ( ! $ this -> has ( $ key ) ) { return false ; } unset ( $ this -> items [ $ key ] ) ; return true ; }
Remove an item from the array collection by its key
29,673
public function get ( string $ key ) { if ( ! $ this -> has ( $ key ) ) { throw new \ RuntimeException ( 'No item with name ' . $ key . ' available' ) ; } return $ this -> items [ $ key ] ; }
Get an item from the collection by its key
29,674
public function transform ( Location $ location ) { return [ 'id' => $ location -> id , 'name' => $ location -> name , 'upcomingJobsCount' => ( count ( $ location -> upcoming_jobs_count ) > 0 ) ? $ location -> upcoming_jobs_count [ 0 ] -> aggregate : 0 , ] ; }
Transformer to generate JSON response with Location data
29,675
static public function formatName ( $ definition ) { if ( is_string ( $ definition ) ) { return $ definition ; } elseif ( is_object ( $ definition ) ) { return get_class ( $ definition ) ; } elseif ( is_array ( $ definition ) ) { if ( ! isset ( $ definition [ 'class' ] ) ) { $ name = $ definition [ 0 ] ; } else { $ name = $ definition [ 'class' ] ; } } else { throw new InvalidConfigException ( "Unsupported definition for :" . gettype ( $ definition ) ) ; } }
format the name use for format config key
29,676
static public function formatDefinition ( $ name , $ definition ) { if ( empty ( $ definition ) ) { return [ 'class' => $ name ] ; } elseif ( is_callable ( $ definition , false ) || is_object ( $ definition ) ) { return $ definition ; } elseif ( is_string ( $ definition ) ) { if ( strpos ( $ definition , ':' ) !== false ) { return $ definition ; } return [ 'class' => $ definition ] ; } elseif ( is_array ( $ definition ) ) { if ( ! isset ( $ definition [ 'class' ] ) ) { if ( strpos ( $ name , '\\' ) !== false ) { $ definition [ 'class' ] = $ name ; } else { throw new InvalidConfigException ( "A class definition requires a \"class\" member." ) ; } } return $ definition ; } else { throw new InvalidConfigException ( "Unsupported definition type for \"$name\": " . gettype ( $ definition ) ) ; } }
format the definition .
29,677
public function get ( $ id ) { if ( isset ( $ this -> _definitions [ $ id ] ) && is_object ( $ this -> _definitions [ $ id ] ) && ! is_callable ( $ this -> _definitions [ $ id ] ) ) { $ this -> _components [ $ id ] = $ this -> _definitions [ $ id ] ; } elseif ( ! isset ( $ this -> _components [ $ id ] ) ) { if ( ! isset ( $ this -> _definitions [ $ id ] ) ) { throw new \ RuntimeException ( 'Must set components before use: ' . $ id ) ; } $ this -> _components [ $ id ] = Ioc :: createObject ( $ this -> _definitions [ $ id ] ) ; } return $ this -> _components [ $ id ] ; }
get component by id id is a brief name
29,678
public function set ( $ id , $ definition ) { if ( is_numeric ( $ id ) ) { $ id = is_string ( $ definition ) ? $ definition : $ definition [ 'class' ] ; } $ this -> _definitions [ $ id ] = $ definition ; return $ this ; }
set component definition with id delay create instance
29,679
public function read ( $ filename ) { $ this -> setUuid ( md5 ( $ this -> getUuid ( ) . $ filename ) ) ; $ configurations = $ this -> getConfigurations ( ) ; if ( isset ( $ configurations [ $ this -> getUuid ( ) ] ) === false ) { if ( true === $ this -> getCache ( ) ) { try { $ configuration = $ this -> getCacheService ( ) -> read ( $ this -> getUuid ( ) , $ this -> getScope ( ) ) ; if ( $ configuration !== null ) { $ configurations [ $ this -> getUuid ( ) ] = $ configuration ; $ this -> setConfiguration ( $ configuration ) ; $ this -> setConfigurations ( $ configurations ) ; return $ configuration ; } } catch ( Doozr_Cache_Service_Exception $ e ) { } } $ configuration = clone $ this -> getConfigurationReader ( ) ; $ configuration -> read ( $ filename ) ; $ configurations [ $ this -> getUuid ( ) ] = $ configuration -> get ( ) ; $ configuration = $ this -> merge ( $ this -> getConfiguration ( ) , $ configuration -> get ( ) ) ; if ( $ this -> getCache ( ) === true ) { $ this -> getCacheService ( ) -> create ( $ this -> getUuid ( ) , $ configuration , null , $ this -> getScope ( ) ) ; } $ this -> setConfiguration ( $ configuration ) ; $ this -> setConfigurations ( $ configurations ) ; } else { return $ configurations [ $ this -> getUuid ( ) ] ; } }
Reads a configuration by using the injected Doozr_Configuration_Reader_Interface . The result of the call will be merged with previously loaded configurations and it will be cached .
29,680
public function get ( $ node = null ) { if ( $ node !== null ) { $ nodes = explode ( ':' , $ node ) ; $ configuration = $ this -> getConfiguration ( ) ; foreach ( $ nodes as $ node ) { $ configuration = $ configuration -> { $ node } ; } } else { $ configuration = $ this -> getConfiguration ( ) ; } return $ configuration ; }
Getter for value of passed node .
29,681
protected function merge ( \ stdClass $ object1 , \ stdClass $ object2 ) { return array_to_object ( array_replace_recursive ( object_to_array ( $ object1 ) , object_to_array ( $ object2 ) ) ) ; }
Merges two configurations of type \ stdClass .
29,682
public function _mergeWithPrevious ( $ previous ) { if ( ! $ previous ) { return $ this ; } if ( $ previous instanceof DeleteOperation ) { return new SetOperation ( $ this -> value ) ; } if ( $ previous instanceof SetOperation ) { return new SetOperation ( $ previous -> getValue ( ) + $ this -> value ) ; } if ( $ previous instanceof IncrementOperation ) { return new IncrementOperation ( $ previous -> getValue ( ) + $ this -> value ) ; } throw new AVException ( 'Operation is invalid after previous operation.' ) ; }
Merge this operation with a previous operation and return the resulting operation .
29,683
protected function _getDefaultAutoloader ( ) { static $ staticLoader ; if ( ! $ staticLoader instanceof iLoaderAutoload ) { $ staticLoader = new LoaderAutoloadAggregate ; $ staticLoader -> attach ( new LoaderAutoloadNamespace ( ) , 10 ) ; $ staticLoader -> attach ( new LoaderAutoloadClassMap ( ) , 100 ) ; $ staticLoader -> register ( true ) ; } return $ staticLoader ; }
Get Autoloader Object
29,684
protected function saveSerializedObject ( $ serializedObject ) { if ( file_exists ( $ this -> path ) && ! is_writable ( $ this -> path ) ) { throw new Exception ( 'The file "' . $ this -> path . '" isn\'t writable!' ) ; } return file_put_contents ( $ this -> path , $ serializedObject ) ; }
Saves the object in the data source
29,685
public static function arrMergeAll ( array & $ arr , $ arr2 ) { if ( is_array ( $ arr2 ) ) { foreach ( $ arr2 as $ key => $ val ) { $ arr [ $ key ] = $ val ; } } else { $ arr [ ] = $ arr2 ; } return $ arr ; }
merge all array if it has the same key number the value will override
29,686
public static function arrExclude ( array $ arr , array $ excludeKeys ) { $ result = [ ] ; foreach ( $ arr as $ key => $ val ) { if ( ! in_array ( $ key , $ excludeKeys ) ) { $ result [ $ key ] = $ val ; } } return $ result ; }
Return all array elements except for a given key
29,687
protected function unsetReadonlyProperty ( string $ name ) : void { if ( $ this -> issetReadonlyProperty ( $ name ) ) { unset ( $ this -> readonlyValues [ $ name ] ) ; } }
This method removes a read - only property .
29,688
private static function cloneArray ( array $ source ) : array { $ ret = [ ] ; foreach ( $ source as $ key => $ value ) { if ( is_array ( $ value ) ) { $ ret [ $ key ] = self :: cloneArray ( $ value ) ; } else if ( is_object ( $ value ) ) { $ ret [ $ key ] = clone $ value ; } else { $ ret [ $ key ] = $ value ; } } return $ ret ; }
This method copies an array . All elements of the array will be cloned .
29,689
function limitPath ( $ file ) { $ x = explode ( '/' , $ file ) ; $ l = count ( $ x ) ; return ( $ l > 1 ) ? $ x [ $ l - 2 ] . '/' . $ x [ $ l - 1 ] : $ file ; }
limit the path for security reasons
29,690
static function dump ( $ var , $ trace = true ) { $ d = Debug :: getInstance ( ) ; if ( $ d -> level < 1 ) { return ; } if ( $ d -> terminal ) { $ c = $ d -> console ; if ( ! is_array ( $ var ) ) { $ c -> writeln ( print_r ( $ var , 1 ) , 'blue' ) ; } else { $ lines = explode ( "\n" , print_r ( $ var , 1 ) ) ; foreach ( $ lines as $ line ) { preg_match_all ( '|(.*)\[(.*)\] \=\>(.*)|' , $ line , $ m ) ; if ( ! isset ( $ m [ 0 ] [ 0 ] ) ) { $ c -> writeln ( $ line ) ; } else { $ c -> write ( $ m [ 1 ] [ 0 ] . '[' , 'blue' ) ; $ c -> write ( $ m [ 2 ] [ 0 ] , 'light_red' ) ; $ c -> write ( '] =>' , 'blue' ) ; $ c -> writeln ( $ m [ 3 ] [ 0 ] , 'blue' ) ; } } } } else { $ txt = preg_replace ( '/\[(.*)\]/u' , '[<span style="color:#d00">$1</span>]' , print_r ( $ var , 1 ) ) ; echo '<pre style="color:blue">' . $ txt . "</pre>" ; } if ( $ trace ) $ d -> _trace ( ) ; }
Dumps the passed object or variable on console or browser
29,691
private function _trace ( $ trace = null ) { $ trace = $ trace ? : debug_backtrace ( ) ; foreach ( $ trace as $ er ) { $ func = isset ( $ er [ 'function' ] ) ? $ er [ 'function' ] : '' ; $ file = isset ( $ er [ 'file' ] ) ? $ er [ 'file' ] : '' ; if ( $ file ) { $ file = $ this -> limitPath ( $ file ) ; $ line = isset ( $ er [ 'line' ] ) ? $ er [ 'line' ] : '' ; $ class = isset ( $ er [ 'class' ] ) ? $ er [ 'class' ] : '' ; if ( $ class == 'IrfanTOOR\Debug' && $ func == '_trace' ) continue ; $ ftag = ( $ class != '' ) ? $ class . '=>' . $ func . '()' : $ func . '()' ; $ txt = '-- file: ' . $ file . ', line: ' . $ line . ', ' . $ ftag ; if ( $ this -> terminal ) $ this -> console -> writeln ( $ txt , 'dark' ) ; else echo '<code style="color:#999">' . $ txt . '</code><br>' ; } } }
Prints the debug trace in the printable format
29,692
public function panes ( ) { global $ step ; $ steps = array ( 'form' => false , 'execute' => true , ) ; if ( ! $ step || ! bouncer ( $ step , $ steps ) ) { $ step = 'form' ; } $ this -> initialize ( ) ; $ this -> verify_terminals ( ) ; $ this -> $ step ( ) ; }
Delivers panes .
29,693
public function add_terminal ( $ name , $ label , $ callback = null ) { if ( $ label === null || $ callback === null ) { unset ( $ this -> terminal_labels [ $ name ] , $ this -> terminals [ $ name ] ) ; } elseif ( ! in_array ( $ label , $ this -> terminal_labels ) ) { $ this -> terminals [ $ name ] = $ callback ; $ this -> terminal_labels [ $ name ] = $ label ; asort ( $ this -> terminal_labels ) ; } return $ this ; }
Registers a terminal processor .
29,694
protected function verify_terminals ( ) { foreach ( $ this -> terminals as $ name => $ callback ) { if ( ! has_privs ( 'rah_terminal.' . $ name ) || ! is_callable ( $ callback ) ) { unset ( $ this -> terminal_labels [ $ name ] , $ this -> terminals [ $ name ] ) ; } } }
Verifies user s terminal permissions .
29,695
public function form ( $ message = '' ) { global $ event ; pagetop ( gTxt ( 'rah_terminal' ) , $ message ) ; echo '<h1 class="txp-heading">' . gTxt ( 'rah_terminal' ) . '</h1>' . n . '<form method="post" action="index.php" id="rah_terminal_container" class="txp-container">' . n . eInput ( $ event ) . sInput ( 'execute' ) . tInput ( ) . n . ' <p>' . selectInput ( 'type' , $ this -> terminal_labels , get_pref ( 'rah_terminal_last_type' ) ) . '</p>' . n . ' <p>' . n . ' <textarea class="code" name="code" rows="12" cols="20">' . txpspecialchars ( ps ( 'code' ) ) . '</textarea>' . n . ' </p>' . n . ' <p>' . n . ' <input type="submit" value="' . gTxt ( 'rah_terminal_run' ) . '" class="publish" />' . n . ' </p>' . n . '</form>' . n ; }
The main panel .
29,696
protected function getSafeValue ( $ code ) { if ( is_bool ( $ code ) ) { return $ code ? '(bool) true' : '(bool) false' ; } if ( is_scalar ( $ code ) ) { return $ code ; } if ( is_array ( $ code ) ) { return print_r ( $ code , true ) ; } return getType ( $ code ) ; }
Takes command s output and makes that into a safe human - readable string .
29,697
public function head ( ) { global $ event , $ theme ; if ( $ event != 'rah_terminal' ) { return ; } $ error = escape_js ( $ theme -> announce_async ( array ( gTxt ( 'rah_terminal_fatal_error' ) , E_ERROR ) ) ) ; echo <<<EOF <style type="text/css"> .rah_terminal_result_close { float: right; } .rah_terminal_result pre { max-height: 9em; overflow-y: auto; } </style>EOF ; $ js = <<<EOF $(document).ready(function(){ $('form#rah_terminal_container').txpAsyncForm({ error : function() { $.globalEval('{$error}'); }, success : function(form, event, data) { if($.trim(data) === '') { $.globalEval('{$error}'); } } }); $(document).on('click', '.rah_terminal_result_close', function(e) { e.preventDefault(); $(this).parents('.rah_terminal_result').remove(); }); });EOF ; echo script_js ( $ js ) ; }
Adds styles and JavaScript to the &lt ; head&gt ; .
29,698
public function error ( $ type , $ message ) { $ error = array ( E_WARNING => 'Warning' , E_NOTICE => 'Notice' , E_USER_ERROR => 'Error' , E_USER_WARNING => 'Warning' , E_USER_NOTICE => 'Notice' , ) ; if ( isset ( $ error [ $ type ] ) ) { $ this -> error [ ] = $ error [ $ type ] . ': ' . $ message ; } return true ; }
Error handler for terminal options .
29,699
public function next ( ) { if ( null === $ this -> _batch || ! $ this -> each || $ this -> each && false === next ( $ this -> _batch ) ) { $ this -> _batch = $ this -> fetchData ( ) ; reset ( $ this -> _batch ) ; } if ( $ this -> each ) { $ this -> _value = current ( $ this -> _batch ) ; if ( null !== key ( $ this -> _batch ) ) { ++ $ this -> _key ; } else { $ this -> _key = null ; } } else { $ this -> _value = $ this -> _batch ; $ this -> _key = null === $ this -> _key ? 0 : $ this -> _key + 1 ; } }
Moves the internal pointer to the next dataset . This method is required by the interface Iterator .