idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
32,500 | public function generateUri ( $ referenceScheme , $ referenceHost , $ referencePort , $ forceCanonical ) { $ url = '' ; $ scheme = $ referenceScheme ; $ port = $ this -> port ; if ( $ forceCanonical || $ this -> scheme !== null && $ referenceScheme !== $ this -> scheme ) { $ url .= ( $ scheme = $ this -> scheme ? : $ referenceScheme ) . ':' ; $ forceCanonical = true ; } if ( null === $ this -> port ) { if ( $ scheme === $ referenceScheme && ( null === $ this -> host || $ this -> host === $ referenceHost ) ) { $ port = $ referencePort ; } else { $ port = 'http' === $ scheme ? 80 : 443 ; } } if ( $ forceCanonical || $ this -> host !== null && $ referenceHost !== $ this -> host || $ port !== $ referencePort ) { $ url .= '//' . ( $ this -> host ? : $ referenceHost ) ; if ( 'http' === $ scheme && 80 !== $ port || 'https' === $ scheme && 443 !== $ port ) { $ url .= ':' . $ port ; } } $ url .= strtr ( rawurlencode ( $ this -> path ) , static :: $ allowedPathChars ) ; if ( $ this -> query !== null ) { $ url .= '?' . http_build_query ( $ this -> query , '' , '&' ) ; } if ( $ this -> fragment !== null ) { $ url .= '#' . $ this -> fragment ; } return $ url ; } | Converts the assembly result to a string . |
32,501 | private function initiatePost ( $ url , $ params ) { $ ch = curl_init ( $ this -> host . '/' . $ url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( "Authentication: Token " . $ this -> token ) ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , http_build_query ( $ params ) ) ; return $ ch ; } | Initiates curl session for POST method |
32,502 | private function initiateGet ( $ url , $ params ) { ; if ( ! empty ( $ params ) ) { $ parameter = implode ( array_values ( $ params ) ) ; $ url .= '/' . $ parameter ; } $ ch = curl_init ( $ this -> host . '/' . $ url ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( "Authentication: Token " . $ this -> token ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; return $ ch ; } | Initiates curl session for GET method |
32,503 | private function initiateUpload ( $ url , $ params ) { $ ch = curl_init ( $ this -> host . '/' . $ url ) ; if ( ! empty ( $ params [ 'file' ] ) ) { $ params [ 'file' ] .= ";filename=" . basename ( $ params [ 'file' ] ) ; } curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( "Authentication: Token " . $ this -> token ) ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ params ) ; return $ ch ; } | Initiate curl session for POST upload |
32,504 | public function sendRequest ( $ url , $ params , $ method ) { if ( $ method == 'POST' ) { if ( ! empty ( $ params [ 'file' ] ) ) $ ch = $ this -> initiateUpload ( $ url , $ params ) ; else $ ch = $ this -> initiatePost ( $ url , $ params ) ; } else if ( $ method == 'GET' ) { $ ch = $ this -> initiateGet ( $ url , $ params ) ; } else if ( $ method == 'DELETE' ) { $ ch = $ this -> initiateDelete ( $ url , $ params ) ; } else { throw new \ Exception ( "Method " . $ method . " not supported!" ) ; } if ( ! $ ret = curl_exec ( $ ch ) ) { trigger_error ( curl_error ( $ ch ) ) ; } curl_close ( $ ch ) ; return $ ret ; } | Sends the request via curl |
32,505 | public function tableExists ( $ tablename ) { $ sql = " SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = ? AND TABLE_NAME = ? " ; $ stmt = $ this -> _conn -> create ( $ sql ) ; $ stmt -> bind ( 1 , $ this -> _dbname ) ; $ stmt -> bind ( 2 , $ tablename ) ; $ result = $ stmt -> execute ( ) ; if ( $ result -> fetch ( ) !== false ) { return true ; } return false ; } | Checks if the given table exists in the database . |
32,506 | public function getColumnDetails ( $ tablename , $ columnname ) { $ sql = " SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_NAME = ? " ; $ stmt = $ this -> _conn -> create ( $ sql ) ; $ stmt -> bind ( 1 , $ this -> _dbname ) ; $ stmt -> bind ( 2 , $ tablename ) ; $ stmt -> bind ( 3 , $ columnname ) ; $ result = $ stmt -> execute ( ) ; if ( ( $ record = $ result -> fetch ( ) ) === false ) { throw new MW_Setup_Exception ( sprintf ( 'Unknown column "%1$s" in table "%2$s"' , $ tablename , $ columnname ) ) ; } return $ this -> _createColumnItem ( $ record ) ; } | Returns an object containing the details of the column . |
32,507 | protected function _createColumnItem ( array $ record = array ( ) ) { $ length = ( isset ( $ record [ 'CHARACTER_MAXIMUM_LENGTH' ] ) ? $ record [ 'CHARACTER_MAXIMUM_LENGTH' ] : $ record [ 'NUMERIC_PRECISION' ] ) ; return new MW_Setup_DBSchema_Column_Item ( $ record [ 'TABLE_NAME' ] , $ record [ 'COLUMN_NAME' ] , $ record [ 'DATA_TYPE' ] , $ length , $ record [ 'COLUMN_DEFAULT' ] , $ record [ 'IS_NULLABLE' ] , $ record [ 'COLLATION_NAME' ] ) ; } | Creates a new column item using the columns of the information_schema . columns . |
32,508 | public function getItem ( $ id , array $ ref = array ( ) ) { if ( ( $ conf = reset ( $ this -> _searchConfig ) ) === false ) { throw new MShop_Exception ( sprintf ( 'Address search configuration not available' ) ) ; } return $ this -> _getItem ( $ conf [ 'code' ] , $ id , $ ref ) ; } | Returns the common address item object specificed by its ID . |
32,509 | public function getListItems ( $ domain = null , $ type = null ) { if ( $ domain === null ) { $ listItems = array ( ) ; foreach ( $ this -> _listItems as $ domain => $ items ) { $ listItems += $ items ; } return $ listItems ; } if ( ! isset ( $ this -> _listItems [ $ domain ] ) ) { return array ( ) ; } if ( ! isset ( $ this -> _sortedLists [ $ domain ] ) ) { foreach ( $ this -> _listItems [ $ domain ] as $ listItem ) { $ refId = $ listItem -> getRefId ( ) ; if ( isset ( $ this -> _refItems [ $ domain ] [ $ refId ] ) ) { $ listItem -> setRefItem ( $ this -> _refItems [ $ domain ] [ $ refId ] ) ; } } uasort ( $ this -> _listItems [ $ domain ] , array ( $ this , '_comparePosition' ) ) ; $ this -> _sortedLists [ $ domain ] = true ; } if ( $ type !== null ) { $ list = array ( ) ; $ iface = 'MShop_Common_Item_Typeid_Interface' ; foreach ( $ this -> _listItems [ $ domain ] as $ id => $ item ) { if ( $ item instanceof $ iface && $ type === $ item -> getType ( ) ) { $ list [ $ id ] = $ item ; } } } else { $ list = $ this -> _listItems [ $ domain ] ; } return $ list ; } | Returns the list items attached optionally filtered by domain and list type . |
32,510 | public function getRefItems ( $ domain , $ type = null , $ listtype = null ) { if ( ! isset ( $ this -> _refItems [ $ domain ] ) || ! isset ( $ this -> _listItems [ $ domain ] ) ) { return array ( ) ; } if ( ! isset ( $ this -> _sortedRefs [ $ domain ] ) ) { $ iface = 'MShop_Common_Item_List_Interface' ; foreach ( $ this -> _listItems [ $ domain ] as $ listItem ) { $ refId = $ listItem -> getRefId ( ) ; if ( isset ( $ this -> _refItems [ $ domain ] [ $ refId ] ) && $ listItem instanceof $ iface ) { $ this -> _refItems [ $ domain ] [ $ refId ] -> _listtype = $ listItem -> getType ( ) ; $ this -> _refItems [ $ domain ] [ $ refId ] -> _position = $ listItem -> getPosition ( ) ; } } uasort ( $ this -> _refItems [ $ domain ] , array ( $ this , '_compareRefPosition' ) ) ; } if ( $ type !== null || $ listtype !== null ) { $ list = array ( ) ; $ iface = 'MShop_Common_Item_Typeid_Interface' ; foreach ( $ this -> _refItems [ $ domain ] as $ id => $ item ) { if ( $ item instanceof $ iface && ( $ type === null || $ type === $ item -> getType ( ) ) && ( $ listtype === null || $ listtype === $ item -> _listtype ) ) { $ list [ $ id ] = $ item ; } } } else { $ list = $ this -> _refItems [ $ domain ] ; } return $ list ; } | Returns the product text etc . items filtered by domain and optionally by type and list type . |
32,511 | public function getName ( ) { $ items = $ this -> getRefItems ( 'text' , 'name' ) ; if ( ( $ item = reset ( $ items ) ) !== false ) { return $ item -> getContent ( ) ; } return $ this -> getLabel ( ) ; } | Returns the localized name of the item or the internal label if no name is available . |
32,512 | protected function _comparePosition ( MShop_Common_Item_Position_Interface $ a , MShop_Common_Item_Position_Interface $ b ) { if ( $ a -> getPosition ( ) === $ b -> getPosition ( ) ) { return 0 ; } return ( $ a -> getPosition ( ) < $ b -> getPosition ( ) ) ? - 1 : 1 ; } | Compares the positions of two items for sorting . |
32,513 | protected function _compareRefPosition ( MShop_Common_Item_Interface $ a , MShop_Common_Item_Interface $ b ) { if ( $ a -> _position === $ b -> _position ) { return 0 ; } return ( $ a -> _position < $ b -> _position ) ? - 1 : 1 ; } | Compares the positions of two referenced items for sorting . |
32,514 | protected function _checkDateFormat ( $ date ) { $ regex = '/^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$/' ; if ( $ date !== null && preg_match ( $ regex , $ date ) !== 1 ) { throw new MShop_Exception ( sprintf ( 'Invalid characters in date "%1$s". ISO format "YYYY-MM-DD hh:mm:ss" expected.' , $ date ) ) ; } } | Tests if the date parameter represents an ISO format . |
32,515 | protected function _checkCurrencyId ( $ currencyid , $ null = true ) { if ( $ null === false && $ currencyid === null ) { throw new MShop_Exception ( sprintf ( 'Invalid ISO currency code "%1$s"' , '<null>' ) ) ; } if ( $ currencyid !== null && preg_match ( '/^[A-Z]{3}$/' , $ currencyid ) !== 1 ) { throw new MShop_Exception ( sprintf ( 'Invalid ISO currency code "%1$s"' , $ currencyid ) ) ; } } | Tests if the currency ID parameter represents an ISO currency format . |
32,516 | public function getServices ( $ type , MShop_Order_Item_Base_Interface $ basket , $ ref = array ( 'media' , 'price' , 'text' ) ) { if ( isset ( $ this -> _items [ $ type ] ) ) { return $ this -> _items [ $ type ] ; } $ serviceManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'service' ) ; $ search = $ serviceManager -> createSearch ( true ) ; $ expr = array ( $ search -> getConditions ( ) , $ search -> compare ( '==' , 'service.type.domain' , 'service' ) , $ search -> compare ( '==' , 'service.type.code' , $ type ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , 'service.position' ) ) ) ; $ this -> _items [ $ type ] = $ serviceManager -> searchItems ( $ search , $ ref ) ; foreach ( $ this -> _items [ $ type ] as $ id => $ service ) { try { $ provider = $ serviceManager -> getProvider ( $ service ) ; if ( $ provider -> isAvailable ( $ basket ) ) { $ this -> _providers [ $ type ] [ $ id ] = $ provider ; } else { unset ( $ this -> _items [ $ type ] [ $ id ] ) ; } } catch ( MShop_Service_Exception $ e ) { $ msg = sprintf ( 'Unable to create provider "%1$s" for service with ID "%2$s"' , $ service -> getCode ( ) , $ id ) ; $ this -> _getContext ( ) -> getLogger ( ) -> log ( $ msg , MW_Logger_Abstract :: WARN ) ; } } return $ this -> _items [ $ type ] ; } | Returns the service items that are available for the service type and the content of the basket . |
32,517 | public function getServiceAttributes ( $ type , $ serviceId , MShop_Order_Item_Base_Interface $ basket ) { if ( isset ( $ this -> _providers [ $ type ] [ $ serviceId ] ) ) { return $ this -> _providers [ $ type ] [ $ serviceId ] -> getConfigFE ( $ basket ) ; } $ item = $ this -> _getServiceItem ( $ type , $ serviceId ) ; $ serviceManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'service' ) ; return $ serviceManager -> getProvider ( $ item ) -> getConfigFE ( $ basket ) ; } | Returns the list of attribute definitions which must be used to render the input form where the customer can enter or chose the required data necessary by the service provider . |
32,518 | public function getServicePrice ( $ type , $ serviceId , MShop_Order_Item_Base_Interface $ basket ) { if ( isset ( $ this -> _providers [ $ type ] [ $ serviceId ] ) ) { return $ this -> _providers [ $ type ] [ $ serviceId ] -> calcPrice ( $ basket ) ; } $ item = $ this -> _getServiceItem ( $ type , $ serviceId ) ; $ serviceManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'service' ) ; return $ serviceManager -> getProvider ( $ item ) -> calcPrice ( $ basket ) ; } | Returns the price of the service . |
32,519 | public function checkServiceAttributes ( $ type , $ serviceId , array $ attributes ) { if ( isset ( $ this -> _providers [ $ type ] [ $ serviceId ] ) ) { return $ this -> _providers [ $ type ] [ $ serviceId ] -> checkConfigFE ( $ attributes ) ; } $ item = $ this -> _getServiceItem ( $ type , $ serviceId ) ; $ serviceManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'service' ) ; return $ serviceManager -> getProvider ( $ item ) -> checkConfigFE ( $ attributes ) ; } | Returns a list of attributes that are invalid . |
32,520 | protected function _getServiceItem ( $ type , $ serviceId ) { $ serviceManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'service' ) ; $ search = $ serviceManager -> createSearch ( true ) ; $ expr = array ( $ search -> getConditions ( ) , $ search -> compare ( '==' , 'service.id' , $ serviceId ) , $ search -> compare ( '==' , 'service.type.domain' , 'service' ) , $ search -> compare ( '==' , 'service.type.code' , $ type ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ items = $ serviceManager -> searchItems ( $ search , array ( 'price' ) ) ; if ( ( $ item = reset ( $ items ) ) === false ) { $ msg = sprintf ( 'Service item for type "%1$s" and ID "%2$s" not found' , $ type , $ serviceId ) ; throw new Controller_Frontend_Service_Exception ( $ msg ) ; } return $ item ; } | Returns the service item specified by its type and ID . |
32,521 | public function setAttributeId ( $ id ) { if ( $ id == $ this -> getAttributeId ( ) ) { return ; } $ this -> _values [ 'attrid' ] = ( string ) $ id ; $ this -> setModified ( ) ; } | Sets the original attribute ID of the service attribute item . |
32,522 | public function setServiceId ( $ id ) { if ( $ id == $ this -> getServiceId ( ) ) { return ; } $ this -> _values [ 'ordservid' ] = ( int ) $ id ; $ this -> setModified ( ) ; } | Sets the order service id . |
32,523 | public function copyFrom ( MShop_Attribute_Item_Interface $ item ) { $ this -> setAttributeId ( $ item -> getId ( ) ) ; $ this -> setName ( $ item -> getName ( ) ) ; $ this -> setCode ( $ item -> getType ( ) ) ; $ this -> setValue ( $ item -> getCode ( ) ) ; $ this -> setModified ( ) ; } | Copys all data from a given attribute item . |
32,524 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'product.id' : $ item -> setId ( $ value ) ; break ; case 'product.code' : $ item -> setCode ( $ value ) ; break ; case 'product.label' : $ item -> setLabel ( $ value ) ; break ; case 'product.typeid' : $ item -> setTypeId ( $ value ) ; break ; case 'product.status' : $ item -> setStatus ( $ value ) ; break ; case 'product.suppliercode' : $ item -> setSupplierCode ( $ value ) ; break ; case 'product.datestart' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'product.datestart' } = $ value ; $ item -> setDateStart ( $ value ) ; } break ; case 'product.dateend' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'product.dateend' } = $ value ; $ item -> setDateEnd ( $ value ) ; } break ; } } return $ item ; } | Creates a new product item and sets the properties from the given array . |
32,525 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'product.stock.id' : $ item -> setId ( $ value ) ; break ; case 'product.stock.productid' : $ item -> setProductId ( $ value ) ; break ; case 'product.stock.warehouseid' : $ item -> setWarehouseId ( $ value ) ; break ; case 'product.stock.stocklevel' : if ( $ value != '' ) { $ item -> setStocklevel ( $ value ) ; } break ; case 'product.stock.dateback' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'product.stock.dateback' } = $ value ; $ item -> setDateBack ( $ value ) ; } break ; } } return $ item ; } | Creates a new product stock item and sets the properties from the given array . |
32,526 | public function setId ( $ key ) { if ( $ key !== null ) { $ this -> setCode ( $ key ) ; $ this -> _values [ 'id' ] = $ this -> _values [ 'code' ] ; $ this -> _modified = false ; } else { $ this -> _values [ 'id' ] = null ; $ this -> _modified = true ; } } | Sets the id of the language . |
32,527 | public function setCode ( $ key ) { if ( $ key == $ this -> getCode ( ) ) { return ; } $ len = strlen ( $ key ) ; if ( $ len < 2 || $ len > 5 || preg_match ( '/^[a-z]{2,3}((-|_)[a-zA-Z]{2})?$/' , $ key ) !== 1 ) { throw new MShop_Locale_Exception ( sprintf ( 'Invalid characters in ISO language code "%1$s"' , $ key ) ) ; } $ this -> _values [ 'code' ] = ( string ) $ key ; $ this -> _modified = true ; } | Sets the two letter ISO language code . |
32,528 | public function getAllOptions ( ) { $ options = array ( ) ; foreach ( $ this -> _flags as $ option => $ index ) { if ( array_key_exists ( $ index , $ this -> _options ) ) { $ options [ $ option ] = $ this -> _options [ $ index ] ; } } return $ options ; } | Gets the values of all options as an associative array . |
32,529 | public function setCompany ( $ company ) { if ( $ company == $ this -> getCompany ( ) ) { return ; } $ this -> _values [ 'company' ] = ( string ) $ company ; $ this -> setModified ( ) ; } | Sets a new company name . |
32,530 | public function setVatID ( $ vatid ) { if ( $ vatid == $ this -> getVatID ( ) ) { return ; } $ this -> _values [ 'vatid' ] = ( string ) $ vatid ; $ this -> setModified ( ) ; } | Sets a new vatid . |
32,531 | public function setTitle ( $ title ) { if ( $ title == $ this -> getTitle ( ) ) { return ; } $ this -> _values [ 'title' ] = ( string ) $ title ; $ this -> setModified ( ) ; } | Sets a new title of the person . |
32,532 | public function setFirstname ( $ firstname ) { if ( $ firstname == $ this -> getFirstname ( ) ) { return ; } $ this -> _values [ 'firstname' ] = ( string ) $ firstname ; $ this -> setModified ( ) ; } | Sets a new first name of the person . |
32,533 | public function setLastname ( $ lastname ) { if ( $ lastname == $ this -> getLastname ( ) ) { return ; } $ this -> _values [ 'lastname' ] = ( string ) $ lastname ; $ this -> setModified ( ) ; } | Sets a new last name of the person . |
32,534 | public function setPostal ( $ postal ) { if ( $ postal == $ this -> getPostal ( ) ) { return ; } $ this -> _values [ 'postal' ] = ( string ) $ postal ; $ this -> setModified ( ) ; } | Sets a new postal code . |
32,535 | public function setCity ( $ city ) { if ( $ city == $ this -> getCity ( ) ) { return ; } $ this -> _values [ 'city' ] = ( string ) $ city ; $ this -> setModified ( ) ; } | Sets a new city name . |
32,536 | public function setState ( $ state ) { if ( $ state == $ this -> getState ( ) ) { return ; } $ this -> _values [ 'state' ] = ( string ) $ state ; $ this -> setModified ( ) ; } | Sets a new state name . |
32,537 | public function setCountryId ( $ countryid ) { if ( $ countryid === $ this -> getCountryId ( ) ) { return ; } $ this -> _values [ 'countryid' ] = strtoupper ( ( string ) $ countryid ) ; $ this -> setModified ( ) ; } | Sets the ID of the country the address is in . |
32,538 | public function setLanguageId ( $ langid ) { if ( $ langid === $ this -> getLanguageId ( ) ) { return ; } $ this -> _values [ 'langid' ] = strtolower ( ( string ) $ langid ) ; $ this -> setModified ( ) ; } | Sets the ID of the language . |
32,539 | public function setTelephone ( $ telephone ) { if ( $ telephone == $ this -> getTelephone ( ) ) { return ; } $ this -> _values [ 'telephone' ] = ( string ) $ telephone ; $ this -> setModified ( ) ; } | Sets a new telephone number . |
32,540 | public function setEmail ( $ email ) { if ( $ email == $ this -> getEmail ( ) ) { return ; } if ( $ email !== '' && preg_match ( '/^.+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/' , $ email ) !== 1 ) { throw new MShop_Exception ( sprintf ( 'Invalid characters in email address: "%1$s"' , $ email ) ) ; } $ this -> _values [ 'email' ] = ( string ) $ email ; $ this -> setModified ( ) ; } | Sets a new email address . |
32,541 | public function setTelefax ( $ telefax ) { if ( $ telefax == $ this -> getTelefax ( ) ) { return ; } $ this -> _values [ 'telefax' ] = ( string ) $ telefax ; $ this -> setModified ( ) ; } | Sets a new telefax number . |
32,542 | public function setFlag ( $ flag ) { if ( $ flag == $ this -> getFlag ( ) ) { return ; } $ this -> _values [ 'flag' ] = ( int ) $ flag ; $ this -> setModified ( ) ; } | Sets a new flag value . |
32,543 | protected function _checkSalutation ( $ value ) { switch ( $ value ) { case MShop_Common_Item_Address_Abstract :: SALUTATION_UNKNOWN : case MShop_Common_Item_Address_Abstract :: SALUTATION_COMPANY : case MShop_Common_Item_Address_Abstract :: SALUTATION_MRS : case MShop_Common_Item_Address_Abstract :: SALUTATION_MISS : case MShop_Common_Item_Address_Abstract :: SALUTATION_MR : return ; default : throw new MShop_Common_Exception ( sprintf ( 'Address salutation "%1$s" not within allowed range' , $ value ) ) ; } } | Checks the given address salutation is valid |
32,544 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'order.id' : $ item -> setId ( $ value ) ; break ; case 'order.type' : $ item -> setType ( $ value ) ; break ; case 'order.baseid' : $ item -> setBaseId ( $ value ) ; break ; case 'order.relatedid' : $ item -> setRelatedId ( $ value ) ; break ; case 'order.statuspayment' : $ item -> setPaymentStatus ( $ value ) ; break ; case 'order.statusdelivery' : $ item -> setDeliveryStatus ( $ value ) ; break ; case 'order.datepayment' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'order.datepayment' } = $ value ; $ item -> setDatePayment ( $ value ) ; } break ; case 'order.datedelivery' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'order.datedelivery' } = $ value ; $ item -> setDateDelivery ( $ value ) ; } break ; } } return $ item ; } | Creates a new order item and sets the properties from the given array . |
32,545 | public function transform ( $ target = null , $ controller = null , $ action = null , array $ params = array ( ) , array $ trailing = array ( ) , array $ config = array ( ) ) { return '' ; } | Returns an empty string as URL . |
32,546 | protected function getenv ( $ varname ) : ? string { $ value = getenv ( $ varname , true ) ; if ( $ value === false ) { $ value = getenv ( $ varname ) ; } return $ value !== false ? $ value : null ; } | Calls getenv for local and system env vars |
32,547 | public function load ( $ source , array $ options = [ ] ) : Config { if ( ! isset ( $ options [ 'map' ] ) ) { throw new BadMethodCallException ( "No 'map' option specified" ) ; } $ config = new Config ( ) ; $ dotkey = DotKey :: on ( $ config ) ; foreach ( $ options [ 'map' ] as $ env => $ key ) { $ value = $ this -> getenv ( $ env ) ; if ( isset ( $ value ) ) { $ dotkey -> put ( $ key , $ value ) ; } } return $ config ; } | Load settings from environment |
32,548 | public function getItem ( $ id , array $ ref = array ( ) ) { return MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product' ) -> getItem ( $ id , $ ref ) ; } | Returns the product item for the given product ID . |
32,549 | public function rebuildIndex ( array $ items = array ( ) ) { $ context = $ this -> _getContext ( ) ; $ config = $ context -> getConfig ( ) ; $ size = $ config -> get ( 'mshop/catalog/manager/index/default/chunksize' , 1000 ) ; $ mode = $ config -> get ( 'mshop/catalog/manager/index/default/index' , 'categorized' ) ; $ default = array ( 'attribute' , 'price' , 'text' , 'product' ) ; $ domains = $ config -> get ( 'mshop/catalog/manager/index/default/domains' , $ default ) ; $ manager = MShop_Factory :: createManager ( $ context , 'product' ) ; $ search = $ manager -> createSearch ( true ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , 'product.id' ) ) ) ; $ defaultConditions = $ search -> getConditions ( ) ; $ paramIds = array ( ) ; foreach ( $ items as $ item ) { $ paramIds [ ] = $ item -> getId ( ) ; } if ( $ mode === 'all' ) { if ( ! empty ( $ paramIds ) ) { $ expr = array ( $ search -> compare ( '==' , 'product.id' , $ paramIds ) , $ defaultConditions , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; } $ this -> _writeIndex ( $ search , $ domains , $ size ) ; return ; } $ catalogListManager = MShop_Factory :: createManager ( $ context , 'catalog/list' ) ; $ catalogSearch = $ catalogListManager -> createSearch ( true ) ; $ expr = array ( $ catalogSearch -> compare ( '==' , 'catalog.list.domain' , 'product' ) ) ; if ( ! empty ( $ paramIds ) ) { $ expr [ ] = $ catalogSearch -> compare ( '==' , 'catalog.list.refid' , $ paramIds ) ; } $ expr [ ] = $ catalogSearch -> getConditions ( ) ; $ catalogSearch -> setConditions ( $ catalogSearch -> combine ( '&&' , $ expr ) ) ; $ catalogSearch -> setSortations ( array ( $ catalogSearch -> sort ( '+' , 'catalog.list.refid' ) ) ) ; $ start = 0 ; do { $ catalogSearch -> setSlice ( $ start , $ size ) ; $ result = $ catalogListManager -> aggregate ( $ catalogSearch , 'catalog.list.refid' ) ; $ expr = array ( $ search -> compare ( '==' , 'product.id' , array_keys ( $ result ) ) , $ defaultConditions , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ this -> _writeIndex ( $ search , $ domains , $ size ) ; $ start += $ size ; } while ( count ( $ result ) > 0 ) ; } | Rebuilds the catalog index for searching products or specified list of products . This can be a long lasting operation . |
32,550 | protected function _writeIndex ( MW_Common_Criteria_Interface $ search , array $ domains , $ size ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product' ) ; $ start = 0 ; do { $ search -> setSlice ( $ start , $ size ) ; $ products = $ manager -> searchItems ( $ search , $ domains ) ; try { $ this -> begin ( ) ; $ this -> deleteItems ( array_keys ( $ products ) ) ; foreach ( $ this -> _getSubManagers ( ) as $ submanager ) { $ submanager -> rebuildIndex ( $ products ) ; } $ this -> _saveSubProducts ( $ products ) ; $ this -> commit ( ) ; } catch ( Exception $ e ) { $ this -> _rollback ( ) ; throw $ e ; } $ count = count ( $ products ) ; $ start += $ count ; } while ( $ count == $ search -> getSliceSize ( ) ) ; } | Re - writes the index entries for all products that are search result of given criteria |
32,551 | protected function _saveSubProducts ( array $ items ) { $ context = $ this -> _getContext ( ) ; $ default = array ( 'attribute' , 'price' , 'text' , 'product' ) ; $ domains = $ context -> getConfig ( ) -> get ( 'mshop/catalog/manager/index/default/domains' , $ default ) ; $ size = $ context -> getConfig ( ) -> get ( 'mshop/catalog/manager/index/default/chunksize' , 1000 ) ; $ manager = MShop_Factory :: createManager ( $ context , 'product' ) ; $ search = $ manager -> createSearch ( true ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , 'product.id' ) ) ) ; $ search -> setSlice ( 0 , $ size ) ; $ defaultConditions = $ search -> getConditions ( ) ; $ prodList = array ( ) ; $ numSubProducts = 0 ; foreach ( $ items as $ id => $ product ) { foreach ( $ product -> getRefItems ( 'product' , null , 'default' ) as $ subId => $ subItem ) { $ prodList [ $ subId ] = $ id ; $ numSubProducts ++ ; } if ( $ numSubProducts >= $ size ) { $ expr = array ( $ search -> compare ( '==' , 'product.id' , array_keys ( $ prodList ) ) , $ defaultConditions , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ this -> _saveSubProductsChunk ( $ search , $ domains , $ prodList , $ size ) ; $ prodList = array ( ) ; $ numSubProducts = 0 ; } } if ( $ numSubProducts > 0 ) { $ expr = array ( $ search -> compare ( '==' , 'product.id' , array_keys ( $ prodList ) ) , $ defaultConditions , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ this -> _saveSubProductsChunk ( $ search , $ domains , $ prodList , $ size ) ; } } | Saves catalog price text and attribute of subproduct . |
32,552 | protected function _saveSubProductsChunk ( MW_Common_Criteria_Interface $ search , array $ domains , array $ list , $ size ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product' ) ; $ start = 0 ; do { $ result = $ manager -> searchItems ( $ search , $ domains ) ; if ( ! empty ( $ result ) ) { foreach ( $ result as $ refId => $ refItem ) { $ refItem -> setId ( null ) ; $ refItem -> setId ( $ list [ $ refId ] ) ; } foreach ( $ this -> _getSubManagers ( ) as $ submanager ) { $ submanager -> rebuildIndex ( $ result ) ; } } $ count = count ( $ result ) ; $ start += $ count ; $ search -> setSlice ( $ start , $ size ) ; } while ( $ count == $ size ) ; } | Saves one chunk of the sub products . |
32,553 | public function assign ( $ count = 1 , $ collection = null , $ replication = null , $ dataCenter = null ) { $ assignProperties = [ 'count' => $ count ] ; if ( ! is_null ( $ collection ) ) { $ assignProperties [ 'collection' ] = $ collection ; } if ( ! is_null ( $ replication ) ) { $ assignProperties [ 'replication' ] = $ replication ; } if ( ! is_null ( $ dataCenter ) ) { $ assignProperties [ 'dataCenter' ] = $ dataCenter ; } $ res = $ this -> client -> get ( $ this -> buildMasterUrl ( self :: DIR_ASSIGN ) , [ 'query' => $ assignProperties ] ) ; if ( $ res -> getStatusCode ( ) != 200 ) { throw new SeaweedFSException ( 'Unexpected response when assigning file: ' . $ res -> getStatusCode ( ) ) ; } $ body = json_decode ( ( string ) $ res -> getBody ( ) ) ; return new File ( $ body , $ this -> scheme ) ; } | Get a volume and file id from the master server . |
32,554 | public function lookup ( $ id ) { if ( $ pos = strpos ( $ id , ',' ) ) { $ id = substr ( $ id , 0 , $ pos ) ; } $ cacheKey = 'volume_' . $ id ; if ( $ this -> cache && $ this -> cache -> has ( $ cacheKey ) ) { $ val = $ this -> cache -> get ( $ cacheKey ) ; if ( ! $ val instanceof Volume ) { $ val = new Volume ( $ val ) ; } return $ val ; } $ res = $ this -> client -> get ( $ this -> buildMasterUrl ( self :: DIR_LOOKUP ) , [ 'query' => [ 'volumeId' => $ id ] ] ) ; if ( $ res -> getStatusCode ( ) != 200 ) { throw new SeaweedFSException ( 'Unexpected response when looking up volume: ' . $ res -> getStatusCode ( ) ) ; } $ body = json_decode ( ( string ) $ res -> getBody ( ) ) ; $ volume = new Volume ( $ body ) ; if ( $ this -> cache ) { $ this -> cache -> put ( $ cacheKey , $ volume ) ; } return $ volume ; } | Lookup a volume or file on the master server . |
32,555 | public function get ( $ fid , $ ext = null ) { $ volume = $ this -> lookup ( $ fid ) ; if ( ! $ volume ) { return null ; } $ path = $ fid ; if ( $ ext ) { $ path = $ path . '.' . $ ext ; } $ res = $ this -> client -> get ( $ this -> buildVolumeUrl ( $ volume -> getPublicUrl ( ) , $ path ) ) ; if ( $ res -> getStatusCode ( ) != 200 ) { throw new SeaweedFSException ( 'Unexpected response when retrieving file: ' . $ res -> getStatusCode ( ) ) ; } return $ res -> getBody ( ) -> detach ( ) ; } | Fetch a file from a volume . |
32,556 | public function delete ( $ fid ) { $ volume = $ this -> lookup ( $ fid ) ; if ( ! $ volume ) { throw new SeaweedFSException ( 'Unable to find volume for ' . $ fid ) ; } $ res = $ this -> client -> delete ( $ this -> buildVolumeUrl ( $ volume -> getUrl ( ) , $ fid ) ) ; if ( $ res -> getStatusCode ( ) != 202 ) { throw new SeaweedFSException ( 'Unexpected response when deleting file: ' . $ res -> getStatusCode ( ) ) ; } if ( $ this -> cache && $ this -> cache -> has ( 'file_meta_' . $ fid ) ) { $ this -> cache -> remove ( 'file_meta_' . $ fid ) ; } return true ; } | Delete the specified file . |
32,557 | public function buildMasterUrl ( $ path = null ) { return sprintf ( '%s://%s/%s' , $ this -> scheme , $ this -> master , $ path ? ltrim ( $ path , '/' ) : '' ) ; } | Build a URL to a master server path . |
32,558 | public function buildVolumeUrl ( $ host , $ path = null ) { return sprintf ( '%s://%s/%s' , $ this -> scheme , $ host , $ path ? ltrim ( $ path , '/' ) : '' ) ; } | Build a URL to a volume server path . |
32,559 | protected function _setup ( array $ files ) { foreach ( $ files as $ rname => $ filepath ) { $ this -> _msg ( 'Using tables from ' . basename ( $ filepath ) , 1 ) ; $ this -> _status ( '' ) ; if ( ( $ content = file_get_contents ( $ filepath ) ) === false ) { throw new MW_Setup_Exception ( sprintf ( 'Unable to get content from file "%1$s"' , $ filepath ) ) ; } $ schema = $ this -> _getSchema ( $ rname ) ; foreach ( $ this -> _getTableDefinitions ( $ content ) as $ name => $ sql ) { $ this -> _msg ( sprintf ( 'Checking table "%1$s": ' , $ name ) , 2 ) ; if ( $ schema -> tableExists ( $ name ) !== true ) { $ this -> _execute ( $ sql , $ rname ) ; $ this -> _status ( 'created' ) ; } else { $ this -> _status ( 'OK' ) ; } } foreach ( $ this -> _getIndexDefinitions ( $ content ) as $ name => $ sql ) { $ parts = explode ( '.' , $ name ) ; $ this -> _msg ( sprintf ( 'Checking index "%1$s": ' , $ name ) , 2 ) ; if ( $ schema -> indexExists ( $ parts [ 0 ] , $ parts [ 1 ] ) !== true ) { $ this -> _execute ( $ sql , $ rname ) ; $ this -> _status ( 'created' ) ; } else { $ this -> _status ( 'OK' ) ; } } } } | Creates all required tables if they don t exist |
32,560 | public function ezodfReplaceOONode ( $ getParams , $ getOptions , $ postParams , $ postOptions ) { try { return $ this -> importOODocument ( $ getParams , $ getOptions , $ postParams , $ postOptions , 'replace' ) ; } catch ( Exception $ e ) { throw $ e ; } } | Replace OpenOffice . org document to specified location . A new version will be created and the existing document will be archived . |
32,561 | public function ezodfFetchOONode ( $ getParams , $ getOptions , $ postParams , $ postOptions ) { $ nodeID = $ getParams [ 'nodeID' ] ; $ languageCode = $ getOptions [ 'languageCode' ] ; $ format = $ getOptions [ 'format' ] ; $ node = eZContentObjectTreeNode :: fetch ( $ nodeID , $ languageCode ) ; if ( ! $ node ) { throw new Exception ( 'Could not fetch node: ' . $ nodeID ) ; } $ domDocument = new DOMDocument ( '1.0' , 'utf-8' ) ; $ ooElement = $ domDocument -> createElement ( 'OONode' ) ; $ ooElement -> appendChild ( $ this -> createTreeNodeDOMElement ( $ domDocument , $ node ) ) ; switch ( $ format ) { case 'doc' : $ ooElement -> appendChild ( $ this -> createDocDOMElement ( $ domDocument , $ node ) ) ; break ; case 'odt' : $ ooElement -> appendChild ( $ this -> createOODOMElement ( $ domDocument , $ node ) ) ; break ; } return $ ooElement ; } | Fetch Node for editing in OpenOffice . org |
32,562 | public function ezodfGetTopNodeList ( $ getParams , $ getOptions , $ postParams , $ postOptions ) { $ domDocument = new DOMDocument ( '1.0' , 'utf-8' ) ; $ nodeListElement = $ domDocument -> createElement ( 'TopNodeList' ) ; $ contentINI = eZINI :: instance ( 'content.ini' ) ; $ odfINI = eZINI :: instance ( 'odf.ini' ) ; $ elementCount = 0 ; foreach ( $ odfINI -> variable ( 'OOMenuSettings' , 'TopNodeNameList' ) as $ topNodeName ) { $ nodeID = $ contentINI -> variable ( 'NodeSettings' , $ topNodeName ) ; $ node = eZContentObjectTreeNode :: fetch ( $ nodeID ) ; if ( ! $ node ) { throw new Exception ( 'Could not fetch node: "' . $ topNodeName . '", ID: ' , $ nodeID ) ; } $ nodeListElement -> appendChild ( $ this -> createTreeNodeDOMElement ( $ domDocument , $ node ) ) ; $ elementCount ++ ; } $ nodeListElement -> setAttribute ( 'count' , $ elementCount ) ; return $ nodeListElement ; } | Get top node list . |
32,563 | public function ezodfGetNodeInfo ( $ getParams , $ getOptions , $ postParams , $ postOptions ) { $ nodeID = $ getParams [ 'nodeID' ] ; $ languageCode = $ getOptions [ 'languageCode' ] ; $ domDocument = new DOMDocument ( '1.0' , 'utf-8' ) ; $ node = eZContentObjectTreeNode :: fetch ( $ nodeID , $ languageCode ) ; if ( ! $ node ) { throw new Exception ( 'Could not fetch node: ' . $ nodeID ) ; } return $ this -> createTreeNodeDOMElement ( $ domDocument , $ node ) ; } | Get eZContentObjectTreeNode information |
32,564 | protected function createTreeNodeDOMElement ( DOMDocument $ domDocument , eZContentObjectTreeNode $ node ) { $ nodeElement = $ domDocument -> createElement ( 'Node' ) ; $ nodeElement -> setAttribute ( 'nodeID' , $ node -> attribute ( 'node_id' ) ) ; $ nodeElement -> setAttribute ( 'parentID' , $ node -> attribute ( 'parent_node_id' ) ) ; $ conditions = array ( 'Depth' => 1 , 'DepthOperator' => 'eq' ) ; $ nodeElement -> setAttribute ( 'childCount' , eZContentObjectTreeNode :: subTreeCountByNodeID ( $ conditions , $ node -> attribute ( 'node_id' ) ) ) ; $ conditions [ 'ClassFilterType' ] = 'include' ; $ conditions [ 'ClassFilterArray' ] = eZINI :: instance ( 'contentstructuremenu.ini' ) -> variable ( 'TreeMenu' , 'ShowClasses' ) ; $ nodeElement -> setAttribute ( 'childMenuCount' , eZContentObjectTreeNode :: subTreeCountByNodeID ( $ conditions , $ node -> attribute ( 'node_id' ) ) ) ; $ nodeElement -> appendChild ( $ this -> createAccessDOMElement ( $ domDocument , $ node ) ) ; $ nodeElement -> appendChild ( $ this -> createObjectDOMElement ( $ domDocument , $ node -> attribute ( 'object' ) ) ) ; return $ nodeElement ; } | Create Node element |
32,565 | protected function createObjectDOMElement ( DOMDocument $ domDocument , eZContentObject $ object ) { $ objectElement = $ domDocument -> createElement ( 'Object' ) ; $ objectElement -> setAttribute ( 'mainNodeID' , $ object -> attribute ( 'main_node_id' ) ) ; $ objectElement -> setAttribute ( 'initialLanguage' , $ object -> attribute ( 'initial_language_code' ) ) ; $ objectElement -> setAttribute ( 'published' , $ object -> attribute ( 'published' ) ) ; $ objectElement -> setAttribute ( 'modified' , $ object -> attribute ( 'modified' ) ) ; $ objectElement -> appendChild ( $ this -> createClassDOMElement ( $ domDocument , $ object -> attribute ( 'content_class' ) ) ) ; $ objectElement -> appendChild ( $ this -> createNameListDOMElementFromContentObject ( $ domDocument , $ object ) ) ; $ objectElement -> appendChild ( $ this -> createOwnerDOMElement ( $ domDocument , $ object -> attribute ( 'owner' ) ) ) ; $ objectElement -> appendChild ( $ this -> createSectionDOMElement ( $ domDocument , eZSection :: fetch ( $ object -> attribute ( 'section_id' ) ) ) ) ; return $ objectElement ; } | Create Object element . |
32,566 | protected function createSectionDOMElement ( DOMDocument $ domDocument , eZSection $ section ) { $ sectionElement = $ domDocument -> createElement ( 'Section' ) ; $ sectionElement -> setAttribute ( 'ID' , $ section -> attribute ( 'id' ) ) ; $ sectionElement -> setAttribute ( 'name' , $ section -> attribute ( 'name' ) ) ; return $ sectionElement ; } | Create Section element . |
32,567 | protected function createOwnerDOMElement ( DOMDocument $ domDocument , eZContentObject $ owner ) { $ ownerElement = $ domDocument -> createElement ( 'Owner' ) ; $ ownerElement -> setAttribute ( 'objectID' , $ owner -> attribute ( 'id' ) ) ; $ ownerElement -> setAttribute ( 'primaryLanguage' , $ owner -> attribute ( 'initial_language_code' ) ) ; $ ownerElement -> appendChild ( $ this -> createNameListDOMElementFromContentObject ( $ domDocument , $ owner ) ) ; return $ ownerElement ; } | Create Owner element . |
32,568 | protected function createClassDOMElement ( DOMDocument $ domDocument , eZContentClass $ class ) { $ classElement = $ domDocument -> createElement ( 'Class' ) ; $ classElement -> setAttribute ( 'ID' , $ class -> attribute ( 'id' ) ) ; $ classElement -> setAttribute ( 'primaryLanguage' , $ class -> attribute ( 'top_priority_language_locale' ) ) ; $ classElement -> setAttribute ( 'identifier' , $ class -> attribute ( 'identifier' ) ) ; $ classElement -> appendChild ( $ this -> createNameListDOMElement ( $ domDocument , $ class -> NameList ) ) ; return $ classElement ; } | Create Class element . |
32,569 | protected function createOODOMElement ( DOMDocument $ domDocument , eZContentObjectTreeNode $ node ) { $ ooDocumentElement = $ domDocument -> createElement ( 'OODocument' ) ; $ fileName = eZOOConverter :: objectToOO ( $ node -> attribute ( 'node_id' ) ) ; if ( is_array ( $ fileName ) ) { throw new Exception ( 'Could not generate OO document, ID: ' . $ node -> attribute ( 'node_id' ) . ', Description: ' . $ fileName [ 0 ] ) ; } $ ooDocumentElement -> setAttribute ( 'base64Encoded' , '1' ) ; $ ooDocumentElement -> setAttribute ( 'filename' , $ node -> attribute ( 'name' ) . '.odt' ) ; $ ooDocumentElement -> appendChild ( $ domDocument -> createCDATASection ( base64_encode ( file_get_contents ( $ fileName ) ) ) ) ; unlink ( $ fileName ) ; return $ ooDocumentElement ; } | Create OO document element . |
32,570 | protected function createDocDOMElement ( DOMDocument $ domDocument , eZContentObjectTreeNode $ node ) { $ ooDocumentElement = $ domDocument -> createElement ( 'OODocument' ) ; $ fileName = eZOOConverter :: objectToOO ( $ node -> attribute ( 'node_id' ) ) ; if ( is_array ( $ fileName ) ) { throw new Exception ( 'Could not generate OO document, ID: ' . $ node -> attribute ( 'node_id' ) . ', Description: ' . $ fileName [ 0 ] ) ; } $ ooDocumentElement -> setAttribute ( 'base64Encoded' , '1' ) ; $ ooDocumentElement -> setAttribute ( 'filename' , $ node -> attribute ( 'name' ) . '.doc' ) ; $ convertedFile = '/tmp/word.doc' ; { } $ this -> daemonConvert ( realpath ( $ fileName ) , $ convertedFile ) ; $ ooDocumentElement -> appendChild ( $ domDocument -> createCDATASection ( base64_encode ( file_get_contents ( $ convertedFile ) ) ) ) ; unlink ( $ fileName ) ; return $ ooDocumentElement ; } | Create OO document element with conversion to Word 97 format . |
32,571 | protected function importOODocument ( $ getParams , $ getOptions , $ postParams , $ postOptions , $ importType = 'import' ) { $ nodeID = $ postParams [ 'nodeID' ] ; $ data = $ postParams [ 'data' ] ; $ format = $ postOptions [ 'format' ] ; $ languageCode = $ postOptions [ 'languageCode' ] ; $ base64Encoded = $ postOptions [ 'base64Encoded' ] ; $ node = eZContentObjectTreeNode :: fetch ( $ nodeID , $ languageCode ) ; if ( ! $ node ) { throw new Exception ( 'Could not fetch node: ' . $ nodeID ) ; } if ( $ base64Encoded ) { $ data = base64_decode ( str_replace ( ' ' , '+' , $ data ) ) ; } $ filename = substr ( md5 ( mt_rand ( ) ) , 0 , 8 ) . ".{$format}" ; $ tmpFilePath = eZSys :: cacheDirectory ( ) . '/ezodf/' . substr ( md5 ( mt_rand ( ) ) , 0 , 8 ) ; $ tmpFilename = $ tmpFilePath . '/' . $ filename ; if ( ! eZFile :: create ( $ filename , $ tmpFilePath , $ data ) ) { throw new Exception ( 'Could not create file: ' . $ tmpFilename ) ; } $ import = new eZOOImport ( ) ; $ result = $ import -> import ( $ tmpFilename , $ nodeID , $ filename , $ importType ) ; eZDir :: recursiveDelete ( $ tmpFilePath ) ; if ( ! $ result ) { throw new Exception ( 'OO import failed: ' . $ import -> getErrorNumber ( ) . ' - ' . $ import -> getErrorMessage ( ) ) ; } $ domDocument = new DOMDocument ( '1.0' , 'utf-8' ) ; $ importElement = $ domDocument -> createElement ( 'OOImport' ) ; $ importElement -> appendChild ( $ this -> createTreeNodeDOMElement ( $ domDocument , $ result [ 'MainNode' ] ) ) ; return $ importElement ; } | Import object . |
32,572 | protected function createAccessDOMElement ( DOMDocument $ domDocument , eZContentObjectTreeNode $ node ) { $ accessElement = $ domDocument -> createElement ( 'AccessRights' ) ; $ accessElement -> setAttribute ( 'canRead' , $ node -> attribute ( 'can_read' ) ? '1' : '0' ) ; $ accessElement -> setAttribute ( 'canEdit' , $ node -> attribute ( 'can_edit' ) ? '1' : '0' ) ; $ accessElement -> setAttribute ( 'canCreate' , $ node -> attribute ( 'can_create' ) ? '1' : '0' ) ; return $ accessElement ; } | Create Access element . |
32,573 | public function setMethod ( $ method ) { if ( $ method == $ this -> getMethod ( ) ) { return ; } $ this -> _values [ 'method' ] = ( string ) $ method ; $ this -> setModified ( ) ; } | Sets the new method for the job . |
32,574 | private function request ( $ query , $ variables , $ headers ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ this -> url ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , json_encode ( [ 'query' => $ query , 'variables' => $ variables ] ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , 0 ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array_merge ( $ headers , [ "X-Token: {$this->token}" , "Content-Type: application/json;charset=utf-8" ] ) ) ; $ output = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return $ output ; } | Make a GraphQL Request and get the raw response . |
32,575 | public function json ( $ query , $ variables = [ ] , $ headers = [ ] , $ assoc = false ) { $ response = $ this -> request ( $ query , $ variables , $ headers ) ; $ responseJson = json_decode ( $ response , $ assoc ) ; if ( $ responseJson === null ) { throw new GraphQLInvalidResponse ( 'GraphQL did not provide a valid JSON response. Please make sure you are pointing at the correct URL.' ) ; } else if ( ! isset ( $ responseJson -> data ) && $ responseJson -> data != null ) { throw new GraphQLMissingData ( 'There was an error with the GraphQL response, no data key was found.' ) ; } return $ responseJson ; } | Make a GraphQL Request and get the response body in JSON form . |
32,576 | public function response ( $ query , $ variables = [ ] , $ headers = [ ] ) { $ response = $ this -> json ( $ query , $ variables , $ headers ) ; return new Response ( $ response ) ; } | Make a GraphQL Request and get the guzzle response . |
32,577 | public function getMethods ( $ alsoProtected = true , $ alsoPrivate = true , $ alsoHerited = false ) { $ ar = parent :: getMethods ( ) ; foreach ( $ ar as $ method ) { if ( substr ( $ method -> name , 0 , 2 ) == '__' || $ method -> isAbstract ( ) || $ method -> isConstructor ( ) || $ method -> isDestructor ( ) ) { continue ; } $ m = new IPReflectionMethod ( $ this -> classname , $ method -> name ) ; if ( ( ! $ m -> isPrivate ( ) || $ alsoPrivate ) && ( ! $ m -> isProtected ( ) || $ alsoProtected ) && ( ( $ m -> getDeclaringClass ( ) -> name == $ this -> classname ) || $ alsoHerited ) ) { $ this -> methods [ $ method -> name ] = $ m ; } } ksort ( $ this -> methods ) ; return $ this -> methods ; } | Levert een array met alle methoden van deze class op . |
32,578 | public function getProperties ( $ alsoProtected = true , $ alsoPrivate = true , $ alsoHerited = false ) { $ ar = parent :: getProperties ( ) ; $ this -> properties = array ( ) ; foreach ( $ ar as $ property ) { if ( ( ! $ property -> isPrivate ( ) || $ alsoPrivate ) && ( ! $ property -> isProtected ( ) || $ alsoProtected ) && ( ( $ property -> getDeclaringClass ( ) -> name == $ this -> classname ) || $ alsoHerited ) ) { try { $ p = new IPReflectionProperty ( $ this -> classname , $ property -> getName ( ) ) ; $ this -> properties [ $ property -> name ] = $ p ; } catch ( ReflectionException $ exception ) { echo 'Fout bij property: ' . $ property -> name . "<br>\n" ; } } } ksort ( $ this -> properties ) ; return $ this -> properties ; } | Levert een array met variabelen van deze class op . |
32,579 | public function getAnnotation ( $ annotationName , $ annotationClass = null ) { return IPPhpDoc :: getAnnotation ( $ this -> comment , $ annotationName , $ annotationClass ) ; } | read an extended annotation . |
32,580 | public function get ( $ key ) { if ( isset ( $ this -> values [ $ key ] ) ) { return $ this -> values [ $ key ] ; } else { return null ; } } | Get a value that has been set |
32,581 | public function values ( array $ values ) { foreach ( $ values as $ k => $ v ) { $ this -> value ( $ k , $ v ) ; } return $ this ; } | Set values . Merges into existing values . |
32,582 | private function _initCriteriaConditions ( MW_Common_Criteria_Interface $ criteria , stdClass $ params ) { if ( isset ( $ params -> condition ) && is_object ( $ params -> condition ) ) { $ existing = $ criteria -> getConditions ( ) ; $ criteria -> setConditions ( $ criteria -> toConditions ( ( array ) $ params -> condition ) ) ; $ expr = array ( $ criteria -> getConditions ( ) , $ existing ) ; $ criteria -> setConditions ( $ criteria -> combine ( '&&' , $ expr ) ) ; } } | Initializes the criteria object with conditions based on the given parameter . |
32,583 | protected function _toArray ( array $ list ) { $ result = array ( ) ; foreach ( $ list as $ item ) { $ result [ ] = ( object ) $ item -> toArray ( ) ; } return $ result ; } | Converts the given list of objects to a list of stdClass objects |
32,584 | public function initializeObject ( ) { if ( ! isset ( $ this -> options [ 'csvFilePath' ] ) || ! is_string ( $ this -> options [ 'csvFilePath' ] ) ) { throw new InvalidArgumentException ( 'Missing or invalid "csvFilePath" in preset part settings' , 1429027715 ) ; } $ this -> csvFilePath = $ this -> options [ 'csvFilePath' ] ; if ( ! is_file ( $ this -> csvFilePath ) ) { throw new \ Exception ( sprintf ( 'File "%s" not found' , $ this -> csvFilePath ) , 1427882078 ) ; } if ( isset ( $ this -> options [ 'csvDelimiter' ] ) ) { $ this -> csvDelimiter = $ this -> options [ 'csvDelimiter' ] ; } if ( isset ( $ this -> options [ 'csvEnclosure' ] ) ) { $ this -> csvEnclosure = $ this -> options [ 'csvEnclosure' ] ; } $ this -> logger -> log ( sprintf ( '%s will read from "%s", using %s as delimiter and %s as enclosure character.' , get_class ( $ this ) , $ this -> csvFilePath , $ this -> csvDelimiter , $ this -> csvEnclosure ) , LOG_DEBUG ) ; } | Initialize this data provider with the currently set options |
32,585 | public function fetch ( ) { static $ currentLine = 0 ; $ dataResult = array ( ) ; if ( isset ( $ this -> options [ 'skipHeader' ] ) && $ this -> options [ 'skipHeader' ] === true ) { $ skipLines = 1 ; } elseif ( isset ( $ this -> options [ 'skipHeader' ] ) && \ is_numeric ( $ this -> options [ 'skipHeader' ] ) ) { $ skipLines = ( int ) $ this -> options [ 'skipHeader' ] ; } else { $ skipLines = 0 ; } if ( ( $ handle = fopen ( $ this -> csvFilePath , 'r' ) ) !== false ) { while ( ( $ data = fgetcsv ( $ handle , 65534 , $ this -> csvDelimiter , $ this -> csvEnclosure ) ) !== false ) { if ( $ currentLine < $ skipLines ) { $ currentLine ++ ; continue ; } if ( $ currentLine >= $ this -> offset && $ currentLine < ( $ this -> offset + $ this -> limit ) ) { if ( isset ( $ data [ 0 ] ) && $ data [ 0 ] !== '' ) { $ this -> preProcessRecordData ( $ data ) ; $ dataResult [ ] = $ data ; } } $ currentLine ++ ; } fclose ( $ handle ) ; } $ this -> logger -> log ( sprintf ( '%s: read %s lines and found %s records.' , $ this -> csvFilePath , $ currentLine , count ( $ dataResult ) ) , LOG_DEBUG ) ; return $ dataResult ; } | Fetch all the data from this Data Source . |
32,586 | protected function _process ( ) { $ this -> _msg ( 'Adding customer performance data' , 0 ) ; $ context = $ this -> _getContext ( ) ; $ customerManager = MShop_Customer_Manager_Factory :: createManager ( $ context ) ; $ customerItem = $ customerManager -> createItem ( ) ; $ customerItem -> setCode ( 'demo-test' ) ; $ customerItem -> setLabel ( 'Test demo unitperf user' ) ; $ customerItem -> setPassword ( sha1 ( microtime ( true ) . getmypid ( ) . rand ( ) ) ) ; $ customerItem -> setStatus ( 1 ) ; $ addrItem = $ customerItem -> getPaymentAddress ( ) ; $ addrItem -> setCompany ( 'Test company' ) ; $ addrItem -> setVatID ( 'DE999999999' ) ; $ addrItem -> setSalutation ( 'mr' ) ; $ addrItem -> setFirstname ( 'Testdemo' ) ; $ addrItem -> setLastname ( 'Perfuser' ) ; $ addrItem -> setAddress1 ( 'Test street' ) ; $ addrItem -> setAddress2 ( '1' ) ; $ addrItem -> setPostal ( '1000' ) ; $ addrItem -> setCity ( 'Test city' ) ; $ addrItem -> setLanguageId ( 'en' ) ; $ addrItem -> setCountryId ( 'DE' ) ; $ addrItem -> setEmail ( 'me@localhost' ) ; $ customerManager -> saveItem ( $ customerItem ) ; $ this -> _status ( 'done' ) ; } | Inserts customer items . |
32,587 | protected function _addProduct ( Controller_Frontend_Interface $ controller , array $ values , array $ options ) { $ controller -> addProduct ( ( isset ( $ values [ 'prod-id' ] ) ? $ values [ 'prod-id' ] : null ) , ( isset ( $ values [ 'quantity' ] ) ? $ values [ 'quantity' ] : 1 ) , $ options , ( isset ( $ values [ 'attrvar-id' ] ) ? array_filter ( ( array ) $ values [ 'attrvar-id' ] ) : array ( ) ) , ( isset ( $ values [ 'attrconf-id' ] ) ? array_filter ( ( array ) $ values [ 'attrconf-id' ] ) : array ( ) ) , ( isset ( $ values [ 'attrhide-id' ] ) ? array_filter ( ( array ) $ values [ 'attrhide-id' ] ) : array ( ) ) , ( isset ( $ values [ 'warehouse' ] ) ? $ values [ 'warehouse' ] : 'default' ) ) ; } | Adds a single product specified by its values to the basket . |
32,588 | public function DisplayLink ( ) { return Controller :: join_links ( DisplayController :: create ( ) -> AbsoluteLink ( "estimate" ) , $ this -> ID , $ this -> AccessKey ) ; } | Generate a link to view the associated front end display for this order |
32,589 | public function getPersonalDetails ( ) { $ return = [ ] ; if ( $ this -> Company ) { $ return [ ] = $ this -> Company ; } if ( $ this -> FirstName ) { $ return [ ] = $ this -> FirstName ; } if ( $ this -> Surname ) { $ return [ ] = $ this -> Surname ; } if ( $ this -> Email ) { $ return [ ] = $ this -> Email ; } if ( $ this -> PhoneNumber ) { $ return [ ] = $ this -> PhoneNumber ; } return implode ( ",\n" , $ return ) ; } | Generate a string of the customer s personal details |
32,590 | public function getBillingAddress ( ) { $ address = ( $ this -> Address1 ) ? $ this -> Address1 . ",\n" : '' ; $ address .= ( $ this -> Address2 ) ? $ this -> Address2 . ",\n" : '' ; $ address .= ( $ this -> City ) ? $ this -> City . ",\n" : '' ; $ address .= ( $ this -> PostCode ) ? $ this -> PostCode . ",\n" : '' ; $ address .= ( $ this -> Country ) ? $ this -> Country : '' ; return $ address ; } | Get the complete billing address for this order |
32,591 | public function getCountryFull ( ) { $ list = i18n :: getData ( ) -> getCountries ( ) ; $ country = strtolower ( $ this -> Country ) ; return ( array_key_exists ( $ country , $ list ) ) ? $ list [ $ country ] : $ country ; } | Get the rendered name of the billing country based on the local |
32,592 | public function getDeliveryAddress ( ) { $ address = ( $ this -> DeliveryAddress1 ) ? $ this -> DeliveryAddress1 . ",\n" : '' ; $ address .= ( $ this -> DeliveryAddress2 ) ? $ this -> DeliveryAddress2 . ",\n" : '' ; $ address .= ( $ this -> DeliveryCity ) ? $ this -> DeliveryCity . ",\n" : '' ; $ address .= ( $ this -> DeliveryPostCode ) ? $ this -> DeliveryPostCode . ",\n" : '' ; $ address .= ( $ this -> DeliveryCountry ) ? $ this -> DeliveryCountry : '' ; return $ address ; } | Get the complete delivery address for this order |
32,593 | public function getDeliveryCountryFull ( ) { $ list = i18n :: getData ( ) -> getCountries ( ) ; $ country = strtolower ( $ this -> DeliveryCountry ) ; return ( array_key_exists ( $ country , $ list ) ) ? $ list [ $ country ] : $ country ; } | Get the rendered name of the delivery country based on the local |
32,594 | public function getTaxTotal ( ) { $ total = 0 ; $ items = $ this -> Items ( ) ; foreach ( $ items as $ item ) { $ tax = $ item -> UnitTax ; $ total += $ tax * $ item -> Quantity ; } $ this -> extend ( "updateTaxTotal" , $ total ) ; $ total = MathsHelper :: round ( $ total , 2 ) ; return $ total ; } | Total values of items in this order |
32,595 | public function getTaxList ( ) { $ taxes = ArrayList :: create ( ) ; foreach ( $ this -> Items ( ) as $ item ) { $ existing = null ; $ rate = $ item -> Tax ( ) ; if ( $ rate -> exists ( ) ) { $ existing = $ taxes -> find ( "ID" , $ rate -> ID ) ; } if ( ! $ existing ) { $ currency = DBCurrency :: create ( ) ; $ currency -> setValue ( $ item -> getTaxTotal ( ) ) ; $ taxes -> push ( ArrayData :: create ( [ "ID" => $ rate -> ID , "Rate" => $ rate , "Total" => $ currency ] ) ) ; } elseif ( $ rate && $ existing ) { $ existing -> Total -> setValue ( $ existing -> Total -> getValue ( ) + $ item -> getTaxTotal ( ) ) ; } } return $ taxes ; } | Get a list of all taxes used and an associated value |
32,596 | public function getTotal ( ) { $ total = $ this -> SubTotal + $ this -> TaxTotal ; $ this -> extend ( "updateTotal" , $ total ) ; return $ total ; } | Total value of order |
32,597 | public function convertToInvoice ( ) { $ id = $ this -> ID ; $ this -> ClassName = Invoice :: class ; $ this -> write ( ) ; $ record = Invoice :: get ( ) -> byID ( $ id ) ; $ record -> Ref = null ; $ record -> Prefix = null ; $ record -> StartDate = null ; $ record -> EndDate = null ; $ record -> write ( ) ; return $ record ; } | Factory method to convert this estimate to an order . |
32,598 | protected function getBaseNumber ( ) { $ base = 0 ; $ prefix = $ this -> get_prefix ( ) ; $ classname = $ this -> ClassName ; $ last = $ classname :: get ( ) -> filter ( "ClassName" , $ classname ) -> sort ( "Ref" , "DESC" ) -> first ( ) ; if ( isset ( $ last ) ) { $ base = str_replace ( $ prefix , "" , $ last -> Ref ) ; $ base = ( int ) str_replace ( "-" , "" , $ base ) ; } $ base ++ ; return $ base ; } | Get a base ID for the last Estimate in the DataBase |
32,599 | public function getLowestPrice ( array $ priceItems , $ quantity ) { $ priceList = array ( ) ; foreach ( $ priceItems as $ priceItem ) { $ iface = 'MShop_Price_Item_Interface' ; if ( ( $ priceItem instanceof $ iface ) === false ) { throw new MShop_Price_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } $ priceList [ $ priceItem -> getQuantity ( ) ] = $ priceItem ; } ksort ( $ priceList ) ; if ( ( $ price = reset ( $ priceList ) ) === false ) { throw new MShop_Price_Exception ( sprintf ( 'Price item not available' ) ) ; } if ( $ price -> getQuantity ( ) > $ quantity ) { $ msg = sprintf ( 'Price for the given quantity "%1$d" not available' , $ quantity ) ; throw new MShop_Price_Exception ( $ msg ) ; } foreach ( $ priceList as $ qty => $ priceItem ) { if ( $ qty <= $ quantity && $ qty > $ price -> getQuantity ( ) ) { $ price = $ priceItem ; } } return clone $ price ; } | Returns the price item with the lowest price for the given quantity . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.