idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
33,200 | public static function checkImmutability ( $ object , array $ array ) { $ exception = new UnauthorizedModificationException ( $ object ) ; foreach ( $ array as $ key => $ previousValue ) { $ methodName = 'get' . ucfirst ( $ key ) ; if ( $ previousValue != $ object -> $ methodName ( ) ) { $ exception -> addModifiedProperty ( $ key ) ; } } if ( $ exception -> hasModifiedProperty ( ) ) { throw $ exception ; } } | Check an object data against old values . |
33,201 | protected function _addDemoData ( ) { $ ds = DIRECTORY_SEPARATOR ; $ path = __DIR__ . $ ds . 'data' . $ ds . 'demo-product.php' ; if ( ( $ data = include ( $ path ) ) == false ) { throw new MShop_Exception ( sprintf ( 'No file "%1$s" found for product domain' , $ path ) ) ; } $ context = $ this -> _getContext ( ) ; $ manager = MShop_Factory :: createManager ( $ context , 'product' ) ; foreach ( $ data as $ entry ) { $ item = $ manager -> createItem ( ) ; $ item -> setTypeId ( $ this -> _getTypeId ( 'product/type' , 'product' , $ entry [ 'type' ] ) ) ; $ item -> setCode ( $ entry [ 'code' ] ) ; $ item -> setLabel ( $ entry [ 'label' ] ) ; $ item -> setSupplierCode ( $ entry [ 'supplier' ] ) ; $ item -> setDateStart ( $ entry [ 'start' ] ) ; $ item -> setDateEnd ( $ entry [ 'end' ] ) ; $ item -> setStatus ( $ entry [ 'status' ] ) ; $ manager -> saveItem ( $ item ) ; $ this -> _addRefItems ( $ entry , $ item -> getId ( ) ) ; } } | Adds the demo data to the database . |
33,202 | protected function _addRefItems ( array $ entry , $ id ) { if ( isset ( $ entry [ 'stock' ] ) ) { $ this -> _addProductStock ( $ id , $ entry [ 'stock' ] ) ; } if ( isset ( $ entry [ 'attribute' ] ) ) { $ this -> _addAttributes ( $ id , $ entry [ 'attribute' ] , 'product' ) ; } if ( isset ( $ entry [ 'media' ] ) ) { $ this -> _addMedia ( $ id , $ entry [ 'media' ] , 'product' ) ; } if ( isset ( $ entry [ 'price' ] ) ) { $ this -> _addPrices ( $ id , $ entry [ 'price' ] , 'product' ) ; } if ( isset ( $ entry [ 'text' ] ) ) { $ this -> _addTexts ( $ id , $ entry [ 'text' ] , 'product' ) ; } if ( isset ( $ entry [ 'product' ] ) ) { $ this -> _addProducts ( $ id , $ entry [ 'product' ] , 'product' ) ; } } | Adds the referenced items from the given entry data . |
33,203 | protected function filterBlocks ( string $ condition , array $ blocks ) { if ( empty ( $ condition ) ) { return $ blocks ; } $ conditions = [ ] ; foreach ( explode ( ';' , $ condition ) as $ condition ) { if ( strpos ( $ condition , ':' ) === false ) { continue ; } list ( $ name , $ value ) = explode ( ":" , $ condition ) ; $ conditions [ $ name ] = $ value ; } $ result = $ blocks ; if ( isset ( $ conditions [ 'prefix' ] ) ) { $ result = [ ] ; foreach ( $ blocks as $ name => $ value ) { if ( strpos ( $ name , $ conditions [ 'prefix' ] ) === 0 ) { $ result [ substr ( $ name , strlen ( $ conditions [ 'prefix' ] ) + 1 ) ] = $ value ; } } } if ( isset ( $ conditions [ 'include' ] ) ) { $ include = explode ( ',' , $ conditions [ 'include' ] ) ; foreach ( $ blocks as $ name => $ value ) { if ( ! in_array ( $ name , $ include ) ) { unset ( $ result [ $ name ] ) ; } } } if ( isset ( $ conditions [ 'exclude' ] ) ) { $ exclude = explode ( ',' , $ conditions [ 'exclude' ] ) ; foreach ( $ blocks as $ name => $ value ) { if ( in_array ( $ name , $ exclude ) ) { unset ( $ result [ $ name ] ) ; } foreach ( $ exclude as $ pattern ) { if ( strpos ( $ pattern , '*' ) === false ) { continue ; } $ pattern = '/^' . str_replace ( '*' , '.+' , $ pattern ) . '/i' ; if ( preg_match ( $ pattern , $ name ) ) { unset ( $ result [ $ name ] ) ; } } } } return $ result ; } | Get blocks matching specified condition . |
33,204 | public static function checkClassList ( $ name , array $ list ) { foreach ( $ list as $ object ) { if ( ( $ object instanceof $ name ) === false ) { throw new MW_Common_Exception ( sprintf ( 'Object doesn\'t implement "%1$s"' , $ name ) ) ; } } } | Tests if a list of objects are an instance of the given class extends the class or implements the interface . |
33,205 | public function getHTML ( $ type = null ) { $ html = '' ; $ param = '?v=' ; if ( strpos ( $ this -> _baseURL , '?' ) !== false ) { $ param = '&v=' ; } foreach ( $ this -> _registeredPackages as $ filetype => $ packageList ) { if ( $ type !== null && $ filetype !== $ type ) { continue ; } foreach ( $ packageList as $ package ) { $ packageFile = $ this -> _deployDir . $ package -> file ; $ packageFileFilesystem = $ this -> _basePath . $ packageFile ; $ packageFileTime = 0 ; $ timestamp = 0 ; if ( DIRECTORY_SEPARATOR !== '/' ) { $ packageFileFilesystem = str_replace ( '/' , DIRECTORY_SEPARATOR , $ packageFileFilesystem ) ; } if ( is_file ( $ packageFileFilesystem ) ) { $ packageFileTime = filemtime ( $ packageFileFilesystem ) ; } $ filesToDisplay = $ this -> _getFileUrls ( $ this -> _baseURL , $ this -> _basePath , $ param , $ package , $ timestamp ) ; if ( $ packageFileTime >= $ timestamp ) { $ filesToDisplay = array ( $ this -> _baseURL . $ packageFile . $ param . $ packageFileTime ) ; } $ html .= $ this -> _createHtml ( $ filesToDisplay , $ filetype ) ; } } return $ html ; } | Returns HTML for packages files with given filter . |
33,206 | public function deploy ( $ type = null , $ debug = true , $ filepermission = 0644 , $ dirpermission = 0755 ) { foreach ( $ this -> _registeredPackages as $ filetype => $ packageFiles ) { if ( $ type !== null && $ filetype !== $ type ) { continue ; } foreach ( $ packageFiles as $ package ) { $ packageFile = $ this -> _basePath . $ this -> _deployDir . $ package -> file ; $ packageDir = dirname ( $ packageFile ) ; if ( DIRECTORY_SEPARATOR !== '/' ) { $ packageDir = str_replace ( '/' , DIRECTORY_SEPARATOR , $ packageDir ) ; } if ( ! is_dir ( $ packageDir ) ) { if ( mkdir ( $ packageDir , $ dirpermission , true ) === false ) { throw new MW_Jsb2_Exception ( sprintf ( 'Unable to create path for package file "%1$s"' , $ packageDir ) ) ; } } $ this -> _minify ( $ package , $ debug , $ filepermission ) ; } } } | Creates minified packages files . |
33,207 | protected function _createHtml ( array $ files , $ filetype ) { $ html = '' ; foreach ( $ files as $ file ) { switch ( $ filetype ) { case 'js' : $ html .= '<script type="text/javascript" src="' . $ file . '"></script>' . PHP_EOL ; break ; case 'css' : $ html .= '<link rel="stylesheet" type="text/css" href="' . $ file . '"/>' . PHP_EOL ; break ; default : throw new MW_Jsb2_Exception ( sprintf ( 'Unknown file extension: "%1$s"' , $ filetype ) ) ; } } return $ html ; } | Generates the tags for the HTML head . |
33,208 | protected function _getFileUrls ( $ baseUrl , $ basePath , $ param , stdClass $ package , & $ timestamp ) { $ timestamp = ( int ) $ timestamp ; $ filesToDisplay = array ( ) ; foreach ( $ package -> fileIncludes as $ singleFile ) { $ filename = $ basePath . $ singleFile -> path . $ singleFile -> text ; if ( DIRECTORY_SEPARATOR !== '/' ) { $ filename = str_replace ( '/' , DIRECTORY_SEPARATOR , $ filename ) ; } if ( ! is_file ( $ filename ) || ( $ fileTime = filemtime ( $ filename ) ) === false ) { throw new MW_Jsb2_Exception ( sprintf ( 'Unable to read filetime of file "%1$s"' , $ filename ) ) ; } $ timestamp = max ( $ timestamp , $ fileTime ) ; $ filesToDisplay [ ] = $ baseUrl . $ singleFile -> path . $ singleFile -> text . $ param . $ fileTime ; } return $ filesToDisplay ; } | Returns the file URLs of the given package object . |
33,209 | protected function _minify ( $ package , $ debug , $ permissions ) { $ content = '' ; $ ds = DIRECTORY_SEPARATOR ; foreach ( $ this -> _getFilenames ( $ package , $ this -> _basePath ) as $ filename ) { if ( $ ds !== '/' ) { $ filename = str_replace ( '/' , $ ds , $ filename ) ; } if ( ( $ content .= file_get_contents ( $ filename ) ) === false ) { throw new MW_Jsb2_Exception ( sprintf ( 'Unable to get content of file "%1$s"' , $ filename ) ) ; } } if ( $ debug !== true ) { $ content = JSMin :: minify ( $ content ) ; } $ pkgFileName = $ this -> _basePath . $ this -> _deployDir . $ package -> file ; if ( $ ds !== '/' ) { $ pkgFileName = str_replace ( '/' , $ ds , $ pkgFileName ) ; } if ( file_put_contents ( $ pkgFileName , $ content ) === false ) { throw new MW_Jsb2_Exception ( sprintf ( 'Unable to create package file "%1$s"' , $ pkgFileName ) ) ; } if ( chmod ( $ pkgFileName , $ permissions ) === false ) { throw new MW_Jsb2_Exception ( sprintf ( 'Unable to change permissions of file "%1$s"' , $ pkgFileName ) ) ; } } | Creates minified file for given package using JSMin . |
33,210 | protected function _getPackages ( $ manifest , $ filter = array ( ) ) { $ packageContainer = array ( ) ; if ( ! isset ( $ manifest -> pkgs ) || ! is_array ( $ manifest -> pkgs ) ) { throw new MW_Jsb2_Exception ( 'No packages found' ) ; } foreach ( $ manifest -> pkgs as $ package ) { if ( ! isset ( $ package -> name ) || ! isset ( $ package -> file ) || ! is_object ( $ package ) ) { throw new MW_Jsb2_Exception ( 'Invalid package content' ) ; } if ( ! isset ( $ package -> fileIncludes ) || ! is_array ( $ package -> fileIncludes ) ) { throw new MW_Jsb2_Exception ( 'No files in package found' ) ; } if ( ! in_array ( $ package -> name , $ filter ) ) { $ packageContainer [ pathinfo ( $ package -> file , PATHINFO_EXTENSION ) ] [ ] = $ package ; } } return $ packageContainer ; } | Get the packages from a JSON decoded manifest and validates them . |
33,211 | protected function _getFilenames ( $ package , $ prePath = '' ) { $ filenames = array ( ) ; $ ds = DIRECTORY_SEPARATOR ; foreach ( $ package -> fileIncludes as $ include ) { if ( ! is_object ( $ include ) ) { throw new MW_Jsb2_Exception ( 'Invalid file inlcude' ) ; } $ filename = $ include -> path . $ include -> text ; $ absfilename = $ this -> _basePath . $ filename ; if ( $ ds !== '/' ) { $ absfilename = str_replace ( '/' , $ ds , $ absfilename ) ; } if ( ! file_exists ( $ absfilename ) ) { throw new MW_Jsb2_Exception ( sprintf ( 'File does not exists: "%1$s"' , $ absfilename ) ) ; } $ filenames [ ] = $ prePath . $ filename ; } return $ filenames ; } | Gets files stored in package an checkes for existence . |
33,212 | protected function _getManifest ( $ filepath ) { if ( ! file_exists ( $ filepath ) ) { throw new MW_Jsb2_Exception ( sprintf ( 'File does not exists: "%1$s"' , $ filepath ) ) ; } if ( ( $ content = file_get_contents ( $ filepath ) ) === false ) { throw new MW_Jsb2_Exception ( sprintf ( 'Unable to read content from "%1$s"' , $ filepath ) ) ; } if ( ( $ content = json_decode ( $ content ) ) === null ) { throw new MW_Jsb2_Exception ( 'File content is not JSON encoded' ) ; } return $ content ; } | Returns the content of a manifest file . |
33,213 | protected function getInstance ( $ name ) { $ route = & $ this -> routes [ $ name ] ; if ( null === $ route [ 'instance' ] ) { $ route [ 'instance' ] = $ this -> routeManager -> build ( ! isset ( $ route [ 'options' ] [ 'type' ] ) ? 'Generic' : $ route [ 'options' ] [ 'type' ] , $ route [ 'options' ] ) ; } return $ route [ 'instance' ] ; } | Returns an instance of a given route . |
33,214 | protected function _getProductList ( MW_View_Interface $ view ) { if ( $ this -> _productList === null ) { $ this -> _searchProducts ( $ view ) ; } return $ this -> _productList ; } | Returns the products found for the current parameters . |
33,215 | protected function _getProductListFilterByParam ( array $ params , $ catfilter = true , $ textfilter = true , $ attrfilter = true ) { $ sortdir = '+' ; $ context = $ this -> _getContext ( ) ; $ config = $ context -> getConfig ( ) ; $ text = ( isset ( $ params [ 'f-search-text' ] ) ? ( string ) $ params [ 'f-search-text' ] : '' ) ; $ catid = ( isset ( $ params [ 'f-catalog-id' ] ) ? ( string ) $ params [ 'f-catalog-id' ] : '' ) ; if ( $ catid == '' && $ catfilter === true ) { $ catid = $ config -> get ( 'client/html/catalog/list/catid-default' , '' ) ; } $ page = $ this -> _getProductListPageByParam ( $ params ) ; $ size = $ this -> _getProductListSizeByParam ( $ params ) ; $ sort = $ this -> _getProductListSortByParam ( $ params , $ sortdir ) ; $ filter = $ this -> _createProductListFilter ( $ text , $ catid , $ sort , $ sortdir , $ page , $ size , $ catfilter , $ textfilter ) ; if ( $ attrfilter === true ) { $ this -> _addAttributeFilterByParam ( $ params , $ filter ) ; } return $ filter ; } | Returns the filter from the given parameters for the product list . |
33,216 | private function _createProductListFilter ( $ text , $ catid , $ sort , $ sortdir , $ page , $ size , $ catfilter , $ textfilter ) { $ controller = Controller_Frontend_Factory :: createController ( $ this -> _getContext ( ) , 'catalog' ) ; if ( $ text !== '' && $ textfilter === true ) { $ filter = $ controller -> createProductFilterByText ( $ text , $ sort , $ sortdir , ( $ page - 1 ) * $ size , $ size ) ; if ( $ catid !== '' && $ catfilter === true ) { $ filter = $ controller -> addProductFilterCategory ( $ filter , $ catid ) ; } return $ filter ; } elseif ( $ catid !== '' && $ catfilter === true ) { return $ controller -> createProductFilterByCategory ( $ catid , $ sort , $ sortdir , ( $ page - 1 ) * $ size , $ size ) ; } else { return $ controller -> createProductFilterDefault ( $ sort , $ sortdir , ( $ page - 1 ) * $ size , $ size ) ; } } | Creates the filter from the given parameters for the product list . |
33,217 | protected function _getProductListFilter ( MW_View_Interface $ view , $ catfilter = true , $ textfilter = true , $ attrfilter = true ) { return $ this -> _getProductListFilterByParam ( $ view -> param ( ) , $ catfilter , $ textfilter , $ attrfilter ) ; } | Returns the filter created from the view parameters for the product list . |
33,218 | protected function _getProductListTotal ( MW_View_Interface $ view ) { if ( $ this -> _productList === null ) { $ this -> _searchProducts ( $ view ) ; } return $ this -> _productTotal ; } | Returns the total number of products available for the current parameters . |
33,219 | protected function _getProductListSortByParam ( array $ params , & $ sortdir ) { $ sortation = ( isset ( $ params [ 'f-sort' ] ) ? ( string ) $ params [ 'f-sort' ] : 'relevance' ) ; $ sortdir = ( $ sortation [ 0 ] === '-' ? '-' : '+' ) ; $ sort = ltrim ( $ sortation , '-' ) ; return ( strlen ( $ sort ) > 0 ? $ sort : 'relevance' ) ; } | Returns the sanitized sortation from the parameters for the product list . |
33,220 | protected function _searchProducts ( MW_View_Interface $ view ) { $ context = $ this -> _getContext ( ) ; $ config = $ context -> getConfig ( ) ; $ domains = $ config -> get ( 'client/html/catalog/domains' , array ( 'media' , 'price' , 'text' ) ) ; $ domains = $ config -> get ( 'client/html/catalog/list/domains' , $ domains ) ; $ productFilter = $ this -> _getProductListFilter ( $ view ) ; $ controller = Controller_Frontend_Factory :: createController ( $ context , 'catalog' ) ; $ this -> _productList = $ controller -> getProductList ( $ productFilter , $ this -> _productTotal , $ domains ) ; } | Searches for the products based on the current paramters . |
33,221 | public function history ( ) { $ member = Security :: getCurrentUser ( ) ; $ list = PaginatedList :: create ( $ member -> HistoricInvoices ( ) , $ this -> owner -> getRequest ( ) ) ; $ this -> owner -> customise ( [ "Title" => _t ( 'Orders.OrderHistory' , 'Order History' ) , "MenuTitle" => _t ( 'Orders.OrderHistory' , 'Order History' ) , "Content" => $ this -> owner -> renderWith ( "SilverCommerce\\OrdersAdmin\\Includes\\OrdersList" , [ "List" => $ list ] ) ] ) ; $ this -> owner -> extend ( "updateHistoricOrders" , $ orders ) ; return $ this -> owner -> renderWith ( [ 'AccountController_history' , AccountController :: class . '_history' , 'AccountController' , AccountController :: class , 'Page' ] ) ; } | Display all historic orders for the current user |
33,222 | public function outstanding ( ) { $ member = Security :: getCurrentUser ( ) ; $ list = PaginatedList :: create ( $ member -> OutstandingInvoices ( ) , $ this -> owner -> getRequest ( ) ) ; $ this -> owner -> customise ( [ "Title" => _t ( 'Orders.OutstandingOrders' , 'Outstanding Orders' ) , "MenuTitle" => _t ( 'Orders.OutstandingOrders' , 'Outstanding Orders' ) , "Content" => $ this -> owner -> renderWith ( "SilverCommerce\\OrdersAdmin\\Includes\\OrdersList" , [ "List" => $ list ] ) ] ) ; $ this -> owner -> extend ( "updateOutstandingOrders" , $ orders ) ; return $ this -> owner -> renderWith ( [ 'AccountController_outstanding' , AccountController :: class . '_outstanding' , 'AccountController' , AccountController :: class , 'Page' ] ) ; } | Display all outstanding orders for the current user |
33,223 | public function onDuplicateKeyUpdate ( $ key , $ value = null ) { if ( func_num_args ( ) == 2 ) { $ this -> onDuplicateKeyUpdate [ $ key ] = $ value ; } else if ( $ key instanceof Expression ) { $ this -> onDuplicateKeyUpdate [ ] = $ key ; } else if ( is_array ( $ key ) ) { $ this -> onDuplicateKeyUpdate = $ key ; } return $ this ; } | Set on duplicate key update clause |
33,224 | protected function pushIgnoreDelayed ( ) { if ( $ this -> delayed ) { $ this -> parts [ ] = 'DELAYED' ; } if ( $ this -> ignore && ! $ this -> replace ) { $ this -> parts [ ] = 'IGNORE' ; } } | Push ignore or delayed onto parts |
33,225 | protected function pushOnDuplicateKeyUpdate ( ) { if ( $ this -> onDuplicateKeyUpdate ) { $ this -> parts [ ] = 'ON DUPLICATE KEY UPDATE' ; $ tmp = $ this -> values ; $ this -> values = $ this -> onDuplicateKeyUpdate ; $ this -> pushValues ( ) ; $ this -> values = $ tmp ; } } | Push on duplicate key update clause |
33,226 | public function compile ( ) { $ container = $ this -> container -> getContainer ( ) ; foreach ( $ container as $ dependencyIndex => $ dependency ) { $ code = $ this -> dependencyCompiler -> getCode ( $ dependency ) ; ( $ this -> dependencySaver ) ( $ dependencyIndex , $ code ) ; } $ this -> savePointcuts ( $ this -> container ) ; \ file_put_contents ( $ this -> scriptDir . ScriptInjector :: MODULE , \ serialize ( $ this -> module ) ) ; } | Compile all dependencies in container |
33,227 | public function searchItems ( MW_Common_Criteria_Interface $ search , array $ ref = array ( ) , & $ total = null ) { $ items = array ( ) ; $ context = $ this -> _getContext ( ) ; $ priceManager = MShop_Factory :: createManager ( $ context , 'price' ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ sitelevel = MShop_Locale_Manager_Abstract :: SITE_SUBTREE ; $ cfgPathSearch = 'mshop/order/manager/base/service/default/item/search' ; $ cfgPathCount = 'mshop/order/manager/base/service/default/item/count' ; $ required = array ( 'order.base.service' ) ; $ results = $ this -> _searchItems ( $ conn , $ search , $ cfgPathSearch , $ cfgPathCount , $ required , $ total , $ sitelevel ) ; try { while ( ( $ row = $ results -> fetch ( ) ) !== false ) { $ price = $ priceManager -> createItem ( ) ; $ price -> setValue ( $ row [ 'price' ] ) ; $ price -> setRebate ( $ row [ 'rebate' ] ) ; $ price -> setCosts ( $ row [ 'costs' ] ) ; $ price -> setTaxRate ( $ row [ 'taxrate' ] ) ; $ items [ $ row [ 'id' ] ] = array ( 'price' => $ price , 'item' => $ row ) ; } } catch ( Exception $ e ) { $ results -> finish ( ) ; throw $ e ; } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } $ result = array ( ) ; $ attributes = $ this -> _getAttributeItems ( array_keys ( $ items ) ) ; foreach ( $ items as $ id => $ row ) { $ attrList = array ( ) ; if ( isset ( $ attributes [ $ id ] ) ) { $ attrList = $ attributes [ $ id ] ; } $ result [ $ id ] = $ this -> _createItem ( $ row [ 'price' ] , $ row [ 'item' ] , $ attrList ) ; } return $ result ; } | Searches for order service items based on the given criteria . |
33,228 | protected function _getAttributeItems ( $ ids ) { $ manager = $ this -> getSubManager ( 'attribute' ) ; $ search = $ manager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'order.base.service.attribute.serviceid' , $ ids ) ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , 'order.base.service.attribute.code' ) ) ) ; $ search -> setSlice ( 0 , 0x7fffffff ) ; $ result = array ( ) ; foreach ( $ manager -> searchItems ( $ search ) as $ item ) { $ result [ $ item -> getServiceId ( ) ] [ $ item -> getId ( ) ] = $ item ; } return $ result ; } | Searches for attribute items connected with order service item . |
33,229 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'media.id' : $ item -> setId ( $ value ) ; break ; case 'media.label' : $ item -> setLabel ( $ value ) ; break ; case 'media.typeid' : $ item -> setTypeId ( $ value ) ; break ; case 'media.domain' : $ item -> setDomain ( $ value ) ; break ; case 'media.status' : $ item -> setStatus ( $ value ) ; break ; case 'media.mimetype' : $ item -> setMimeType ( $ value ) ; break ; case 'media.preview' : $ item -> setPreview ( $ value ) ; break ; case 'media.url' : $ item -> setUrl ( $ value ) ; break ; case 'media.languageid' : if ( $ value != null ) { $ item -> setLanguageId ( $ value ) ; } break ; } } return $ item ; } | Creates a new media item and sets the properties from the given array . |
33,230 | protected function _checkFileUpload ( $ filename , $ errcode ) { if ( is_uploaded_file ( $ filename ) === false ) { throw new Controller_ExtJS_Exception ( 'File was not uploaded' ) ; } switch ( $ errcode ) { case UPLOAD_ERR_OK : break ; case UPLOAD_ERR_INI_SIZE : case UPLOAD_ERR_FORM_SIZE : throw new Controller_ExtJS_Exception ( 'The uploaded file exceeds the max. allowed filesize' ) ; case UPLOAD_ERR_PARTIAL : throw new Controller_ExtJS_Exception ( 'The uploaded file was only partially uploaded' ) ; case UPLOAD_ERR_NO_FILE : throw new Controller_ExtJS_Exception ( 'No file was uploaded' ) ; case UPLOAD_ERR_NO_TMP_DIR : throw new Controller_ExtJS_Exception ( 'Temporary folder is missing' ) ; case UPLOAD_ERR_CANT_WRITE : throw new Controller_ExtJS_Exception ( 'Failed to write file to disk' ) ; case UPLOAD_ERR_EXTENSION : throw new Controller_ExtJS_Exception ( 'File upload stopped by extension' ) ; default : throw new Controller_ExtJS_Exception ( 'Unknown upload error' ) ; } } | Checks if the file is a valid uploaded file |
33,231 | protected function _getAbsoluteDirectory ( $ relativeDir ) { $ config = $ this -> _getContext ( ) -> getConfig ( ) ; if ( ( $ dir = $ config -> get ( 'controller/extjs/media/default/basedir' , null ) ) === null ) { throw new Controller_ExtJS_Exception ( 'No base directory configured' ) ; } $ perms = $ config -> get ( 'controller/extjs/media/default/upload/dirperms' , 0775 ) ; $ dir .= DIRECTORY_SEPARATOR . $ relativeDir ; if ( is_dir ( $ dir ) === false && mkdir ( $ dir , $ perms , true ) === false ) { $ msg = sprintf ( 'Couldn\'t create directory "%1$s" with permissions "%2$o"' , $ dir , $ perms ) ; throw new Controller_ExtJS_Exception ( $ msg ) ; } return $ dir ; } | Returns the absolute directory for a given relative one . |
33,232 | protected function _getMimeIcon ( $ mimetype ) { $ config = $ this -> _getContext ( ) -> getConfig ( ) ; if ( ( $ mimedir = $ config -> get ( 'controller/extjs/media/default/mimeicon/directory' , null ) ) === null ) { $ this -> _getContext ( ) -> getLogger ( ) -> log ( 'No directory for mime type images configured' ) ; return '' ; } $ ext = $ config -> get ( 'controller/extjs/media/default/mimeicon/extension' , '.png' ) ; $ abspath = $ this -> _getAbsoluteDirectory ( $ mimedir ) . DIRECTORY_SEPARATOR . $ mimetype . $ ext ; $ mimeicon = $ mimedir . DIRECTORY_SEPARATOR . $ mimetype . $ ext ; if ( is_file ( $ abspath ) === false ) { $ mimeicon = $ mimedir . DIRECTORY_SEPARATOR . 'unknown' . $ ext ; } return $ mimeicon ; } | Returns the relative path to the mime icon for the given mime type . |
33,233 | protected function _createImage ( MW_Media_Image_Interface $ mediaFile , $ type , $ domain , $ src , $ filename ) { $ mimetype = $ mediaFile -> getMimetype ( ) ; $ config = $ this -> _getContext ( ) -> getConfig ( ) ; $ default = array ( 'image/jpeg' , 'image/png' , 'image/gif' ) ; $ allowed = $ config -> get ( 'controller/extjs/media/default/' . $ type . '/allowedtypes' , $ default ) ; if ( in_array ( $ mimetype , $ allowed ) === false ) { if ( ( $ defaulttype = reset ( $ allowed ) ) !== false ) { $ mimetype = $ defaulttype ; } else { throw new Controller_ExtJS_Exception ( sprintf ( 'No allowed image types configured for "%1$s"' , $ type ) ) ; } } if ( ( $ mediadir = $ config -> get ( 'controller/extjs/media/default/upload/directory' , null ) ) === null ) { throw new Controller_ExtJS_Exception ( 'No media directory configured' ) ; } $ ds = DIRECTORY_SEPARATOR ; $ fileext = $ this -> _getFileExtension ( $ mimetype ) ; $ filepath = $ mediadir . $ ds . $ type . $ ds . $ domain . $ ds . $ filename [ 0 ] . $ ds . $ filename [ 1 ] ; $ dest = $ this -> _getAbsoluteDirectory ( $ filepath ) . $ ds . $ filename . $ fileext ; $ maxwidth = $ config -> get ( 'controller/extjs/media/default/' . $ type . '/maxwidth' , null ) ; $ maxheight = $ config -> get ( 'controller/extjs/media/default/' . $ type . '/maxheight' , null ) ; $ mediaFile -> scale ( $ maxwidth , $ maxheight ) ; $ mediaFile -> save ( $ dest , $ mimetype ) ; $ perms = $ config -> get ( 'controller/extjs/media/default/upload/fileperms' , 0664 ) ; if ( chmod ( $ dest , $ perms ) === false ) { $ msg = sprintf ( 'Changing file permissions for "%1$s" to "%2$o" failed' , $ dest , $ perms ) ; $ this -> _getContext ( ) -> getLogger ( ) -> log ( $ msg , MW_Logger_Abstract :: WARN ) ; } return "${mediadir}/${type}/${domain}/${filename[0]}/${filename[1]}/${filename}${fileext}" ; } | Creates a scaled image and returns it s new file name . |
33,234 | protected function _copyFile ( MW_Media_Interface $ mediaFile , $ domain , $ filename ) { $ config = $ this -> _getContext ( ) -> getConfig ( ) ; if ( ( $ mediadir = $ config -> get ( 'controller/extjs/media/default/upload/directory' , null ) ) === null ) { throw new Controller_ExtJS_Exception ( 'No media directory configured' ) ; } $ ds = DIRECTORY_SEPARATOR ; $ fileext = $ this -> _getFileExtension ( $ mediaFile -> getMimetype ( ) ) ; $ filepath = $ mediadir . $ ds . 'files' . $ ds . $ domain . $ ds . $ filename [ 0 ] . $ ds . $ filename [ 1 ] ; $ dest = $ this -> _getAbsoluteDirectory ( $ filepath ) . $ ds . $ filename . $ fileext ; $ mediaFile -> save ( $ dest , $ mediaFile -> getMimetype ( ) ) ; $ perms = $ config -> get ( 'controller/extjs/media/default/upload/fileperms' , 0664 ) ; if ( chmod ( $ dest , $ perms ) === false ) { $ msg = sprintf ( 'Changing file permissions for "%1$s" to "%1$o" failed' , $ dest , $ perms ) ; $ this -> _getContext ( ) -> getLogger ( ) -> log ( $ msg , MW_Logger_Abstract :: WARN ) ; } return "${mediadir}/files/${domain}/${filename[0]}/${filename[1]}/${filename}${fileext}" ; } | Copies the given file to a new location . |
33,235 | private function findEditionByEditionFiles ( ) { $ facts = $ this -> getFacts ( ) ; $ edition = '' ; if ( is_dir ( $ facts -> getEnterpriseEditionRootPath ( ) ) === true ) { $ edition = static :: ENTERPRISE ; } elseif ( is_dir ( $ facts -> getProfessionalEditionRootPath ( ) ) === true ) { $ edition = static :: PROFESSIONAL ; } elseif ( is_dir ( $ facts -> getCommunityEditionSourcePath ( ) ) === true ) { $ edition = static :: COMMUNITY ; } if ( $ edition === '' ) { throw new \ Exception ( "Shop directory structure is not setup properly. Edition could not be detected" ) ; } return $ edition ; } | Find edition by directories of the editions in the vendor directory |
33,236 | function storeFitInSession ( ) { $ search = $ this -> flexibleSearch ( ) ; $ mapping_id = $ search -> storeFitInSession ( ) ; if ( $ this -> shouldEnableVaftireModule ( ) ) { $ tireSearch = new VF_Tire_FlexibleSearch ( $ search ) ; $ tireSearch -> storeTireSizeInSession ( ) ; } if ( $ this -> shouldEnableVafWheelModule ( ) ) { $ wheelSearch = new VF_Wheel_FlexibleSearch ( $ search ) ; $ wheelSearch -> storeSizeInSession ( ) ; } if ( $ this -> shouldEnableVafwheeladapterModule ( ) ) { $ wheeladapterSearch = new VF_Wheeladapter_FlexibleSearch ( $ search ) ; $ wheeladapterSearch -> storeAdapterSizeInSession ( ) ; } return $ mapping_id ; } | store paramaters in the session |
33,237 | function getLoadingText ( ) { return isset ( $ this -> getConfig ( ) -> search -> loadingText ) ? $ this -> getConfig ( ) -> search -> loadingText : 'loading' ; } | Get the option loading text for the ajax |
33,238 | function _closeMCrypt ( ) { if ( $ this -> encryptStream !== false ) { if ( $ this -> continuousBuffer ) { mcrypt_generic_deinit ( $ this -> encryptStream ) ; } mcrypt_module_close ( $ this -> encryptStream ) ; $ this -> encryptStream = false ; } if ( $ this -> decryptStream !== false ) { if ( $ this -> continuousBuffer ) { mcrypt_generic_deinit ( $ this -> decryptStream ) ; } mcrypt_module_close ( $ this -> decryptStream ) ; $ this -> decryptStream = false ; } } | Properly close the MCrypt objects . |
33,239 | public function setCode ( $ code ) { $ this -> _checkCode ( $ code ) ; $ this -> _values [ 'code' ] = ( string ) $ code ; $ this -> setModified ( ) ; } | Sets the code of the warehouse item . |
33,240 | protected function _createTerm ( $ name , $ type , $ value ) { $ escaped = $ this -> _escape ( $ this -> getOperator ( ) , $ type , $ value ) ; return $ name . ' ' . self :: $ _operators [ $ this -> getOperator ( ) ] . ' ' . $ escaped ; } | Creates a term string from the given parameters . |
33,241 | protected function _createNullTerm ( $ name ) { switch ( $ this -> getOperator ( ) ) { case '==' : return $ name . ' === null' ; case '!=' : return $ name . ' !== null' ; default : throw new MW_Common_Exception ( sprintf ( 'null value not allowed for operator "%1$s"' , $ this -> getOperator ( ) ) ) ; } } | Creates a term which contains a null value . |
33,242 | public function callback ( $ opcode , $ subject , $ offset , $ length ) { if ( $ opcode === 'i' ) { return ; } if ( $ opcode === 'c' ) { return htmlentities ( substr ( $ subject , $ offset , $ length ) ) ; } $ deletion = substr ( $ subject , $ offset , $ length ) ; if ( strcspn ( $ deletion , " \n\r" ) === 0 ) { $ deletion = str_replace ( array ( "\n" , "\r" ) , array ( '\n' , '\r' ) , $ deletion ) ; } return '<del>' . htmlentities ( $ deletion ) . '</del>' ; } | Render an deletion diff . |
33,243 | public function resizeX ( $ x ) { return $ this -> handle ( ) -> resize ( $ x , null , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; } | Resize image to specific width . |
33,244 | public function resizeY ( $ y ) { $ this -> handle ( ) -> resize ( null , $ y , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; } | Resize image to specific height . |
33,245 | public function resizeXorY ( $ x , $ y ) { if ( $ x > $ y ) { $ this -> resizeX ( $ x ) ; } else { $ this -> resizeY ( $ y ) ; } } | Resize image to whats greater width or height . |
33,246 | public function extension ( $ extension = null ) { if ( is_null ( $ extension ) ) { if ( ! empty ( $ this -> extension ) ) { return $ this -> extension ; } if ( isset ( $ this -> attributes [ 'extension' ] ) ) { return $ this -> attributes [ 'extension' ] ; } } $ this -> extension = $ this -> checkExtension ( $ extension ) ; return $ this ; } | Set or get extension . |
33,247 | public function parseSize ( $ size ) { if ( ctype_alnum ( $ size ) ) { if ( preg_match ( '/^([0-9]{1,4})x([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => '{x}x{y}' , 'x' => intval ( $ output [ 1 ] ) , 'y' => intval ( $ output [ 2 ] ) , ] ; } elseif ( preg_match ( '/^([0-9]{1,4})o([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => '{x}o{y}' , 'x' => intval ( $ output [ 1 ] ) , 'y' => intval ( $ output [ 2 ] ) , ] ; } elseif ( preg_match ( '/^x([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => 'x{x}' , 'x' => intval ( $ output [ 1 ] ) , ] ; } elseif ( preg_match ( '/^y([0-9]{1,4})$/' , $ size , $ output ) ) { return ( object ) [ 'raw' => $ output [ 0 ] , 'method' => 'y{y}' , 'y' => intval ( $ output [ 1 ] ) , ] ; } else { dd ( 'Illegal size. Supported: {x}x{y},{x}o{y},x{x},y{y}' ) ; } } else { abort ( 403 , 'Illegal size.' ) ; } } | Check if size is correct . |
33,248 | public function watermarkPath ( $ path = null ) { if ( is_null ( $ path ) ) { if ( isset ( $ this -> watermark_path ) ) { return $ this -> watermark_path ; } return ; } $ this -> watermark_path = $ path ; } | Set or get watermark path . |
33,249 | public function watermark ( $ path = null ) { if ( is_null ( $ path ) ) { $ this -> watermarkPath ( config ( 'images.watermark_path' ) ) ; } $ this -> watermarkPath ( $ path ) ; $ this -> todo ( 'watermark' ) ; return $ this ; } | Include watermark in thumbnail . |
33,250 | public function calculateWatermarkResolution ( $ width , $ height , $ watermark , $ handle ) { $ width = ( int ) str_replace ( '%' , '' , $ width ) / 100 ; $ height = ( int ) str_replace ( '%' , '' , $ height ) / 100 ; $ width_px = ( int ) round ( $ handle -> width ( ) * $ width ) ; $ height_px = ( int ) round ( $ handle -> height ( ) * $ height ) ; return ( object ) [ 'width' => $ width_px , 'height' => $ height_px , ] ; } | This function calculate what should be the thumbnail size . |
33,251 | public function addWatermark ( $ watermark_path = null ) { if ( is_null ( $ watermark_path ) ) { $ watermark_path = $ this -> watermarkPath ( ) ; } $ watermark = \ Intervention \ Image \ Facades \ Image :: make ( $ watermark_path ) ; $ watermark_width = config ( 'images.watermark_width' ) ; $ watermark_height = config ( 'images.watermark_height' ) ; $ watermark_resolution = $ this -> calculateWatermarkResolution ( $ watermark_width , $ watermark_height , $ watermark , $ this -> handle ( ) ) ; $ watermark -> resize ( $ watermark_resolution -> width , $ watermark_resolution -> height , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; $ this -> handle ( ) -> insert ( $ watermark , config ( 'images.watermark_position' ) ) ; } | Add watermark to image . Opacity should be set in watermark file . |
33,252 | public function loadImageHandle ( ) { if ( method_exists ( $ this , 'cacheable' ) && $ this -> cacheable ( ) ) { return $ this -> getHandleFromCache ( ) ; } return $ this -> makeImage ( $ this -> getOriginalImageFile ( ) ) ; } | Load image handle from cached or original file . |
33,253 | public function response ( $ extension = null ) { if ( ! is_null ( $ extension ) ) { $ this -> extension ( $ extension ) ; } if ( method_exists ( $ this , 'cacheable' ) && $ this -> cacheable ( ) ) { if ( ! $ this -> cached ( ) ) { $ this -> apply ( ) ; $ this -> cache ( $ this -> handle ( ) ) ; } $ age = config ( 'images.cache_age' , '86400' ) ; return $ this -> cached ( ) -> response ( $ extension ) -> setLastModified ( new \ DateTime ( 'now' ) ) -> setExpires ( new \ DateTime ( '@' . ( time ( ) + $ age ) ) ) ; } $ this -> apply ( ) ; return $ this -> handle ( ) -> response ( $ extension ) ; } | Generate laravel response . |
33,254 | public static function endsWith ( string $ subject , string $ search , bool $ caseSensitive = true ) : bool { if ( ! $ caseSensitive ) { $ subject = mb_strtolower ( $ subject ) ; $ search = mb_strtolower ( $ search ) ; } return $ search === '' || mb_substr ( $ subject , - mb_strlen ( $ search ) ) === $ search ; } | Returns whether the subjects ends with the search string . |
33,255 | public static function camelCase ( string $ text , bool $ lowercaseFirstChar = false ) : string { $ text = strtr ( ucwords ( strtr ( $ text , [ '_' => ' ' , '.' => '_ ' , '\\' => '_ ' , ] ) ) , [ ' ' => '' ] ) ; if ( $ lowercaseFirstChar ) { $ text = lcfirst ( $ text ) ; } return $ text ; } | Converts a string from snake case to camel case . |
33,256 | protected function _getProductListTypeId ( MShop_Common_Manager_Interface $ productListManager , $ code ) { $ productListTypeManager = $ productListManager -> getSubManager ( 'type' ) ; $ search = $ productListTypeManager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'product.list.type.code' , $ code ) ) ; $ items = $ productListTypeManager -> searchItems ( $ search ) ; if ( ( $ suggestionType = reset ( $ items ) ) === false ) { $ suggestionType = $ productListTypeManager -> createItem ( ) ; $ suggestionType -> setCode ( $ code ) ; $ suggestionType -> setLabel ( ucfirst ( $ code ) ) ; $ suggestionType -> setDomain ( 'product' ) ; $ suggestionType -> setStatus ( 1 ) ; $ suggestionType -> setSiteId ( $ this -> _getContext ( ) -> getLocale ( ) -> getSiteId ( ) ) ; $ productListTypeManager -> saveItem ( $ suggestionType ) ; } return $ suggestionType -> getId ( ) ; } | Gets or creates product list type item with specified code . |
33,257 | protected function _createProductListSuggestions ( $ productId , array $ productList , $ listTypeId , MShop_Common_Manager_Interface $ productListManager ) { if ( empty ( $ productList ) ) { return ; } $ listItem = $ productListManager -> createItem ( ) ; foreach ( $ productList as $ key => $ id ) { $ listItem -> setId ( null ) ; $ listItem -> setParentId ( $ productId ) ; $ listItem -> setDomain ( 'product' ) ; $ listItem -> setTypeId ( $ listTypeId ) ; $ listItem -> setRefId ( $ id ) ; $ listItem -> setStatus ( 1 ) ; $ listItem -> setPosition ( $ key ) ; $ productListManager -> saveItem ( $ listItem ) ; } } | Adds products to the product list as suggested . |
33,258 | protected function _removeProductSuggestions ( $ productId , $ listTypeId , MShop_Common_Manager_Interface $ productListManager ) { $ search = $ productListManager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , 'product.list.parentid' , $ productId ) , $ search -> compare ( '==' , 'product.list.type.id' , $ listTypeId ) ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ listItems = $ productListManager -> searchItems ( $ search ) ; $ productListManager -> deleteItems ( array_keys ( $ listItems ) ) ; } | Optionally first remove all suggested products from product list . |
33,259 | private function initJsonApiSupport ( IntegrationInterface $ integration ) { $ this -> integration = $ integration ; $ factory = $ this -> getIntegration ( ) -> getFromContainer ( FactoryInterface :: class ) ; $ this -> codecMatcher = $ integration -> getFromContainer ( CodecMatcherInterface :: class ) ; $ this -> exceptionThrower = $ integration -> getFromContainer ( ExceptionThrowerInterface :: class ) ; $ this -> parametersParser = $ factory -> createParametersParser ( ) ; $ this -> supportedExtensions = $ factory -> createSupportedExtensions ( $ this -> extensions ) ; $ this -> parametersChecker = $ factory -> createParametersChecker ( $ this -> exceptionThrower , $ this -> codecMatcher , $ this -> allowUnrecognizedParams , $ this -> allowedIncludePaths , $ this -> allowedFieldSetTypes , $ this -> allowedSortFields , $ this -> allowedPagingParameters , $ this -> allowedFilteringParameters ) ; $ integration -> setInContainer ( SupportedExtensionsInterface :: class , $ this -> supportedExtensions ) ; } | Init integrations with JSON API implementation . |
33,260 | protected function getCodeResponse ( $ statusCode ) { $ this -> checkParameters ( ) ; $ responses = $ this -> getIntegration ( ) -> getFromContainer ( ResponsesInterface :: class ) ; $ outputMediaType = $ this -> codecMatcher -> getEncoderRegisteredMatchedType ( ) ; return $ responses -> getResponse ( $ statusCode , $ outputMediaType , null , $ this -> supportedExtensions ) ; } | Get response with HTTP code only . |
33,261 | protected function getMetaResponse ( $ meta , $ statusCode = Response :: HTTP_OK ) { $ this -> checkParameters ( ) ; $ responses = $ this -> getIntegration ( ) -> getFromContainer ( ResponsesInterface :: class ) ; $ encoder = $ this -> codecMatcher -> getEncoder ( ) ; $ outputMediaType = $ this -> codecMatcher -> getEncoderRegisteredMatchedType ( ) ; $ content = $ encoder -> encodeMeta ( $ meta ) ; return $ responses -> getResponse ( $ statusCode , $ outputMediaType , $ content , $ this -> supportedExtensions ) ; } | Get response with meta information only . |
33,262 | protected function getContentResponse ( $ data , $ statusCode = Response :: HTTP_OK , $ links = null , $ meta = null ) { $ parameters = $ this -> getParameters ( ) ; $ encoder = $ this -> codecMatcher -> getEncoder ( ) ; $ outputMediaType = $ this -> codecMatcher -> getEncoderRegisteredMatchedType ( ) ; $ links === null ? : $ encoder -> withLinks ( $ links ) ; $ meta === null ? : $ encoder -> withMeta ( $ meta ) ; $ responses = $ this -> getIntegration ( ) -> getFromContainer ( ResponsesInterface :: class ) ; $ content = $ encoder -> encodeData ( $ data , $ parameters ) ; return $ responses -> getResponse ( $ statusCode , $ outputMediaType , $ content , $ this -> supportedExtensions ) ; } | Get response with regular JSON API Document in body . |
33,263 | public function transferOperations ( array $ operations ) { foreach ( $ operations as $ operation ) { try { $ this -> transfer ( $ operation ) ; $ this -> logger -> info ( "[OK] Transfer operation " . $ operation -> getTransferId ( ) . " executed" , array ( 'miraklId' => $ operation -> getMiraklId ( ) , "action" => "Transfer" ) ) ; } catch ( InvalidAmountException $ e ) { $ this -> logger -> info ( $ e -> getMessage ( ) , array ( 'miraklId' => $ operation -> getMiraklId ( ) , "action" => "Transfer" ) ) ; } catch ( Exception $ e ) { $ this -> logger -> warning ( "[KO] Transfer operation failed" , array ( 'miraklId' => $ operation -> getMiraklId ( ) , "action" => "Transfer" ) ) ; $ this -> handleException ( $ e , 'critical' ) ; } } } | Execute the operation needing transfer . |
33,264 | protected function getTransferableOperations ( ) { $ toTransferCreated = $ this -> operationManager -> findByStatus ( new Status ( Status :: CREATED ) ) ; $ toTransferFailed = $ this -> operationManager -> findByStatus ( new Status ( Status :: TRANSFER_FAILED ) ) ; $ toTransferNegative = $ this -> operationManager -> findByStatus ( new Status ( Status :: TRANSFER_NEGATIVE ) ) ; $ toTransfer = array_merge ( $ toTransferNegative , $ toTransferFailed , $ toTransferCreated ) ; return $ toTransfer ; } | Fetch the operation to transfer from the storage |
33,265 | public function getNavData ( ) { $ result = [ ] ; if ( $ this -> menu -> items ) { foreach ( $ this -> menu -> items as $ item ) { $ data = $ this -> getRecursiveData ( $ item ) ; if ( ! ArrayHelper :: getValue ( $ data , 'url' ) && ! ArrayHelper :: getValue ( $ data , 'items' ) ) { } else { $ result [ $ item -> id ] = $ data ; } } } return $ result ; } | Data to build the widget \ yii \ bootstrap \ Nav |
33,266 | public static function mock ( $ userSettings = array ( ) ) { self :: $ environment = new self ( array_merge ( array ( 'REQUEST_METHOD' => 'GET' , 'SCRIPT_NAME' => '' , 'PATH_INFO' => '' , 'QUERY_STRING' => '' , 'SERVER_NAME' => 'localhost' , 'SERVER_PORT' => 80 , 'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' , 'ACCEPT_LANGUAGE' => 'en-US,en;q=0.8' , 'ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3' , 'USER_AGENT' => 'Slim Framework' , 'REMOTE_ADDR' => '127.0.0.1' , 'slim.url_scheme' => 'http' , 'slim.input' => '' , 'slim.errors' => @ fopen ( 'php://stderr' , 'w' ) ) , $ userSettings ) ) ; return self :: $ environment ; } | Get mock environment instance |
33,267 | public function setSiteId ( $ id ) { if ( $ id === $ this -> getSiteId ( ) ) { return ; } $ this -> _values [ 'siteid' ] = ( int ) $ id ; $ this -> _sitePath = array ( ( int ) $ id ) ; $ this -> _siteSubTree = array ( ( int ) $ id ) ; $ this -> setModified ( ) ; } | Sets the identifier of the shop instance . |
33,268 | public function setLanguageId ( $ langid ) { if ( $ langid == $ this -> getLanguageId ( ) ) { return ; } $ this -> _checkLanguageId ( $ langid ) ; $ this -> _values [ 'langid' ] = $ langid ; $ this -> setModified ( ) ; } | Sets the ISO language code . |
33,269 | protected function _process ( array $ stmts ) { $ this -> _msg ( 'Adding constraint for table mshop_product_tag' , 0 ) ; $ this -> _status ( '' ) ; if ( $ this -> _schema -> tableExists ( 'mshop_product_tag' ) === true ) { foreach ( $ stmts as $ constraint => $ stmt ) { $ this -> _msg ( sprintf ( 'Checking constraint "%1$s": ' , $ constraint ) , 1 ) ; if ( $ this -> _schema -> constraintExists ( 'mshop_product_tag' , $ constraint ) === false ) { $ this -> _execute ( $ stmt ) ; $ this -> _status ( 'added' ) ; } else { $ this -> _status ( 'OK' ) ; } } } } | Executes the SQL statements if necessary . |
33,270 | protected function clarifyException ( ViewSource $ source , CompileException $ exception ) : CompileException { if ( empty ( $ exception -> getToken ( ) ) ) { return $ exception ; } $ target = explode ( "\n" , $ exception -> getToken ( ) [ HtmlTokenizer :: TOKEN_CONTENT ] ) [ 0 ] ; $ lines = explode ( "\n" , $ source -> getCode ( ) ) ; foreach ( $ lines as $ number => $ line ) { if ( strpos ( $ line , $ target ) !== false ) { $ exception -> setLocation ( $ source -> getFilename ( ) , $ number + 1 ) ; break ; } } return $ exception ; } | Clarify exception with it s actual location . |
33,271 | public function run ( $ n = null , $ restoreErroneousMappers = true ) { if ( $ n !== null && is_numeric ( $ n ) === false ) { throw new InvalidParamException ( 'n must be a numeric value' ) ; } $ i = 0 ; while ( ( $ n === null || $ i ++ < $ n ) && ( $ mapper = CommandMapper :: find ( ) -> orderBy ( $ this -> getOrder ( ) ) -> one ( ) ) ) { $ this -> processMapper ( $ mapper ) ; } if ( $ this -> hasErroneousMappers ( ) ) { if ( $ restoreErroneousMappers ) { $ this -> restoreErroneousMappers ( ) ; } return false ; } else { return $ i ; } } | Runs the processor for the specified number of mappers . |
33,272 | protected function processMapper ( CommandMapper $ mapper ) { $ command = $ mapper -> getCommand ( ) ; try { $ mapper -> delete ( ) ; $ command -> execute ( ) ; } catch ( Exception $ ex ) { $ this -> erroneousMappers -> push ( $ mapper ) ; Yii :: getLogger ( ) -> log ( 'An error ocurred while processing command [' . get_class ( $ command ) . '].' . PHP_EOL . 'Exception: [' . $ ex -> getTraceAsString ( ) . ']' , Logger :: LEVEL_ERROR , 'command' ) ; } } | Processes a mapper deleting it from the list and executing the command stored in it . |
33,273 | protected function restoreErroneousMappers ( ) { $ this -> erroneousMappers -> rewind ( ) ; while ( $ this -> erroneousMappers -> valid ( ) ) { $ this -> erroneousMappers -> current ( ) -> save ( ) ; $ this -> erroneousMappers -> next ( ) ; } } | Restores the erroneous mappers into the database . |
33,274 | private function canProxy ( ) { $ trustedProxies = config ( 'proxypass.trusted_proxies' ) ; if ( empty ( $ trustedProxies ) ) { return true ; } $ proxyArr = explode ( "," , $ trustedProxies ) ; array_walk ( $ proxyArr , 'trim' ) ; if ( ! empty ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { if ( in_array ( $ _SERVER [ 'REMOTE_ADDR' ] , $ proxyArr ) ) { return true ; } } if ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_SERVER' ] ) ) { if ( in_array ( trim ( $ _SERVER [ 'HTTP_X_FORWARDED_SERVER' ] ) , $ proxyArr ) ) { return true ; } } return false ; } | Returns whether the proxy server is allowed to perform proxy operations and affect how the URLs are generated . |
33,275 | protected function _process ( ) { $ iface = 'MShop_Context_Item_Interface' ; if ( ! ( $ this -> _additional instanceof $ iface ) ) { throw new MW_Setup_Exception ( sprintf ( 'Additionally provided object is not of type "%1$s"' , $ iface ) ) ; } $ this -> _msg ( 'Adding performance data for MShop locale domain' , 0 ) ; $ this -> _status ( '' ) ; $ this -> _additional -> setEditor ( 'unitperf:core' ) ; $ ds = DIRECTORY_SEPARATOR ; $ filename = dirname ( __FILE__ ) . $ ds . 'data' . $ ds . 'locale.php' ; if ( ( $ testdata = include ( $ filename ) ) == false ) { throw new MW_Setup_Exception ( sprintf ( 'No data file "%1$s" found' , $ filename ) ) ; } $ localeManager = MShop_Locale_Manager_Factory :: createManager ( $ this -> _additional ) ; $ localeSiteManager = $ localeManager -> getSubManager ( 'site' ) ; $ siteIds = array ( ) ; $ search = $ localeSiteManager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'locale.site.code' , 'unitperf' ) ) ; foreach ( $ localeSiteManager -> searchItems ( $ search ) as $ site ) { $ this -> _additional -> setLocale ( $ localeManager -> bootstrap ( $ site -> getCode ( ) , '' , '' , false ) ) ; $ localeSiteManager -> deleteItem ( $ site -> getId ( ) ) ; } if ( isset ( $ testdata [ 'locale/site' ] ) ) { $ siteIds = $ this -> _addLocaleSiteData ( $ localeManager , $ testdata [ 'locale/site' ] ) ; } if ( isset ( $ testdata [ 'locale' ] ) ) { $ this -> _addLocaleData ( $ localeManager , $ testdata [ 'locale' ] , $ siteIds ) ; } } | Insert records from file containing the SQL records . |
33,276 | private function addChildren ( $ path , $ file , $ tree = [ ] ) { $ child = null ; if ( count ( $ path ) > 0 ) { $ child = array_shift ( $ path ) ; $ tree = $ this -> addChildren ( $ path , $ file , $ tree ) ; } $ newTree = [ ] ; if ( $ child ) { $ newTree [ 'folders' ] [ $ child ] = $ tree ; } else { $ newTree [ 'files' ] [ ] = $ file ; } return $ newTree ; } | Recursive method that adds the children of tree menu . |
33,277 | protected function _get ( $ config , $ parts ) { if ( ( $ current = array_shift ( $ parts ) ) !== null && isset ( $ config [ $ current ] ) ) { if ( count ( $ parts ) > 0 ) { return $ this -> _get ( $ config [ $ current ] , $ parts ) ; } return $ config [ $ current ] ; } return null ; } | Returns a configuration value from an array . |
33,278 | protected function _set ( $ config , $ path , $ value ) { if ( ( $ current = array_shift ( $ path ) ) !== null ) { if ( isset ( $ config [ $ current ] ) ) { $ config [ $ current ] = $ this -> _set ( $ config [ $ current ] , $ path , $ value ) ; } else { $ config [ $ current ] = $ this -> _set ( array ( ) , $ path , $ value ) ; } return $ config ; } return $ value ; } | Sets a configuration value in the array . |
33,279 | protected function _merge ( array $ left , array $ right ) { foreach ( $ right as $ key => $ value ) { if ( isset ( $ left [ $ key ] ) && is_array ( $ left [ $ key ] ) && is_array ( $ value ) ) { $ left [ $ key ] = $ this -> _merge ( $ left [ $ key ] , $ value ) ; } else { $ left [ $ key ] = $ value ; } } return $ left ; } | Merges a multi - dimensional array into another one |
33,280 | protected function _process ( array $ stmts ) { $ this -> _msg ( 'Altering type of supplier_address id' , 0 ) ; foreach ( $ stmts as $ table => $ stmt ) { if ( $ this -> _schema -> tableExists ( $ table ) && strtolower ( $ this -> _schema -> getColumnDetails ( $ table , 'id' ) -> getDataType ( ) ) == 'bigint' ) { $ this -> _execute ( $ stmt ) ; $ this -> _status ( 'changed' ) ; } else { $ this -> _status ( 'OK' ) ; } } } | Change type of supplier_address_id from BIGINT to INT . |
33,281 | public function searchItems ( MW_Common_Criteria_Interface $ search , array $ ref = array ( ) , & $ total = null ) { $ items = array ( ) ; $ context = $ this -> _getContext ( ) ; $ priceManager = MShop_Factory :: createManager ( $ context , 'price' ) ; $ localeManager = MShop_Factory :: createManager ( $ context , 'locale' ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ sitelevel = MShop_Locale_Manager_Abstract :: SITE_SUBTREE ; $ cfgPathSearch = 'mshop/order/manager/base/default/item/search' ; $ cfgPathCount = 'mshop/order/manager/base/default/item/count' ; $ required = array ( 'order.base' ) ; $ results = $ this -> _searchItems ( $ conn , $ search , $ cfgPathSearch , $ cfgPathCount , $ required , $ total , $ sitelevel ) ; while ( ( $ row = $ results -> fetch ( ) ) !== false ) { $ price = $ priceManager -> createItem ( ) ; $ price -> setCurrencyId ( $ row [ 'currencyid' ] ) ; $ price -> setValue ( $ row [ 'price' ] ) ; $ price -> setCosts ( $ row [ 'costs' ] ) ; $ price -> setRebate ( $ row [ 'rebate' ] ) ; $ localeItem = $ localeManager -> createItem ( ) ; $ localeItem -> setLanguageId ( $ row [ 'langid' ] ) ; $ localeItem -> setCurrencyId ( $ row [ 'currencyid' ] ) ; $ localeItem -> setSiteId ( $ row [ 'siteid' ] ) ; $ items [ $ row [ 'id' ] ] = $ this -> _createItem ( $ price , $ localeItem , $ row ) ; } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } return $ items ; } | Search for orders based on the given criteria . |
33,282 | public function getSession ( $ type = '' ) { $ context = $ this -> _getContext ( ) ; $ session = $ context -> getSession ( ) ; $ locale = $ context -> getLocale ( ) ; $ currency = $ locale -> getCurrencyId ( ) ; $ language = $ locale -> getLanguageId ( ) ; $ sitecode = $ locale -> getSite ( ) -> getCode ( ) ; $ key = 'arcavias/basket/content-' . $ sitecode . '-' . $ language . '-' . $ currency . '-' . strval ( $ type ) ; if ( ( $ serorder = $ session -> get ( $ key ) ) === null ) { return $ this -> createItem ( ) ; } $ iface = 'MShop_Order_Item_Base_Interface' ; if ( ( $ order = unserialize ( $ serorder ) ) === false || ! ( $ order instanceof $ iface ) ) { $ msg = sprintf ( 'Invalid serialized basket. "%1$s" returns "%2$s".' , __METHOD__ , $ serorder ) ; $ context -> getLogger ( ) -> log ( $ msg , MW_Logger_Abstract :: WARN ) ; return $ this -> createItem ( ) ; } MShop_Factory :: createManager ( $ context , 'plugin' ) -> register ( $ order , 'order' ) ; return $ order ; } | Returns the current basket of the customer . |
33,283 | public function getSessionLock ( $ type = '' ) { $ context = $ this -> _getContext ( ) ; $ session = $ context -> getSession ( ) ; $ locale = $ context -> getLocale ( ) ; $ currency = $ locale -> getCurrencyId ( ) ; $ language = $ locale -> getLanguageId ( ) ; $ sitecode = $ locale -> getSite ( ) -> getCode ( ) ; $ key = 'arcavias/basket/lock-' . $ sitecode . '-' . $ language . '-' . $ currency . '-' . strval ( $ type ) ; if ( ( $ value = $ session -> get ( $ key ) ) !== null ) { return ( int ) $ value ; } return MShop_Order_Manager_Base_Abstract :: LOCK_DISABLE ; } | Returns the current lock status of the basket . |
33,284 | public function setSession ( MShop_Order_Item_Base_Interface $ order , $ type = '' ) { $ context = $ this -> _getContext ( ) ; $ session = $ context -> getSession ( ) ; $ locale = $ context -> getLocale ( ) ; $ currency = $ locale -> getCurrencyId ( ) ; $ language = $ locale -> getLanguageId ( ) ; $ sitecode = $ locale -> getSite ( ) -> getCode ( ) ; $ key = 'arcavias/basket/content-' . $ sitecode . '-' . $ language . '-' . $ currency . '-' . strval ( $ type ) ; $ session -> set ( $ key , serialize ( clone $ order ) ) ; } | Saves the current shopping basket of the customer . |
33,285 | public function setSessionLock ( $ lock , $ type = '' ) { $ this -> _checkLock ( $ lock ) ; $ context = $ this -> _getContext ( ) ; $ session = $ context -> getSession ( ) ; $ locale = $ context -> getLocale ( ) ; $ currency = $ locale -> getCurrencyId ( ) ; $ language = $ locale -> getLanguageId ( ) ; $ sitecode = $ locale -> getSite ( ) -> getCode ( ) ; $ key = 'arcavias/basket/lock-' . $ sitecode . '-' . $ language . '-' . $ currency . '-' . strval ( $ type ) ; $ session -> set ( $ key , strval ( $ lock ) ) ; } | Locks or unlocks the session by setting the lock value . The lock is a cooperative lock and you have to check the lock value before you proceed . |
33,286 | public function load ( $ id , $ fresh = false ) { $ search = $ this -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'order.base.id' , $ id ) ) ; $ context = $ this -> _getContext ( ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ sitelevel = MShop_Locale_Manager_Abstract :: SITE_SUBTREE ; $ cfgPathSearch = 'mshop/order/manager/base/default/item/search' ; $ cfgPathCount = 'mshop/order/manager/base/default/item/count' ; $ required = array ( 'order.base' ) ; $ total = null ; $ results = $ this -> _searchItems ( $ conn , $ search , $ cfgPathSearch , $ cfgPathCount , $ required , $ total , $ sitelevel ) ; if ( ( $ row = $ results -> fetch ( ) ) === false ) { throw new MShop_Order_Exception ( sprintf ( 'Order base item with order ID "%1$s" not found' , $ id ) ) ; } $ results -> finish ( ) ; $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } $ priceManager = MShop_Factory :: createManager ( $ context , 'price' ) ; $ localeManager = MShop_Factory :: createManager ( $ context , 'locale' ) ; $ price = $ priceManager -> createItem ( ) ; $ price -> setCurrencyId ( $ row [ 'currencyid' ] ) ; $ price -> setValue ( $ row [ 'price' ] ) ; $ price -> setCosts ( $ row [ 'costs' ] ) ; $ price -> setRebate ( $ row [ 'rebate' ] ) ; $ localeItem = $ localeManager -> createItem ( ) ; $ localeItem -> setLanguageId ( $ row [ 'langid' ] ) ; $ localeItem -> setCurrencyId ( $ row [ 'currencyid' ] ) ; $ localeItem -> setSiteId ( $ row [ 'siteid' ] ) ; if ( $ fresh === false ) { $ basket = $ this -> _load ( $ id , $ price , $ localeItem , $ row ) ; } else { $ basket = $ this -> _loadFresh ( $ id , $ price , $ localeItem , $ row ) ; } return $ basket ; } | Creates a new basket containing all items from the order excluding the coupons . The items will be marked as new and modified so an additional order is stored when the basket is saved . |
33,287 | public function store ( MShop_Order_Item_Base_Interface $ basket ) { $ this -> saveItem ( $ basket ) ; $ this -> _storeProducts ( $ basket ) ; $ this -> _storeCoupons ( $ basket ) ; $ this -> _storeAddresses ( $ basket ) ; $ this -> _storeServices ( $ basket ) ; } | Saves the complete basket to the storage including all items attached . |
33,288 | protected function _loadProducts ( $ id , $ fresh ) { $ attributes = $ products = $ subProducts = array ( ) ; $ manager = $ this -> getSubManager ( 'product' ) ; $ attrManager = $ manager -> getSubManager ( 'attribute' ) ; $ criteria = $ manager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.product.baseid' , $ id ) ) ; $ criteria -> setSortations ( array ( $ criteria -> sort ( '-' , 'order.base.product.position' ) ) ) ; $ items = $ manager -> searchItems ( $ criteria ) ; $ criteria = $ attrManager -> createSearch ( ) ; $ expr = $ criteria -> compare ( '==' , 'order.base.product.attribute.productid' , array_keys ( $ items ) ) ; $ criteria -> setConditions ( $ expr ) ; foreach ( $ attrManager -> searchItems ( $ criteria ) as $ id => $ attribute ) { if ( $ fresh == true ) { $ attributes [ $ attribute -> getProductId ( ) ] [ ] = $ attribute ; $ attribute -> setProductId ( null ) ; $ attribute -> setId ( null ) ; } else { $ attributes [ $ attribute -> getProductId ( ) ] [ $ id ] = $ attribute ; } } foreach ( $ items as $ id => $ item ) { if ( isset ( $ attributes [ $ id ] ) ) { $ item -> setAttributes ( $ attributes [ $ id ] ) ; } if ( $ item -> getOrderProductId ( ) === null ) { $ item -> setProducts ( $ subProducts ) ; $ products [ $ item -> getPosition ( ) ] = $ item ; $ subProducts = array ( ) ; } else { $ subProducts [ $ item -> getPosition ( ) ] = $ item ; } if ( $ fresh == true ) { $ item -> setPosition ( null ) ; $ item -> setBaseId ( null ) ; $ item -> setId ( null ) ; } } return array_reverse ( $ products , true ) ; } | Retrieves the ordered products from the storage . |
33,289 | protected function _loadAddresses ( $ id , $ fresh ) { $ items = array ( ) ; $ manager = $ this -> getSubManager ( 'address' ) ; $ criteria = $ manager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.address.baseid' , $ id ) ) ; foreach ( $ manager -> searchItems ( $ criteria ) as $ item ) { if ( $ fresh === true ) { $ item -> setBaseId ( null ) ; $ item -> setId ( null ) ; } $ items [ $ item -> getType ( ) ] = $ item ; } return $ items ; } | Retrieves the addresses of the order from the storage . |
33,290 | protected function _loadCoupons ( $ id , $ fresh , array $ products ) { $ items = array ( ) ; $ manager = $ this -> getSubManager ( 'coupon' ) ; $ criteria = $ manager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.coupon.baseid' , $ id ) ) ; foreach ( $ manager -> searchItems ( $ criteria ) as $ item ) { if ( ! isset ( $ items [ $ item -> getCode ( ) ] ) ) { $ items [ $ item -> getCode ( ) ] = array ( ) ; } if ( $ item -> getProductId ( ) !== null ) { foreach ( $ products as $ product ) { if ( $ product -> getId ( ) == $ item -> getProductId ( ) ) { $ items [ $ item -> getCode ( ) ] [ ] = $ product ; } } } } return $ items ; } | Retrieves the coupons of the order from the storage . |
33,291 | protected function _loadServices ( $ id , $ fresh ) { $ items = array ( ) ; $ manager = $ this -> getSubManager ( 'service' ) ; $ criteria = $ manager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.service.baseid' , $ id ) ) ; foreach ( $ manager -> searchItems ( $ criteria ) as $ item ) { if ( $ fresh === true ) { foreach ( $ item -> getAttributes ( ) as $ attribute ) { $ attribute -> setId ( null ) ; $ attribute -> setServiceId ( null ) ; } $ item -> setBaseId ( null ) ; $ item -> setId ( null ) ; } $ items [ $ item -> getType ( ) ] = $ item ; } return $ items ; } | Retrieves the services of the order from the storage . |
33,292 | protected function _storeProducts ( MShop_Order_Item_Base_Interface $ basket ) { $ position = 1 ; $ manager = $ this -> getSubManager ( 'product' ) ; $ attrManager = $ manager -> getSubManager ( 'attribute' ) ; foreach ( $ basket -> getProducts ( ) as $ item ) { $ baseId = $ basket -> getId ( ) ; $ item -> setBaseId ( $ baseId ) ; if ( ( $ pos = $ item -> getPosition ( ) ) === null ) { $ item -> setPosition ( $ position ++ ) ; } else { $ position = ++ $ pos ; } $ manager -> saveItem ( $ item ) ; $ productId = $ item -> getId ( ) ; foreach ( $ item -> getAttributes ( ) as $ attribute ) { $ attribute -> setProductId ( $ productId ) ; $ attrManager -> saveItem ( $ attribute ) ; } foreach ( $ item -> getProducts ( ) as $ subProduct ) { $ subProduct -> setBaseId ( $ baseId ) ; $ subProduct -> setOrderProductId ( $ productId ) ; if ( ( $ pos = $ subProduct -> getPosition ( ) ) === null ) { $ subProduct -> setPosition ( $ position ++ ) ; } else { $ position = ++ $ pos ; } $ manager -> saveItem ( $ subProduct ) ; $ subProductId = $ subProduct -> getId ( ) ; foreach ( $ subProduct -> getAttributes ( ) as $ attribute ) { $ attribute -> setProductId ( $ subProductId ) ; $ attrManager -> saveItem ( $ attribute ) ; } } } } | Saves the ordered products to the storage . |
33,293 | protected function _storeAddresses ( MShop_Order_Item_Base_Interface $ basket ) { $ manager = $ this -> getSubManager ( 'address' ) ; foreach ( $ basket -> getAddresses ( ) as $ type => $ item ) { $ item -> setBaseId ( $ basket -> getId ( ) ) ; $ item -> setType ( $ type ) ; $ manager -> saveItem ( $ item ) ; } } | Saves the addresses of the order to the storage . |
33,294 | protected function _storeCoupons ( MShop_Order_Item_Base_Interface $ basket ) { $ manager = $ this -> getSubManager ( 'coupon' ) ; $ item = $ manager -> createItem ( ) ; $ item -> setBaseId ( $ basket -> getId ( ) ) ; foreach ( $ basket -> getCoupons ( ) as $ code => $ products ) { $ item -> setCode ( $ code ) ; if ( empty ( $ products ) ) { $ item -> setId ( null ) ; $ manager -> saveItem ( $ item ) ; continue ; } foreach ( $ products as $ product ) { $ item -> setId ( null ) ; $ item -> setProductId ( $ product -> getId ( ) ) ; $ manager -> saveItem ( $ item ) ; } } } | Saves the coupons of the order to the storage . |
33,295 | protected function _storeServices ( MShop_Order_Item_Base_Interface $ basket ) { $ manager = $ this -> getSubManager ( 'service' ) ; $ attrManager = $ manager -> getSubManager ( 'attribute' ) ; foreach ( $ basket -> getServices ( ) as $ type => $ item ) { $ item -> setBaseId ( $ basket -> getId ( ) ) ; $ item -> setType ( $ type ) ; $ manager -> saveItem ( $ item ) ; foreach ( $ item -> getAttributes ( ) as $ attribute ) { $ attribute -> setServiceId ( $ item -> getId ( ) ) ; $ attrManager -> saveItem ( $ attribute ) ; } } } | Saves the services of the order to the storage . |
33,296 | protected function _load ( $ id , $ price , $ localeItem , $ row ) { $ products = $ this -> _loadProducts ( $ id , false ) ; $ addresses = $ this -> _loadAddresses ( $ id , false ) ; $ services = $ this -> _loadServices ( $ id , false ) ; $ coupons = $ this -> _loadCoupons ( $ id , false , $ products ) ; $ basket = $ this -> _createItem ( $ price , $ localeItem , $ row , $ products , $ addresses , $ services , $ coupons ) ; return $ basket ; } | Load the basket item for the given ID . |
33,297 | protected function _loadFresh ( $ id , $ price , $ localeItem , $ row ) { $ products = $ this -> _loadProducts ( $ id , true ) ; $ addresses = $ this -> _loadAddresses ( $ id , true ) ; $ services = $ this -> _loadServices ( $ id , true ) ; $ basket = $ this -> _createItem ( $ price , $ localeItem , $ row ) ; $ basket -> setId ( null ) ; $ pluginManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'plugin' ) ; $ pluginManager -> register ( $ basket , 'order' ) ; foreach ( $ products as $ item ) { $ basket -> addProduct ( $ item ) ; } foreach ( $ addresses as $ item ) { $ basket -> setAddress ( $ item , $ item -> getType ( ) ) ; } foreach ( $ services as $ item ) { $ basket -> setService ( $ item , $ item -> getType ( ) ) ; } return $ basket ; } | Create a new basket item as a clone from an existing order ID . |
33,298 | function display ( VF_Search_Form $ searchForm , $ level , $ prevLevel = false , $ displayBrTag = null , $ yearRangeAlias = null ) { $ this -> displayBrTag = $ displayBrTag ; $ this -> searchForm = $ searchForm ; $ this -> level = $ level ; $ this -> prevLevel = $ prevLevel ; $ this -> yearRangeAlias = $ yearRangeAlias ; return $ this -> _display ( ) ; } | Display a select box pre - populated with values if its the first or if there s a prev . selection . |
33,299 | function isLevelSelected ( $ levelObject ) { if ( $ this -> level != $ this -> leafLevel ( ) ) { return ( bool ) ( $ levelObject -> getId ( ) == $ this -> searchForm -> getSelected ( $ this -> level ) ) ; } VF_Singleton :: getInstance ( ) -> setRequest ( $ this -> searchForm -> getRequest ( ) ) ; $ currentSelection = VF_Singleton :: getInstance ( ) -> vehicleSelection ( ) ; if ( false === $ currentSelection ) { return false ; } if ( 'year_start' == $ this -> yearRangeAlias ) { return ( bool ) ( $ levelObject -> getTitle ( ) == $ this -> earliestYearInVehicles ( $ currentSelection ) ) ; } else { if ( 'year_end' == $ this -> yearRangeAlias ) { return ( bool ) ( $ levelObject -> getTitle ( ) == $ this -> latestYearInVehicles ( $ currentSelection ) ) ; } } $ level = false ; if ( is_array ( $ currentSelection ) && count ( $ currentSelection ) == 1 ) { $ firstVehicle = $ currentSelection [ 0 ] ; $ level = $ firstVehicle -> getLevel ( $ this -> leafLevel ( ) ) ; } elseif ( $ currentSelection instanceof VF_Vehicle ) { $ level = $ currentSelection -> getLevel ( $ this -> leafLevel ( ) ) ; } if ( $ level ) { return ( bool ) ( $ levelObject -> getTitle ( ) == $ level -> getTitle ( ) ) ; } } | Check if an entity is the selected one for this level |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.