idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
14,700 | public function convertWithAdditionalSettings ( $ saveFormat = 'pdf' , $ textCompression = '' , $ embedFullFonts = '' , $ compliance = '' , $ jpegQuality = '' , $ saveMetafilesAsPng = '' , $ pdfPassword = '' , $ embedTrueTypeFontsForASCII = '' ) { $ strURI = Product :: $ baseProductUri . '/slides/' . $ this -> getFileName ( ) . '?format=' . $ saveFormat ; if ( $ textCompression != '' ) $ strURI .= '&TextCompression=' . $ textCompression ; if ( $ embedFullFonts != '' ) $ strURI .= '&EmbedFullFonts=' . $ embedFullFonts ; if ( $ compliance != '' ) $ strURI .= '&Compliance=' . $ compliance ; if ( $ jpegQuality != '' ) $ strURI .= '&JpegQuality=' . $ jpegQuality ; if ( $ saveMetafilesAsPng != '' ) $ strURI .= '&SaveMetafilesAsPng=' . $ saveMetafilesAsPng ; if ( $ pdfPassword != '' ) $ strURI .= '&PdfPassword=' . $ pdfPassword ; if ( $ embedTrueTypeFontsForASCII != '' ) $ strURI .= '&EmbedTrueTypeFontsForASCII=' . $ embedTrueTypeFontsForASCII ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ outputPath = AsposeApp :: $ outPutLocation . Utils :: getFileName ( $ this -> getFileName ( ) ) . '.' . $ saveFormat ; Utils :: saveFile ( $ responseStream , $ outputPath ) ; return $ outputPath ; } else { return $ v_output ; } } | Convert PowerPoint Documents to other File Formats with Additional Settings |
14,701 | public function getTiffFrameProperties ( $ frameId ) { if ( $ frameId == '' ) throw new Exception ( 'Frame ID not specified' ) ; $ strURI = Product :: $ baseProductUri . '/imaging/' . $ this -> getFileName ( ) . '/frames/' . $ frameId . '/properties' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json ; else return false ; } | Get TIFF Frame Properties . |
14,702 | public function extractFrames ( $ frameId , $ outPath ) { if ( $ frameId == '' ) throw new Exception ( 'Frame ID not specified' ) ; if ( $ outPath == '' ) throw new Exception ( 'Output file not specified' ) ; $ strURI = Product :: $ baseProductUri . '/imaging/' . $ this -> getFileName ( ) . '/frames/' . $ frameId . '?saveOtherFrames=false&outPath=' . $ outPath ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ folder = new Folder ( ) ; $ outputStream = $ folder -> GetFile ( $ outPath ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ outPath ; Utils :: saveFile ( $ outputStream , $ outputPath ) ; return $ outputPath ; } else return $ v_output ; } | Extract Frame from a Multi - Frame TIFF Image . |
14,703 | public function cropFrame ( $ frameId , $ x , $ y , $ recWidth , $ recHeight , $ outPath ) { if ( $ frameId == '' ) throw new Exception ( 'Frame ID not specified' ) ; if ( $ x == '' ) throw new Exception ( 'X position not specified' ) ; if ( $ y == '' ) throw new Exception ( 'Y position not specified' ) ; if ( $ recWidth == '' ) throw new Exception ( 'Width of cropping rectangle not specified' ) ; if ( $ recHeight == '' ) throw new Exception ( 'Height of cropping rectangle not specified' ) ; if ( $ outPath == '' ) throw new Exception ( 'Output file not specified' ) ; $ strURI = Product :: $ baseProductUri . '/imaging/' . $ this -> getFileName ( ) . '/frames/' . $ frameId . '?saveOtherFrames=true&$x=' . $ x . '&y=' . $ y . '&rectWidth=' . $ recWidth . '&rectHeight=' . $ recHeight . '&outPath=' . $ outPath ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ folder = new Folder ( ) ; $ outputStream = $ folder -> GetFile ( $ outPath ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ outPath ; Utils :: saveFile ( $ outputStream , $ outputPath ) ; return $ outputPath ; } else return $ v_output ; } | Crop a TIFF Frame . |
14,704 | public function manipulateFrame ( $ frameId , $ rotateFlipMethod , $ newWidth , $ newHeight , $ x , $ y , $ rectWidth , $ rectHeight , $ outPath ) { if ( $ frameId == '' ) throw new Exception ( 'Frame ID not specified' ) ; if ( $ rotateFlipMethod == '' ) throw new Exception ( 'RotateFlip method not specified' ) ; if ( $ newWidth == '' ) throw new Exception ( 'New width not specified' ) ; if ( $ newHeight == '' ) throw new Exception ( 'New height not specified' ) ; if ( $ x == '' ) throw new Exception ( 'X position not specified' ) ; if ( $ y == '' ) throw new Exception ( 'Y position not specified' ) ; if ( $ rectWidth == '' ) throw new Exception ( 'Width of cropping rectangle not specified' ) ; if ( $ rectHeight == '' ) throw new Exception ( 'Height of cropping rectangle not specified' ) ; if ( $ outPath == '' ) throw new Exception ( 'Output file not specified' ) ; $ strURI = Product :: $ baseProductUri . '/imaging/' . $ this -> getFileName ( ) . '/frames/' . $ frameId . '?saveOtherFrames=false&rotateFlipMethod=' . $ rotateFlipMethod . '&newWidth=' . $ newWidth . '&newHeight=' . $ newHeight . '&x=' . $ x . '&y=' . $ y . '&rectWidth=' . $ rectWidth . '&rectHeight=' . $ rectHeight . '&outPath=' . $ outPath ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ folder = new Folder ( ) ; $ outputStream = $ folder -> GetFile ( $ outPath ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ outPath ; Utils :: saveFile ( $ outputStream , $ outputPath ) ; return $ outputPath ; } else return $ v_output ; } | Manipulate a Frame and Save the Modified Frame Along with Unmodified Frames . |
14,705 | public function checkFlag ( array $ context ) : bool { 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 UserInterface ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The user class must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.' , $ this -> getName ( ) ) ) ; } if ( ! isset ( $ context [ 'model' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Missing key "model" in context parameter. We cannot evaluate the %s flag without a model.' , $ this -> getName ( ) ) ) ; } $ model = $ context [ 'model' ] ; if ( is_string ( $ model ) && class_exists ( $ model ) ) { return false ; } if ( $ model instanceof UserInterface ) { return $ user -> getId ( ) === $ model -> getId ( ) ; } if ( $ model instanceof ModelInterface ) { $ author = $ model -> getAuthor ( ) ; if ( ! $ author ) { return true ; } if ( ! ( $ author instanceof UserInterface ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The author of the model must implement Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.' , $ this -> getName ( ) ) ) ; } return $ user -> getId ( ) === $ author -> getId ( ) ; } throw new \ InvalidArgumentException ( sprintf ( 'The model class must implement either Ordermind\LogicalAuthorizationBundle\Interfaces\ModelInterface or Ordermind\LogicalAuthorizationBundle\Interfaces\UserInterface to be able to evaluate the %s flag.' , $ this -> getName ( ) ) ) ; } | Checks if the author of a model is the same as the user in a given context . |
14,706 | public function shift ( TreeNodeInterface $ node , int $ stateIndex ) : void { $ item = new StackItem ( ) ; $ item -> state = $ stateIndex ; $ item -> node = $ node ; if ( $ this -> actions ) { $ this -> actions -> applyToNode ( $ node ) ; } $ this -> items [ ] = $ item ; $ this -> stateIndex = $ stateIndex ; $ this -> stateRow = $ this -> table -> getRow ( $ stateIndex ) ; } | Perform a Shift of a node into the stack |
14,707 | public function reduce ( ) : void { $ rule = $ this -> stateRow -> reduceRule ; if ( ! $ rule ) { throw new NoReduceException ( ) ; } $ reduce_count = count ( $ rule -> getDefinition ( ) ) ; $ total_count = count ( $ this -> items ) ; if ( $ total_count < $ reduce_count ) { throw new InternalException ( 'Not enough items in stack' ) ; } $ nodes = [ ] ; $ offset = null ; $ reduce_items = array_slice ( $ this -> items , - $ reduce_count ) ; foreach ( $ rule -> getDefinition ( ) as $ i => $ symbol ) { $ item = $ reduce_items [ $ i ] ; if ( $ item -> node -> getNodeName ( ) !== $ symbol -> getName ( ) ) { throw new InternalException ( 'Unexpected stack content' ) ; } if ( ! $ symbol -> isHidden ( ) ) { $ nodes [ ] = $ item -> node ; } if ( null === $ offset ) { $ offset = $ item -> node -> getOffset ( ) ; } } $ base_state_index = ( $ total_count > $ reduce_count ) ? $ this -> items [ $ total_count - 1 - $ reduce_count ] -> state : 0 ; $ base_state_row = $ this -> table -> getRow ( $ base_state_index ) ; $ new_symbol_name = $ rule -> getSubject ( ) -> getName ( ) ; $ new_node = new NonTerminal ( $ new_symbol_name , $ nodes , $ rule -> getTag ( ) , $ offset ) ; $ goto = $ base_state_row -> gotoSwitches ; if ( ! isset ( $ goto [ $ new_symbol_name ] ) ) { throw new InternalException ( 'No required state in GOTO table' ) ; } $ next_state = $ goto [ $ new_symbol_name ] ; array_splice ( $ this -> items , - $ reduce_count ) ; $ this -> shift ( $ new_node , $ next_state ) ; } | Perform the Reduce |
14,708 | public function setInstallmentDataBeforeAuthorization ( $ installmentQuantity ) { if ( $ this -> _calculator === null ) { throw new LocalizedException ( new Phrase ( 'You need to set an installment calculator befor prior to' . 'installments' ) ) ; } $ quote = $ this -> _getQuote ( ) ; $ interestRate = $ this -> _getCalculator ( ) -> getInterestRateForInstallment ( $ installmentQuantity ) ; $ interestAmount = $ this -> _getCalculator ( ) -> getInterestAmount ( $ this -> _getPaymentAmount ( ) , $ installmentQuantity ) ; $ baseinterestAmount = $ this -> _getCalculator ( ) -> getInterestAmount ( $ this -> _getBasePaymentAmount ( ) , $ installmentQuantity ) ; $ quote -> setGabrielqsInstallmentsQty ( $ installmentQuantity ) -> setGabrielqsInstallmentsInterestRate ( $ interestRate ) -> setGabrielqsInstallmentsInterestAmount ( $ interestAmount ) -> setBaseGabrielqsInstallmentsInterestAmount ( $ baseinterestAmount ) -> setTotalsCollectedFlag ( false ) -> collectTotals ( ) ; } | Sets interest info on order object with help from the installments order manager class |
14,709 | public function getInstallmentConfig ( ) { $ installmentConfig = $ this -> _dataObjectFactory -> create ( ) ; $ maxInstallmentQty = $ this -> getMaximumInstallmentQuantity ( ) ; $ installmentConfig -> maximumInstallmentQty = $ maxInstallmentQty ; $ installmentConfig -> minimumInstallmentAmount = $ this -> getMinimumInstallmentAmount ( ) ; $ installmentConfig -> interestRate = $ this -> getInterestRate ( ) ; $ installments = [ ] ; for ( $ curInstallment = 1 ; ( $ curInstallment <= 12 && $ curInstallment <= $ maxInstallmentQty ) ; $ curInstallment ++ ) { if ( $ curInstallment === 1 ) { $ installments [ $ curInstallment ] = $ this -> _dataObjectFactory -> create ( ) ; $ installments [ $ curInstallment ] -> interestRate = $ this -> getInterestRateForInstallment ( $ curInstallment ) ; $ installments [ $ curInstallment ] -> numberInstallments = 1 ; $ installments [ $ curInstallment ] -> minimumAmountNoInterest = null ; continue ; } else { $ installments [ $ curInstallment ] = $ this -> _dataObjectFactory -> create ( ) ; $ installments [ $ curInstallment ] -> interestRate = $ this -> getInterestRateForInstallment ( $ curInstallment ) ; $ installments [ $ curInstallment ] -> numberInstallments = $ curInstallment ; $ installments [ $ curInstallment ] -> minimumAmountNoInterest = $ this -> getMinimumAmountNoInterest ( $ curInstallment ) ; } } $ installmentConfig -> installments = $ installments ; return $ installmentConfig ; } | Returns all the information that another class might need to compute interest rates and installments |
14,710 | public function getInstallments ( $ paymentAmount ) { $ installments = [ ] ; $ this -> setPaymentAmount ( $ paymentAmount ) ; $ maxInstallmentQty = $ this -> getMaximumInstallmentQuantity ( ) ; for ( $ curInstallment = 1 ; ( $ curInstallment <= 12 && $ curInstallment <= $ maxInstallmentQty ) ; $ curInstallment ++ ) { if ( $ curInstallment === 1 ) { $ installments [ $ curInstallment ] = $ this -> _dataObjectFactory -> create ( ) ; $ installments [ $ curInstallment ] -> installmentValue = $ paymentAmount ; $ installments [ $ curInstallment ] -> numberInstallments = 1 ; $ installments [ $ curInstallment ] -> interestsApplied = false ; continue ; } else { $ totalAmountAfterInterest = $ this -> getTotalAmountAfterInterest ( $ curInstallment ) ; $ amountPerInstallment = $ totalAmountAfterInterest / $ curInstallment ; $ minimumInstallmentAmount = $ this -> getMinimumInstallmentAmount ( ) ; if ( $ amountPerInstallment < $ minimumInstallmentAmount ) { continue ; } $ installments [ $ curInstallment ] = $ this -> _dataObjectFactory -> create ( ) ; $ installments [ $ curInstallment ] -> installmentValue = $ amountPerInstallment ; $ installments [ $ curInstallment ] -> numberInstallments = $ curInstallment ; $ installments [ $ curInstallment ] -> interestsApplied = $ this -> isApplyInterest ( $ curInstallment ) ; } } return ( array ) $ installments ; } | Computes the installments for a given payment amount |
14,711 | public function getInterestAmount ( $ amount , $ installmentQuantity ) { $ minimumAmountNoInterest = $ this -> getMinimumAmountNoInterest ( $ installmentQuantity ) ; if ( ( $ minimumAmountNoInterest === null ) || ( $ minimumAmountNoInterest !== null ) && ( $ amount < $ minimumAmountNoInterest ) ) { $ interestRateForInstallment = $ this -> getInterestRateForInstallment ( $ installmentQuantity ) ; } else { $ interestRateForInstallment = 1 ; } $ totalInstallmentAmount = $ interestRateForInstallment * $ amount ; return ( $ totalInstallmentAmount - $ amount ) ; } | Returns the interest fee for a given amount and interest rate |
14,712 | public function getInterestRateForInstallment ( $ installments ) { $ interestRate = $ this -> getInterestRate ( ) ; $ computationInstallments = ( $ installments - 1 ) ; $ totalInterestRate = ( float ) pow ( $ interestRate , $ computationInstallments ) ; return $ totalInterestRate ; } | Given a number of installments returns the total interest rate do be applied |
14,713 | public function getMinimumAmountNoInterest ( $ installments ) { $ return = null ; foreach ( $ this -> _minimumAmountNoInterest as $ installmentQty => $ minOrderValue ) { if ( $ installmentQty == $ installments ) { $ return = ( float ) $ minOrderValue ; break ; } } return $ return ; } | Gets the minimum amount for which in the specified installment qty no interest should apply |
14,714 | public function getTotalAmountAfterInterest ( $ installments ) { $ return = $ amount = $ this -> getPaymentAmount ( ) ; if ( $ this -> isApplyInterest ( $ installments ) ) { $ return = ( $ amount ) * $ this -> getInterestRateForInstallment ( $ installments ) ; } return $ return ; } | Computes the maximum amount after interest is applied |
14,715 | public function isApplyInterest ( $ installments ) { $ return = true ; $ interestRate = $ this -> getInterestRate ( ) ; $ paymentAmount = $ this -> getPaymentAmount ( ) ; if ( ( $ installments > 1 ) && ( $ interestRate > 1 ) ) { $ minimumOrderValueNoInterest = $ this -> getMinimumAmountNoInterest ( $ installments ) ; if ( ( $ paymentAmount > $ minimumOrderValueNoInterest ) && ( $ minimumOrderValueNoInterest !== null ) ) { $ return = false ; } } return $ return ; } | Decides whether interest should be applied to the current payment |
14,716 | public function reset ( ) { $ this -> url = null ; $ this -> params = array ( ) ; $ this -> options = array ( ) ; $ this -> callType = null ; $ this -> responseType = null ; } | Resets all variables to prepare for fresh object creation if needed for looping . |
14,717 | public function setParams ( $ params ) { if ( is_array ( $ params ) ) { foreach ( $ params as $ key => $ param ) { $ this -> params [ $ key ] = $ param ; } } } | Expects an array of one or more key = > value pairs of params to later add to the URL string |
14,718 | public function setOptions ( $ options ) { if ( is_array ( $ options ) ) { foreach ( $ options as $ key => $ option ) { $ this -> options [ $ key ] = $ option ; } } } | Expects an array of one or more key = > value pairs of params to later use as options with curl to alter the way curl is used . |
14,719 | public function doApiCall ( ) { $ parsedResponse = array ( ) ; $ jsonResponse = false ; $ curlUrl = $ this -> createUrl ( ) ; if ( $ curlUrl ) { $ jsonResponse = $ this -> submitCurlRequest ( $ curlUrl ) ; } if ( $ jsonResponse ) { $ parsedResponse = $ this -> parseJsonResponse ( $ jsonResponse ) ; } return $ parsedResponse ; } | This is a wrapper to execute the entire process of an API call . It initiates the creation of the URL and using the returned URL it initiates the curl request and the resulting JSON is then sent to the parser . The end result is a usable array . |
14,720 | public function createUrl ( ) { $ curlUrl = $ this -> url . '?' ; foreach ( $ this -> params as $ key => $ value ) { $ curlUrl .= $ key . '=' . $ value ; $ curlUrl .= '&' ; } return $ curlUrl ; } | Create the URL string complete with any params . |
14,721 | protected function submitCurlRequest ( $ curlUrl ) { $ session = curl_init ( ) ; curl_setopt ( $ session , CURLOPT_URL , $ curlUrl ) ; curl_setopt ( $ session , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ session , CURLOPT_RETURNTRANSFER , 1 ) ; if ( ! empty ( $ this -> options ) ) { foreach ( $ this -> options as $ key => $ value ) { curl_setopt ( $ session , $ key , $ value ) ; } } $ rawResponse = curl_exec ( $ session ) ; curl_close ( $ session ) ; return $ rawResponse ; } | Build the curl resource and execute it to return the raw result . |
14,722 | public static function processCommand ( $ url , $ method = 'GET' , $ headerType = 'XML' , $ src = '' , $ returnType = 'xml' ) { $ dispatcher = AsposeApp :: getEventDispatcher ( ) ; $ method = strtoupper ( $ method ) ; $ headerType = strtoupper ( $ headerType ) ; AsposeApp :: getLogger ( ) -> info ( "Aspose Cloud SDK: processCommand called" , array ( 'url' => $ url , 'method' => $ method , 'headerType' => $ headerType , 'src' => $ src , 'returnType' => $ returnType , ) ) ; $ session = curl_init ( ) ; curl_setopt ( $ session , CURLOPT_URL , $ url ) ; if ( $ method == 'GET' ) { curl_setopt ( $ session , CURLOPT_HTTPGET , 1 ) ; } else { curl_setopt ( $ session , CURLOPT_POST , 1 ) ; curl_setopt ( $ session , CURLOPT_POSTFIELDS , $ src ) ; curl_setopt ( $ session , CURLOPT_CUSTOMREQUEST , $ method ) ; } curl_setopt ( $ session , CURLOPT_HEADER , false ) ; if ( $ headerType == 'XML' ) { curl_setopt ( $ session , CURLOPT_HTTPHEADER , array ( 'Accept: application/' . $ returnType . '' , 'Content-Type: application/xml' , 'x-aspose-client: PHPSDK/v1.0' ) ) ; } else { curl_setopt ( $ session , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' , 'x-aspose-client: PHPSDK/v1.0' ) ) ; } curl_setopt ( $ session , CURLOPT_RETURNTRANSFER , true ) ; if ( preg_match ( '/^(https)/i' , $ url ) ) curl_setopt ( $ session , CURLOPT_SSL_VERIFYPEER , false ) ; $ event = new ProcessCommandEvent ( $ session ) ; $ dispatcher -> dispatch ( ProcessCommandEvent :: PRE_CURL , $ event ) ; $ result = curl_exec ( $ session ) ; $ headers = curl_getinfo ( $ session ) ; if ( substr ( $ headers [ 'http_code' ] , 0 , 1 ) != '2' ) { if ( curl_errno ( $ session ) !== 0 ) { throw new AsposeCurlException ( curl_strerror ( curl_errno ( $ session ) ) , $ headers , curl_errno ( $ session ) ) ; AsposeApp :: getLogger ( ) -> warning ( curl_strerror ( curl_errno ( $ session ) ) ) ; } else { throw new Exception ( $ result ) ; AsposeApp :: getLogger ( ) -> warning ( $ result ) ; } } else { if ( preg_match ( '/You have processed/i' , $ result ) || preg_match ( '/Your pricing plan allows only/i' , $ result ) ) { AsposeApp :: getLogger ( ) -> alert ( $ result ) ; throw new Exception ( $ result ) ; } } $ event = new ProcessCommandEvent ( $ session , $ result ) ; $ dispatchedEvent = $ dispatcher -> dispatch ( ProcessCommandEvent :: POST_CURL , $ event ) ; curl_close ( $ session ) ; return $ dispatchedEvent -> getResult ( ) ; } | Performs Aspose Api Request . |
14,723 | public static function uploadFileBinary ( $ url , $ localFile , $ headerType = 'XML' , $ method = 'PUT' ) { $ method = strtoupper ( $ method ) ; $ headerType = strtoupper ( $ headerType ) ; AsposeApp :: getLogger ( ) -> info ( "Aspose Cloud SDK: uploadFileBinary called" , array ( 'url' => $ url , 'localFile' => $ localFile , 'headerType' => $ headerType , 'method' => $ method , ) ) ; $ fp = fopen ( $ localFile , 'r' ) ; $ session = curl_init ( ) ; curl_setopt ( $ session , CURLOPT_VERBOSE , 1 ) ; curl_setopt ( $ session , CURLOPT_USERPWD , 'user:password' ) ; curl_setopt ( $ session , CURLOPT_URL , $ url ) ; if ( $ method == 'PUT' ) { curl_setopt ( $ session , CURLOPT_PUT , 1 ) ; } else { curl_setopt ( $ session , CURLOPT_UPLOAD , true ) ; curl_setopt ( $ session , CURLOPT_CUSTOMREQUEST , 'POST' ) ; } curl_setopt ( $ session , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ session , CURLOPT_HEADER , false ) ; if ( $ headerType == 'XML' ) { curl_setopt ( $ session , CURLOPT_HTTPHEADER , array ( 'Accept: application/xml' , 'Content-Type: application/xml' , 'x-aspose-client: PHPSDK/v1.0' ) ) ; } else { curl_setopt ( $ session , CURLOPT_HTTPHEADER , array ( 'Content-Type: application/json' , 'x-aspose-client: PHPSDK/v1.0' ) ) ; } curl_setopt ( $ session , CURLOPT_INFILE , $ fp ) ; curl_setopt ( $ session , CURLOPT_INFILESIZE , filesize ( $ localFile ) ) ; $ result = curl_exec ( $ session ) ; curl_close ( $ session ) ; fclose ( $ fp ) ; return $ result ; } | Performs Aspose Api Request to Upload a file . |
14,724 | public static function saveFile ( $ input , $ fileName ) { $ fh = fopen ( $ fileName , 'w' ) or die ( 'cant open file' ) ; fwrite ( $ fh , $ input ) ; fclose ( $ fh ) ; } | Saves the files |
14,725 | public function getFieldCount ( $ jsonResponse , $ fieldName ) { $ arr = json_decode ( $ jsonResponse ) -> { $ fieldName } ; return count ( $ arr , COUNT_RECURSIVE ) ; } | This method parses XML for a count of a particular field . |
14,726 | private function getVideo ( ) { $ videoUrl = 'http://file.api.wechat.com/cgi-bin/media/get?access_token=' . $ this -> getAccessToken ( ) . '&media_id=' . $ this -> event -> get ( 'MediaId' ) ; return [ new Video ( $ videoUrl , $ this -> event ) ] ; } | Create the video url from an incoming message . |
14,727 | public function read ( $ symbology ) { $ strURI = Product :: $ baseProductUri . '/barcode/' . $ this -> getFileName ( ) . '/recognize?' . ( ! isset ( $ symbology ) || trim ( $ symbology ) === '' ? 'type=' : 'type=' . $ symbology ) ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Barcodes ; } | Reads all or specific barcodes from images . |
14,728 | public function readFromLocalImage ( $ localImage , $ remoteFolder , $ barcodeReadType ) { $ folder = new Folder ( ) ; $ folder -> UploadFile ( $ localImage , $ remoteFolder ) ; $ data = $ this -> ReadR ( basename ( $ localImage ) , $ remoteFolder , $ barcodeReadType ) ; return $ data ; } | Read Barcode from Local Image . |
14,729 | public function readR ( $ remoteImageName , $ remoteFolder , $ readType ) { $ uri = $ this -> uriBuilder ( $ remoteImageName , $ remoteFolder , $ readType ) ; $ signedURI = Utils :: sign ( $ uri ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> Barcodes ; } | Read Barcode from Aspose Cloud Storage |
14,730 | public function uriBuilder ( $ remoteImage , $ remoteFolder , $ readType ) { $ uri = Product :: $ baseProductUri . '/barcode/' ; if ( $ remoteImage != null ) $ uri .= $ remoteImage . '/' ; $ uri .= 'recognize?' ; if ( $ readType == 'AllSupportedTypes' ) $ uri .= 'type=' ; else $ uri .= 'type=' . $ readType ; if ( $ remoteFolder != null && trim ( $ remoteFolder ) === '' ) $ uri .= '&format=' . $ remoteFolder ; if ( $ remoteFolder != null && trim ( $ remoteFolder ) === '' ) $ uri .= '&folder=' . $ remoteFolder ; return $ uri ; } | Build uri . |
14,731 | public function readFromURL ( $ url , $ symbology ) { if ( $ url == '' ) throw new Exception ( 'URL not specified' ) ; if ( $ symbology == '' ) throw new Exception ( 'Symbology not specified' ) ; $ strURI = Product :: $ baseProductUri . '/barcode/recognize?type=' . $ symbology . '&url=' . $ url ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Barcodes ; else return false ; } | Read Barcode from External Image URL |
14,732 | public function readSpecificRegion ( $ symbology , $ rectX , $ rectY , $ rectWidth , $ rectHeight ) { if ( $ symbology == '' ) throw new Exception ( 'Symbology not specified' ) ; if ( $ rectX == '' ) throw new Exception ( 'X position not specified' ) ; if ( $ rectY == '' ) throw new Exception ( 'Y position not specified' ) ; if ( $ rectWidth == '' ) throw new Exception ( 'Width not specified' ) ; if ( $ rectHeight == '' ) throw new Exception ( 'Height not specified' ) ; $ strURI = Product :: $ baseProductUri . '/barcode/' . $ this -> getFileName ( ) . '/recognize?type=' . $ symbology . '&rectX=' . $ rectX . '&rectY=' . $ rectY . '&rectWidth=' . $ rectWidth . '&rectHeight=' . $ rectHeight ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Barcodes ; else return false ; } | Read Barcode from Specific Region of Image |
14,733 | public function readWithChecksum ( $ symbology , $ checksumValidation ) { if ( $ symbology == '' ) throw new Exception ( 'Symbology not specified' ) ; if ( $ checksumValidation == '' ) throw new Exception ( 'Checksum not specified' ) ; $ strURI = Product :: $ baseProductUri . '/barcode/' . $ this -> getFileName ( ) . '/recognize?type=' . $ symbology . '&checksumValidation=' . $ checksumValidation ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Barcodes ; else return false ; } | Recognize Barcode with Checksum Option from Storage |
14,734 | public function readByAlgorithm ( $ symbology , $ binarizationHints ) { if ( $ symbology == '' ) throw new Exception ( 'Symbology not specified' ) ; if ( $ binarizationHints == '' ) throw new Exception ( 'Binarization Hints count not specified' ) ; $ strURI = Product :: $ baseProductUri . '/barcode/' . $ this -> getFileName ( ) . '/recognize?type=' . $ symbology . '&BinarizationHints=' . $ binarizationHints ; $ signedURI = Utils :: sign ( $ strURI ) ; $ response = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ response ) ; if ( $ json -> Code == 200 ) return $ json -> Barcodes ; else return false ; } | Read Barcodes by Applying Image Processing Algorithm |
14,735 | public function insertPageNumber ( $ fileName , $ alignment , $ format , $ isTop , $ setPageNumberOnFirstPage ) { if ( $ fileName == '' ) throw new Exception ( 'File not specified' ) ; $ fieldsArray = array ( 'Format' => $ format , 'Alignment' => $ alignment , 'IsTop' => $ isTop , 'SetPageNumberOnFirstPage' => $ setPageNumberOnFirstPage ) ; $ json = json_encode ( $ fieldsArray ) ; $ strURI = Product :: $ baseProductUri . '/words/' . $ fileName . '/insertPageNumbers' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'POST' , 'json' , $ json ) ; $ v_output = Utils :: validateOutput ( $ responseStream ) ; if ( $ v_output === '' ) { $ folder = new Folder ( ) ; $ outputStream = $ folder -> GetFile ( $ fileName ) ; $ outputPath = AsposeApp :: $ outPutLocation . $ fileName ; Utils :: saveFile ( $ outputStream , $ outputPath ) ; return $ outputPath ; } else return $ v_output ; } | Inserts page number field into the document . |
14,736 | public function getMailMergeFieldNames ( $ fileName ) { if ( $ fileName == '' ) throw new Exception ( 'No file name specified' ) ; $ strURI = Product :: $ baseProductUri . '/words/' . $ fileName . '/mailMergeFieldNames' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; return $ json -> FieldNames -> Names ; } | Gets all merge filed names from document . |
14,737 | public function query ( $ q = null ) { return Product :: where ( function ( $ query ) use ( $ q ) { if ( $ q ) { foreach ( explode ( ' ' , $ q ) as $ keyword ) { $ query -> where ( 'description' , 'like' , "%{$keyword}%" ) ; } } } ) -> orderBy ( 'description' ) -> paginate ( ) ; } | Queries the product catalogue and returns a paginated result . |
14,738 | public function save ( ProductContract $ product , array $ attributes = [ ] ) { $ result = $ product -> save ( ) ; $ details = [ ] ; foreach ( $ attributes as $ key => $ value ) { if ( $ value ) { $ details [ $ key ] = compact ( 'value' ) ; } } $ product -> attributes ( ) -> sync ( $ details ) ; return $ result ; } | Stores a product . |
14,739 | public function getResources ( ) { $ strURI = Product :: $ baseProductUri . '/tasks/' . $ this -> getFileName ( ) . '/resources/' ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Resources -> ResourceItem ; else return false ; } | Get project resource items . Each resource item has a link to get full resource representation in the project . |
14,740 | public function getResource ( $ resourceId ) { if ( $ resourceId == '' ) throw new Exception ( 'Resource ID not specified' ) ; $ strURI = Product :: $ baseProductUri . '/tasks/' . $ this -> getFileName ( ) . '/resources/' . $ resourceId ; $ signedURI = Utils :: sign ( $ strURI ) ; $ responseStream = Utils :: processCommand ( $ signedURI , 'GET' , '' , '' ) ; $ json = json_decode ( $ responseStream ) ; if ( $ json -> Code == 200 ) return $ json -> Resource ; else return false ; } | Get resource information . |
14,741 | protected function getStubContent ( $ name ) { if ( ! isset ( static :: $ stubs [ $ name ] ) ) { if ( ! is_file ( $ path = base_path ( "resources/stubs/vendor/models-generator/$name.stub" ) ) ) { $ path = __DIR__ . "/../../resources/stubs/$name.stub" ; } static :: $ stubs [ $ name ] = file_get_contents ( $ path ) ; } return static :: $ stubs [ $ name ] ; } | Retourne le contenu d un stub . |
14,742 | public static function handle ( $ model ) { if ( ! $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) return false ; return $ model -> save ( ) ; } | Handles a comment model when submitted |
14,743 | public function querySync ( ) { $ adapter = $ this -> _dbAdapter ? : Table :: getDefaultDbAdapter ( ) ; return $ adapter -> querySync ( $ this -> assemble ( ) , $ this -> _bind , $ this -> _consistency , $ this -> _options ) ; } | Executes the current query and returns the response |
14,744 | public function prepare ( ) { $ adapter = $ this -> _dbAdapter ? : Table :: getDefaultDbAdapter ( ) ; return $ adapter -> prepare ( $ this -> assemble ( ) ) ; } | Prepares the current query and returns the response |
14,745 | public function loadParameters ( ) { $ container = \ System :: getContainer ( ) ; if ( $ container -> hasParameter ( 'contao.video.valid_extensions' ) ) { $ GLOBALS [ 'TL_CONFIG' ] [ 'validVideoTypes' ] = implode ( ',' , $ container -> getParameter ( 'contao.video.valid_extensions' ) ) ; } if ( $ container -> hasParameter ( 'contao.audio.valid_extensions' ) ) { $ GLOBALS [ 'TL_CONFIG' ] [ 'validAudioTypes' ] = implode ( ',' , $ container -> getParameter ( 'contao.audio.valid_extensions' ) ) ; } } | Push symfony configuration into the contao config array |
14,746 | public static function getFromRequest ( $ create = true ) { $ sessionData = [ 'LastIP' => inet_pton ( $ _SERVER [ 'REMOTE_ADDR' ] ) , 'LastRequest' => time ( ) , ] ; if ( ! empty ( $ _COOKIE [ static :: $ cookieName ] ) ) { if ( $ Session = static :: getByHandle ( $ _COOKIE [ static :: $ cookieName ] ) ) { $ Session = static :: updateSession ( $ Session , $ sessionData ) ; } } if ( empty ( $ Session ) && ! empty ( $ _REQUEST [ static :: $ cookieName ] ) ) { if ( $ Session = static :: getByHandle ( $ _REQUEST [ static :: $ cookieName ] ) ) { $ Session = static :: updateSession ( $ Session , $ sessionData ) ; } } if ( ! empty ( $ Session ) ) { return $ Session ; } elseif ( $ create ) { return static :: create ( $ sessionData , true ) ; } else { return false ; } } | Gets or sets up a session based on current cookies . Will always update the current session s LastIP and LastRequest fields . |
14,747 | public function overviewAction ( Request $ request , FormFactoryInterface $ formFactory , ExtraFormBuilderInterface $ extraFormBuilder ) { $ formName = 'overview' ; $ data = $ request -> request -> get ( $ formName ) ; $ configurationRaw = $ data [ 'configuration' ] ; $ configuration = json_decode ( $ configurationRaw , true ) ; $ overviewBuilder = $ formFactory -> createNamedBuilder ( $ formName ) -> setAction ( $ this -> generateUrl ( 'idci_extra_form_editor_overview' ) ) -> add ( 'configuration' , HiddenType :: class , array ( 'data' => $ configurationRaw , ) ) ; $ form = $ extraFormBuilder -> build ( $ configuration , array ( ) , array ( ) , $ overviewBuilder ) -> add ( 'submit' , SubmitType :: class ) -> getForm ( ) ; if ( count ( $ data ) > 1 ) { $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { return new Response ( 'This form was well submitted' ) ; } } return $ this -> render ( '@IDCIExtraForm/Editor/overview.html.twig' , array ( 'form' => $ form -> createView ( ) , ) ) ; } | Overview action . |
14,748 | public function create ( $ filename = null , array $ options = [ ] , array $ plugins = [ ] ) { try { $ thumb = new PHPThumb ( $ filename , $ options , $ plugins ) ; } catch ( \ Exception $ exc ) { throw new Exception \ RuntimeException ( $ exc -> getMessage ( ) , $ exc -> getCode ( ) , $ exc ) ; } return $ thumb ; } | Create image thumbnail object |
14,749 | public function createReflection ( $ percent , $ reflection , $ white , $ border , $ borderColor ) { return new Plugins \ Reflection ( $ percent , $ reflection , $ white , $ border , $ borderColor ) ; } | Create reflection plugin |
14,750 | public function createWatermark ( PHPThumb $ watermarkThumb , array $ position = [ 0 , 0 ] , $ scale = .5 ) { return new Plugins \ Watermark ( $ watermarkThumb , $ position , $ scale ) ; } | Create a watermark on image |
14,751 | public function offsetSet ( $ columnName , $ value ) { if ( ! in_array ( $ columnName , static :: $ _primary ) ) { $ this -> _modifiedData [ $ columnName ] = $ value ; } parent :: offsetSet ( $ columnName , $ value ) ; } | Set row field value |
14,752 | public function onPreSerialize ( ObjectEvent $ event ) { $ configuredType = $ event -> getObject ( ) ; if ( $ configuredType instanceof ConfiguredType ) { try { $ configurationArray = json_decode ( $ configuredType -> getConfiguration ( ) , true ) ; $ extraFormType = $ this -> registry -> getType ( $ configurationArray [ 'form_type' ] ) ; $ configuredType -> setExtraFormType ( $ extraFormType ) ; } catch ( \ Exception $ e ) { return ; } } } | Method called on pre serialize event . |
14,753 | protected function outputComment ( $ comment ) { if ( $ this -> commentOptions instanceof \ Closure ) { $ options = call_user_func ( $ this -> commentOptions , $ comment ) ; } else { $ options = $ this -> commentOptions ; } $ options = ArrayHelper :: merge ( $ options , [ 'data-comment-id' => $ comment -> id ] ) ; if ( $ this -> useBootstrapClasses ) Html :: addCssClass ( $ options , 'media' ) ; echo Html :: beginTag ( 'div' , $ options ) ; $ wrapperOptions = [ 'class' => 'comment-wrapper' ] ; if ( $ this -> useBootstrapClasses ) Html :: addCssClass ( $ wrapperOptions , 'media-body' ) ; echo Html :: beginTag ( 'div' , $ wrapperOptions ) ; if ( ! empty ( $ comment -> title ) ) { $ titleOptions = [ 'class' => 'comment-title' ] ; if ( $ this -> useBootstrapClasses ) Html :: addCssClass ( $ titleOptions , 'media-heading' ) ; $ title = $ this -> encodeCommentTitle ? Html :: encode ( $ comment -> title ) : $ comment -> title ; echo Html :: tag ( $ this -> commentTitleTag , $ title , $ titleOptions ) ; } $ content = $ this -> encodeCommentContents ? Html :: encode ( $ comment -> content ) : $ comment -> content ; echo Html :: tag ( 'div' , $ content , [ 'class' => 'comment-content' ] ) ; echo Html :: beginTag ( 'dl' , [ 'class' => 'comment-meta' ] ) ; echo Html :: tag ( 'dt' , Yii :: t ( 'app' , 'Created' ) ) ; echo Html :: tag ( 'dd' , Yii :: $ app -> formatter -> asDatetime ( $ comment -> created ) ) ; if ( ! empty ( $ comment -> updated ) && $ comment -> updated != $ comment -> created ) { echo Html :: tag ( 'dt' , Yii :: t ( 'app' , 'Updated' ) ) ; echo Html :: tag ( 'dd' , Yii :: $ app -> formatter -> asDatetime ( $ comment -> updated ) ) ; } if ( ! empty ( $ comment -> user_id ) ) { $ author = $ this -> authorCallback === null ? $ comment -> created_by : call_user_func ( $ this -> authorCallback , $ comment -> created_by ) ; echo Html :: tag ( 'dt' , Yii :: t ( 'app' , 'Author' ) ) ; echo Html :: tag ( 'dd' , $ author ) ; } echo Html :: endTag ( 'dl' ) ; echo Html :: endTag ( 'div' ) ; echo Html :: endTag ( 'div' ) ; } | Outputs a single comment |
14,754 | public static function create ( $ dir , $ debug = false , array $ options = array ( ) ) { $ options = array_merge ( self :: $ defaultOptions , $ options ) ; $ commandString = $ options [ 'git_executable' ] . ' init' ; $ command = new $ options [ 'command_class' ] ( $ dir , $ commandString , $ debug ) ; $ command -> run ( ) ; $ repo = new self ( $ dir , $ debug , $ options ) ; return $ repo ; } | Create a new Git repository in filesystem running git init Returns the git repository wrapper |
14,755 | public static function cloneUrl ( $ url , $ dir , $ debug = false , array $ options = array ( ) ) { $ options = array_merge ( self :: $ defaultOptions , $ options ) ; $ commandString = $ options [ 'git_executable' ] . ' clone ' . escapeshellarg ( $ url ) . ' ' . escapeshellarg ( $ dir ) ; $ command = new $ options [ 'command_class' ] ( getcwd ( ) , $ commandString , $ debug ) ; $ command -> run ( ) ; $ repo = new self ( $ dir , $ debug , $ options ) ; return $ repo ; } | Clone a new Git repository in filesystem running git clone Returns the git repository wrapper |
14,756 | public function getCommits ( $ nbCommits = 10 ) { $ output = $ this -> git ( sprintf ( 'log -n %d --date=%s --format=format:%s' , $ nbCommits , $ this -> dateFormat , $ this -> logFormat ) ) ; return $ this -> parseLogsIntoArray ( $ output ) ; } | Return the result of git log formatted in a PHP array |
14,757 | private function parseLogsIntoArray ( $ logOutput ) { $ commits = array ( ) ; foreach ( explode ( "\n" , $ logOutput ) as $ line ) { $ infos = explode ( '|' , $ line ) ; $ commits [ ] = array ( 'id' => $ infos [ 0 ] , 'tree' => $ infos [ 1 ] , 'author' => array ( 'name' => $ infos [ 2 ] , 'email' => $ infos [ 3 ] ) , 'authored_date' => $ infos [ 4 ] , 'commiter' => array ( 'name' => $ infos [ 5 ] , 'email' => $ infos [ 6 ] ) , 'committed_date' => $ infos [ 7 ] , 'message' => $ infos [ 8 ] ) ; } return $ commits ; } | Convert a formatted log string into an array |
14,758 | public function setOutputPath ( $ path ) { if ( ! file_exists ( $ path ) ) { if ( ! mkdir ( $ path , 0755 , true ) ) { throw new BadOutputPathException ( sprintf ( 'Output path %s does not exist and could not be created!' , $ path ) , $ path ) ; } } else { if ( ! is_dir ( $ path ) ) { throw new BadOutputPathException ( sprintf ( 'The argument to `output` is expected to the a directory, but got %s!' , $ path ) , $ path ) ; } } $ this -> path = $ path ; } | Sets output path . |
14,759 | protected function processFoxyRequest ( HTTPRequest $ request ) { $ encryptedData = $ request -> postVar ( 'FoxyData' ) ? urldecode ( $ request -> postVar ( 'FoxyData' ) ) : urldecode ( $ request -> postVar ( 'FoxySubscriptionData' ) ) ; $ decryptedData = $ this -> decryptFeedData ( $ encryptedData ) ; $ this -> parseFeedData ( $ encryptedData , $ decryptedData ) ; $ this -> extend ( 'addIntegrations' , $ encryptedData ) ; } | Process a request after a transaction is completed via Foxy |
14,760 | private function parseFeedData ( $ encryptedData , $ decryptedData ) { $ orders = new \ SimpleXMLElement ( $ decryptedData ) ; foreach ( $ orders -> transactions -> transaction as $ transaction ) { $ this -> processTransaction ( $ transaction , $ encryptedData ) ; } } | Parse the XML data feed from Foxy to a SimpleXMLElement object |
14,761 | public function sso ( ) { $ fcsid = $ this -> request -> getVar ( 'fcsid' ) ; $ timestampNew = strtotime ( '+30 days' ) ; if ( ! $ Member = Security :: getCurrentUser ( ) ) { $ Member = new Member ( ) ; $ Member -> Customer_ID = 0 ; } $ auth_token = sha1 ( $ Member -> Customer_ID . '|' . $ timestampNew . '|' . FoxyCart :: getStoreKey ( ) ) ; $ config = FoxyStripeSetting :: current_foxystripe_setting ( ) ; if ( $ config -> CustomSSL ) { $ link = FoxyCart :: getFoxyCartStoreName ( ) ; } else { $ link = FoxyCart :: getFoxyCartStoreName ( ) . '.foxycart.com' ; } $ params = [ 'fc_auth_token' => $ auth_token , 'fcsid' => $ fcsid , 'fc_customer_id' => $ Member -> Customer_ID , 'timestamp' => $ timestampNew , ] ; $ httpQuery = http_build_query ( $ params ) ; $ this -> redirect ( "https://{$link}/checkout?$httpQuery" ) ; } | Single Sign on integration with FoxyCart . |
14,762 | private static function terminate ( ) : Promise { if ( self :: $ onClose === null ) { return Promise \ any ( [ ] ) ; } if ( self :: $ signalWatchers ) { foreach ( self :: $ signalWatchers as $ watcher ) { Loop :: cancel ( $ watcher ) ; } } $ onClose = self :: $ onClose ; self :: $ onClose = null ; $ promises = [ ] ; foreach ( $ onClose as $ callable ) { $ promises [ ] = call ( $ callable ) ; } return Promise \ any ( $ promises ) ; } | Invokes any termination callbacks . |
14,763 | private static function onReceivedMessage ( string $ event , $ data ) { foreach ( self :: $ onMessage [ $ event ] ?? [ ] as $ callback ) { asyncCall ( $ callback , $ data ) ; } } | Internal callback triggered when a message is received from the parent . |
14,764 | public static function createLogHandler ( string $ logLevel = LogLevel :: DEBUG , bool $ bubble = false ) : HandlerInterface { if ( ! self :: isWorker ( ) ) { throw new \ Error ( __FUNCTION__ . " should only be called when running as a worker. " . "Create your own log handler when not running as part of a cluster" ) ; } return new Internal \ IpcLogHandler ( self :: $ client , $ logLevel , $ bubble ) ; } | Creates a log handler in worker processes that communicates log messages to the parent . |
14,765 | public static function prepareOptions ( $ value , $ defaults = [ ] ) { if ( is_string ( $ value ) ) { $ value = json_decode ( $ value , true ) ; } return is_array ( $ value ) ? array_merge ( $ defaults , $ value ) : $ defaults ; } | Prepares options . |
14,766 | public function process ( DOMElement $ node , Item $ item ) { foreach ( $ this -> keys as $ key ) { $ item -> setExtra ( $ key , $ this -> getValue ( $ node , $ key ) ) ; } } | Execute the Aggregator |
14,767 | public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; if ( $ this -> owner -> PasswordEncryption != Security :: config ( ) -> get ( 'password_encryption_algorithm' ) ) { $ this -> resetPasswordEncryption ( ) ; } } | If the PasswordEncryption for the current membrer is different than the default update to the default . |
14,768 | public function setDataFromTransaction ( $ transaction ) { foreach ( $ this -> owner -> config ( ) -> get ( 'customer_map' ) as $ type => $ map ) { switch ( $ type ) { case 'int' : foreach ( $ map as $ foxyField => $ foxyStripeField ) { if ( ( int ) $ transaction -> { $ foxyField } ) { $ this -> owner -> { $ foxyStripeField } = ( int ) $ transaction -> { $ foxyField } ; } } break ; case 'string' : foreach ( $ map as $ foxyField => $ foxyStripeField ) { if ( ( string ) $ transaction -> { $ foxyField } ) { $ this -> owner -> { $ foxyStripeField } = ( string ) $ transaction -> { $ foxyField } ; } } break ; } } $ this -> owner -> PasswordEncryption = 'none' ; return $ this -> owner ; } | Use the config setting for Member mapping the Foxy fields to the SilverStripe fields . |
14,769 | private function resetPasswordEncryption ( ) { $ defaultEncryption = Security :: config ( ) -> get ( 'password_encryption_algorithm' ) ; if ( $ this -> owner -> PasswordEncryption != $ defaultEncryption ) { DB :: prepared_query ( 'UPDATE "Member" SET "PasswordEncryption" = ? WHERE ID = ?' , [ $ defaultEncryption , $ this -> owner -> ID ] ) ; } } | Reset the password encryption for the member to the config default . Passwords from Foxy are encrypted so the encryption type is set to none when processing the account from the data feed . Reseting is required for login to work on the website . |
14,770 | protected function buildConstraint ( array $ constraint ) { $ extraFormConstraint = $ this -> constraintRegistry -> getConstraint ( $ constraint [ 'extra_form_constraint' ] ) ; $ className = $ extraFormConstraint -> getClassName ( ) ; $ options = isset ( $ constraint [ 'options' ] ) ? $ constraint [ 'options' ] : array ( ) ; return new $ className ( $ options ) ; } | Build constraint . |
14,771 | protected function buildFormOptions ( $ name , array $ field , $ data = null ) { if ( isset ( $ field [ 'options' ] [ 'constraints' ] ) ) { $ field [ 'options' ] [ 'options' ] = $ this -> buildFormOptions ( '' , $ field [ 'options' ] ) ; } $ constraints = array ( ) ; foreach ( $ field [ 'constraints' ] as $ constraint ) { $ constraints [ ] = $ this -> buildConstraint ( $ constraint ) ; } $ field [ 'options' ] [ 'constraints' ] = $ constraints ; if ( null !== $ data && isset ( $ data [ $ name ] ) ) { $ field [ 'options' ] [ 'data' ] = $ data [ $ name ] ; } return $ field [ 'options' ] ; } | Build form options . |
14,772 | public function updatevalue ( \ SilverStripe \ Control \ HTTPRequest $ request ) { if ( $ request -> getVar ( 'Price' ) && FoxyStripeSetting :: current_foxystripe_setting ( ) -> CartValidation ) { $ vars = $ request -> getVars ( ) ; $ signedPrice = FoxyCart_Helper :: fc_hash_value ( $ this -> Code , 'price' , $ vars [ 'Price' ] , 'name' , false ) ; $ json = json_encode ( [ 'Price' => $ signedPrice ] ) ; $ this -> response -> setBody ( $ json ) ; $ this -> response -> addHeader ( 'Content-Type' , 'application/json' ) ; return $ this -> response ; } return 'false' ; } | create new encrypted price value based on user input . |
14,773 | public function addFeed ( $ channel , $ feed ) { if ( ! filter_var ( $ feed , FILTER_VALIDATE_URL ) ) { throw new LogicException ( 'You tried to add a invalid url.' ) ; } $ this -> feeds [ $ channel ] [ ] = $ feed ; } | Add feed to channel |
14,774 | public function getFeed ( $ channel ) { if ( ! isset ( $ this -> feeds [ $ channel ] ) ) { throw new LogicException ( 'You tried to get a not existent channel' ) ; } return $ this -> feeds [ $ channel ] ; } | Retrieve a channel |
14,775 | public function setFeed ( $ channel , $ feed ) { if ( ! is_string ( $ channel ) ) { throw new LogicException ( 'You tried to add a invalid channel.' ) ; } $ this -> feeds [ $ channel ] = array ( ) ; $ this -> addFeed ( $ channel , $ feed ) ; } | Set a channel |
14,776 | protected function get ( $ url ) { $ request = $ this -> http -> get ( $ url , array ( 'User-Agent' => self :: USER_AGENT . ' v.' . self :: VERSION ) ) ; $ response = $ request -> send ( ) ; if ( ! $ response -> isSuccessful ( ) ) { $ this -> log ( 'fail with ' . $ response -> getStatusCode ( ) . ' http code in url "' . $ url . '" ' ) ; return ; } $ this -> logger -> log ( LogLevel :: INFO , 'retrieved url "' . $ url . '" ' ) ; return $ response -> getBody ( ) ; } | Retrieve content from a resource |
14,777 | public function getPermutations ( array $ sourceDataSet , $ subsetSize = null ) { $ combinationMap = $ this -> _combination -> getCombinations ( $ sourceDataSet , $ subsetSize ) ; $ permutationsMap = [ ] ; foreach ( $ combinationMap as $ combination ) { $ permutationsMap = array_merge ( $ permutationsMap , $ this -> _findPermutations ( $ combination ) ) ; } return $ permutationsMap ; } | Creates all the possible permutations for the source data set . |
14,778 | private function _findPermutations ( $ combination ) { if ( count ( $ combination ) <= 1 ) { return [ $ combination ] ; } $ permutationList = [ ] ; $ startKey = $ this -> _processSubPermutations ( $ combination , $ permutationList ) ; $ key = key ( $ combination ) ; while ( $ key != $ startKey ) { $ this -> _processSubPermutations ( $ combination , $ permutationList ) ; $ key = key ( $ combination ) ; } return $ permutationList ; } | Recursive function to find the permutations of the given combination . |
14,779 | public function generate ( ) { $ this -> objElement = \ ElementsModel :: findPublishedByAlias ( $ this -> type ) ; if ( $ this -> objElement === null ) { return ; } if ( ! array_key_exists ( $ this -> objElement -> template , TemplateLoader :: getFiles ( ) ) ) { TemplateLoader :: addFile ( $ this -> objElement -> template , $ this -> objElement -> getRelated ( 'pid' ) -> templates ) ; } if ( TL_MODE == 'BE' && $ this -> objElement -> backendTpl ) { $ this -> strTemplate = $ this -> objElement -> backendTpl ; } else { $ this -> strTemplate = $ this -> objElement -> template ; } if ( TL_MODE == 'FE' && ! BE_USER_LOGGED_IN && ( $ this -> invisible || ( $ this -> start != '' && $ this -> start > time ( ) ) || ( $ this -> stop != '' && $ this -> stop < time ( ) ) ) ) { return '' ; } $ this -> Template = new Template ( $ this -> strTemplate ) ; $ this -> Template -> setData ( array ( 'id' => $ this -> id , 'pid' => $ this -> pid , 'ptable' => $ this -> ptable , 'element' => $ this -> type , 'tstamp' => $ this -> tstamp , 'start' => $ this -> start , 'stop' => $ this -> stop , 'protected' => $ this -> protected , 'inColumn' => $ this -> strColumn ) ) ; $ this -> compile ( ) ; return $ this -> Template -> parse ( ) ; } | Generate the pattern data and parse the elements template |
14,780 | protected function compile ( ) { $ colPattern = \ PatternModel :: findVisibleByPid ( $ this -> objElement -> id ) ; if ( $ colPattern === null ) { return ; } $ intPid = ( $ this -> origId ) ? $ this -> origId : $ this -> id ; $ colData = \ DataModel :: findByPid ( $ intPid ) ; if ( $ colData !== null ) { foreach ( $ colData as $ objData ) { $ arrData [ $ objData -> pattern ] = $ objData ; } } foreach ( $ colPattern as $ objPattern ) { if ( ! Pattern :: hasOutput ( $ objPattern -> type ) ) { continue ; } $ strClass = Pattern :: findClass ( $ objPattern -> type ) ; if ( ! class_exists ( $ strClass ) ) { System :: log ( 'Pattern element class "' . $ strClass . '" (pattern element "' . $ objPattern -> type . '") does not exist' , __METHOD__ , TL_ERROR ) ; } else { $ objPatternClass = new $ strClass ( $ objPattern ) ; $ objPatternClass -> pid = $ intPid ; $ objPatternClass -> Template = $ this -> Template ; $ objPatternClass -> data = $ arrData [ $ objPattern -> alias ] ; $ objPatternClass -> compile ( ) ; } } } | Compile the pattern |
14,781 | protected static function setPath ( $ path = null ) { if ( ! static :: $ pathStack ) { $ requestURI = parse_url ( $ _SERVER [ 'REQUEST_URI' ] ) ; static :: $ pathStack = static :: $ requestPath = explode ( '/' , ltrim ( $ requestURI [ 'path' ] , '/' ) ) ; } static :: $ _path = isset ( $ path ) ? $ path : static :: $ pathStack ; } | protected static methods |
14,782 | public function reverseTransform ( $ out ) { if ( null !== $ out && is_array ( $ out ) ) { return strtoupper ( sprintf ( '%s%s%s%s%s%s%s%s' , $ out [ 'c1' ] , $ out [ 'c2' ] , $ out [ 'c3' ] , $ out [ 'c4' ] , $ out [ 'c5' ] , $ out [ 'c6' ] , $ out [ 'c7' ] , $ out [ 'c8' ] ) ) ; } return $ out ; } | Reverse transforms . |
14,783 | public function setDefaultType ( $ value , DataContainer $ dc ) { $ db = Database :: getInstance ( ) ; if ( $ value ) { $ db -> prepare ( "UPDATE tl_elements SET defaultType='' WHERE NOT id=? AND pid=?" ) -> execute ( $ dc -> activeRecord -> id , $ dc -> activeRecord -> pid ) ; } return $ value ; } | Reset all other default type settings |
14,784 | public function checkTitle ( $ value , DataContainer $ dc ) { $ db = Database :: getInstance ( ) ; $ objTitle = $ db -> prepare ( "SELECT id FROM tl_elements WHERE NOT id=? AND pid=? AND title=?" ) -> execute ( $ dc -> activeRecord -> id , $ dc -> activeRecord -> pid , $ value ) ; if ( $ objTitle -> numRows > 0 ) { throw new Exception ( sprintf ( $ GLOBALS [ 'TL_LANG' ] [ 'ERR' ] [ 'aliasExists' ] , $ value ) ) ; } return $ value ; } | Check if the title is not already in use |
14,785 | public function generateAlias ( DataContainer $ dc ) { $ db = Database :: getInstance ( ) ; $ alias = \ StringUtil :: generateAlias ( \ ThemeModel :: findById ( $ dc -> activeRecord -> pid ) -> name . '-' . $ dc -> activeRecord -> title ) ; if ( $ alias != $ dc -> activeRecord -> alias ) { $ db -> prepare ( "UPDATE tl_elements SET alias=? WHERE id=?" ) -> execute ( $ alias , $ dc -> activeRecord -> id ) ; if ( $ dc -> activeRecord -> alias ) { $ db -> prepare ( "UPDATE tl_content SET type=? WHERE type=?" ) -> execute ( $ alias , $ dc -> activeRecord -> alias ) ; } } } | Auto - generate an element alias and adjust existing content in case the element is renamed |
14,786 | public function getContentElementTemplates ( DataContainer $ dc ) { $ arrTemplates = array ( ) ; foreach ( \ TemplateLoader :: getPrefixedFiles ( 'ce_' ) as $ strTemplate ) { $ arrTemplates [ $ strTemplate ] [ ] = 'root' ; } $ arrCustomized = glob ( TL_ROOT . '/templates/ce_*' ) ; if ( is_array ( $ arrCustomized ) ) { foreach ( $ arrCustomized as $ strFile ) { $ strTemplate = basename ( $ strFile , strrchr ( $ strFile , '.' ) ) ; $ arrTemplates [ $ strTemplate ] [ ] = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'global' ] ; } } $ theme = \ ThemeModel :: findById ( $ dc -> activeRecord -> pid ) ; $ arrCustomized = glob ( TL_ROOT . '/' . $ theme -> templates . '/' . 'ce_*' ) ; if ( is_array ( $ arrCustomized ) ) { foreach ( $ arrCustomized as $ strFile ) { $ strTemplate = basename ( $ strFile , strrchr ( $ strFile , '.' ) ) ; $ arrTemplates [ $ strTemplate ] [ ] = $ theme -> name ; } } foreach ( $ arrTemplates as $ k => $ v ) { $ v = array_filter ( $ v , function ( $ a ) { return $ a != 'root' ; } ) ; if ( empty ( $ v ) ) { $ arrTemplates [ $ k ] = $ k ; } else { $ arrTemplates [ $ k ] = $ k . ' (' . implode ( ', ' , $ v ) . ')' ; } } ksort ( $ arrTemplates ) ; return $ arrTemplates ; } | Return content element templates as array |
14,787 | public function editButton ( $ row , $ href , $ label , $ title , $ icon , $ attributes ) { switch ( $ row [ 'type' ] ) { case 'group' : return \ Image :: getHtml ( str_replace ( '.' , '_.' , $ icon ) , $ label ) . ' ' ; case 'element' : return '<a href="' . $ this -> addToUrl ( $ href . '&id=' . $ row [ 'id' ] ) . '" title="' . \ StringUtil :: specialchars ( $ title ) . '"' . $ attributes . '>' . \ Image :: getHtml ( $ icon , $ label ) . '</a> ' ; } } | Return the pattern edit button |
14,788 | public function findByTags ( array $ tags ) { $ qb = $ this -> createQueryBuilder ( 'c' ) ; foreach ( $ tags as $ key => $ tag ) { $ operator = substr ( $ tag , 0 , 1 ) ; if ( $ operator === '+' || $ operator === '-' ) { $ tag = substr ( $ tag , 1 ) ; } $ literalExpr = $ qb -> expr ( ) -> literal ( '%' . $ tag . '%' ) ; if ( $ operator === '-' ) { $ qb -> andWhere ( $ qb -> expr ( ) -> notLike ( 'c.tags' , $ literalExpr ) ) ; } elseif ( $ operator === '+' ) { $ qb -> andWhere ( $ qb -> expr ( ) -> like ( 'c.tags' , $ literalExpr ) ) ; } elseif ( $ key === 0 ) { $ qb -> where ( $ qb -> expr ( ) -> like ( 'c.tags' , $ literalExpr ) ) ; } else { $ qb -> orWhere ( $ qb -> expr ( ) -> like ( 'c.tags' , $ literalExpr ) ) ; } } return $ qb -> getQuery ( ) -> getResult ( ) ; } | Find configured types by tags . |
14,789 | public function getAllTags ( ) { $ qb = $ this -> createQueryBuilder ( 'c' ) ; $ qb -> select ( 'c.tags' ) -> where ( $ qb -> expr ( ) -> isNotNull ( 'c.tags' ) ) -> distinct ( ) ; $ tagStrings = array_map ( 'current' , $ qb -> getQuery ( ) -> getScalarResult ( ) ) ; $ distinctTags = array ( ) ; foreach ( $ tagStrings as $ tagString ) { foreach ( explode ( ',' , $ tagString ) as $ tag ) { if ( ! in_array ( $ tag , $ distinctTags ) ) { array_push ( $ distinctTags , $ tag ) ; } } } return $ distinctTags ; } | Get all tags . |
14,790 | public function find ( $ username ) { $ parameters [ 'username' ] = $ username ; return $ this -> apiClient -> callEndpoint ( self :: ENDPOINT , $ parameters ) ; } | Returns a user . This resource cannot be accessed anonymously . |
14,791 | public function update ( $ username , $ parameters = array ( ) ) { $ parameters [ 'username' ] = $ username ; return $ this -> apiClient -> callEndpoint ( self :: ENDPOINT , $ parameters , null , HttpMethod :: REQUEST_PUT ) ; } | Modify user . The value fields present will override the existing value . Fields skipped in request will not be changed . |
14,792 | public function add ( $ username , $ parameters = array ( ) ) { $ parameters [ 'username' ] = $ username ; return $ this -> apiClient -> callEndpoint ( self :: ENDPOINT , $ parameters , null , HttpMethod :: REQUEST_POST ) ; } | Create user . By default created user will not be notified with email . If password field is not set then password will be randomly generated . |
14,793 | public function findAvatars ( $ username ) { $ parameters [ 'username' ] = $ username ; return $ this -> apiClient -> callEndpoint ( sprintf ( '%s/avatars' , self :: ENDPOINT ) , $ parameters ) ; } | Returns all avatars which are visible for the currently logged in user . |
14,794 | public function updatePassword ( $ username , $ password ) { $ parameters [ 'username' ] = $ username ; $ parameters [ 'password' ] = $ password ; return $ this -> apiClient -> callEndpoint ( sprintf ( '%s/avatars' , self :: ENDPOINT ) , $ parameters , null , HttpMethod :: REQUEST_PUT ) ; } | Modify user password . |
14,795 | public function picker ( $ query , $ maxResults = null , $ showAvatar = null , $ exclude = null ) { $ parameters = array ( 'query' => $ query , 'maxResults' => $ maxResults , 'showAvatar' => $ showAvatar , 'exclude' => $ exclude ) ; return $ this -> apiClient -> callEndpoint ( sprintf ( '%s/picker' , self :: ENDPOINT ) , $ parameters ) ; } | Returns a list of users matching query with highlighting . This resource cannot be accessed anonymously . |
14,796 | public function search ( $ username , $ startAt = null , $ maxResults = null , $ includeActive = null , $ includeInactive = null ) { $ parameters = array ( 'username' => $ username , 'startAt' => $ startAt , 'maxResults' => $ maxResults , 'includeActive' => $ includeActive , 'includeInactive' => $ includeInactive ) ; return $ this -> apiClient -> callEndpoint ( sprintf ( '%s/search' , self :: ENDPOINT ) , $ parameters ) ; } | Returns a list of users that match the search string . This resource cannot be accessed anonymously . |
14,797 | public static function getRevisionRecords ( $ options = [ ] ) { $ options = Util :: prepareOptions ( $ options , [ 'indexField' => false , 'conditions' => [ ] , 'order' => false , 'limit' => false , 'offset' => 0 , ] ) ; $ query = 'SELECT * FROM `%s` WHERE (%s)' ; $ params = [ static :: getHistoryTable ( ) , count ( $ options [ 'conditions' ] ) ? join ( ') AND (' , static :: _mapConditions ( $ options [ 'conditions' ] ) ) : 1 , ] ; if ( $ options [ 'order' ] ) { $ query .= ' ORDER BY ' . join ( ',' , static :: _mapFieldOrder ( $ options [ 'order' ] ) ) ; } if ( $ options [ 'limit' ] ) { $ query .= sprintf ( ' LIMIT %u,%u' , $ options [ 'offset' ] , $ options [ 'limit' ] ) ; } if ( $ options [ 'indexField' ] ) { return DB :: table ( static :: _cn ( $ options [ 'indexField' ] ) , $ query , $ params ) ; } else { return DB :: allRecords ( $ query , $ params ) ; } } | Gets raw revision data from the database and constructs a query |
14,798 | public function beforeVersionedSave ( ) { $ this -> wasDirty = false ; if ( $ this -> isDirty && static :: $ createRevisionOnSave ) { $ this -> Created = time ( ) ; $ this -> wasDirty = true ; } } | Sets wasDirty isDirty Created for the object before save |
14,799 | public function afterVersionedSave ( ) { if ( $ this -> wasDirty && static :: $ createRevisionOnSave ) { $ recordValues = $ this -> _prepareRecordValues ( ) ; $ set = static :: _mapValuesToSet ( $ recordValues ) ; DB :: nonQuery ( 'INSERT INTO `%s` SET %s' , [ static :: getHistoryTable ( ) , join ( ',' , $ set ) , ] ) ; } } | After save to regular database this saves to the history table |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.