idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
7,800
protected function getProperties ( ) { return array ( "chat" => $ this -> chatProperties , "chat_avatar" => $ this -> chatAvatarProperties , "map_info" => $ this -> mapInfoProperties , "countdown" => $ this -> countdownProperties , "go" => $ this -> goProperties , "endmap_ladder_recap" => $ this -> endMapLadderRecapProperties , "scorestable" => $ this -> scoresTableProperties ) ; }
Get associative array of all properties
7,801
protected function setPositionProperty ( array & $ properties , $ positionX , $ positionY , $ positionZ = null ) { $ position = array ( ( float ) $ positionX , ( float ) $ positionY ) ; if ( $ positionZ ) { array_push ( $ position , ( float ) $ positionZ ) ; } $ this -> setProperty ( $ properties , "pos" , implode ( " " , $ position ) ) ; return $ this ; }
Set the Position property value
7,802
public function createScope ( $ closure ) { $ newScope = ( new static ( $ this -> request , $ this -> result , $ this -> urlGenerator ) ) ; $ newScope -> setupParent ( $ this -> prefix , $ this -> prefixMatched , $ this -> requestPathOffset , $ this -> params ) ; $ newScope -> use ( $ this -> middlewares ) ; $ newScope -> namespace ( $ this -> namespace ) ; $ closure ( $ newScope ) ; }
Create a child scope .
7,803
public function prefix ( $ prefix ) { $ this -> prefix = $ this -> parentPrefix ; $ this -> requestPathOffset = $ this -> parentRequestPathOffset ; if ( $ this -> parentPrefixMatched ) { $ this -> prefixMatched = $ this -> parentPrefixMatched ; } if ( ! $ this -> result -> hasHandler ( ) && $ this -> prefixMatched ) { $ this -> prefixMatched = $ this -> matchPartial ( $ prefix ) ; } $ this -> prefix .= $ prefix ; return $ this ; }
Set a common path prefix for all routes .
7,804
public function use ( $ middlewares ) { $ middlewares = ( array ) $ middlewares ; if ( $ this -> namespace ) { foreach ( $ middlewares as & $ middleware ) { $ middleware = $ this -> namespace . $ middleware ; } } $ this -> middlewares = array_merge ( $ this -> middlewares , ( array ) $ middlewares ) ; return $ this ; }
Add middlewares .
7,805
public function on ( $ method , $ path , $ handler , $ name = '' ) { if ( ! $ this -> result -> hasHandler ( ) && $ this -> prefixMatched && $ this -> request -> isMethod ( $ method ) ) { if ( $ this -> matchPartial ( $ path , true ) ) { $ handlers = ( array ) $ handler ; if ( $ this -> namespace ) { foreach ( $ handlers as & $ handler ) { $ handler = $ this -> namespace . $ handler ; } } if ( $ this -> middlewares ) { $ handlers = array_merge ( $ this -> middlewares , $ handlers ) ; } $ this -> result -> setHandler ( $ handlers ) ; $ this -> result -> setStatus ( 200 ) ; $ this -> result -> setParams ( $ this -> params ) ; } } if ( $ name ) { $ this -> urlGenerator -> add ( $ name , $ this -> prefix . $ path ) ; } return $ this ; }
Add a route .
7,806
public function setupParent ( $ prefix , $ prefixMatched , $ requestPathOffset , $ params ) { $ this -> prefix = $ prefix ; $ this -> parentPrefix = $ prefix ; $ this -> prefixMatched = $ prefixMatched ; $ this -> parentPrefixMatched = $ prefixMatched ; $ this -> requestPathOffset = $ requestPathOffset ; $ this -> parentRequestPathOffset = $ requestPathOffset ; $ this -> params = $ params ; }
Inherit data from parent scope .
7,807
protected function matchPartial ( $ routePathPartial , $ toEnd = false ) { $ result = false ; $ numOfRouteMatches = preg_match_all ( self :: ROUTE_PARAM_PATTERN , $ routePathPartial , $ routeMatches , PREG_OFFSET_CAPTURE ) ; if ( $ numOfRouteMatches === 0 ) { if ( $ toEnd ) { $ requestPathPartial = substr ( $ this -> request -> getPath ( ) , $ this -> requestPathOffset ) ; } else { $ requestPathPartial = substr ( $ this -> request -> getPath ( ) , $ this -> requestPathOffset , strlen ( $ routePathPartial ) ) ; } if ( $ routePathPartial === $ requestPathPartial ) { $ result = true ; if ( ! $ toEnd ) { $ this -> requestPathOffset += strlen ( $ routePathPartial ) ; } } } else if ( $ numOfRouteMatches > 0 ) { $ pos = 0 ; $ pattern = '#^' ; for ( $ i = 0 ; $ i < $ numOfRouteMatches ; $ i ++ ) { $ pattern .= substr ( $ routePathPartial , $ pos , $ routeMatches [ 1 ] [ $ i ] [ 1 ] - $ pos ) ; $ pattern .= '(?P<' . $ routeMatches [ 2 ] [ $ i ] [ 0 ] . '>[^/]+)' ; $ pos = $ routeMatches [ 1 ] [ $ i ] [ 1 ] + strlen ( $ routeMatches [ 1 ] [ $ i ] [ 0 ] ) ; } $ pattern .= substr ( $ routePathPartial , $ pos ) ; if ( $ toEnd ) { $ pattern .= '$' ; } $ pattern .= '#' ; $ requestPathPartial = substr ( $ this -> request -> getPath ( ) , $ this -> requestPathOffset ) ; $ numOfPathMatches = preg_match ( $ pattern , $ requestPathPartial , $ pathMatches ) ; if ( $ numOfPathMatches === 1 ) { $ result = true ; foreach ( $ routeMatches [ 2 ] as $ m ) { $ paramName = $ m [ 0 ] ; $ this -> params [ $ paramName ] = $ pathMatches [ $ paramName ] ; } if ( ! $ toEnd ) { $ this -> requestPathOffset += strlen ( $ pathMatches [ 0 ] ) ; } } } return $ result ; }
Match path partial with request path . This will move the request path offset .
7,808
public function getHtml ( $ name = null ) { $ host = self :: API_SERVER ; $ langOption = '' ; if ( isset ( $ this -> options [ 'lang' ] ) && ! empty ( $ this -> options [ 'lang' ] ) ) { $ langOption = "?hl={$this->options['lang']}" ; } $ return = <<<HTML<script type="text/javascript" src="{$host}{$langOption}" async defer></script>HTML ; return $ return ; }
Get the HTML code for the captcha
7,809
protected function query ( $ responseField ) { $ params = new Parameters ( $ this -> secretKey , $ responseField , $ this -> ip ) ; return $ this -> request -> send ( $ params ) ; }
Gets a solution to the verify server
7,810
public function actionProfile ( ) { $ model = UserProfile :: findOne ( [ 'user_id' => Yii :: $ app -> user -> identity -> getId ( ) ] ) ; if ( Yii :: $ app -> request -> isAjax && $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; return ActiveForm :: validate ( $ model ) ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'yuncms' , 'Your profile has been updated' ) ) ; return $ this -> refresh ( ) ; } return $ this -> render ( 'profile' , [ 'model' => $ model , ] ) ; }
Shows profile settings form .
7,811
public function actionAvatar ( ) { $ model = new AvatarForm ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , Yii :: t ( 'yuncms' , 'Your avatar has been updated' ) ) ; } return $ this -> render ( 'avatar' , [ 'model' => $ model , ] ) ; }
Show portrait setting form
7,812
private function getAssociatedClass ( $ errno ) { $ associations = [ E_WARNING => Exception \ WarningException :: class , E_NOTICE => Exception \ NoticeException :: class , E_USER_ERROR => Exception \ UserErrorException :: class , E_USER_WARNING => Exception \ UserWarningException :: class , E_USER_NOTICE => Exception \ UserNoticeException :: class , E_STRICT => Exception \ StrictException :: class , E_RECOVERABLE_ERROR => Exception \ RecoverableErrorException :: class , E_DEPRECATED => Exception \ DeprecatedException :: class , E_USER_DEPRECATED => Exception \ UserDeprecatedException :: class , ] ; if ( isset ( $ associations [ $ errno ] ) ) { return $ associations [ $ errno ] ; } return Exception \ ErrorException :: class ; }
Getting the exception class name associated with error code .
7,813
public function initCustomers ( $ overrideExisting = true ) { if ( null !== $ this -> collCustomers && ! $ overrideExisting ) { return ; } $ this -> collCustomers = new PropelObjectCollection ( ) ; $ this -> collCustomers -> setModel ( 'Customer' ) ; }
Initializes the collCustomers collection .
7,814
public function getCustomers ( $ criteria = null , PropelPDO $ con = null ) { $ partial = $ this -> collCustomersPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCustomers || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomers ) { $ this -> initCustomers ( ) ; } else { $ collCustomers = CustomerQuery :: create ( null , $ criteria ) -> filterByCountry ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collCustomersPartial && count ( $ collCustomers ) ) { $ this -> initCustomers ( false ) ; foreach ( $ collCustomers as $ obj ) { if ( false == $ this -> collCustomers -> contains ( $ obj ) ) { $ this -> collCustomers -> append ( $ obj ) ; } } $ this -> collCustomersPartial = true ; } $ collCustomers -> getInternalIterator ( ) -> rewind ( ) ; return $ collCustomers ; } if ( $ partial && $ this -> collCustomers ) { foreach ( $ this -> collCustomers as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collCustomers [ ] = $ obj ; } } } $ this -> collCustomers = $ collCustomers ; $ this -> collCustomersPartial = false ; } } return $ this -> collCustomers ; }
Gets an array of Customer objects which contain a foreign key that references this object .
7,815
public function countCustomers ( Criteria $ criteria = null , $ distinct = false , PropelPDO $ con = null ) { $ partial = $ this -> collCustomersPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collCustomers || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collCustomers ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getCustomers ( ) ) ; } $ query = CustomerQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByCountry ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collCustomers ) ; }
Returns the number of related Customer objects .
7,816
public function addCustomer ( Customer $ l ) { if ( $ this -> collCustomers === null ) { $ this -> initCustomers ( ) ; $ this -> collCustomersPartial = true ; } if ( ! in_array ( $ l , $ this -> collCustomers -> getArrayCopy ( ) , true ) ) { $ this -> doAddCustomer ( $ l ) ; if ( $ this -> customersScheduledForDeletion and $ this -> customersScheduledForDeletion -> contains ( $ l ) ) { $ this -> customersScheduledForDeletion -> remove ( $ this -> customersScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; }
Method called to associate a Customer object to this object through the Customer foreign key attribute .
7,817
public function down ( Table $ table , $ id , $ step = 1 ) { return $ this -> _move ( $ table , $ id , $ step , self :: TYPE_DOWN ) ; }
Move down record in tree .
7,818
public function up ( Table $ table , $ id , $ step = 1 ) { return $ this -> _move ( $ table , $ id , $ step ) ; }
Move up record in tree .
7,819
protected function _move ( Table $ table , $ id , $ step = 1 , $ type = self :: TYPE_UP ) { $ behaviors = $ table -> behaviors ( ) ; if ( ! Arr :: in ( 'Tree' , $ behaviors -> loaded ( ) ) ) { $ behaviors -> load ( 'Tree' ) ; } $ entity = $ table -> get ( $ id ) ; $ treeBehavior = $ behaviors -> get ( 'Tree' ) ; $ treeBehavior -> setConfig ( 'scope' , $ entity -> get ( 'id' ) ) ; if ( $ table -> { $ type } ( $ entity , $ step ) ) { $ this -> Flash -> success ( $ this -> _configRead ( 'messages.success' ) ) ; } else { $ this -> Flash -> error ( $ this -> _configRead ( 'messages.error' ) ) ; } return $ this -> _redirect ( ) ; }
Move object in tree table .
7,820
protected function _redirect ( ) { $ request = $ this -> _controller -> request ; return $ this -> _controller -> redirect ( [ 'prefix' => $ request -> getParam ( 'prefix' ) , 'plugin' => $ request -> getParam ( 'plugin' ) , 'controller' => $ request -> getParam ( 'controller' ) , 'action' => $ this -> getConfig ( 'action' ) ] ) ; }
Process redirect .
7,821
function & getDebugAsXMLComment ( ) { while ( strpos ( $ this -> debug_str , '--' ) ) { $ this -> debug_str = str_replace ( '--' , '- -' , $ this -> debug_str ) ; } $ ret = "<!--\n" . $ this -> debug_str . "\n ; return $ ret ; }
gets the current debug data for this instance as an XML comment this may change the contents of the debug data
7,822
function serializeTypeDef ( $ type ) { if ( $ typeDef = $ this -> getTypeDef ( $ type ) ) { $ str .= '<' . $ type ; if ( is_array ( $ typeDef [ 'attrs' ] ) ) { foreach ( $ typeDef [ 'attrs' ] as $ attName => $ data ) { $ str .= " $attName=\"{type = " . $ data [ 'type' ] . "}\"" ; } } $ str .= " xmlns=\"" . $ this -> schema [ 'targetNamespace' ] . "\"" ; if ( count ( $ typeDef [ 'elements' ] ) > 0 ) { $ str .= ">" ; foreach ( $ typeDef [ 'elements' ] as $ element => $ eData ) { $ str .= $ this -> serializeTypeDef ( $ element ) ; } $ str .= "</$type>" ; } elseif ( $ typeDef [ 'typeClass' ] == 'element' ) { $ str .= "></$type>" ; } else { $ str .= "/>" ; } return $ str ; } return FALSE ; }
returns a sample serialization of a given type or false if no type by the given name
7,823
function typeToForm ( $ name , $ type ) { if ( $ typeDef = $ this -> getTypeDef ( $ type ) ) { if ( $ typeDef [ 'phpType' ] == 'struct' ) { $ buffer .= '<table>' ; foreach ( $ typeDef [ 'elements' ] as $ child => $ childDef ) { $ buffer .= " <tr><td align='right'>$childDef[name] (type: " . $ this -> getLocalPart ( $ childDef [ 'type' ] ) . "):</td> <td><input type='text' name='parameters[" . $ name . "][$childDef[name]]'></td></tr>" ; } $ buffer .= '</table>' ; } elseif ( $ typeDef [ 'phpType' ] == 'array' ) { $ buffer .= '<table>' ; for ( $ i = 0 ; $ i < 3 ; $ i ++ ) { $ buffer .= " <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> <td><input type='text' name='parameters[" . $ name . "][]'></td></tr>" ; } $ buffer .= '</table>' ; } else { $ buffer .= "<input type='text' name='parameters[$name]'>" ; } } else { $ buffer .= "<input type='text' name='parameters[$name]'>" ; } return $ buffer ; }
returns HTML form elements that allow a user to enter values for creating an instance of the given type .
7,824
function addComplexType ( $ name , $ typeClass = 'complexType' , $ phpType = 'array' , $ compositor = '' , $ restrictionBase = '' , $ elements = [ ] , $ attrs = [ ] , $ arrayType = '' ) { $ this -> complexTypes [ $ name ] = [ 'name' => $ name , 'typeClass' => $ typeClass , 'phpType' => $ phpType , 'compositor' => $ compositor , 'restrictionBase' => $ restrictionBase , 'elements' => $ elements , 'attrs' => $ attrs , 'arrayType' => $ arrayType ] ; $ this -> xdebug ( "addComplexType $name:" ) ; $ this -> appendDebug ( $ this -> varDump ( $ this -> complexTypes [ $ name ] ) ) ; }
adds a complex type to the schema
7,825
function setURL ( $ url ) { $ this -> url = $ url ; $ u = parse_url ( $ url ) ; foreach ( $ u as $ k => $ v ) { $ this -> debug ( "parsed URL $k = $v" ) ; $ this -> $ k = $ v ; } if ( isset ( $ u [ 'query' ] ) && $ u [ 'query' ] != '' ) { $ this -> path .= '?' . $ u [ 'query' ] ; } if ( ! isset ( $ u [ 'port' ] ) ) { if ( $ u [ 'scheme' ] == 'https' ) { $ this -> port = 443 ; } else { $ this -> port = 80 ; } } $ this -> uri = $ this -> path ; $ this -> digest_uri = $ this -> uri ; if ( ! isset ( $ u [ 'port' ] ) ) { $ this -> setHeader ( 'Host' , $ this -> host ) ; } else { $ this -> setHeader ( 'Host' , $ this -> host . ':' . $ this -> port ) ; } if ( isset ( $ u [ 'user' ] ) && $ u [ 'user' ] != '' ) { $ this -> setCredentials ( urldecode ( $ u [ 'user' ] ) , isset ( $ u [ 'pass' ] ) ? urldecode ( $ u [ 'pass' ] ) : '' ) ; } }
sets the URL to which to connect
7,826
function setEncoding ( $ enc = 'gzip, deflate' ) { if ( function_exists ( 'gzdeflate' ) ) { $ this -> protocol_version = '1.1' ; $ this -> setHeader ( 'Accept-Encoding' , $ enc ) ; if ( ! isset ( $ this -> outgoing_headers [ 'Connection' ] ) ) { $ this -> setHeader ( 'Connection' , 'close' ) ; $ this -> persistentConnection = FALSE ; } $ this -> encoding = $ enc ; } }
use http encoding
7,827
function register ( $ name , $ in = [ ] , $ out = [ ] , $ namespace = FALSE , $ soapaction = FALSE , $ style = FALSE , $ use = FALSE , $ documentation = '' , $ encodingStyle = '' ) { global $ HTTP_SERVER_VARS ; if ( $ this -> externalWSDLURL ) { die ( 'You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.' ) ; } if ( ! $ name ) { die ( 'You must specify a name when you register an operation' ) ; } if ( ! is_array ( $ in ) ) { die ( 'You must provide an array for operation inputs' ) ; } if ( ! is_array ( $ out ) ) { die ( 'You must provide an array for operation outputs' ) ; } if ( FALSE == $ namespace ) { } if ( FALSE == $ soapaction ) { if ( isset ( $ _SERVER ) ) { $ SERVER_NAME = $ _SERVER [ 'SERVER_NAME' ] ; $ SCRIPT_NAME = isset ( $ _SERVER [ 'PHP_SELF' ] ) ? $ _SERVER [ 'PHP_SELF' ] : $ _SERVER [ 'SCRIPT_NAME' ] ; $ HTTPS = isset ( $ _SERVER [ 'HTTPS' ] ) ? $ _SERVER [ 'HTTPS' ] : ( isset ( $ HTTP_SERVER_VARS [ 'HTTPS' ] ) ? $ HTTP_SERVER_VARS [ 'HTTPS' ] : 'off' ) ; } elseif ( isset ( $ HTTP_SERVER_VARS ) ) { $ SERVER_NAME = $ HTTP_SERVER_VARS [ 'SERVER_NAME' ] ; $ SCRIPT_NAME = isset ( $ HTTP_SERVER_VARS [ 'PHP_SELF' ] ) ? $ HTTP_SERVER_VARS [ 'PHP_SELF' ] : $ HTTP_SERVER_VARS [ 'SCRIPT_NAME' ] ; $ HTTPS = isset ( $ HTTP_SERVER_VARS [ 'HTTPS' ] ) ? $ HTTP_SERVER_VARS [ 'HTTPS' ] : 'off' ; } else { $ this -> setError ( "Neither _SERVER nor HTTP_SERVER_VARS is available" ) ; } if ( $ HTTPS == '1' || $ HTTPS == 'on' ) { $ SCHEME = 'https' ; } else { $ SCHEME = 'http' ; } $ soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name" ; } if ( FALSE == $ style ) { $ style = "rpc" ; } if ( FALSE == $ use ) { $ use = "encoded" ; } if ( $ use == 'encoded' && $ encodingStyle == '' ) { $ encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/' ; } $ this -> operations [ $ name ] = [ 'name' => $ name , 'in' => $ in , 'out' => $ out , 'namespace' => $ namespace , 'soapaction' => $ soapaction , 'style' => $ style ] ; if ( $ this -> wsdl ) { $ this -> wsdl -> addOperation ( $ name , $ in , $ out , $ namespace , $ soapaction , $ style , $ use , $ documentation , $ encodingStyle ) ; } return TRUE ; }
register a service function with the server
7,828
function getOperations ( $ portName = '' , $ bindingType = 'soap' ) { $ ops = [ ] ; if ( $ bindingType == 'soap' ) { $ bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/' ; } elseif ( $ bindingType == 'soap12' ) { $ bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/' ; } else { $ this -> debug ( "getOperations bindingType $bindingType may not be supported" ) ; } $ this -> debug ( "getOperations for port '$portName' bindingType $bindingType" ) ; foreach ( $ this -> ports as $ port => $ portData ) { $ this -> debug ( "getOperations checking port $port bindingType " . $ portData [ 'bindingType' ] ) ; if ( $ portName == '' || $ port == $ portName ) { if ( $ portData [ 'bindingType' ] == $ bindingType ) { $ this -> debug ( "getOperations found port $port bindingType $bindingType" ) ; if ( isset ( $ this -> bindings [ $ portData [ 'binding' ] ] [ 'operations' ] ) ) { $ ops = array_merge ( $ ops , $ this -> bindings [ $ portData [ 'binding' ] ] [ 'operations' ] ) ; } } } } if ( count ( $ ops ) == 0 ) { $ this -> debug ( "getOperations found no operations for port '$portName' bindingType $bindingType" ) ; } return $ ops ; }
returns an assoc array of operation names = > operation data
7,829
function parseResponse ( $ headers , $ data ) { $ this -> debug ( 'Entering parseResponse() for data of length ' . strlen ( $ data ) . ' headers:' ) ; $ this -> appendDebug ( $ this -> varDump ( $ headers ) ) ; if ( ! isset ( $ headers [ 'content-type' ] ) ) { $ this -> setError ( 'Response not of type text/xml (no content-type header)' ) ; return FALSE ; } if ( ! strstr ( $ headers [ 'content-type' ] , 'text/xml' ) ) { $ this -> setError ( 'Response not of type text/xml: ' . $ headers [ 'content-type' ] ) ; return FALSE ; } if ( strpos ( $ headers [ 'content-type' ] , '=' ) ) { $ enc = str_replace ( '"' , '' , substr ( strstr ( $ headers [ "content-type" ] , '=' ) , 1 ) ) ; $ this -> debug ( 'Got response encoding: ' . $ enc ) ; if ( preg_match ( '/^(ISO-8859-1|US-ASCII|UTF-8)$/i' , $ enc ) ) { $ this -> xml_encoding = strtoupper ( $ enc ) ; } else { $ this -> xml_encoding = 'US-ASCII' ; } } else { $ this -> xml_encoding = 'ISO-8859-1' ; } $ this -> debug ( 'Use encoding: ' . $ this -> xml_encoding . ' when creating nusoap_parser' ) ; $ parser = new nusoap_parser ( $ data , $ this -> xml_encoding , $ this -> operations , $ this -> decode_utf8 ) ; $ this -> appendDebug ( $ parser -> getDebug ( ) ) ; if ( $ errstr = $ parser -> getError ( ) ) { $ this -> setError ( $ errstr ) ; unset ( $ parser ) ; return FALSE ; } else { $ this -> responseHeaders = $ parser -> getHeaders ( ) ; $ this -> responseHeader = $ parser -> get_soapheader ( ) ; $ return = $ parser -> get_soapbody ( ) ; $ this -> document = $ parser -> document ; unset ( $ parser ) ; return $ return ; } }
processes SOAP message returned from server
7,830
function getProxy ( ) { $ r = rand ( ) ; $ evalStr = $ this -> _getProxyClassCode ( $ r ) ; if ( $ this -> getError ( ) ) { $ this -> debug ( "Error from _getProxyClassCode, so return null" ) ; return NULL ; } eval ( $ evalStr ) ; eval ( "\$proxy = new nusoap_proxy_$r('');" ) ; $ proxy -> endpointType = 'wsdl' ; $ proxy -> wsdlFile = $ this -> wsdlFile ; $ proxy -> wsdl = $ this -> wsdl ; $ proxy -> operations = $ this -> operations ; $ proxy -> defaultRpcParams = $ this -> defaultRpcParams ; $ proxy -> soap_defencoding = $ this -> soap_defencoding ; $ proxy -> username = $ this -> username ; $ proxy -> password = $ this -> password ; $ proxy -> authtype = $ this -> authtype ; $ proxy -> certRequest = $ this -> certRequest ; $ proxy -> requestHeaders = $ this -> requestHeaders ; $ proxy -> endpoint = $ this -> endpoint ; $ proxy -> forceEndpoint = $ this -> forceEndpoint ; $ proxy -> proxyhost = $ this -> proxyhost ; $ proxy -> proxyport = $ this -> proxyport ; $ proxy -> proxyusername = $ this -> proxyusername ; $ proxy -> proxypassword = $ this -> proxypassword ; $ proxy -> http_encoding = $ this -> http_encoding ; $ proxy -> timeout = $ this -> timeout ; $ proxy -> response_timeout = $ this -> response_timeout ; $ proxy -> persistentConnection = & $ this -> persistentConnection ; $ proxy -> decode_utf8 = $ this -> decode_utf8 ; $ proxy -> curl_options = $ this -> curl_options ; $ proxy -> bindingType = $ this -> bindingType ; $ proxy -> use_curl = $ this -> use_curl ; return $ proxy ; }
dynamically creates an instance of a proxy class allowing user to directly call methods from wsdl
7,831
function _getProxyClassCode ( $ r ) { $ this -> debug ( "in getProxy endpointType=$this->endpointType" ) ; $ this -> appendDebug ( "wsdl=" . $ this -> varDump ( $ this -> wsdl ) ) ; if ( $ this -> endpointType != 'wsdl' ) { $ evalStr = 'A proxy can only be created for a WSDL client' ; $ this -> setError ( $ evalStr ) ; $ evalStr = "echo \"$evalStr\";" ; return $ evalStr ; } if ( $ this -> endpointType == 'wsdl' && is_null ( $ this -> wsdl ) ) { $ this -> loadWSDL ( ) ; if ( $ this -> getError ( ) ) { return "echo \"" . $ this -> getError ( ) . "\";" ; } } $ evalStr = '' ; foreach ( $ this -> operations as $ operation => $ opData ) { if ( $ operation != '' ) { if ( sizeof ( $ opData [ 'input' ] [ 'parts' ] ) > 0 ) { $ paramStr = '' ; $ paramArrayStr = '' ; $ paramCommentStr = '' ; foreach ( $ opData [ 'input' ] [ 'parts' ] as $ name => $ type ) { $ paramStr .= "\$$name, " ; $ paramArrayStr .= "'$name' => \$$name, " ; $ paramCommentStr .= "$type \$$name, " ; } $ paramStr = substr ( $ paramStr , 0 , strlen ( $ paramStr ) - 2 ) ; $ paramArrayStr = substr ( $ paramArrayStr , 0 , strlen ( $ paramArrayStr ) - 2 ) ; $ paramCommentStr = substr ( $ paramCommentStr , 0 , strlen ( $ paramCommentStr ) - 2 ) ; } else { $ paramStr = '' ; $ paramArrayStr = '' ; $ paramCommentStr = 'void' ; } $ opData [ 'namespace' ] = ! isset ( $ opData [ 'namespace' ] ) ? 'http://testuri.com' : $ opData [ 'namespace' ] ; $ evalStr .= "// $paramCommentStr function " . str_replace ( '.' , '__' , $ operation ) . "($paramStr) { \$params = array($paramArrayStr); return \$this->call('$operation', \$params, '" . $ opData [ 'namespace' ] . "', '" . ( isset ( $ opData [ 'soapAction' ] ) ? $ opData [ 'soapAction' ] : '' ) . "'); } " ; unset ( $ paramStr ) ; unset ( $ paramCommentStr ) ; } } $ evalStr = 'class nusoap_proxy_' . $ r . ' extends nusoap_client { ' . $ evalStr . '}' ; return $ evalStr ; }
dynamically creates proxy class code
7,832
public function validateSet ( ) { $ this -> validatedComponents = array ( ) ; $ exceptions = array ( ) ; foreach ( $ this -> components as $ component ) { try { $ this -> validateComponent ( $ component ) ; } catch ( ValidatorException $ e ) { if ( $ this -> exceptionList ) { $ exceptions [ ] = $ e ; } else { throw $ e ; } } } if ( $ this -> exceptionList && count ( $ exceptions ) > 0 ) { throw new ValidatorExceptionList ( $ exceptions ) ; } $ this -> postValidation ( ) ; return $ this ; }
Validiert alle Daten anhand der Meta - Daten von den FormDaten
7,833
protected function getContentType ( $ method ) { $ method = null ; $ file = $ this -> getArgument ( "file" ) ; if ( ! is_null ( $ file ) ) { return "text/csv" ; } $ soundFile = $ this -> getArgument ( "sound_file" ) ; if ( ! is_null ( $ soundFile ) ) { return "audio/mpeg" ; } return 'application/json' ; }
Returns the content type for this endpoint .
7,834
protected function getAcceptContentType ( $ method ) { $ method = null ; $ acceptFile = $ this -> getArgument ( "accept_file" ) ; if ( ! is_null ( $ acceptFile ) ) { return "text/csv" ; } $ acceptAnyFile = $ this -> getArgument ( "accept_any_file" ) ; if ( ! is_null ( $ acceptAnyFile ) ) { return "*/*" ; } $ acceptSoundFile = $ this -> getArgument ( "accept_sound_file" ) ; if ( ! is_null ( $ acceptSoundFile ) ) { return "audio/mpeg" ; } return 'application/json' ; }
Returns the accepted content type for this endpoint .
7,835
protected function run ( $ method ) { $ endpoint = $ this -> getEndpoint ( $ method ) ; $ outputFile = $ this -> getArgument ( 'accept_file' ) ; if ( is_null ( $ outputFile ) ) { $ outputFile = $ this -> getArgument ( 'accept_any_file' ) ; } if ( is_null ( $ outputFile ) ) { $ outputFile = $ this -> getArgument ( 'accept_sound_file' ) ; } $ cType = $ this -> getContentType ( $ method ) ; $ aCType = $ this -> getAcceptContentType ( $ method ) ; $ this -> delArgument ( 'accept_file' ) ; $ this -> delArgument ( 'accept_any_file' ) ; $ this -> delArgument ( 'accept_sound_file' ) ; $ body = $ this -> getBody ( $ method ) ; return $ this -> client -> run ( $ endpoint , $ method , $ cType , $ aCType , $ body , $ outputFile ) ; }
Runs this command with the given method and returns the result .
7,836
public function getOriginalFile ( $ source_file ) { $ original_file = $ this -> options [ 'path_local' ] . '/' . $ source_file ; if ( ! is_file ( $ original_file ) ) { throw new Exceptions \ NotFoundException ( 'File not found' ) ; } return $ original_file ; }
The path to the original file
7,837
public function handleRequest ( $ preset_key , $ file ) { $ preset = $ this -> getPresetActions ( $ preset_key , $ file ) ; $ source_file = $ this -> getOriginalFilename ( $ file ) ; $ original_file = $ this -> getOriginalFile ( $ source_file ) ; $ final_file = $ this -> localUrl ( $ preset_key , $ file ) ; $ this -> verifyDirectoryExistence ( $ this -> options [ 'path_local' ] , dirname ( $ final_file ) ) ; $ final_file = $ this -> options [ 'path_local' ] . '/' . $ final_file ; if ( file_exists ( $ final_file ) ) { return $ final_file ; } $ image = $ this -> loadImage ( $ original_file ) ; return $ this -> buildImage ( $ preset , $ image , $ final_file ) -> source ; }
Take a preset and a file and return a transformed image
7,838
protected function verifyDirectoryExistence ( $ base , $ cacheDir ) { if ( is_dir ( "$base/$cacheDir" ) ) { return ; } $ folder_path = explode ( '/' , $ cacheDir ) ; foreach ( $ folder_path as $ element ) { $ base .= '/' . $ element ; if ( ! is_dir ( $ base ) ) { mkdir ( $ base , 0755 , true ) ; chmod ( $ base , 0755 ) ; } } }
Create the folder containing the cached images if it doesn t exist
7,839
protected function buildImage ( $ actions , Image $ image , $ dst ) { foreach ( $ actions as $ action ) { if ( isset ( $ action [ 'width' ] ) ) { $ action [ 'width' ] = $ this -> percent ( $ action [ 'width' ] , $ image -> getWidth ( ) ) ; } if ( isset ( $ action [ 'height' ] ) ) { $ action [ 'height' ] = $ this -> percent ( $ action [ 'height' ] , $ image -> getHeight ( ) ) ; } if ( isset ( $ action [ 'xoffset' ] ) ) { $ action [ 'xoffset' ] = $ this -> keywords ( $ action [ 'xoffset' ] , $ image -> getWidth ( ) , $ action [ 'width' ] ) ; } if ( isset ( $ action [ 'yoffset' ] ) ) { $ action [ 'yoffset' ] = $ this -> keywords ( $ action [ 'yoffset' ] , $ image -> getHeight ( ) , $ action [ 'height' ] ) ; } $ this -> getMethodCaller ( ) -> call ( $ image , $ action [ 'action' ] , $ action ) ; } return $ image -> save ( $ dst ) ; }
Create a new image based on an image preset .
7,840
public function percent ( $ value , $ current_pixels ) { if ( strpos ( $ value , '%' ) !== false ) { $ value = str_replace ( '%' , '' , $ value ) * 0.01 * $ current_pixels ; } return $ value ; }
Accept a percentage and return it in pixels .
7,841
public function process ( $ name , array $ ids = [ ] ) { $ allowActions = $ this -> getConfig ( 'actions' ) ; if ( ! Arr :: key ( $ name , $ allowActions ) ) { throw new \ InvalidArgumentException ( __d ( 'core' , 'Invalid action to perform' ) ) ; } $ action = $ allowActions [ $ name ] ; if ( $ action === false ) { throw new \ InvalidArgumentException ( __d ( 'core' , 'Action "{0}" is disabled' , $ name ) ) ; } if ( Arr :: in ( $ action , get_class_methods ( $ this -> _table ) ) ) { return $ this -> _table -> { $ action } ( $ ids ) ; } return $ this -> { $ action } ( $ ids ) ; }
Process table method .
7,842
public function processDelete ( array $ ids ) { return $ this -> _table -> deleteAll ( [ $ this -> _table -> getPrimaryKey ( ) . ' IN (' . implode ( ',' , $ ids ) . ')' ] ) ; }
Process delete method .
7,843
protected function _toggleField ( array $ ids , $ value = STATUS_UN_PUBLISH ) { return $ this -> _table -> updateAll ( [ $ this -> _configRead ( 'field' ) => $ value , ] , [ $ this -> _table -> getPrimaryKey ( ) . ' IN (' . implode ( ',' , $ ids ) . ')' ] ) ; }
Toggle table field .
7,844
public function setId ( $ id = null ) { $ this -> id = ( $ id !== null ) ? $ id : SecureKey :: generate ( ) ; return $ this ; }
Set token ID
7,845
public function setSessionId ( $ session_id = null ) { $ this -> session_id = ( $ session_id !== null ) ? $ session_id : null ; return $ this ; }
Set the session id that this token is associated to ..
7,846
protected function getExistingIdentity ( UserResponseInterface $ response ) { $ repo = $ this -> om -> getRepository ( $ this -> userIdentityClass ) ; return $ repo -> findOneBy ( array ( 'identifier' => $ response -> getUsername ( ) , 'type' => $ response -> getResourceOwner ( ) -> getName ( ) , ) ) ; }
Checks whether the authenticating Identity already exists
7,847
protected function createUser ( UserResponseInterface $ response ) { $ user = $ this -> userManager -> createUser ( ) ; $ user -> setUsername ( $ this -> createUniqueUsername ( $ this -> getRealName ( $ response ) ) ) ; $ user -> setEmail ( $ this -> getEmail ( $ response ) ) ; $ user -> setPassword ( '' ) ; $ user -> setEnabled ( true ) ; $ this -> userManager -> updateUser ( $ user ) ; $ this -> createIdentity ( $ user , $ response ) ; return $ user ; }
Creates new User
7,848
protected function createIdentity ( User $ user , UserResponseInterface $ response ) { $ identity = new $ this -> userIdentityClass ; $ identity -> setAccessToken ( $ this -> getAccessToken ( $ response ) ) ; $ identity -> setIdentifier ( $ response -> getUsername ( ) ) ; $ identity -> setType ( $ response -> getResourceOwner ( ) -> getName ( ) ) ; $ identity -> setUser ( $ user ) ; $ identity -> setName ( $ this -> getRealName ( $ response ) ) ; $ identity -> setEmail ( $ this -> getEmail ( $ response ) ) ; $ this -> om -> persist ( $ identity ) ; $ this -> om -> flush ( ) ; return $ identity ; }
Creates new Identity
7,849
protected function createUniqueUsername ( $ username ) { $ originalName = $ username ; $ existingUser = $ this -> userManager -> findUserByUsername ( $ username ) ; $ suffix = 0 ; while ( $ existingUser ) { $ suffix ++ ; $ username = $ originalName . $ suffix ; $ existingUser = $ this -> userManager -> findUserByUsername ( $ username ) ; } return $ username ; }
Ensures uniqueness of username
7,850
public function setCacheHeaders ( ) { $ cacheTime = 31536000 ; $ this -> getHeaders ( ) -> set ( 'Expires' , gmdate ( 'D, d M Y H:i:s' , time ( ) + $ cacheTime ) . ' GMT' ) -> set ( 'Pragma' , 'cache' ) -> set ( 'Cache-Control' , 'max-age=' . $ cacheTime ) ; return $ this ; }
Sets headers that will instruct the client to cache this response .
7,851
public function setLastModifiedHeader ( string $ path ) { $ modifiedTime = filemtime ( $ path ) ; if ( $ modifiedTime ) { $ this -> getHeaders ( ) -> set ( 'Last-Modified' , gmdate ( 'D, d M Y H:i:s' , $ modifiedTime ) . ' GMT' ) ; } return $ this ; }
Sets a Last - Modified header based on a given file path .
7,852
public function sendFile ( $ file ) { if ( $ this -> sent ) { return $ this ; } $ this -> setMode ( self :: MODE_FILE ) ; $ this -> send ( $ file ) ; return $ this ; }
Send a file .
7,853
public function redirect ( $ url , $ statusCode = 302 ) { $ this -> setStatusCode ( $ statusCode ) -> setHeader ( 'Location' , $ url ) -> setBody ( sprintf ( '<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="refresh" content="1;url=%1$s"><title>Redirecting to %1$s</title>Redirecting to <a href="%1$s">%1$s</a>' , htmlspecialchars ( $ url , ENT_QUOTES , 'UTF-8' ) ) ) ; return $ this ; }
Setup HTTP redirect .
7,854
public function redirectRoute ( $ name , $ params = [ ] , $ statusCode = 302 ) { $ this -> redirect ( $ this -> urlGenerator -> generate ( $ name , $ params ) , $ statusCode ) ; return $ this ; }
HTTP redirect to a named route .
7,855
public static function closeOutputBuffers ( $ targetLevel , $ flush ) { $ status = ob_get_status ( true ) ; $ level = count ( $ status ) ; while ( $ level -- > $ targetLevel && ( ! empty ( $ status [ $ level ] [ 'del' ] ) || ( isset ( $ status [ $ level ] [ 'flags' ] ) && ( $ status [ $ level ] [ 'flags' ] & PHP_OUTPUT_HANDLER_REMOVABLE ) && ( $ status [ $ level ] [ 'flags' ] & ( $ flush ? PHP_OUTPUT_HANDLER_FLUSHABLE : PHP_OUTPUT_HANDLER_CLEANABLE ) ) ) ) ) { if ( $ flush ) { ob_end_flush ( ) ; } else { ob_end_clean ( ) ; } } }
Cleans or flushes output buffers up to target level .
7,856
public function log ( $ text , $ severity = 'info' ) { if ( $ severity === 'warn' || $ severity === 'warning' ) { return Log :: warning ( $ text ) ; } if ( $ severity === 'err' || $ severity === 'error' ) { return Log :: error ( $ text ) ; } return Log :: info ( $ text ) ; }
Write to application log
7,857
public function getAnonymizeed ( ) { $ userinfo = $ this -> toObject ( ) ; $ userinfo -> password_clear = '******' ; if ( isset ( $ userinfo -> password ) ) { $ userinfo -> password = substr ( $ userinfo -> password , 0 , 6 ) . '********' ; } if ( isset ( $ userinfo -> password_salt ) ) { $ userinfo -> password_salt = substr ( $ userinfo -> password_salt , 0 , 4 ) . '*****' ; } return $ userinfo ; }
hides sensitive information
7,858
private function render ( ) { $ strings = implode ( $ this -> strings ) ; foreach ( $ this -> incTemplates as $ path => $ include ) { $ incOutput = $ include -> render ( ) ; $ path = preg_replace ( "/\//" , "\/" , $ path ) ; $ strings = preg_replace ( "/\{include\s$path\}/" , $ incOutput , $ strings ) ; } foreach ( $ this -> ifTemplates as $ key => $ sub ) { foreach ( $ sub as $ iKey => $ instance ) { $ str = '' ; if ( $ this -> expressions [ $ key ] -> evaluate ( $ this -> vars ) ) { $ str = $ instance -> render ( ) ; } $ pregKey = preg_quote ( $ key , '/' ) ; $ strings = preg_replace ( "/\{if:$pregKey:$iKey\}/" , $ str , $ strings ) ; } } foreach ( $ this -> forTemplates as $ key => $ sub ) { foreach ( $ sub as $ iKey => $ instance ) { $ tmplGen = '' ; if ( isset ( $ this -> vars [ $ key ] ) && is_array ( $ this -> vars [ $ key ] ) ) { foreach ( $ this -> vars [ $ key ] as $ assocArray ) { foreach ( $ assocArray as $ k => $ v ) $ instance -> set ( $ k , $ v ) ; $ tmplGen .= $ instance -> render ( ) ; } } $ pregKey = preg_quote ( $ key , '/' ) ; $ strings = preg_replace ( "/\{for:$pregKey:$iKey\}/" , $ tmplGen , $ strings ) ; } } foreach ( $ this -> vars as $ key => $ val ) { if ( ! is_array ( $ val ) ) $ strings = preg_replace ( "/\{$key\}/" , $ val , $ strings ) ; } foreach ( $ this -> expressions as $ key => $ expr ) { $ eval = $ expr -> evaluate ( $ this -> vars ) ; if ( is_array ( $ eval ) ) { $ eval = count ( $ eval ) ; } $ pregKey = preg_quote ( $ key , '/' ) ; $ strings = preg_replace ( '/\{' . $ pregKey . '\}/' , $ eval , $ strings ) ; } $ strings = preg_replace ( "/\\\{/" , '{' , $ strings ) ; $ strings = preg_replace ( "/\\\}/" , '}' , $ strings ) ; return $ strings ; }
The render function goes through and renders the parsed document .
7,859
private function set ( $ var , $ val ) { $ this -> vars [ $ var ] = $ val ; foreach ( $ this -> forTemplates as $ templateBunch ) foreach ( $ templateBunch as $ sub ) $ sub -> set ( $ var , $ val ) ; foreach ( $ this -> ifTemplates as $ templateBunch ) foreach ( $ templateBunch as $ sub ) $ sub -> set ( $ var , $ val ) ; foreach ( $ this -> incTemplates as $ sub ) $ sub -> set ( $ var , $ val ) ; }
Sets the value of a variable .
7,860
private function parseRecursive ( $ start , $ regex , $ subName = 'template' ) { $ re_beg = $ regex [ 0 ] ; $ re_end = $ regex [ 1 ] ; $ numLines = count ( $ this -> strings ) ; $ i = $ start ; $ n = 0 ; $ line = 0 ; for ( $ i ; $ i < $ numLines ; $ i ++ ) { $ match = preg_match ( $ re_beg , $ this -> strings [ $ i ] ) ; if ( $ match ) $ n += 1 ; $ match = preg_match ( $ re_end , $ this -> strings [ $ i ] ) ; if ( $ match ) { $ n -= 1 ; if ( $ n == 0 ) break ; } $ line ++ ; } if ( $ n > 0 ) { echo "Opening brace on line $line of {$subName} has no closing brace\n<br />" ; } if ( $ start == $ i ) { $ subTmpl = $ this -> strings [ $ start ] ; $ beg = strpos ( $ subTmpl , '}' ) + 1 ; $ subTmpl = array ( substr ( $ subTmpl , $ beg , strrpos ( $ subTmpl , '{' ) - $ beg ) ) ; } else if ( $ i == ( $ start + 1 ) ) { $ subTmpl = $ this -> strings [ $ i ] ; $ subTmpl = array ( substr ( $ subTmpl , 0 , strrpos ( $ subTmpl , '{' ) ) ) ; } else { $ subTmpl = array_slice ( $ this -> strings , $ start + 1 , $ i - ( $ start + 1 ) ) ; } for ( $ j = $ start ; $ j <= $ i ; $ j ++ ) { $ this -> strings [ $ j ] = '' ; } if ( $ subName != 'comment' ) return new Scurvy ( $ subTmpl , $ this -> template_dir , false , $ subName ) ; }
This function is used by the parse function to grab the contents of scurvy block statements .
7,861
public function setPassword ( $ password ) { if ( is_array ( $ password ) ) { if ( $ password [ 'password' ] == NULL ) return $ this ; $ this -> hashPassword ( $ password [ 'password' ] ) ; } else { if ( $ password == NULL ) return $ this ; $ this -> password = $ password ; } return $ this ; }
Das setzt das gehashte Passwort und sollte nur intern benutzt werden
7,862
public function indexAction ( Request $ request ) { $ exportManager = $ this -> get ( 'chill.main.export_manager' ) ; $ exports = $ exportManager -> getExports ( true ) ; return $ this -> render ( 'ChillMainBundle:Export:layout.html.twig' , array ( 'exports' => $ exports ) ) ; }
Render the list of available exports
7,863
public function newAction ( Request $ request , $ alias ) { $ exportManager = $ this -> get ( 'chill.main.export_manager' ) ; $ export = $ exportManager -> getExport ( $ alias ) ; if ( $ exportManager -> isGrantedForElement ( $ export ) === FALSE ) { throw $ this -> createAccessDeniedException ( 'The user does not have access to this export' ) ; } $ step = $ request -> query -> getAlpha ( 'step' , 'centers' ) ; switch ( $ step ) { case 'centers' : return $ this -> selectCentersStep ( $ request , $ alias ) ; case 'export' : return $ this -> exportFormStep ( $ request , $ alias ) ; break ; case 'formatter' : return $ this -> formatterFormStep ( $ request , $ alias ) ; break ; case 'generate' : return $ this -> forwardToGenerate ( $ request , $ alias ) ; break ; default : throw $ this -> createNotFoundException ( "The given step '$step' is invalid" ) ; } }
handle the step to build a query for an export
7,864
protected function exportFormStep ( Request $ request , $ alias ) { $ exportManager = $ this -> get ( 'chill.main.export_manager' ) ; $ data = $ this -> get ( 'session' ) -> get ( 'centers_step' , null ) ; if ( $ data === null ) { return $ this -> redirectToRoute ( 'chill_main_export_new' , array ( 'step' => $ this -> getNextStep ( 'export' , true ) , 'alias' => $ alias ) ) ; } $ export = $ exportManager -> getExport ( $ alias ) ; $ form = $ this -> createCreateFormExport ( $ alias , 'export' , $ data ) ; if ( $ request -> getMethod ( ) === 'POST' ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ this -> get ( 'logger' ) -> debug ( 'form export is valid' , array ( 'location' => __METHOD__ ) ) ; $ data = $ form -> getData ( ) ; $ this -> get ( 'session' ) -> set ( 'export_step_raw' , $ request -> request -> all ( ) ) ; $ this -> get ( 'session' ) -> set ( 'export_step' , $ data ) ; return $ this -> redirect ( $ this -> generateUrl ( 'chill_main_export_new' , array ( 'step' => $ this -> getNextStep ( 'export' ) , 'alias' => $ alias ) ) ) ; } else { $ this -> get ( 'logger' ) -> debug ( 'form export is invalid' , array ( 'location' => __METHOD__ ) ) ; } } return $ this -> render ( 'ChillMainBundle:Export:new.html.twig' , array ( 'form' => $ form -> createView ( ) , 'export_alias' => $ alias , 'export' => $ export ) ) ; }
Render the export form
7,865
protected function createCreateFormExport ( $ alias , $ step , $ data = array ( ) ) { $ exportManager = $ this -> get ( 'chill.main.export_manager' ) ; $ isGenerate = strpos ( $ step , 'generate_' ) === 0 ; $ builder = $ this -> get ( 'form.factory' ) -> createNamedBuilder ( null , FormType :: class , array ( ) , array ( 'method' => $ isGenerate ? 'GET' : 'POST' , 'csrf_protection' => $ isGenerate ? false : true , ) ) ; if ( $ step === 'centers' or $ step === 'generate_centers' ) { $ builder -> add ( 'centers' , PickCenterType :: class , array ( 'export_alias' => $ alias ) ) ; } if ( $ step === 'export' or $ step === 'generate_export' ) { $ builder -> add ( 'export' , ExportType :: class , array ( 'export_alias' => $ alias , 'picked_centers' => $ exportManager -> getPickedCenters ( $ data [ 'centers' ] ) ) ) ; } if ( $ step === 'formatter' or $ step === 'generate_formatter' ) { $ builder -> add ( 'formatter' , FormatterType :: class , array ( 'formatter_alias' => $ exportManager -> getFormatterAlias ( $ data [ 'export' ] ) , 'export_alias' => $ alias , 'aggregator_aliases' => $ exportManager -> getUsedAggregatorsAliases ( $ data [ 'export' ] ) ) ) ; } $ builder -> add ( 'submit' , 'submit' , array ( 'label' => 'Generate' ) ) ; return $ builder -> getForm ( ) ; }
create a form to show on different steps .
7,866
private function iterate ( array $ content , $ parent = null ) { foreach ( $ content as $ element ) { $ this -> process ( $ element , $ parent ) ; } }
Iterate given content array and call process for every element inside
7,867
private function process ( array $ element , $ parent = null ) { $ apiElement = $ element [ 'element' ] ; if ( isset ( $ this -> elementMap [ $ apiElement ] ) ) { $ this -> processElement ( $ element , $ this -> elementMap [ $ apiElement ] , $ parent ) ; } if ( $ element [ 'element' ] === 'category' ) { $ this -> processCategory ( $ element , $ parent ) ; } }
Create php classes using raw element data ; called recursively
7,868
private function processElement ( array $ element , $ class , BaseElement $ parent , $ replaceAttribute = null ) { $ apiElement = new $ class ( $ element ) ; if ( ! $ replaceAttribute ) { $ parent -> addContentElement ( $ apiElement ) ; } else { $ parent -> replaceAttributeWithElement ( $ replaceAttribute , $ apiElement ) ; } if ( isset ( $ element [ 'attributes' ] ) ) { foreach ( $ element [ 'attributes' ] as $ attributeName => $ attributeValue ) { if ( ! isset ( $ this -> elementMap [ $ attributeName ] ) ) { continue ; } $ this -> processElement ( $ attributeValue , $ this -> elementMap [ $ attributeName ] , $ apiElement , $ attributeName ) ; } } if ( ! isset ( $ element [ 'content' ] ) ) { return ; } if ( ! is_array ( $ element [ 'content' ] ) ) { return ; } $ this -> iterate ( $ element [ 'content' ] , $ apiElement ) ; }
Create new element from raw data and add it to its parent
7,869
private function processCategory ( array $ element , $ parent = null ) { if ( $ this -> isMasterCategory ( $ element ) ) { $ this -> createCategory ( $ element , MasterCategoryElement :: class , $ this -> parseResult ) ; } if ( $ this -> isResourceGroup ( $ element ) ) { $ this -> createCategory ( $ element , ResourceGroupElement :: class , $ parent ) ; } if ( $ this -> isDataStructureCategory ( $ element ) ) { $ this -> createCategory ( $ element , DataStructureCategoryElement :: class , $ parent ) ; } }
Helper to create different php classes from element category which carries its actual meaning in its classes
7,870
private function createCategory ( array $ element , $ className , BaseElement $ parent ) { $ newElement = new $ className ( $ element ) ; $ parent -> addContentElement ( $ newElement ) ; $ this -> iterate ( $ element [ 'content' ] , $ newElement ) ; }
Sub - helper for processCategory
7,871
final public function call ( MVC $ mvc , $ method , $ fileView = null ) { if ( ! method_exists ( $ this , $ method ) ) { throw new \ LogicException ( sprintf ( 'Method "s" don\'t exists.' , $ method ) ) ; } $ this -> view = $ mvc -> view ( ) ; $ arguments = array ( ) ; $ reflectionMethod = new \ ReflectionMethod ( get_class ( $ this ) , $ method ) ; $ reflectionParams = $ reflectionMethod -> getParameters ( ) ; foreach ( $ reflectionParams as $ param ) { if ( $ paramClass = $ param -> getClass ( ) ) { $ className = $ paramClass -> name ; if ( $ className === 'MVC\\MVC' || $ className === '\\MVC\\MVC' ) { $ arguments [ ] = $ mvc ; } elseif ( $ className === 'MVC\\Server\\HttpRequest' || $ className === '\\MVC\\Server\\HttpRequest' ) { $ arguments [ ] = $ mvc -> request ( ) ; } } else { foreach ( $ mvc -> request ( ) -> params as $ keyReqParam => $ valueReqParam ) { if ( $ param -> name === $ keyReqParam ) { $ arguments [ ] = $ valueReqParam ; break ; } } } } $ response = call_user_func_array ( $ reflectionMethod -> getClosure ( $ this ) , $ arguments ) ; if ( empty ( $ response ) ) { throw new \ LogicException ( 'Response null returned.' ) ; } if ( is_string ( $ response ) ) { $ this -> response [ 'body' ] = $ response ; } elseif ( $ mvc -> request ( ) -> isAjax ( ) ) { $ this -> response [ 'body' ] = $ this -> renderJson ( $ response ) ; } elseif ( is_array ( $ response ) ) { if ( ! $ fileView ) { throw new \ LogicException ( 'File view is null.' ) ; } $ class = explode ( "\\" , get_called_class ( ) ) ; $ classname = end ( $ class ) ; $ classname = str_replace ( 'Controller' , '' , $ classname ) ; $ file = $ classname . "/{$fileView}" ; $ this -> response [ 'body' ] = $ this -> renderHtml ( $ file , $ response ) ; } return $ this -> response ; }
Call a action of controller
7,872
public function renderJson ( $ value ) { $ options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP ; return json_encode ( $ value , $ options ) ; }
Converts the supplied value to JSON .
7,873
public function offset ( $ timezone ) { $ timeOffset = ( new \ DateTimeZone ( $ timezone ) ) -> getOffset ( new \ DateTime ( 'now' , new \ DateTimeZone ( 'UTC' ) ) ) ; if ( $ timeOffset < 0 ) { return 'UTC -' . gmdate ( 'H:i' , - $ timeOffset ) ; } else { return 'UTC +' . gmdate ( 'H:i' , $ timeOffset ) ; } }
Get Time Offset
7,874
public function datetime ( $ datetime , $ timezone = null , $ format = 'M/d/Y - h:i:s A' ) { $ datetime = new \ DateTime ( $ datetime ) ; if ( $ timezone ) { $ datetime -> setTimezone ( new \ DateTimeZone ( $ timezone ) ) ; } return $ datetime -> format ( $ format ) ; }
Set Date and Time
7,875
public function createTask ( $ name ) { $ this -> init ( ) ; $ class = Code :: expandNamespace ( \ Webforge \ Common \ String :: expand ( $ name , 'Task' ) , 'Psc\System\Deploy' ) ; $ gClass = GClass :: factory ( $ class ) ; $ params = array ( ) ; if ( $ gClass -> hasMethod ( '__construct' ) ) { $ constructor = $ gClass -> getMethod ( '__construct' ) ; foreach ( $ constructor -> getParameters ( ) as $ parameter ) { $ params [ ] = $ this -> resolveTaskDependency ( $ parameter , $ gClass ) ; } } return $ gClass -> newInstance ( $ params ) ; }
wird automatisch mit dependencies erstellt
7,876
public function setResponse ( JsonResponse $ response ) { $ this -> response = $ response ; if ( ! $ response -> getRequest ( ) ) { $ response -> setRequest ( $ this ) ; } return $ this ; }
Set response .
7,877
public function isValid ( ) { if ( empty ( $ this -> jsonrpc ) ) { return false ; } if ( empty ( $ this -> method ) || ! is_string ( $ this -> method ) ) { return false ; } if ( ! empty ( $ this -> params ) && ! is_array ( $ this -> params ) ) { return false ; } return true ; }
Is valid .
7,878
public function toArray ( ) { $ json = [ ] ; $ json [ 'jsonrpc' ] = $ this -> jsonrpc ; if ( $ this -> method ) { $ json [ 'method' ] = $ this -> method ; } $ json [ 'method' ] = $ this -> method ; if ( $ this -> params ) { $ json [ 'params' ] = $ this -> params ; } if ( $ this -> id ) { $ json [ 'id' ] = $ this -> id ; } return $ json ; }
Convert JsonRequest to json string .
7,879
public function filter ( $ value , array $ options = [ ] ) { return is_string ( $ value ) ? filter_var ( Str :: lower ( trim ( $ value ) ) , FILTER_SANITIZE_EMAIL ) : $ value ; }
Sanitize email of the given string .
7,880
public function createMessage ( TicketInterface $ ticket = null ) { $ message = new $ this -> ticketMessageClass ( ) ; if ( $ ticket ) { $ message -> setPriority ( $ ticket -> getPriority ( ) ) ; $ message -> setStatus ( $ ticket -> getStatus ( ) ) ; $ message -> setTicket ( $ ticket ) ; } else { $ message -> setStatus ( TicketMessage :: STATUS_OPEN ) ; } return $ message ; }
Create a new instance of TicketMessage Entity .
7,881
public function isPreviouslyDeployed ( Asset $ asset ) { $ outputBasename = $ this -> computeOutputBasename ( $ asset ) ; $ file = $ this -> destinationPath . DIRECTORY_SEPARATOR . $ outputBasename ; if ( is_file ( $ file ) ) { $ objectUrl = $ this -> baseUrl . '/' . $ outputBasename ; $ asset -> setOutputUrl ( $ objectUrl ) ; return true ; } return false ; }
Attempt to retrieve a previously deployed asset ; if it does exist then update the Asset instance s outputUrl property without performing any further filters actions . fullPath and outputExtension are set at this point in the Asset instance .
7,882
public function deploy ( Asset $ asset ) { $ outputBasename = $ this -> computeOutputBasename ( $ asset ) ; $ fullPath = $ this -> destinationPath . DIRECTORY_SEPARATOR . $ outputBasename ; $ saving = file_put_contents ( $ fullPath , $ asset -> getContents ( ) ) ; if ( $ saving === false ) { throw new PhassetsInternalException ( 'file_put_contents() could not write to ' . $ fullPath . '. It is writable?' ) ; } $ objectUrl = $ this -> baseUrl . '/' . $ outputBasename ; $ asset -> setOutputUrl ( $ objectUrl ) ; }
Given an Asset instance try to deploy is using internal rules of this deployer and update Asset s property outputUrl .
7,883
public function isSupported ( ) { $ this -> destinationPath = $ this -> configurator -> getConfig ( 'filesystem_deployer' , 'destination_path' ) ; $ this -> baseUrl = $ this -> configurator -> getConfig ( 'filesystem_deployer' , 'base_url' ) ; $ this -> trigger = $ this -> configurator -> getConfig ( 'filesystem_deployer' , 'changes_trigger' ) ; if ( $ this -> destinationPath === null ) { throw new PhassetsInternalException ( __CLASS__ . ': no "destination_path" setting found' ) ; } if ( ! is_dir ( $ this -> destinationPath ) || ! is_writable ( $ this -> destinationPath ) ) { throw new PhassetsInternalException ( __CLASS__ . ": 'destination_path' ({$this->destinationPath}) is " . 'either not a valid dir, nor writable.' ) ; } }
This must throw a PhassetsInternalException if the current configuration doesn t allow this deployer to deploy processed assets .
7,884
public function compile ( $ lessFile , $ basePath = null ) { try { $ basePath = $ this -> _prepareBasepath ( $ basePath , dirname ( $ lessFile ) ) ; $ cache = new Cache ( $ this -> _options ) ; $ cache -> setFile ( $ lessFile , $ basePath ) ; $ isExpired = $ cache -> isExpired ( ) ; $ isForce = $ this -> _options -> get ( 'force' , false , 'bool' ) ; if ( $ isForce || $ cache -> isExpired ( ) ) { $ result = $ this -> _driver -> compile ( $ lessFile , $ basePath ) ; $ cache -> save ( $ result ) ; } $ isExpired = ( $ isForce ) ? true : $ isExpired ; $ return = [ FS :: clean ( $ cache -> getFile ( ) , '/' ) , $ isExpired ] ; } catch ( \ Exception $ e ) { $ message = 'Less error: ' . $ e -> getMessage ( ) ; throw new Exception ( $ message ) ; } return $ return ; }
Compile less file .
7,885
public static function getVariableValues ( Schema $ schema , array $ asts , array $ inputs ) { $ values = [ ] ; foreach ( $ asts as $ ast ) { $ variable = $ ast -> get ( 'variable' ) -> get ( 'name' ) -> get ( 'value' ) ; $ values [ $ variable ] = self :: getvariableValue ( $ schema , $ ast , isset ( $ inputs [ $ variable ] ) ? $ inputs [ $ variable ] : NULL ) ; } return $ values ; }
Prepares an object map of variables of the correct type based on the provided variable definitions and arbitrary input . If the input cannot be coerced to match the variable definitions a Error will be thrown .
7,886
protected static function getVariableValue ( Schema $ schema , VariableDefinition $ definition , $ input ) { $ type = TypeInfo :: typeFromAST ( $ schema , $ definition -> get ( 'type' ) ) ; if ( ! $ type ) { return NULL ; } if ( self :: isValidValue ( $ type , $ input ) ) { if ( ! isset ( $ input ) ) { $ default = $ definition -> get ( 'defaultValue' ) ; if ( $ default ) { return self :: coerceValueAST ( $ type , $ default ) ; } } return self :: coerceValue ( $ type , $ input ) ; } throw new \ Exception ( sprintf ( 'Variable $%s expected value of different type.' , $ definition -> get ( 'variable' ) -> get ( 'name' ) -> get ( 'value' ) ) ) ; }
Given a variable definition and any value of input return a value which adheres to the variable definition or throw an error .
7,887
protected static function isValidValue ( TypeInterface $ type , $ value ) { if ( $ type instanceof NonNullModifier ) { if ( NULL === $ value ) { return FALSE ; } return self :: isValidValue ( $ type -> getWrappedType ( ) , $ value ) ; } if ( $ value === NULL ) { return TRUE ; } if ( $ type instanceof ListModifier ) { $ itemType = $ type -> getWrappedType ( ) ; if ( is_array ( $ value ) ) { foreach ( $ value as $ item ) { if ( ! self :: isValidValue ( $ itemType , $ item ) ) { return FALSE ; } } return TRUE ; } else { return self :: isValidValue ( $ itemType , $ value ) ; } } if ( $ type instanceof InputObjectType ) { $ fields = $ type -> getFields ( ) ; foreach ( $ fields as $ fieldName => $ field ) { if ( ! self :: isValidValue ( $ field -> getType ( ) , isset ( $ value [ $ fieldName ] ) ? $ value [ $ fieldName ] : NULL ) ) { return FALSE ; } } return TRUE ; } if ( $ type instanceof ScalarType || $ type instanceof EnumType ) { return NULL !== $ type -> coerce ( $ value ) ; } return FALSE ; }
Given a type and any value return true if that value is valid .
7,888
protected static function coerceValue ( TypeInterface $ type , $ value ) { if ( $ type instanceof NonNullModifier ) { return self :: coerceValue ( $ type -> getWrappedType ( ) , $ value ) ; } if ( ! isset ( $ value ) ) { return NULL ; } if ( $ type instanceof ListModifier ) { $ itemType = $ type -> getWrappedType ( ) ; if ( is_array ( $ value ) ) { return array_map ( function ( $ item ) use ( $ itemType ) { return Values :: coerceValue ( $ itemType , $ item ) ; } , $ value ) ; } else { return [ self :: coerceValue ( $ itemType , $ value ) ] ; } } if ( $ type instanceof InputObjectType ) { $ fields = $ type -> getFields ( ) ; $ object = [ ] ; foreach ( $ fields as $ fieldName => $ field ) { $ fieldValue = self :: coerceValue ( $ field -> getType ( ) , $ value [ $ fieldName ] ) ; $ object [ $ fieldName ] = $ fieldValue === NULL ? $ field -> getDefaultValue ( ) : $ fieldValue ; } return $ object ; } if ( $ type instanceof ScalarType || $ type instanceof EnumType ) { $ coerced = $ type -> coerce ( $ value ) ; if ( NULL !== $ coerced ) { return $ coerced ; } } return NULL ; }
Given a type and any value return a runtime value coerced to match the type .
7,889
protected static function coerceValueAST ( TypeInterface $ type , $ ast , $ variables = NULL ) { if ( $ type instanceof NonNullModifier ) { return self :: coerceValueAST ( $ type -> getWrappedType ( ) , $ ast , $ variables ) ; } if ( ! $ ast ) { return NULL ; } if ( $ ast :: KIND === Node :: KIND_VARIABLE ) { $ variableName = $ ast -> get ( 'name' ) -> get ( 'value' ) ; if ( ! isset ( $ variables , $ variables [ $ variableName ] ) ) { return NULL ; } return $ variables [ $ variableName ] ; } if ( $ type instanceof ListModifier ) { $ itemType = $ type -> getWrappedType ( ) ; if ( $ ast :: KIND === Node :: KIND_ARRAY_VALUE ) { $ tmp = [ ] ; foreach ( $ ast -> get ( 'values' ) as $ itemAST ) { $ tmp [ ] = self :: coerceValueAST ( $ itemType , $ itemAST , $ variables ) ; } return $ tmp ; } else { return [ self :: coerceValueAST ( $ itemType , $ ast , $ variables ) ] ; } } if ( $ type instanceof InputObjectType ) { $ fields = $ type -> getFields ( ) ; if ( $ ast :: KIND !== Node :: KIND_OBJECT_VALUE ) { return NULL ; } $ asts = array_reduce ( $ ast -> get ( 'fields' ) , function ( $ carry , $ field ) { $ carry [ $ field -> get ( 'name' ) -> get ( 'value' ) ] = $ field ; return $ carry ; } , [ ] ) ; $ object = [ ] ; foreach ( $ fields as $ name => $ item ) { $ field = $ asts [ $ name ] ; $ fieldValue = self :: coerceValueAST ( $ item -> getType ( ) , $ field ? $ field -> get ( 'value' ) : NULL , $ variables ) ; $ object [ $ name ] = $ fieldValue === NULL ? $ item -> getDefaultValue ( ) : $ fieldValue ; } return $ object ; } if ( $ type instanceof ScalarType || $ type instanceof EnumType ) { $ coerced = $ type -> coerceLiteral ( $ ast ) ; if ( isset ( $ coerced ) ) { return $ coerced ; } } return NULL ; }
Given a type and a value AST node known to match this type build a runtime value .
7,890
public function close ( ) { if ( isset ( $ this -> zip ) ) { $ this -> zip -> close ( ) ; $ this -> zip = null ; } }
Release the zip resource .
7,891
public function prepend ( ContainerBuilder $ container ) { $ configs = array ( 'bazinga_geocoder' => array ( 'providers' => array ( 'google_maps' => null ) ) , 'doctrine' => array ( 'orm' => array ( 'dql' => array ( 'numeric_functions' => array ( 'GEO_DISTANCE' => 'Craue\GeoBundle\Doctrine\Query\Mysql\GeoDistance' ) ) ) ) ) ; foreach ( $ configs as $ name => $ config ) { $ container -> prependExtensionConfig ( $ name , $ config ) ; } }
Configure sensitive defaults for other bundles
7,892
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof ApiLogQuery ) { return $ criteria ; } $ query = new ApiLogQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
Returns a new ApiLogQuery object .
7,893
public function filterByDtCall ( $ dtCall = null , $ comparison = null ) { if ( is_array ( $ dtCall ) ) { $ useMinMax = false ; if ( isset ( $ dtCall [ 'min' ] ) ) { $ this -> addUsingAlias ( ApiLogPeer :: DT_CALL , $ dtCall [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ dtCall [ 'max' ] ) ) { $ this -> addUsingAlias ( ApiLogPeer :: DT_CALL , $ dtCall [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( ApiLogPeer :: DT_CALL , $ dtCall , $ comparison ) ; }
Filter the query on the dt_call column
7,894
public function filterByLastResponse ( $ lastResponse = null , $ comparison = null ) { return $ this -> addUsingAlias ( ApiLogPeer :: LAST_RESPONSE , $ lastResponse , $ comparison ) ; }
Filter the query on the last_response column
7,895
public function encrypt ( $ plaintext , $ key ) { $ inputData = cryptoHelpers :: convertStringToByteArray ( $ plaintext ) ; $ keyAsNumbers = cryptoHelpers :: toNumbers ( bin2hex ( $ key ) ) ; $ keyLength = count ( $ keyAsNumbers ) ; $ iv = cryptoHelpers :: generateSharedKey ( 16 ) ; $ encrypted = AES :: encrypt ( $ inputData , AES :: modeOfOperation_CBC , $ keyAsNumbers , $ keyLength , $ iv ) ; $ retVal = $ encrypted [ 'originalsize' ] . self :: SEPARATOR_CRYPTO_PARTS . cryptoHelpers :: toHex ( $ iv ) . self :: SEPARATOR_CRYPTO_PARTS . cryptoHelpers :: toHex ( $ encrypted [ 'cipher' ] ) ; return self :: IDENTIFIER . self :: SEPARATOR_ALGORITHM . $ retVal ; }
encrypts the given plain text with a key
7,896
public function decrypt ( $ encrypted , $ key ) { if ( empty ( $ encrypted ) ) return null ; list ( $ identifier , $ input ) = explode ( self :: SEPARATOR_ALGORITHM , $ encrypted , 2 ) ; if ( $ identifier !== self :: IDENTIFIER ) throw new Exception ( 'Encryption can not be decrypted. Unsupported identifier: ' . $ identifier ) ; $ cipherSplit = explode ( self :: SEPARATOR_CRYPTO_PARTS , $ input ) ; $ originalSize = intval ( $ cipherSplit [ 0 ] ) ; $ iv = cryptoHelpers :: toNumbers ( $ cipherSplit [ 1 ] ) ; $ cipherText = $ cipherSplit [ 2 ] ; $ cipherIn = cryptoHelpers :: toNumbers ( $ cipherText ) ; $ keyAsNumbers = cryptoHelpers :: toNumbers ( bin2hex ( $ key ) ) ; $ keyLength = count ( $ keyAsNumbers ) ; $ decrypted = AES :: decrypt ( $ cipherIn , $ originalSize , AES :: modeOfOperation_CBC , $ keyAsNumbers , $ keyLength , $ iv ) ; $ hexDecrypted = cryptoHelpers :: toHex ( $ decrypted ) ; $ retVal = pack ( "H*" , $ hexDecrypted ) ; return $ retVal ; }
decrypts a message
7,897
protected function edebug ( $ str ) { if ( ! $ this -> SMTPDebug ) { return ; } switch ( $ this -> Debugoutput ) { case 'error_log' : error_log ( $ str ) ; break ; case 'html' : echo htmlentities ( preg_replace ( '/[\r\n]+/' , '' , $ str ) , ENT_QUOTES , $ this -> CharSet ) . "<br>\n" ; break ; case 'echo' : default : echo $ str . "\n" ; } }
Output debugging info via user - defined method . Only if debug output is enabled .
7,898
public function addAttachment ( $ path , $ name = '' , $ encoding = 'base64' , $ type = '' , $ disposition = 'attachment' ) { try { if ( ! @ is_file ( $ path ) ) { throw new phpmailerException ( $ this -> lang ( 'file_access' ) . $ path , self :: STOP_CONTINUE ) ; } if ( $ type == '' ) { $ type = self :: filenameToType ( $ path ) ; } $ filename = basename ( $ path ) ; if ( $ name == '' ) { $ name = $ filename ; } $ this -> attachment [ ] = array ( 0 => $ path , 1 => $ filename , 2 => $ name , 3 => $ encoding , 4 => $ type , 5 => false , 6 => $ disposition , 7 => 0 ) ; } catch ( phpmailerException $ exc ) { $ this -> setError ( $ exc -> getMessage ( ) ) ; $ this -> edebug ( $ exc -> getMessage ( ) ) ; if ( $ this -> exceptions ) { throw $ exc ; } return false ; } return true ; }
Add an attachment from a path on the filesystem . Returns false if the file could not be found or read .
7,899
public function encodeQ ( $ str , $ position = 'text' ) { $ pattern = '' ; $ encoded = str_replace ( array ( "\r" , "\n" ) , '' , $ str ) ; switch ( strtolower ( $ position ) ) { case 'phrase' : $ pattern = '^A-Za-z0-9!*+\/ -' ; break ; case 'comment' : $ pattern = '\(\)"' ; case 'text' : default : $ pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $ pattern ; break ; } $ matches = array ( ) ; if ( preg_match_all ( "/[{$pattern}]/" , $ encoded , $ matches ) ) { $ eqkey = array_search ( '=' , $ matches [ 0 ] ) ; if ( $ eqkey !== false ) { unset ( $ matches [ 0 ] [ $ eqkey ] ) ; array_unshift ( $ matches [ 0 ] , '=' ) ; } foreach ( array_unique ( $ matches [ 0 ] ) as $ char ) { $ encoded = str_replace ( $ char , '=' . sprintf ( '%02X' , ord ( $ char ) ) , $ encoded ) ; } } return str_replace ( ' ' , '_' , $ encoded ) ; }
Encode a string using Q encoding .