idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
14,600
public function addCustomProperty ( $ propertiesList ) { if ( $ propertiesList == '' ) throw new Exception ( 'Properties not specified' ) ; $ strURI = Product :: $ baseProductUri . '/slides/' . $ this -> getFileName ( ) . '/documentProperties' ; $ put_data = json_encode ( $ propertiesList ) ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'PUT' , 'json' , $ put_data ) ; $ json = json_decode ( $ responseStream ) ; return $ json ; }
Add custom document properties .
14,601
public function saveAs ( $ outputPath , $ saveFormat , $ jpegQuality = '' , $ storageName = '' , $ folder = '' ) { if ( $ outputPath == '' ) throw new Exception ( 'Output path not specified' ) ; if ( $ saveFormat == '' ) throw new Exception ( 'Save format not specified' ) ; $ strURI = Product :: $ baseProductUri . '/slides/' . $ this -> getFileName ( ) . '?format=' . $ saveFormat ; if ( $ folder != '' ) { $ strURI .= '&folder=' . $ folder ; } if ( $ storageName != '' ) { $ strURI .= '&storage=' . $ storageName ; } if ( $ jpegQuality != '' ) { $ strURI .= '&jpegQuality=' . $ jpegQuality ; } $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ output = $ outputPath . Utils :: getFileName ( $ this -> getFileName ( ) ) . '.' . $ saveFormat ; Utils :: saveFile ( $ responseStream , $ output ) ; return $ output ; } else return $ v_output ; }
saves the document into various formats .
14,602
public function saveSlideAs ( $ slideNumber , $ outputPath , $ saveFormat ) { if ( $ outputPath == '' ) throw new Exception ( 'Output path not specified' ) ; if ( $ saveFormat == '' ) throw new Exception ( 'Save format not specified' ) ; if ( $ slideNumber == '' ) throw new Exception ( 'Slide number not specified' ) ; $ strURI = Product :: $ baseProductUri . '/slides/' . $ this -> getFileName ( ) . '/slides/' . $ slideNumber . '?format=' . $ saveFormat ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ output = $ outputPath . Utils :: getFileName ( $ this -> getFileName ( ) ) . '_' . $ slideNumber . '.' . $ saveFormat ; Utils :: saveFile ( $ responseStream , $ output ) ; return $ output ; } else return $ v_output ; }
Saves a particular slide into various formats .
14,603
public function aspectRatio ( $ slideNumber ) { if ( $ slideNumber == '' ) throw new Exception ( 'Slide number not specified' ) ; $ strURI = Product :: $ baseProductUri . '/slides/' . $ this -> getFileName ( ) . '/slides/' . $ slideNumber ; $ signedURI = Utils :: sign ( $ strURI ) ; $ response = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ response ) ; if ( $ json -> Code == 200 ) return $ json -> Slide -> Width / $ json -> Slide -> Height ; else return false ; }
Get Aspect Ratio of a PowerPoint Slide
14,604
private function wantSymbol ( string $ name , bool $ isHidden = false , bool $ isInline = false ) : Symbol { if ( $ isInline ) { if ( ! isset ( $ this -> inline [ $ name ] ) && isset ( $ this -> symbols [ $ name ] ) ) { throw new GrammarException ( "Inline '$name' conflicts with token <$name> defined previously" ) ; } if ( isset ( $ this -> defines [ $ name ] ) ) { throw new GrammarException ( "Inline '$name' conflicts with DEFINE" ) ; } $ this -> inline [ $ name ] = $ name ; $ isHidden = true ; } else { if ( isset ( $ this -> inline [ $ name ] ) ) { throw new GrammarException ( "Token <$name> conflicts with inline '$name' defined previously" ) ; } if ( isset ( $ this -> defines [ $ name ] ) ) { throw new GrammarException ( "Token <$name> conflicts with DEFINE" ) ; } } return $ this -> symbols [ $ name ] [ $ isHidden ] ?? ( $ this -> symbols [ $ name ] [ $ isHidden ] = new Symbol ( $ name , true , $ isHidden ) ) ; }
Register a Symbol
14,605
public function getCalendars ( ) { $ strURI = Product :: $ baseProductUri . '/tasks/' . $ this -> getFileName ( ) . '/calendars/' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Calendars -> List ; else return false ; }
Get project calendar items . Each calendar item has a link to get full calendar representation in the project .
14,606
public function getCalendar ( $ calendarUid ) { if ( $ calendarUid == '' ) throw new Exception ( 'Calendar Uid not specified' ) ; $ strURI = Product :: $ baseProductUri . '/tasks/' . $ this -> getFileName ( ) . '/calendars/' . $ calendarUid ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Calendar ; else return false ; }
Get project calendar .
14,607
public function addCalendar ( $ jsonData ) { if ( $ jsonData == '' ) throw new Exception ( 'Data not specified' ) ; $ strURI = Product :: $ baseProductUri . '/tasks/' . $ this -> getFileName ( ) . '/calendars/' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , 'json' , $ jsonData ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Status == 'Created' ) return $ json -> CalendarItem ; else return false ; }
Add Calendar to Project
14,608
public function defines ( array $ defines ) : self { if ( ! $ defines ) { return $ this ; } $ dup_keys = array_intersect_key ( $ this -> defines , $ defines ) ; if ( $ dup_keys ) { throw new \ InvalidArgumentException ( "Cannot redefine defines: " . join ( ', ' , array_keys ( $ dup_keys ) ) ) ; } $ copy = clone $ this ; $ copy -> defines += $ defines ; return $ copy ; }
Create new Lexer extending this one with DEFINEs
14,609
public function whitespaces ( array $ whitespaces ) : self { if ( ! $ whitespaces ) { return $ this ; } $ copy = clone $ this ; $ copy -> whitespaces = array_merge ( $ copy -> whitespaces , $ whitespaces ) ; return $ copy ; }
Create new Lexer extending this one with whitespaces
14,610
public function fixed ( array $ fixed ) : self { if ( ! $ fixed ) { return $ this ; } $ new_fixed = $ this -> addNamedTokens ( $ this -> fixed , $ fixed , 'fixed' ) ; $ copy = clone $ this ; $ copy -> fixed = $ new_fixed ; return $ copy ; }
Create new Lexer extending this one with fixed tokens
14,611
public function inline ( array $ inline ) : self { if ( ! $ inline ) { return $ this ; } $ copy = clone $ this ; $ copy -> inlines = array_merge ( $ this -> inlines , $ inline ) ; return $ copy ; }
Create new Lexer extending this one with inline tokens
14,612
public function terminals ( array $ terminals ) : self { if ( ! $ terminals ) { return $ this ; } $ new_terminals = $ this -> addNamedTokens ( $ this -> regexpMap , $ terminals , 'terminal' ) ; $ copy = clone $ this ; $ copy -> regexpMap = $ new_terminals ; return $ copy ; }
Create new Lexer extending this one with terminals
14,613
public function modifiers ( string $ modifiers ) : self { if ( '' === $ modifiers ) { return $ this ; } $ copy = clone $ this ; $ copy -> modifiers .= $ modifiers ; return $ copy ; }
Create new Lexer extending this one with RegExp modifiers
14,614
private function addNamedTokens ( array $ oldTokens , array $ addTokens , string $ errorType ) : array { $ dup_keys = array_intersect_key ( $ oldTokens , $ addTokens ) ; if ( $ dup_keys ) { throw new \ InvalidArgumentException ( "Cannot redefine $errorType: " . join ( ', ' , array_keys ( $ dup_keys ) ) ) ; } return $ oldTokens + $ addTokens ; }
Extends array of named tokens
14,615
public function getAllAnnotations ( $ pageNumber ) { $ iTotalAnnotation = $ this -> GetAnnotationsCount ( $ pageNumber ) ; $ listAnnotations = array ( ) ; for ( $ index = 1 ; $ index <= $ iTotalAnnotation ; $ index ++ ) { array_push ( $ listAnnotations , $ this -> GetAnnotation ( $ pageNumber , $ index ) ) ; } return $ listAnnotations ; }
Gets list of all the annotations on a specified document page .
14,616
public function getAnnotationsCount ( $ pageNumber ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/pages/' . $ pageNumber . '/annotations' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return count ( $ json -> Annotations -> List ) ; }
Gets number of annotations on a specified document page .
14,617
public function getAnnotation ( $ pageNumber , $ annotationIndex ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/pages/' . $ pageNumber . '/annotations/' . $ annotationIndex ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Annotation ; }
Gets a specfied annotation on a specified document page .
14,618
public function getChildBookmarksCount ( $ parent ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/bookmarks/' . $ parent . '/bookmarks' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return count ( $ json -> Bookmarks -> List ) ; }
Gets number of child bookmarks in a specfied parent bookmark .
14,619
public function getChildBookmark ( $ parentIndex , $ childIndex ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/bookmarks/' . $ parentIndex . '/bookmarks/' . $ childIndex ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Bookmark ; }
Gets a specfied child Bookmark for selected parent bookmark in Pdf document .
14,620
public function isChildBookmark ( $ bookmarkIndex ) { if ( $ bookmarkIndex === '' ) throw new Exception ( 'bookmark index not specified' ) ; $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/bookmarks/' . $ bookmarkIndex ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Bookmark ; }
Checks whether selected bookmark is parent or child Gets a specfied child Bookmark for selected parent bookmark in Pdf document .
14,621
public function getAllBookmarks ( ) { $ iTotalBookmarks = $ this -> GetBookmarksCount ( ) ; $ listBookmarks = array ( ) ; for ( $ index = 1 ; $ index <= $ iTotalBookmarks ; $ index ++ ) { array_push ( $ listBookmarks , $ this -> GetBookmark ( $ index ) ) ; } return $ listBookmarks ; }
Gets list of all the Bookmarks in a Pdf document .
14,622
public function getAllAttachments ( ) { $ iTotalAttachments = $ this -> GetAttachmentsCount ( ) ; $ listAttachments = array ( ) ; for ( $ index = 1 ; $ index <= $ iTotalAttachments ; $ index ++ ) { array_push ( $ listAttachments , $ this -> GetAttachment ( $ index ) ) ; } return $ listAttachments ; }
Gets List of all the attachments in Pdf document .
14,623
public function getAttachmentsCount ( ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/attachments' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return count ( $ json -> Attachments -> List ) ; }
Gets number of attachments in the Pdf document .
14,624
public function getAttachment ( $ attachmentIndex ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/attachments/' . $ attachmentIndex ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Attachment ; }
Gets selected attachment from Pdf document .
14,625
public function downloadAttachment ( $ attachmentIndex ) { $ fileInformation = $ this -> GetAttachment ( $ attachmentIndex ) ; $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/attachments/' . $ attachmentIndex . '/download' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { Utils :: saveFile ( $ responseStream , AsposeApp :: $ outPutLocation . $ fileInformation -> Name ) ; return '' ; } else return $ v_output ; }
Download the selected attachment from Pdf document .
14,626
public function getAllLinks ( $ pageNumber ) { $ iTotalLinks = $ this -> GetLinksCount ( $ pageNumber ) ; $ listLinks = array ( ) ; for ( $ index = 1 ; $ index <= $ iTotalLinks ; $ index ++ ) { array_push ( $ listLinks , $ this -> GetLink ( $ pageNumber , $ index ) ) ; } return $ listLinks ; }
Gets list of all the links on a specified document page .
14,627
public function getLinksCount ( $ pageNumber ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/pages/' . $ pageNumber . '/links' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return count ( $ json -> Links -> List ) ; }
Gets number of links on a specified document page .
14,628
public function getLink ( $ pageNumber , $ linkIndex ) { $ strURI = Product :: $ baseProductUri . '/pdf/' . $ this -> getFileName ( ) . '/pages/' . $ pageNumber . '/links/' . $ linkIndex ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Link ; }
Gets a specfied link on a specified document page
14,629
public function checkPermission ( $ role , $ context ) { if ( ! is_string ( $ role ) ) { throw new \ TypeError ( 'The role parameter must be a string.' ) ; } if ( ! $ role ) { throw new \ InvalidArgumentException ( 'The role parameter cannot be empty.' ) ; } if ( ! is_array ( $ context ) ) { throw new \ TypeError ( 'The context parameter must be an array.' ) ; } if ( ! isset ( $ context [ 'user' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The context parameter must contain a "user" key to be able to evaluate the %s flag.' , $ this -> getName ( ) ) ) ; } $ user = $ context [ 'user' ] ; if ( is_string ( $ user ) ) { return false ; } if ( ! ( $ user instanceof SecurityUserInterface ) ) { throw new \ InvalidArgumentException ( 'The user class must implement Symfony\Component\Security\Core\User\UserInterface to be able to evaluate the user role.' ) ; } $ roles = $ user -> getRoles ( ) ; foreach ( $ roles as $ i => $ thisRole ) { if ( is_string ( $ thisRole ) ) { $ roles [ $ i ] = new SecurityRole ( $ thisRole ) ; } elseif ( ! ( $ thisRole instanceof SecurityRole ) ) { throw new \ InvalidArgumentException ( 'One of the roles of this user is neither a string nor an instance of Symfony\Component\Security\Core\Role\Role.' ) ; } } $ roles = $ this -> roleHierarchy -> getReachableRoles ( $ roles ) ; foreach ( $ roles as $ thisRole ) { $ strRole = ( string ) $ thisRole -> getRole ( ) ; if ( $ role === $ strRole ) { return true ; } } return false ; }
Checks if a role is present on a user in a given context
14,630
public function getAccountInformation ( ) { $ url = $ this -> url . self :: $ API_ROUTES [ 'ACCOUNT_INFO' ] ; $ url .= '?apiVersion=' . $ this -> apiVersion ; $ result = $ this -> doGet ( $ url , array ( ) , false ) ; if ( $ result !== null && is_object ( $ result ) ) { $ accountInfo = AccountInformation :: getFromJson ( $ result ) ; if ( $ accountInfo != null ) { return $ accountInfo ; } } return null ; }
Get information about the API account .
14,631
public function preparePayment ( ) { if ( $ this -> validate ( ) ) { $ trans = array ( ) ; foreach ( $ this -> fieldsJSON as $ fieldName ) { if ( is_array ( $ this -> { $ fieldName } ) || ! C2PValidate :: isEmpty ( $ this -> { $ fieldName } ) ) { $ trans [ $ fieldName ] = $ this -> { "get" . ucfirst ( $ fieldName ) } ( ) ; } } $ post_data = str_replace ( '\\/' , '/' , json_encode ( $ trans ) ) ; $ url = $ this -> url . Connect2PayClient :: $ API_ROUTES [ 'TRANS_PREPARE' ] ; $ result = $ this -> doPost ( $ url , $ post_data ) ; if ( $ result != null && is_array ( $ result ) ) { $ this -> returnCode = $ result [ 'code' ] ; $ this -> returnMessage = $ result [ 'message' ] ; if ( $ this -> returnCode == "200" ) { $ this -> merchantToken = $ result [ 'merchantToken' ] ; $ this -> customerToken = $ result [ 'customerToken' ] ; return true ; } else { $ this -> clientErrorMessage = $ this -> returnMessage ; } } } return false ; }
Prepare a new payment on the payment page application . This method will validate the payment data and call the payment page application to create a new payment . The fields returnCode returnMessage merchantToken and customerToken will be populated according to the call result .
14,632
public function getPaymentStatus ( $ merchantToken ) { if ( $ merchantToken != null && strlen ( trim ( $ merchantToken ) ) > 0 ) { $ url = $ this -> url . str_replace ( ":merchantToken" , $ merchantToken , Connect2PayClient :: $ API_ROUTES [ 'PAYMENT_STATUS' ] ) ; $ url .= '?apiVersion=' . $ this -> apiVersion ; $ result = $ this -> doGet ( $ url , array ( ) , false ) ; if ( $ result !== null && is_object ( $ result ) ) { $ this -> initStatus ( $ result ) ; if ( isset ( $ this -> status ) ) { return $ this -> status ; } } } return null ; }
Do a transaction status request on the payment page application .
14,633
public function refundTransaction ( $ transactionID , $ amount ) { if ( $ transactionID !== null && $ amount !== null && ( is_int ( $ amount ) || ctype_digit ( $ amount ) ) ) { $ url = $ this -> url . str_replace ( ":transactionID" , $ transactionID , Connect2PayClient :: $ API_ROUTES [ 'TRANS_REFUND' ] ) ; $ trans = array ( ) ; $ trans [ 'apiVersion' ] = $ this -> apiVersion ; $ trans [ 'amount' ] = intval ( $ amount ) ; $ result = $ this -> doPost ( $ url , json_encode ( $ trans ) ) ; $ this -> status = null ; if ( $ result != null && is_array ( $ result ) ) { $ this -> status = new RefundStatus ( ) ; if ( isset ( $ result [ 'code' ] ) ) { $ this -> status -> setCode ( $ result [ 'code' ] ) ; } if ( isset ( $ result [ 'message' ] ) ) { $ this -> status -> setMessage ( $ result [ 'message' ] ) ; } if ( isset ( $ result [ 'transactionID' ] ) ) { $ this -> status -> setTransactionID ( $ result [ 'transactionID' ] ) ; } if ( isset ( $ result [ 'operation' ] ) ) { $ this -> status -> setOperation ( $ result [ 'operation' ] ) ; } return $ this -> status ; } else { $ this -> clientErrorMessage = 'No result received from refund call' ; } } else { $ this -> clientErrorMessage = '"transactionID" must not be null, "amount" must be a positive integer' ; } return null ; }
Refund a transaction .
14,634
public function cancelSubscription ( $ subscriptionID , $ cancelReason ) { if ( $ subscriptionID != null && is_numeric ( $ subscriptionID ) && isset ( $ cancelReason ) && is_numeric ( $ cancelReason ) ) { $ url = $ this -> url . str_replace ( ":subscriptionID" , $ subscriptionID , Connect2PayClient :: $ API_ROUTES [ 'SUB_CANCEL' ] ) ; $ trans = array ( ) ; $ trans [ 'apiVersion' ] = $ this -> apiVersion ; $ trans [ 'cancelReason' ] = intval ( $ cancelReason ) ; $ result = $ this -> doPost ( $ url , json_encode ( $ trans ) ) ; if ( $ result != null && is_array ( $ result ) ) { $ this -> clientErrorMessage = $ result [ 'message' ] ; return $ result [ 'code' ] ; } } else { $ this -> clientErrorMessage = 'subscriptionID and cancelReason must be not null and numeric' ; } return null ; }
Do a subscription cancellation .
14,635
public function directAliPayProcess ( $ customerToken , $ request ) { if ( $ customerToken !== null && $ request !== null ) { $ url = $ this -> url . str_replace ( ":customerToken" , $ customerToken , Connect2PayClient :: $ API_ROUTES [ 'ALIPAY_DIRECT_PROCESS' ] ) ; $ request -> setApiVersion ( $ this -> getApiVersion ( ) ) ; $ result = $ this -> doPost ( $ url , json_encode ( $ request ) , false ) ; if ( $ result != null && is_object ( $ result ) ) { $ apiResponse = AliPayDirectProcessResponse :: getFromJson ( $ result ) ; return $ apiResponse ; } else { $ this -> clientErrorMessage = 'No result received from direct AliPay processing call: ' . $ this -> clientErrorMessage ; } } else { $ this -> clientErrorMessage = '"customerToken" and "request" must not be null' ; } return null ; }
Direct AliPay transaction process . Must be preceded by a payment prepare call .
14,636
public function validate ( ) { $ arrErrors = array ( ) ; $ arrErrors = $ this -> validateFields ( ) ; if ( sizeof ( $ arrErrors ) > 0 ) { foreach ( $ arrErrors as $ error ) { $ this -> clientErrorMessage .= $ error . " * " ; } return false ; } return true ; }
Validate the current transaction data .
14,637
public function addCartProduct ( $ cartProduct ) { if ( $ this -> orderCartContent == null || ! is_array ( $ this -> orderCartContent ) ) { $ this -> orderCartContent = array ( ) ; } if ( $ cartProduct instanceof CartProduct ) { $ this -> orderCartContent [ ] = $ cartProduct ; } return $ this ; }
Add a CartProduct in the orderCartContent .
14,638
public function setDefaultOrderCartContent ( ) { $ this -> orderCartContent = array ( ) ; $ product = new CartProduct ( ) ; $ product -> setCartProductId ( 0 ) -> setCartProductName ( "NA" ) ; $ product -> setCartProductUnitPrice ( 0 ) -> setCartProductQuantity ( 1 ) ; $ product -> setCartProductBrand ( "NA" ) -> setCartProductMPN ( "NA" ) ; $ product -> setCartProductCategoryName ( "NA" ) -> setCartProductCategoryID ( 0 ) ; $ this -> orderCartContent [ ] = $ product ; }
Set a default cart content to be used when anti fraud system is enabled and no real cart is known
14,639
private function validateFields ( ) { $ fieldsRequired = $ this -> fieldsRequired ; $ returnError = array ( ) ; foreach ( $ fieldsRequired as $ field ) { if ( C2PValidate :: isEmpty ( $ this -> { $ field } ) && ( ! is_numeric ( $ this -> { $ field } ) ) ) $ returnError [ ] = $ field . ' is empty' ; } foreach ( $ this -> fieldsSize as $ field => $ size ) { if ( isset ( $ this -> { $ field } ) && C2PValidate :: strlen ( $ this -> { $ field } ) > $ size ) $ returnError [ ] = $ field . ' Length ' . $ size ; } foreach ( $ this -> fieldsValidate as $ field => $ method ) { if ( ! C2PValidate :: isEmpty ( $ this -> { $ field } ) && ! call_user_func ( array ( 'PayXpert\Connect2Pay\C2PValidate' , $ method ) , $ this -> { $ field } ) ) $ returnError [ ] = $ field . ' = ' . $ this -> { $ field } ; } return $ returnError ; }
Check for fields validity
14,640
public function getLastInitialTransactionAttempt ( ) { $ lastAttempt = null ; if ( isset ( $ this -> transactions ) && is_array ( $ this -> transactions ) && count ( $ this -> transactions ) > 0 ) { foreach ( $ this -> transactions as $ transaction ) { if ( in_array ( $ transaction -> getOperation ( ) , array ( "sale" , "authorize" , "submission" ) ) && $ transaction -> getRefTransactionID ( ) == null ) { if ( $ lastAttempt == null || $ lastAttempt -> getDate ( ) < $ transaction -> getDate ( ) ) { $ lastAttempt = $ transaction ; } } } } return $ lastAttempt ; }
Return the last initial transaction attempt done for this payment . Only returns sale authorize or submission . Transactions with a referral are not considered by this method only initial transactions done by the customer to complete the payment .
14,641
public function getReferringTransactionAttempt ( $ refTransactionId , $ transactionOperation ) { $ attempts = $ this -> getReferringTransactionAttempts ( $ refTransactionId , $ transactionOperation ) ; if ( is_array ( $ attempts ) && count ( $ attempts ) > 0 ) { return $ attempts [ 0 ] ; } return null ; }
Get the transaction attempt referring to the provided transactionId with the given operation . In case several transactions are found will return the older one . Used for example to retrieve the collection for a submission .
14,642
public function getReferringTransactionAttempts ( $ refTransactionId , $ transactionOperation = null ) { $ attempts = array ( ) ; if ( $ refTransactionId !== null && isset ( $ this -> transactions ) && is_array ( $ this -> transactions ) && count ( $ this -> transactions ) > 0 ) { foreach ( $ this -> transactions as $ transaction ) { if ( $ refTransactionId === $ transaction -> getRefTransactionId ( ) && ( $ transactionOperation == null || $ transactionOperation === $ transaction -> getOperation ( ) ) ) { $ attempts [ ] = $ transaction ; } } if ( count ( $ attempts ) > 1 ) { usort ( $ attempts , function ( $ t1 , $ t2 ) { $ date1 = $ t1 -> getDate ( ) ; $ date2 = $ t2 -> getDate ( ) ; if ( $ date1 === null && $ date2 !== null ) { return - 1 ; } if ( $ date1 !== null && $ date2 === null ) { return 1 ; } return ( $ date1 === $ date2 ? 0 : ( $ date1 < $ date2 ? - 1 : 1 ) ) ; } ) ; } } return $ attempts ; }
Get the transaction attempts referring to the provided transactionId with the given operation .
14,643
public static function getISO4217CurrencyFromCode ( $ code ) { foreach ( Connect2PayCurrencyHelper :: $ currencies as $ currency => $ data ) { if ( $ data [ "code" ] == $ code ) { return $ currency ; } } return null ; }
Get a currency alphabetic code according to its numeric code in ISO4217
14,644
public static function getISO4217CurrencyCode ( $ currency ) { return ( array_key_exists ( $ currency , Connect2PayCurrencyHelper :: $ currencies ) ) ? Connect2PayCurrencyHelper :: $ currencies [ $ currency ] [ "code" ] : null ; }
Return the ISO4217 currency code .
14,645
public static function getCurrencySymbol ( $ currency ) { return ( array_key_exists ( $ currency , Connect2PayCurrencyHelper :: $ currencies ) ) ? Connect2PayCurrencyHelper :: $ currencies [ $ currency ] [ "symbol" ] : null ; }
Return the currency symbol .
14,646
public static function getCurrencyName ( $ currency ) { return ( array_key_exists ( $ currency , Connect2PayCurrencyHelper :: $ currencies ) ) ? Connect2PayCurrencyHelper :: $ currencies [ $ currency ] [ "currency" ] : null ; }
Return the currency name .
14,647
public static function getRate ( $ from , $ to ) { if ( ! Connect2PayCurrencyHelper :: currencyIsAvailable ( $ from ) || ! Connect2PayCurrencyHelper :: currencyIsAvailable ( $ to ) ) { return null ; } $ url = Connect2PayCurrencyHelper :: $ APIIO_SERVICE_URL . date ( "Y-m-d" ) . "?base=" . $ from . "&symbols=" . $ to ; $ curl = curl_init ( $ url ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; if ( Connect2PayCurrencyHelper :: $ proxy_host != null && Connect2PayCurrencyHelper :: $ proxy_port != null ) { curl_setopt ( $ curl , CURLOPT_PROXY , Connect2PayCurrencyHelper :: $ proxy_host ) ; curl_setopt ( $ curl , CURLOPT_PROXYPORT , Connect2PayCurrencyHelper :: $ proxy_port ) ; if ( Connect2PayCurrencyHelper :: $ proxy_username != null && Connect2PayCurrencyHelper :: $ proxy_password != null ) { curl_setopt ( $ curl , CURLOPT_PROXYAUTH , CURLAUTH_BASIC ) ; curl_setopt ( $ curl , CURLOPT_PROXYUSERPWD , Connect2PayCurrencyHelper :: $ proxy_username . ":" . Connect2PayCurrencyHelper :: $ proxy_password ) ; } } $ json = trim ( curl_exec ( $ curl ) ) ; $ httpCode = curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ; curl_close ( $ curl ) ; if ( $ httpCode == 200 ) { $ obj = json_decode ( $ json , true ) ; if ( is_array ( $ obj ) && array_key_exists ( "rates" , $ obj ) && array_key_exists ( $ to , $ obj [ 'rates' ] ) && preg_match ( '/^[0-9.]+$/' , $ obj [ 'rates' ] [ $ to ] ) ) { return $ obj [ 'rates' ] [ $ to ] ; } } return null ; }
Get a currency conversion rate from Yahoo webservice .
14,648
public static function convert ( $ amount , $ from , $ to , $ cent = true ) { $ rate = Connect2PayCurrencyHelper :: getRate ( $ from , $ to ) ; if ( $ rate != null ) { $ convert = $ amount * $ rate ; return ( $ cent ) ? round ( $ convert , 0 ) : round ( $ convert , 2 ) ; } return null ; }
Convert an amount from one currency to another
14,649
static public function isPaymentMethod ( $ paymentMethod ) { return ( ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_CREDITCARD || ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_TODITOCASH || ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_BANKTRANSFER || ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_DIRECTDEBIT || ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_WECHAT || ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_LINE || ( string ) $ paymentMethod == Connect2PayClient :: PAYMENT_METHOD_ALIPAY ) ; }
Payment Mean validity
14,650
static public function isPaymentNetwork ( $ paymentNetwork ) { return ( ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_SOFORT || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_PRZELEWY24 || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_IDEAL || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_GIROPAY || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_EPS || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_POLI || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_DRAGONPAY || ( string ) $ paymentNetwork == Connect2PayClient :: PAYMENT_NETWORK_TRUSTLY ) ; }
Payment network validity
14,651
static public function isPaymentMode ( $ paymentMode ) { return ( ( string ) $ paymentMode == Connect2PayClient :: PAYMENT_MODE_SINGLE || ( string ) $ paymentMode == Connect2PayClient :: PAYMENT_MODE_ONSHIPPING || ( string ) $ paymentMode == Connect2PayClient :: PAYMENT_MODE_RECURRENT || ( string ) $ paymentMode == Connect2PayClient :: PAYMENT_MODE_INSTALMENTS ) ; }
Payment Type validity
14,652
static public function isSubscriptionType ( $ subscriptionType ) { return ( ( string ) $ subscriptionType == Connect2PayClient :: SUBSCRIPTION_TYPE_NORMAL || ( string ) $ subscriptionType == Connect2PayClient :: SUBSCRIPTION_TYPE_INFINITE || ( string ) $ subscriptionType == Connect2PayClient :: SUBSCRIPTION_TYPE_ONETIME || ( string ) $ subscriptionType == Connect2PayClient :: SUBSCRIPTION_TYPE_LIFETIME ) ; }
Subscription Type validity
14,653
public static function strlen ( $ str ) { if ( is_array ( $ str ) ) return false ; if ( function_exists ( 'mb_strlen' ) ) return mb_strlen ( $ str , 'UTF-8' ) ; return strlen ( $ str ) ; }
strlen overloaded function
14,654
public function migrateModule ( ModuleContainerInterface $ module ) { $ path = $ module -> getPath ( [ 'database' , 'migrations' ] ) ; $ files = $ this -> migrator -> getMigrationFiles ( $ path ) ; $ ran = $ this -> migrator -> getRepository ( ) -> getRan ( ) ; $ migrations = array_diff ( $ files , $ ran ) ; $ this -> migrator -> requireFiles ( $ path , $ migrations ) ; foreach ( $ migrations as $ migration ) { $ this -> migrations [ ] = $ migration ; } return $ this ; }
Run migrations on a single module .
14,655
public function addModuleToReset ( ModuleContainerInterface $ module ) { $ path = $ module -> getPath ( [ 'database' , 'migrations' ] ) ; $ this -> migrator -> requireFiles ( $ path , $ this -> migrator -> getMigrationFiles ( $ path ) ) ; return $ this ; }
Reset migrations on a single module .
14,656
public function seedModule ( ModuleContainerInterface $ module , array $ data = [ ] ) { $ className = $ module -> getNamespace ( ) . '\\database\\seeds\\DatabaseSeeder' ; if ( ! class_exists ( $ className ) ) { return false ; } $ seeder = app ( $ className , $ data ) ; $ seeder -> run ( ) ; $ this -> output ( sprintf ( '<info>Seeded %s</info> ' , $ module ) ) ; return $ this ; }
Run seeds on a module .
14,657
public function removeAllProperties ( ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/documentProperties' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'DELETE' ) ; $ json = json_decode ( $ responseStream ) ; if ( is_object ( $ json ) ) { if ( $ json -> Code == 200 ) return true ; else return false ; } return true ; }
Remove All Document s properties .
14,658
public function createWorkbookFromTemplate ( $ templateFileName ) { if ( $ templateFileName == '' ) throw new Exception ( 'Template file not specified' ) ; $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '?templatefile=' . $ templateFileName ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'PUT' ) ; $ json = json_decode ( $ responseStream ) ; return $ json ; }
Create Empty Workbook .
14,659
public function getWorksheetsCount ( ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/worksheets' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return count ( $ json -> Worksheets -> WorksheetList ) ; }
Get Worksheets Count in Workbook .
14,660
public function getNamesCount ( ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/names' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Names -> Count ; }
Get Names Count in Workbook .
14,661
public function getDefaultStyle ( ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/defaultStyle' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Style ; }
Get Default Style .
14,662
public function encryptWorkbook ( $ encryptionType = 'XOR' , $ password = '' , $ keyLength = '' ) { $ fieldsArray [ 'EncriptionType' ] = $ encryptionType ; $ fieldsArray [ 'KeyLength' ] = $ keyLength ; $ fieldsArray [ 'Password' ] = $ password ; $ json = json_encode ( $ fieldsArray ) ; $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/encryption' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , 'json' , $ json ) ; $ json_response = json_decode ( $ responseStream ) ; if ( $ json_response -> Code == 200 ) return true ; else return false ; }
Encrypt workbook .
14,663
public function addWorksheet ( $ worksheetName ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/worksheets/' . $ worksheetName ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'PUT' , '' , '' ) ; $ json_response = json_decode ( $ responseStream ) ; if ( $ json_response -> Code == 201 ) return true ; else return false ; }
Add worksheet .
14,664
public function mergeWorkbook ( $ mergeFileName ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/merge?mergeWith=' . $ mergeFileName ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , '' , '' ) ; $ json_response = json_decode ( $ responseStream ) ; if ( $ json_response -> Code == 200 ) return true ; else return false ; }
Merge workbook .
14,665
public function autofitRows ( $ saveFormat = "" ) { $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '?isAutoFit=true' ; if ( $ saveFormat != '' ) $ strURI .= '&format=' . $ saveFormat ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { if ( $ saveFormat == '' ) { $ strURI = Product :: $ baseProductUri . '/storage/file/' . $ this -> getFileName ( ) ; $ signedURI = Utils :: Sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , "GET" , "" , "" ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ this -> getFileName ( ) ; Utils :: saveFile ( $ responseStream , $ outputFile ) ; } else { $ outputPath = AsposeApp :: $ outPutLocation . Utils :: getFileName ( $ this -> getFileName ( ) ) . '.' . $ saveFormat ; Utils :: saveFile ( $ responseStream , $ outputPath ) ; } return $ outputPath ; } else { return $ v_output ; } }
Auto Fit Rows in Excel Workbooks
14,666
public function saveAs ( $ strXML , $ outputFile ) { if ( $ strXML == '' ) throw new Exception ( 'XML Data not specified' ) ; if ( $ outputFile == '' ) throw new Exception ( 'Output Filename along extension not specified' ) ; $ strURI = Product :: $ baseProductUri . '/cells/' . $ this -> getFileName ( ) . '/saveAs?newfilename=' . $ outputFile ; $ signedURI = Utils :: Sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , "POST" , "XML" , $ strXML ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ strURI = Product :: $ baseProductUri . '/storage/file/' . $ outputFile ; $ signedURI = Utils :: Sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , "GET" , "" , "" ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ outputFile ; Utils :: saveFile ( $ responseStream , $ outputPath ) ; return $ outputPath ; } else { return $ v_output ; } }
Convert Excel Workbook with Additional Settings
14,667
public static function codepointToUtf8 ( $ codepoint ) { if ( $ codepoint < 0x80 ) { return chr ( $ codepoint ) ; } if ( $ codepoint < 0x800 ) { return chr ( $ codepoint >> 6 & 0x3f | 0xc0 ) . chr ( $ codepoint & 0x3f | 0x80 ) ; } if ( $ codepoint < 0x10000 ) { return chr ( $ codepoint >> 12 & 0x0f | 0xe0 ) . chr ( $ codepoint >> 6 & 0x3f | 0x80 ) . chr ( $ codepoint & 0x3f | 0x80 ) ; } if ( $ codepoint < 0x110000 ) { return chr ( $ codepoint >> 18 & 0x07 | 0xf0 ) . chr ( $ codepoint >> 12 & 0x3f | 0x80 ) . chr ( $ codepoint >> 6 & 0x3f | 0x80 ) . chr ( $ codepoint & 0x3f | 0x80 ) ; } throw new InvalidArgumentException ( "Asked for code outside of range ($codepoint)" ) ; }
Return UTF - 8 sequence for a given Unicode code point .
14,668
public static function hexSequenceToUtf8 ( $ sequence ) { $ utf = '' ; foreach ( explode ( ' ' , $ sequence ) as $ hex ) { $ n = hexdec ( $ hex ) ; $ utf .= self :: codepointToUtf8 ( $ n ) ; } return $ utf ; }
Take a series of space - separated hexadecimal numbers representing Unicode code points and return a UTF - 8 string composed of those characters . Used by UTF - 8 data generation and testing routines .
14,669
private static function utf8ToHexSequence ( $ str ) { $ buf = '' ; foreach ( preg_split ( '//u' , $ str , - 1 , PREG_SPLIT_NO_EMPTY ) as $ cp ) { $ buf .= sprintf ( '%04x ' , self :: utf8ToCodepoint ( $ cp ) ) ; } return rtrim ( $ buf ) ; }
Take a UTF - 8 string and return a space - separated series of hex numbers representing Unicode code points . For debugging .
14,670
public static function utf8ToCodepoint ( $ char ) { $ z = ord ( $ char [ 0 ] ) ; if ( $ z & 0x80 ) { $ length = 0 ; while ( $ z & 0x80 ) { $ length ++ ; $ z <<= 1 ; } } else { $ length = 1 ; } if ( $ length != strlen ( $ char ) ) { return false ; } if ( $ length == 1 ) { return ord ( $ char ) ; } $ z &= 0xff ; $ z >>= $ length ; for ( $ i = 1 ; $ i < $ length ; $ i ++ ) { $ z <<= 6 ; $ z |= ord ( $ char [ $ i ] ) & 0x3f ; } return $ z ; }
Determine the Unicode codepoint of a single - character UTF - 8 sequence . Does not check for invalid input data .
14,671
private function setContentLength ( ) { if ( ! is_string ( $ this -> body ) ) { return ; } $ headers = array_map ( 'strtolower' , array_keys ( $ this -> headers ) ) ; if ( ! in_array ( 'content-length' , $ headers , true ) ) { $ this -> headers [ 'Content-Length' ] = strlen ( $ this -> body ) ; } }
Adds if needed a Content - Length header field to the request .
14,672
public static function instantiate ( AttributeContract $ attribute , $ value ) { if ( ! $ attribute -> supportsValues ( ) ) { throw new AttributeMustSupportValues ( ) ; } return new static ( [ 'attribute_id' => $ attribute -> id , 'value' => $ value , ] ) ; }
Instantiates a new attribute value .
14,673
public static function instantiate ( ProductNumberContract $ productNumber , ProductTypeContract $ productType , $ description ) { return new static ( [ 'product_number' => $ productNumber , 'product_type_id' => $ productType -> id , 'description' => $ description , ] ) ; }
Instantiate a new product .
14,674
public function actionStart ( $ taskCommand = null ) { $ cron = $ this -> module -> get ( $ this -> module -> nameComponent ) ; $ cron -> eraseJobs ( ) ; $ common_params = $ this -> module -> params ; if ( ! empty ( $ this -> module -> tasks ) ) { if ( $ taskCommand && isset ( $ this -> module -> tasks [ $ taskCommand ] ) ) { $ task = $ this -> module -> tasks [ $ taskCommand ] ; $ params = ArrayHelper :: merge ( ArrayHelper :: getValue ( $ task , 'params' , [ ] ) , $ common_params ) ; $ cron -> addApplicationJob ( $ this -> module -> phpPath . ' ' . $ this -> getYiiPath ( ) , $ task [ 'command' ] , $ params , ArrayHelper :: getValue ( $ task , 'min' ) , ArrayHelper :: getValue ( $ task , 'hour' ) , ArrayHelper :: getValue ( $ task , 'day' ) , ArrayHelper :: getValue ( $ task , 'month' ) , ArrayHelper :: getValue ( $ task , 'dayofweek' ) , $ this -> module -> cronGroup ) ; } else { foreach ( $ this -> module -> tasks as $ commandName => $ task ) { $ params = ArrayHelper :: merge ( ArrayHelper :: getValue ( $ task , 'params' , [ ] ) , $ common_params ) ; $ cron -> addApplicationJob ( $ this -> module -> phpPath . ' ' . $ this -> getYiiPath ( ) , $ task [ 'command' ] , $ params , ArrayHelper :: getValue ( $ task , 'min' ) , ArrayHelper :: getValue ( $ task , 'hour' ) , ArrayHelper :: getValue ( $ task , 'day' ) , ArrayHelper :: getValue ( $ task , 'month' ) , ArrayHelper :: getValue ( $ task , 'dayofweek' ) , $ this -> module -> cronGroup ) ; } } $ cron -> saveCronFile ( ) ; $ cron -> saveToCrontab ( ) ; echo $ this -> ansiFormat ( 'Cron Tasks started.' . PHP_EOL , Console :: FG_GREEN ) ; } else { echo $ this -> ansiFormat ( 'Cron do not have Tasks.' . PHP_EOL , Console :: FG_GREEN ) ; } }
Start cron tasks
14,675
public function actionLs ( $ params = false ) { if ( false == $ params ) { $ cron = $ this -> module -> get ( $ this -> module -> nameComponent ) ; $ jobs = $ cron -> getJobs ( ) ; foreach ( $ jobs as $ index => $ job ) { if ( $ job -> getGroup ( ) == $ this -> module -> cronGroup ) echo '[' . $ index . '] ' . $ this -> ansiFormat ( $ job -> getJobCommand ( ) , Console :: FG_CYAN ) ; } } elseif ( $ params == 'a' || $ params == 'al' ) { echo shell_exec ( 'crontab -l' ) . PHP_EOL ; } }
List Application Cron Jobs ; a|al All jobs
14,676
protected function runActionHandler ( $ action , TreeNodeInterface $ node ) { if ( $ node instanceof Token ) { try { return $ action ( $ node -> getContent ( ) ) ; } catch ( AbortParsingException $ e ) { if ( null === $ e -> getOffset ( ) ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getOffset ( ) , $ e ) ; } throw $ e ; } catch ( AbortNodeException $ e ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getOffset ( ) , $ e ) ; } catch ( \ Throwable $ e ) { throw new \ RuntimeException ( "Action failure in `{$this::buildActionName($node)}`" , 0 , $ e ) ; } } $ args = [ ] ; foreach ( $ node -> getChildren ( ) as $ child ) { $ args [ ] = $ child -> made ( ) ; } try { $ result = $ action ( ... $ args ) ; } catch ( AbortNodeException $ e ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getChild ( $ e -> getNodeIndex ( ) - 1 ) -> getOffset ( ) , $ e ) ; } catch ( AbortParsingException $ e ) { if ( null === $ e -> getOffset ( ) ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getOffset ( ) , $ e ) ; } throw $ e ; } catch ( \ Throwable $ e ) { throw new \ RuntimeException ( "Action failure in `{$this::buildActionName($node)}`" , 0 , $ e ) ; } if ( $ this -> prune ) { $ node -> prune ( ) ; } return $ result ; }
Run action handler and return its result
14,677
public function extractTextFromLocalFile ( $ localFile , $ language , $ useDefaultDictionaries ) { $ strURI = Product :: $ baseProductUri . '/ocr/recognize?language=' . $ language . '&useDefaultDictionaries=' ; $ strURI .= ( $ useDefaultDictionaries ) ? 'true' : 'false' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ stream = file_get_contents ( $ localFile ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , 'json' , $ stream ) ; $ json = json_decode ( $ responseStream ) ; return $ json ; }
Extract OCR or HOCR Text from Images without using Storage .
14,678
public function extractTextFromUrl ( $ url , $ language , $ useDefaultDictionaries ) { $ strURI = Product :: $ baseProductUri . '/ocr/recognize?url=' . $ url . '&language=' . $ language . '&useDefaultDictionaries=' . $ useDefaultDictionaries ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI ) ; $ json = json_decode ( $ responseStream ) ; return $ json ; }
Extract OCR or HOCR Text from image url .
14,679
public function parse ( string $ input ) { $ pos = 0 ; while ( null !== ( $ match = $ this -> parseOne ( $ input , $ pos ) ) ) { $ pos = $ match -> nextOffset ; yield $ match -> token ; } }
Parse input text into Tokens
14,680
public function parseOne ( string $ input , int $ pos , array $ preferredTokens = [ ] ) : ? Match { $ length = strlen ( $ input ) ; if ( $ pos >= $ length ) { return null ; } $ this -> compile ( ) ; $ whitespace_length = $ this -> getWhitespaceLength ( $ input , $ pos ) ; if ( $ whitespace_length ) { $ pos += $ whitespace_length ; if ( $ pos >= $ length ) { return null ; } } $ match = $ this -> match ( $ input , $ pos , $ preferredTokens ) ; if ( ! $ match ) { $ near = substr ( $ input , $ pos , self :: DUMP_NEAR_LENGTH ) ; if ( "" === $ near || false === $ near ) { $ near = '<EOF>' ; } else { $ near = '"' . $ near . '"' ; } throw new UnknownCharacterException ( "Cannot parse none of expected tokens near $near" , $ pos ) ; } return $ match ; }
Parse one next token from input at the given offset
14,681
private function checkOverlappingNames ( array $ maps ) : void { $ index = 0 ; foreach ( $ maps as $ type => $ map ) { $ rest_maps = array_slice ( $ maps , $ index + 1 , null , true ) ; foreach ( $ rest_maps as $ type2 => $ map2 ) { $ same = array_intersect_key ( $ map , $ map2 ) ; if ( $ same ) { throw new \ InvalidArgumentException ( "Duplicating $type tokens and $type2 tokens: " . join ( ', ' , array_keys ( $ same ) ) ) ; } } ++ $ index ; } }
Check defined tokens for duplicating names
14,682
private function buildFixedAndInlines ( array $ fixedMap , array $ inlines ) : array { $ overlapped = array_intersect ( $ fixedMap , $ inlines ) ; if ( $ overlapped ) { throw new \ InvalidArgumentException ( "Duplicating fixed tokens and inline tokens strings: " . join ( ', ' , array_map ( 'json_encode' , $ overlapped ) ) ) ; } $ all = $ fixedMap + array_values ( $ inlines ) ; arsort ( $ all , SORT_STRING ) ; $ re_map = [ ] ; $ alias_name = 'a' ; foreach ( $ all as $ name => $ text ) { if ( is_int ( $ name ) ) { $ name = '_' . $ alias_name ; $ alias_name ++ ; $ this -> aliased [ $ name ] = $ text ; $ this -> aliasOf [ $ text ] = $ name ; } $ re_map [ $ name ] = $ this -> textToRegExp ( $ text ) ; } return $ re_map ; }
Build inline tokens into regexp map
14,683
private function buildMap ( array $ map , string $ join ) : string { $ alt = [ ] ; foreach ( $ map as $ type => $ re ) { $ alt [ ] = "(?<$type>$re)" ; } if ( false !== $ join ) { $ alt = join ( $ join , $ alt ) ; } return $ alt ; }
Build regexp map into one regexp part or list of ready parts
14,684
private function match ( string $ input , int $ pos , array $ preferredTokens ) : ? Match { $ current_regexp = $ this -> getRegexpForTokens ( $ preferredTokens ) ; if ( false === preg_match ( $ current_regexp , $ input , $ match , 0 , $ pos ) ) { $ error_code = preg_last_error ( ) ; throw new \ RuntimeException ( "PCRE error #" . $ error_code . " for token at input pos $pos; REGEXP = $current_regexp" , $ error_code ) ; } if ( ! $ match ) { return null ; } $ full_match = $ match [ 0 ] ; if ( '' === $ full_match ) { throw new DevException ( 'Tokens should not match empty string' . '; context: `' . substr ( $ input , $ pos , 10 ) . '`' . '; expected: ' . json_encode ( $ preferredTokens ) . "; REGEXP: $current_regexp" ) ; } foreach ( $ match as $ key => $ value ) { if ( null === $ value || '' === $ value || ( 0 !== $ key && is_int ( $ key ) ) ) { unset ( $ match [ $ key ] ) ; } } $ named = $ match ; unset ( $ named [ 0 ] ) ; if ( 1 !== count ( $ named ) ) { throw new InternalException ( 'Match with multiple named group' ) ; } $ content = reset ( $ named ) ; $ type = key ( $ named ) ; $ is_inline = false ; if ( isset ( $ this -> aliased [ $ type ] ) ) { $ type = $ this -> aliased [ $ type ] ; $ is_inline = true ; } $ token = new Token ( $ type , $ content , $ match , $ pos , $ is_inline ) ; $ result = new Match ( ) ; $ result -> token = $ token ; $ result -> nextOffset = $ pos + strlen ( $ full_match ) ; return $ result ; }
Search a match in input text at a position
14,685
private function getWhitespaceLength ( string $ input , int $ pos ) : int { if ( $ this -> regexpWhitespace ) { if ( false === preg_match ( $ this -> regexpWhitespace , $ input , $ match , 0 , $ pos ) ) { $ error_code = preg_last_error ( ) ; throw new \ RuntimeException ( "PCRE error #$error_code for whitespace at input pos $pos" . '; REGEXP = ' . $ this -> regexpWhitespace , $ error_code ) ; } if ( $ match ) { return strlen ( $ match [ 0 ] ) ; } } return 0 ; }
Search a presens of whitespaces in input text in a position
14,686
private function checkMapNames ( array $ map ) : void { $ names = array_keys ( $ map ) ; $ bad_names = preg_grep ( self :: RE_NAME , $ names , PREG_GREP_INVERT ) ; if ( $ bad_names ) { throw new \ InvalidArgumentException ( 'Bad names: ' . join ( ', ' , $ bad_names ) ) ; } }
Check names in regexps map for validity
14,687
private static function validateRegExp ( string $ regExp , string $ displayName ) : void { set_error_handler ( [ __CLASS__ , 'convertErrorToException' ] , E_WARNING ) ; try { if ( false === preg_match ( $ regExp , null ) ) { throw new \ InvalidArgumentException ( "PCRE error in $displayName RegExp: $regExp" , preg_last_error ( ) ) ; } } catch ( \ ErrorException $ e ) { throw new \ InvalidArgumentException ( "PCRE error in $displayName RegExp: " . $ e -> getMessage ( ) . "; RegExp: $regExp" , preg_last_error ( ) , $ e ) ; } finally { restore_error_handler ( ) ; } }
Validate given RegExp
14,688
protected function textToRegExp ( string $ text ) : string { if ( false === strpos ( $ this -> modifiers , 'x' ) || ! preg_match ( '~[\\s/#]|\\\\E~' , $ text ) ) { return preg_quote ( $ text , '/' ) ; } return '\\Q' . strtr ( $ text , [ '\\E' => '\\E\\\\\\QE' , '/' => '\\E\\/\\Q' ] ) . '\\E' ; }
Escape plain text to be a RegExp matching the text
14,689
public static function compare ( Symbol $ a , Symbol $ b ) : int { return ( $ a -> isTerminal - $ b -> isTerminal ) ? : strcmp ( $ a -> name , $ b -> name ) ; }
Compares two symbols
14,690
public static function compareList ( array $ a , array $ b ) : int { foreach ( $ a as $ i => $ symbol ) { if ( ! isset ( $ b [ $ i ] ) ) { return 1 ; } $ result = static :: compare ( $ symbol , $ b [ $ i ] ) ; if ( $ result ) { return $ result ; } } if ( count ( $ b ) > count ( $ a ) ) { return - 1 ; } return 0 ; }
Compare two lists of symbols
14,691
public static function dumpName ( string $ name ) : string { if ( self :: isLikeName ( $ name ) ) { return $ name ; } return self :: dumpInline ( $ name ) ; }
Dump symbol name for debug purpose
14,692
public static function dumpType ( string $ type ) : string { if ( self :: isLikeName ( $ type ) ) { return "<$type>" ; } return self :: dumpInline ( $ type ) ; }
Dump symbol type for debug purpose
14,693
public static function dumpInline ( string $ inline ) : string { if ( false === strpos ( $ inline , '"' ) ) { return '"' . $ inline . '"' ; } if ( false === strpos ( $ inline , "'" ) ) { return "'$inline'" ; } return "<$inline>" ; }
Dump inline symbol for debug purpose
14,694
public function getText ( ) { $ strURI = Product :: $ baseProductUri . '/words/' . $ this -> getFileName ( ) . '/textItems' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> TextItems -> List ; }
Gets Text items list from document .
14,695
public function getDrawingObject ( $ objectURI , $ outputPath ) { if ( $ outputPath == '' ) throw new Exception ( 'Output path not specified' ) ; if ( $ objectURI == '' ) throw new Exception ( 'Object URI not specified' ) ; $ url_arr = explode ( '/' , $ objectURI ) ; $ objectIndex = end ( $ url_arr ) ; $ strURI = $ objectURI ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) { if ( $ json -> DrawingObject -> ImageDataLink != '' ) { $ strURI = $ strURI . '/imageData' ; $ outputPath = $ outputPath . '\\DrawingObject_' . $ objectIndex . '.jpeg' ; } else if ( $ json -> DrawingObject -> OleDataLink != '' ) { $ strURI = $ strURI . '/oleData' ; $ outputPath = $ outputPath . '\\DrawingObject_' . $ objectIndex . '.xlsx' ; } else { $ strURI = $ strURI . '?format=jpeg' ; $ outputPath = $ outputPath . '\\DrawingObject_' . $ objectIndex . '.jpeg' ; } $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { Utils :: saveFile ( $ responseStream , $ outputPath ) ; return $ outputPath ; } else return $ v_output ; } else { return false ; } }
Get the drawing object from document .
14,696
public function getProtection ( ) { $ strURI = Product :: $ baseProductUri . '/words/' . $ this -> getFileName ( ) . '/protection' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ response = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ response ) ; if ( $ json -> Code == 200 ) return $ json -> ProtectionData -> ProtectionType ; else return false ; }
Get the Current Protection of the Word
14,697
protected function push ( Statement $ statement ) { $ maxConnections = $ this -> pool -> getConnectionLimit ( ) ; if ( $ this -> statements -> count ( ) > ( $ maxConnections / 10 ) ) { return ; } if ( $ maxConnections === $ this -> pool -> getConnectionCount ( ) && $ this -> pool -> getIdleConnectionCount ( ) === 0 ) { return ; } $ this -> statements -> push ( $ statement ) ; }
Only retains statements if less than 10% of the pool is consumed by this statement and the pool has available connections .
14,698
protected function pop ( ) : \ Generator { while ( ! $ this -> statements -> isEmpty ( ) ) { $ statement = $ this -> statements -> shift ( ) ; \ assert ( $ statement instanceof Statement ) ; if ( $ statement -> isAlive ( ) ) { return $ statement ; } } $ statement = yield ( $ this -> prepare ) ( $ this -> sql ) ; \ assert ( $ statement instanceof Statement ) ; return $ statement ; }
Coroutine returning a Statement object from the pool or creating a new Statement .
14,699
public function convertToImagebySize ( $ slideNumber , $ imageFormat , $ width , $ height ) { $ strURI = Product :: $ baseProductUri . '/slides/' . $ this -> getFileName ( ) . '/slides/' . $ slideNumber . '?format=' . $ imageFormat . '&width=' . $ width . '&height=' . $ height ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output == '' ) { $ outputPath = AsposeApp :: $ outPutLocation . 'output.' . $ imageFormat ; Utils :: saveFile ( $ responseStream , $ outputPath ) ; return $ outputPath ; } else { return $ v_output ; } }
Convert a particular slide into various formats with specified width and height .