idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
55,300
|
protected function getListCollectionStore ( ) { if ( empty ( $ this -> data_store [ 'store_id' ] ) ) { return array ( ) ; } $ conditions = array ( 'status' => 1 , 'store_id' => $ this -> data_store [ 'store_id' ] ) ; $ collections = ( array ) $ this -> collection -> getList ( $ conditions ) ; $ list = array ( ) ; foreach ( $ collections as $ collection ) { $ list [ $ collection [ 'type' ] ] [ $ collection [ 'collection_id' ] ] = $ collection ; } return $ list ; }
|
Returns an array of enabled collection for the store keyed by an entity name
|
55,301
|
protected function submitEditStore ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteStore ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditStore ( ) ) { if ( isset ( $ this -> data_store [ 'store_id' ] ) ) { $ this -> updateStore ( ) ; } else { $ this -> addStore ( ) ; } } }
|
Handles a submitted store data
|
55,302
|
protected function validateEditStore ( ) { $ this -> setSubmitted ( 'store' , null , false ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_store ) ; $ this -> setSubmittedBool ( 'data.anonymous_checkout' ) ; foreach ( array ( 'email' , 'phone' , 'fax' , 'map' ) as $ field ) { $ this -> setSubmittedArray ( "data.$field" ) ; } $ this -> validateComponent ( 'store' ) ; return ! $ this -> hasErrors ( ) ; }
|
Validates a submitted store data
|
55,303
|
protected function deleteStore ( ) { $ this -> controlAccess ( 'store_delete' ) ; if ( $ this -> store -> delete ( $ this -> data_store [ 'store_id' ] ) ) { $ this -> redirect ( 'admin/settings/store' , $ this -> text ( 'Store has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Store has not been deleted' ) , 'danger' ) ; }
|
Deletes a store
|
55,304
|
protected function addStore ( ) { $ this -> controlAccess ( 'store_add' ) ; if ( $ this -> store -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/settings/store' , $ this -> text ( 'Store has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Store has not been added' ) , 'warning' ) ; }
|
Adds a new store
|
55,305
|
protected function setDataEditStore ( ) { foreach ( array ( 'logo' , 'favicon' ) as $ field ) { $ value = $ this -> getData ( "store.data.$field" ) ; if ( ! empty ( $ value ) ) { $ this -> setData ( "store.{$field}_thumb" , $ this -> image ( $ value ) ) ; } } foreach ( array ( 'email' , 'phone' , 'fax' , 'map' ) as $ field ) { $ value = $ this -> getData ( "store.data.$field" ) ; if ( isset ( $ value ) ) { $ this -> setData ( "store.data.$field" , implode ( "\n" , ( array ) $ value ) ) ; } } }
|
Prepares a store data
|
55,306
|
protected function seTitleEditStore ( ) { if ( isset ( $ this -> data_store [ 'store_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_store [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add store' ) ; } $ this -> setTitle ( $ title ) ; }
|
Sets titles on the store edit page
|
55,307
|
protected function setBreadcrumbEditStore ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/store' ) , 'text' => $ this -> text ( 'Stores' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the store edit page
|
55,308
|
public function init ( $ modules = null ) { if ( ! isset ( $ modules ) ) { $ modules = $ this -> module -> getEnabled ( ) ; } foreach ( ( array ) $ modules as $ module ) { if ( empty ( $ module [ 'hooks' ] ) ) { continue ; } foreach ( $ module [ 'hooks' ] as $ method ) { $ this -> register ( $ method , $ module [ 'class' ] ) ; } } return $ this -> hooks ; }
|
Registers module hooks
|
55,309
|
public function attach ( $ hook , & $ a = null , & $ b = null , & $ c = null , & $ d = null , & $ e = null ) { $ module_id = null ; if ( strpos ( $ hook , '|' ) !== false ) { list ( $ hook , $ module_id ) = explode ( '|' , $ hook , 2 ) ; } $ method = $ this -> getMethod ( $ hook ) ; if ( isset ( $ module_id ) ) { $ class = $ this -> module -> getClass ( $ module_id ) ; return $ this -> call ( $ class , $ method , $ a , $ b , $ c , $ d , $ e ) ; } if ( empty ( $ this -> hooks [ $ method ] ) ) { return false ; } foreach ( array_keys ( $ this -> hooks [ $ method ] ) as $ class ) { $ this -> call ( $ class , $ method , $ a , $ b , $ c , $ d , $ e ) ; } return true ; }
|
Call all defined functions for the hook
|
55,310
|
public function call ( $ class , $ method , & $ a = null , & $ b = null , & $ c = null , & $ d = null , & $ e = null ) { if ( ! is_callable ( array ( $ class , $ method ) ) ) { return false ; } try { $ instance = Container :: get ( $ class ) ; $ instance -> { $ method } ( $ a , $ b , $ c , $ d , $ e ) ; $ this -> called [ $ method ] [ $ class ] = array ( $ class , $ method ) ; return array ( $ a , $ b , $ c , $ d , $ e ) ; } catch ( Exception $ exc ) { return false ; } }
|
Calls a hook method
|
55,311
|
public function collection ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateCollection ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateTitle ( ) ; $ this -> validateDescription ( ) ; $ this -> validateTranslation ( ) ; $ this -> validateStoreId ( ) ; $ this -> validateTypeCollection ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
|
Performs full collection data validation
|
55,312
|
protected function validateCollection ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> collection -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Collection' ) ) ; return false ; } $ this -> setSubmitted ( 'update' , $ data ) ; return true ; }
|
Validates a collection to be updated
|
55,313
|
protected function validateTypeCollection ( ) { $ field = 'type' ; if ( $ this -> isExcluded ( $ field ) || $ this -> isUpdating ( ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; $ label = $ this -> translation -> text ( 'Type' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } $ types = $ this -> collection -> getTypes ( ) ; if ( ! isset ( $ types [ $ value ] ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
|
Validates collection type field
|
55,314
|
public static function get ( $ class ) { $ key = strtolower ( $ class ) ; if ( isset ( static :: $ instances [ $ key ] ) ) { return static :: $ instances [ $ key ] ; } static :: override ( $ class ) ; if ( ! class_exists ( $ class ) ) { throw new ReflectionException ( "Class $class does not exist" ) ; } $ instance = static :: getInstance ( $ class ) ; static :: register ( $ class , $ instance ) ; return $ instance ; }
|
Instantiates and registers a class
|
55,315
|
public static function getInstance ( $ class ) { $ reflection = new ReflectionClass ( $ class ) ; $ constructor = $ reflection -> getConstructor ( ) ; if ( empty ( $ constructor ) ) { return new $ class ; } $ parameters = $ constructor -> getParameters ( ) ; if ( empty ( $ parameters ) ) { return new $ class ; } $ dependencies = array ( ) ; foreach ( $ parameters as $ parameter ) { $ parameter_class = $ parameter -> getClass ( ) ; $ dependencies [ ] = static :: get ( $ parameter_class -> getName ( ) ) ; } return $ reflection -> newInstanceArgs ( $ dependencies ) ; }
|
Returns an instance using a class name
|
55,316
|
protected static function override ( & $ class ) { $ map = gplcart_config_get ( GC_FILE_CONFIG_COMPILED_OVERRIDE ) ; if ( isset ( $ map [ $ class ] ) ) { $ override = end ( $ map [ $ class ] ) ; $ class = $ override ; } return $ class ; }
|
Override a class namespace
|
55,317
|
public function productClass ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateProductClass ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateTitle ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
|
Performs full product class validation
|
55,318
|
public function set ( $ langcode , $ context ) { $ result = null ; $ this -> hook -> attach ( 'translation.set.before' , $ langcode , $ context , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ this -> setContext ( $ context ) ; $ this -> setLangcode ( $ langcode ) ; $ result = $ this -> prepareFiles ( $ langcode ) ; $ this -> hook -> attach ( 'translation.set.after' , $ langcode , $ context , $ result , $ this ) ; return ( bool ) $ result ; }
|
Set up a language
|
55,319
|
protected function prepareFiles ( $ langcode ) { if ( empty ( $ langcode ) || $ langcode === 'en' ) { return $ this -> prepared = false ; } $ main_file = $ this -> getFile ( $ langcode ) ; if ( ! is_file ( $ main_file ) ) { return $ this -> prepared = false ; } $ dir = $ this -> getCompiledDirectory ( ) ; if ( ! file_exists ( $ dir ) && ! mkdir ( $ dir , 0775 , true ) ) { return $ this -> prepared = false ; } $ common_file = $ this -> getCommonFile ( $ langcode ) ; if ( is_file ( $ common_file ) ) { return $ this -> prepared = true ; } $ directory = dirname ( $ common_file ) ; if ( ! file_exists ( $ directory ) && ! mkdir ( $ directory , 0775 , true ) ) { return $ this -> prepared = false ; } return $ this -> prepared = copy ( $ main_file , $ common_file ) ; }
|
Prepare all necessary files for the language
|
55,320
|
public function getFile ( $ langcode = null , $ module_id = '' ) { if ( ! isset ( $ langcode ) ) { $ langcode = $ this -> langcode ; } if ( empty ( $ module_id ) ) { $ directory = $ this -> getDirectory ( $ langcode ) ; } else { $ directory = $ this -> getModuleDirectory ( $ module_id ) ; } return "$directory/$langcode.csv" ; }
|
Returns a path to a translation file
|
55,321
|
public function getCommonFile ( $ langcode = null ) { if ( ! isset ( $ langcode ) ) { $ langcode = $ this -> langcode ; } return $ this -> getCompiledDirectory ( $ langcode ) . "/$langcode.csv" ; }
|
Returns the path to a common translation file
|
55,322
|
public function getContextFile ( $ context , $ langcode ) { if ( empty ( $ context ) ) { return '' ; } static $ files = array ( ) ; if ( ! isset ( $ files [ "$context$langcode" ] ) ) { $ filename = $ this -> getFilenameFromContext ( $ context ) ; $ directory = $ this -> getCompiledDirectory ( $ langcode ) ; $ files [ "$context$langcode" ] = "$directory/$filename.csv" ; } return $ files [ "$context$langcode" ] ; }
|
Returns a context translation file
|
55,323
|
protected function formatString ( $ source , array $ args , array $ data = array ( ) ) { if ( ! isset ( $ data [ 0 ] ) || $ data [ 0 ] === '' ) { return gplcart_string_format ( $ source , $ args ) ; } return gplcart_string_format ( $ data [ 0 ] , $ args ) ; }
|
Returns a translated and formated string
|
55,324
|
public function loadTranslation ( $ file ) { $ translations = & gplcart_static ( "translation.$file" ) ; if ( isset ( $ translations ) ) { return ( array ) $ translations ; } $ translations = array ( ) ; if ( empty ( $ file ) || ! is_file ( $ file ) ) { return $ translations = array ( ) ; } foreach ( $ this -> parseCsv ( $ file ) as $ row ) { $ key = array_shift ( $ row ) ; $ translations [ $ key ] = $ row ; } return $ translations ; }
|
Returns an array of translations from CSV files
|
55,325
|
public function loadJsTranslation ( $ langcode = null ) { $ strings = $ this -> loadTranslation ( $ this -> getContextJsFile ( $ langcode ) ) ; $ translations = array ( ) ; foreach ( $ strings as $ source => $ translation ) { if ( isset ( $ translation [ 0 ] ) && $ translation [ 0 ] !== '' ) { $ translations [ $ source ] = $ translation ; } } return $ translations ; }
|
Returns an array of JS translations
|
55,326
|
public function parseCsv ( $ file ) { $ handle = fopen ( $ file , 'r' ) ; if ( ! is_resource ( $ handle ) ) { return array ( ) ; } $ content = array ( ) ; while ( ( $ data = fgetcsv ( $ handle ) ) !== false ) { $ content [ ] = $ data ; } fclose ( $ handle ) ; return $ content ; }
|
Parse a translation file
|
55,327
|
protected function addTranslation ( $ string , array $ translations , $ file ) { if ( $ this -> prepared && ! isset ( $ this -> written [ $ file ] [ $ string ] ) && ! empty ( $ this -> context ) ) { $ data = array ( $ string ) ; if ( isset ( $ translations [ $ string ] [ 0 ] ) && $ translations [ $ string ] [ 0 ] !== '' ) { $ data = $ translations [ $ string ] ; array_unshift ( $ data , $ string ) ; } gplcart_file_csv ( $ file , $ data ) ; $ this -> written [ $ file ] [ $ string ] = true ; } }
|
Append the string to the translation file
|
55,328
|
public function createJsTranslation ( $ content , $ langcode = null ) { $ extracted = $ this -> parseJs ( $ content ) ; if ( empty ( $ extracted ) ) { return false ; } $ file = $ this -> getContextJsFile ( $ langcode ) ; $ translations = $ this -> loadTranslation ( $ this -> getCommonFile ( $ langcode ) ) ; foreach ( $ extracted as $ string ) { $ this -> addTranslation ( $ string , $ translations , $ file ) ; } return true ; }
|
Creates context JS translation
|
55,329
|
public function refresh ( $ langcode = null ) { $ result = null ; $ this -> hook -> attach ( 'translation.refresh.before' , $ langcode , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } gplcart_file_empty ( $ this -> getCompiledDirectory ( $ langcode ) , array ( 'csv' ) ) ; gplcart_static_clear ( ) ; $ this -> prepareFiles ( $ langcode ) ; $ this -> mergeModuleTranslations ( $ langcode ) ; $ result = true ; $ this -> hook -> attach ( 'translation.refresh.after' , $ langcode , $ result , $ this ) ; return $ result ; }
|
Removes cached translation files
|
55,330
|
protected function mergeTranslation ( $ merge_file , $ langcode = null ) { $ common_file = $ this -> getCommonFile ( $ langcode ) ; $ merge_translations = $ this -> loadTranslation ( $ merge_file ) ; $ common_translations = $ this -> loadTranslation ( $ common_file ) ; if ( ! empty ( $ merge_translations ) ) { foreach ( $ merge_translations as $ source => $ translation ) { if ( ! isset ( $ common_translations [ $ source ] ) ) { array_unshift ( $ translation , $ source ) ; gplcart_file_csv ( $ common_file , $ translation ) ; } } } }
|
Merge two translations
|
55,331
|
protected function mergeModuleTranslations ( $ langcode = null ) { $ modules = $ this -> module -> getEnabled ( ) ; gplcart_array_sort ( $ modules , 'weight' , false ) ; foreach ( $ modules as $ module ) { $ file = $ this -> getFile ( $ langcode , $ module [ 'module_id' ] ) ; if ( is_file ( $ file ) ) { $ this -> mergeTranslation ( $ file , $ langcode ) ; } } }
|
Add translations from all enabled modules to common file
|
55,332
|
public function post ( Request $ request ) { $ this -> validate ( $ request , [ 'file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:4096' , ] ) ; $ fileName = basename ( $ request -> file -> getClientOriginalName ( ) , '.' . $ request -> file -> getClientOriginalExtension ( ) ) ; $ fileExtension = $ request -> file -> getClientOriginalExtension ( ) ; $ postName = $ this -> sanitizeUrl ( $ fileName ) ; $ mime = $ request -> file -> getMimeType ( ) ; $ postmeta = NikuPostmeta :: where ( [ [ 'meta_key' , '=' , 'attachment_url' ] , [ 'meta_value' , 'LIKE' , '/uploads/images/' . $ fileName . '%' ] ] ) -> get ( ) ; if ( $ postmeta -> count ( ) != 0 ) { $ count = $ postmeta -> count ( ) + 1 ; $ fileCount = '-' . $ count ; } else { $ fileCount = '' ; } $ postName = $ postName . $ fileCount ; $ fileName = $ fileName . $ fileCount . '.' . $ fileExtension ; $ post = new NikuPosts ; $ post -> post_title = $ fileName ; $ post -> post_name = $ postName ; $ post -> post_type = 'attachment' ; $ post -> post_mime_type = $ mime ; $ post -> status = 'inherit' ; if ( Auth :: check ( ) ) { $ post -> post_author = Auth :: user ( ) -> id ; } else { $ post -> post_author = '0' ; } $ post -> save ( ) ; $ postmeta = new NikuPostmeta ; $ postmeta -> post_id = $ post -> id ; $ postmeta -> meta_key = 'attachment_url' ; $ postmeta -> meta_value = '/uploads/images/' . $ fileName ; $ postmeta -> save ( ) ; $ request -> file -> move ( public_path ( 'uploads/images' ) , $ fileName ) ; $ postObject = collect ( [ 'status' => 0 , 'postmeta' => [ 0 => [ 'meta_value' => $ postmeta -> meta_value , ] ] , 'id' => $ postmeta -> post_id ] ) ; return response ( ) -> json ( [ 'object' => $ postObject ] ) ; }
|
Add attachment to the filesystem and add it to the database
|
55,333
|
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ mm = $ serviceLocator -> get ( 'ModuleManager' ) ; $ mm -> loadModules ( ) ; $ moduleParams = $ mm -> getEvent ( ) -> getParams ( ) ; $ config = ArrayUtils :: merge ( $ moduleParams [ 'configListener' ] -> getMergedConfig ( false ) , $ serviceLocator -> get ( 'ApplicationConfig' ) ) ; $ parametersBag = $ serviceLocator -> get ( 'ApplicationParameters' ) ; $ config [ 'parameters' ] = isset ( $ config [ 'parameters' ] ) ? ArrayUtils :: merge ( $ parametersBag -> all ( ) , $ config [ 'parameters' ] ) : $ config [ 'parameters' ] = $ parametersBag -> all ( ) ; return $ parametersBag -> resolveArray ( $ config ) ; }
|
Create the application configuration service .
|
55,334
|
public function setUsed ( $ price_rule_id ) { $ sql = 'UPDATE price_rule SET used=used + 1 WHERE price_rule_id=?' ; return ( bool ) $ this -> db -> run ( $ sql , array ( $ price_rule_id ) ) -> rowCount ( ) ; }
|
Increments a number of usages by 1
|
55,335
|
public function codeMatches ( $ price_rule_id , $ code ) { $ sql = 'SELECT price_rule_id FROM price_rule WHERE code=? AND price_rule_id=? AND status=?' ; return ( bool ) $ this -> db -> fetchColumn ( $ sql , array ( $ code , $ price_rule_id , 1 ) ) ; }
|
Performs simple rule code validation
|
55,336
|
public function calculate ( & $ total , $ data , & $ components , array $ price_rule ) { try { $ callback = Handler :: get ( $ this -> getTypes ( ) , $ price_rule [ 'value_type' ] , 'calculate' ) ; call_user_func_array ( $ callback , array ( & $ total , & $ components , $ price_rule , $ data ) ) ; } catch ( Exception $ ex ) { trigger_error ( $ ex -> getMessage ( ) ) ; } }
|
Calculate a price rule
|
55,337
|
public function getTypes ( ) { $ handlers = & gplcart_static ( 'price.rule.types' ) ; if ( isset ( $ handlers ) ) { return $ handlers ; } $ handlers = gplcart_config_get ( GC_FILE_CONFIG_PRICE_RULE_TYPE ) ; $ this -> hook -> attach ( 'price.rule.types' , $ handlers , $ this ) ; return $ handlers ; }
|
Returns an array of price rule types
|
55,338
|
public function getTriggered ( array $ data , array $ options ) { $ options [ 'trigger_id' ] = $ this -> trigger -> getTriggered ( $ data , $ options ) ; if ( empty ( $ options [ 'trigger_id' ] ) ) { return array ( ) ; } $ coupons = 0 ; $ results = array ( ) ; foreach ( ( array ) $ this -> getList ( $ options ) as $ id => $ rule ) { if ( $ rule [ 'code' ] !== '' ) { $ coupons ++ ; } if ( $ coupons <= 1 ) { $ results [ $ id ] = $ rule ; } } uasort ( $ results , function ( $ a ) { return $ a [ 'code' ] === '' ? - 1 : 1 ; } ) ; return $ results ; }
|
Returns an array of triggered price rules
|
55,339
|
public function itemId ( array $ condition , array $ data ) { if ( ! isset ( $ data [ 'product_id' ] ) || ! isset ( $ data [ 'bundle' ] ) ) { return false ; } if ( ! is_array ( $ data [ 'bundle' ] ) ) { $ data [ 'bundle' ] = explode ( ',' , ( string ) $ data [ 'bundle' ] ) ; } return $ this -> compare ( $ data [ 'bundle' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the product is a bundled item and its ID is in a list of allowed IDs
|
55,340
|
public function itemCount ( array $ condition , array $ data ) { if ( ! isset ( $ data [ 'product_id' ] ) || ! isset ( $ data [ 'bundle' ] ) ) { return false ; } if ( ! is_array ( $ data [ 'bundle' ] ) ) { $ data [ 'bundle' ] = explode ( ',' , ( string ) $ data [ 'bundle' ] ) ; } return $ this -> compare ( count ( $ data [ 'bundle' ] ) , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the product has the given number of bundled items
|
55,341
|
public function editReview ( $ product_id , $ review_id = null ) { $ this -> setProductReview ( $ product_id ) ; $ this -> setReview ( $ review_id ) ; $ this -> setTitleEditReview ( ) ; $ this -> setBreadcrumbEditReview ( ) ; $ this -> setData ( 'review' , $ this -> data_review ) ; $ this -> setData ( 'product' , $ this -> data_product ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteReview ( ) ) ; $ this -> submitEditReview ( ) ; $ this -> setDataRatingEditReview ( ) ; $ this -> outputEditReview ( ) ; }
|
Displays the edit review page
|
55,342
|
protected function setProductReview ( $ product_id ) { $ this -> data_product = $ this -> product -> get ( $ product_id ) ; if ( empty ( $ this -> data_product [ 'status' ] ) || $ this -> data_product [ 'store_id' ] != $ this -> store_id ) { $ this -> outputHttpStatus ( 404 ) ; } $ this -> prepareProductReview ( $ this -> data_product ) ; }
|
Sets a product data
|
55,343
|
protected function setDataRatingEditReview ( ) { $ options = array ( 'product' => $ this -> data_product , 'review' => $ this -> getData ( 'review' ) , 'unvote' => $ this -> config ( 'rating_unvote' , 1 ) ) ; $ this -> setData ( 'rating' , $ this -> render ( 'common/rating/edit' , $ options ) ) ; }
|
Sets rating widget
|
55,344
|
protected function validateEditReview ( ) { $ this -> setSubmitted ( 'review' ) ; $ this -> filterSubmitted ( array ( 'text' , 'rating' ) ) ; $ this -> setSubmitted ( 'user_id' , $ this -> uid ) ; $ this -> setSubmitted ( 'update' , $ this -> data_review ) ; $ this -> setSubmitted ( 'product_id' , $ this -> data_product [ 'product_id' ] ) ; $ this -> setSubmitted ( 'status' , ( int ) $ this -> config ( 'review_status' , 1 ) ) ; $ this -> validateComponent ( 'review' ) ; return ! $ this -> hasErrors ( false ) ; }
|
Validates an array of submitted review data
|
55,345
|
protected function updateReview ( ) { $ submitted = $ this -> getSubmitted ( ) ; if ( $ this -> review -> update ( $ this -> data_review [ 'review_id' ] , $ submitted ) ) { $ message = $ this -> text ( 'Review has been updated' ) ; if ( empty ( $ submitted [ 'status' ] ) ) { $ message = $ this -> text ( 'Review has been updated and will be published after approval' ) ; } $ this -> redirect ( "product/{$this->data_product['product_id']}" , $ message , 'success' ) ; } $ this -> redirect ( "product/{$this->data_product['product_id']}" ) ; }
|
Updates a submitted review
|
55,346
|
protected function addReview ( ) { $ submitted = $ this -> getSubmitted ( ) ; $ added = $ this -> review -> add ( $ submitted ) ; if ( empty ( $ added ) ) { $ message = $ this -> text ( 'Review has not been added' ) ; $ this -> redirect ( '' , $ message , 'warning' ) ; } $ message = $ this -> text ( 'Review has been added' ) ; if ( empty ( $ submitted [ 'status' ] ) ) { $ message = $ this -> text ( 'Review has been added and will be published after approval' ) ; } $ this -> redirect ( "product/{$this->data_product['product_id']}" , $ message , 'success' ) ; }
|
Adds a submitted review
|
55,347
|
protected function controlAccessEditReview ( ) { if ( ! $ this -> config ( 'review_enabled' , 1 ) || empty ( $ this -> uid ) ) { $ this -> outputHttpStatus ( 403 ) ; } if ( ! $ this -> config ( 'review_editable' , 1 ) ) { $ this -> outputHttpStatus ( 403 ) ; } if ( isset ( $ this -> data_review [ 'review_id' ] ) && $ this -> data_review [ 'user_id' ] != $ this -> uid ) { $ this -> outputHttpStatus ( 403 ) ; } }
|
Controls access to the edit review page
|
55,348
|
protected function prepareReview ( array & $ review ) { $ rating = $ this -> rating -> getByUser ( $ this -> data_product [ 'product_id' ] , $ this -> uid ) ; $ review [ 'rating' ] = isset ( $ rating [ 'rating' ] ) ? $ rating [ 'rating' ] : 0 ; }
|
Prepares an array of review data
|
55,349
|
protected function prepareProductReview ( array & $ product ) { $ this -> setItemImages ( $ product , 'product' , $ this -> image ) ; $ this -> setItemThumbProduct ( $ product , $ this -> image ) ; $ this -> setItemPriceCalculated ( $ product , $ this -> product ) ; $ this -> setItemPriceFormatted ( $ product , $ this -> price , $ this -> current_currency ) ; }
|
Prepares an array of product data
|
55,350
|
public function getLoader ( ) { if ( null === $ this -> loader ) { $ locator = new FileLocator ( $ this -> paths ) ; $ resolver = new LoaderResolver ( array ( new YamlFileLoader ( $ locator ) , new PhpFileLoader ( $ locator ) , new IniFileLoader ( $ locator ) , new ArrayLoader ( ) , ) ) ; $ this -> loader = new DelegatingLoader ( $ resolver ) ; } return $ this -> loader ; }
|
Returns a loader to handle config loading .
|
55,351
|
public function get ( $ method_id ) { $ methods = $ this -> getList ( ) ; return empty ( $ methods [ $ method_id ] ) ? array ( ) : $ methods [ $ method_id ] ; }
|
Returns a payment method
|
55,352
|
public function enable ( $ module_id ) { try { $ result = $ this -> canEnable ( $ module_id ) ; } catch ( Exception $ ex ) { $ result = $ ex -> getMessage ( ) ; } $ this -> hook -> attach ( "module.enable.before|$module_id" , $ result , $ this ) ; if ( $ result !== true ) { return $ result ; } $ this -> module -> update ( $ module_id , array ( 'status' => 1 ) ) ; $ this -> setOverrideConfig ( ) ; $ this -> hook -> attach ( "module.enable.after|$module_id" , $ result , $ this ) ; return $ result ; }
|
Enables a module
|
55,353
|
public function disable ( $ module_id ) { try { $ result = $ this -> canDisable ( $ module_id ) ; } catch ( Exception $ ex ) { $ result = $ ex -> getMessage ( ) ; } $ this -> hook -> attach ( "module.disable.before|$module_id" , $ result , $ this ) ; if ( $ result !== true ) { return $ result ; } if ( $ this -> module -> isInstalled ( $ module_id ) ) { $ this -> module -> update ( $ module_id , array ( 'status' => false ) ) ; } else { $ this -> module -> add ( array ( 'status' => false , 'module_id' => $ module_id ) ) ; } $ this -> setOverrideConfig ( ) ; $ this -> hook -> attach ( "module.disable.after|$module_id" , $ result , $ this ) ; return $ result ; }
|
Disables a module
|
55,354
|
public function uninstall ( $ module_id ) { try { $ result = $ this -> canUninstall ( $ module_id ) ; } catch ( Exception $ ex ) { $ result = $ ex -> getMessage ( ) ; } $ this -> hook -> attach ( "module.uninstall.before|$module_id" , $ result , $ this ) ; if ( $ result !== true ) { return $ result ; } $ this -> module -> delete ( $ module_id ) ; $ this -> setOverrideConfig ( ) ; $ this -> hook -> attach ( "module.uninstall.after|$module_id" , $ result , $ this ) ; return $ result ; }
|
Un - install a module
|
55,355
|
public function canEnable ( $ module_id ) { if ( $ this -> module -> isEnabled ( $ module_id ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Module already installed and enabled' ) ) ; } if ( $ this -> module -> isLocked ( $ module_id ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Module is locked in code' ) ) ; } if ( $ this -> module -> isInstaller ( $ module_id ) ) { $ error = $ this -> translation -> text ( 'Modules with "installer" type cannot be installed/enabled when system is already set up' ) ; throw new UnexpectedValueException ( $ error ) ; } $ this -> module -> getInstance ( $ module_id ) ; return $ this -> checkRequirements ( $ module_id ) ; }
|
Whether a given module can be enabled
|
55,356
|
public function canUninstall ( $ module_id ) { if ( $ this -> module -> isActiveTheme ( $ module_id ) ) { $ error = $ this -> translation -> text ( 'Modules with "theme" type and active status cannot be disabled/uninstalled' ) ; throw new UnexpectedValueException ( $ error ) ; } if ( $ this -> module -> isLocked ( $ module_id ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Module is locked in code' ) ) ; } return $ this -> checkDependentModules ( $ module_id , $ this -> module -> getList ( ) ) ; }
|
Whether a given module can be un - installed
|
55,357
|
public function checkRequirements ( $ module_id ) { $ this -> checkModuleId ( $ module_id ) ; $ module = $ this -> module -> getInfo ( $ module_id ) ; $ this -> checkCore ( $ module ) ; $ this -> checkPhpVersion ( $ module ) ; if ( $ this -> module -> isInstaller ( $ module_id ) ) { $ error = $ this -> translation -> text ( 'Modules with "installer" type cannot be installed/enabled when system is already set up' ) ; throw new UnexpectedValueException ( $ error ) ; } $ this -> checkDependenciesExtensions ( $ module ) ; $ this -> checkDependenciesModule ( $ module_id ) ; return true ; }
|
Checks all requirements for the module
|
55,358
|
public function checkPhpVersion ( array $ module ) { if ( ! empty ( $ module [ 'php' ] ) ) { $ components = $ this -> getVersionComponents ( $ module [ 'php' ] ) ; if ( empty ( $ components ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Failed to read PHP version' ) ) ; } list ( $ operator , $ number ) = $ components ; if ( ! version_compare ( PHP_VERSION , $ number , $ operator ) ) { $ error = $ this -> translation -> text ( 'Requires incompatible version of @name' , array ( '@name' => 'PHP' ) ) ; throw new UnexpectedValueException ( $ error ) ; } } return true ; }
|
Checks PHP version compatibility for the module ID
|
55,359
|
public function checkModuleId ( $ module_id ) { if ( ! $ this -> module -> isValidId ( $ module_id ) ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Invalid module ID' ) ) ; } return true ; }
|
Checks a module ID
|
55,360
|
public function checkCore ( array $ module ) { if ( ! isset ( $ module [ 'core' ] ) ) { throw new OutOfBoundsException ( $ this -> translation -> text ( 'Missing core version' ) ) ; } if ( version_compare ( gplcart_version ( ) , $ module [ 'core' ] ) < 0 ) { throw new UnexpectedValueException ( $ this -> translation -> text ( 'Module incompatible with the current system core version' ) ) ; } return true ; }
|
Checks core version requirements
|
55,361
|
public function checkDependentModules ( $ module_id , array $ modules ) { unset ( $ modules [ $ module_id ] ) ; $ required_by = array ( ) ; foreach ( $ modules as $ info ) { if ( empty ( $ info [ 'dependencies' ] ) ) { continue ; } foreach ( array_keys ( $ info [ 'dependencies' ] ) as $ dependency ) { if ( $ dependency === $ module_id && ! empty ( $ info [ 'status' ] ) ) { $ required_by [ ] = $ info [ 'name' ] ; } } } if ( empty ( $ required_by ) ) { return true ; } throw new UnexpectedValueException ( $ this -> translation -> text ( 'Required by' ) . ': ' . implode ( ', ' , $ required_by ) ) ; }
|
Checks dependent modules
|
55,362
|
public function getOverrideMap ( ) { gplcart_static_clear ( ) ; $ map = array ( ) ; foreach ( $ this -> module -> getEnabled ( ) as $ module ) { $ directory = GC_DIR_MODULE . "/{$module['id']}/override/classes" ; if ( ! is_readable ( $ directory ) ) { continue ; } foreach ( $ this -> scanOverrideFiles ( $ directory ) as $ file ) { $ original = str_replace ( '/' , '\\' , str_replace ( $ directory . '/' , '' , preg_replace ( '/Override$/' , '' , $ file ) ) ) ; $ override = str_replace ( '/' , '\\' , str_replace ( GC_DIR_SYSTEM . '/' , '' , $ file ) ) ; $ map [ "gplcart\\$original" ] [ $ module [ 'id' ] ] = "gplcart\\$override" ; } } return $ map ; }
|
Returns an array of class name spaces to be overridden
|
55,363
|
protected function checkDependenciesModule ( $ module_id ) { $ modules = $ this -> module -> getList ( ) ; $ validated = $ this -> validateDependencies ( $ modules , true ) ; if ( empty ( $ validated [ $ module_id ] [ 'errors' ] ) ) { return true ; } $ messages = array ( ) ; foreach ( $ validated [ $ module_id ] [ 'errors' ] as $ error ) { list ( $ text , $ arguments ) = $ error ; $ messages [ ] = $ this -> translation -> text ( $ text , $ arguments ) ; } throw new UnexpectedValueException ( implode ( '<br>' , $ messages ) ) ; }
|
Checks module dependencies
|
55,364
|
protected function scanOverrideFiles ( $ directory , array & $ results = array ( ) ) { foreach ( new DirectoryIterator ( $ directory ) as $ file ) { if ( $ file -> isFile ( ) && $ file -> getExtension ( ) === 'php' ) { $ results [ ] = $ file -> getFilename ( ) ; } elseif ( $ file -> isDir ( ) && ! $ file -> isDot ( ) ) { $ this -> scanOverrideFiles ( $ file -> getRealPath ( ) , $ results ) ; } } return $ results ; }
|
Recursively scans module override files
|
55,365
|
public function listAccountAddress ( $ user_id ) { $ this -> setUserAccountAddress ( $ user_id ) ; $ this -> actionAccountAddress ( ) ; $ this -> setTitleListAccountAddress ( ) ; $ this -> setBreadcrumbListAccountAddress ( ) ; $ this -> setData ( 'user' , $ this -> data_user ) ; $ this -> setData ( 'addresses' , $ this -> getListAccountAddress ( ) ) ; $ this -> outputListAccountAddress ( ) ; }
|
Displays the address overview page
|
55,366
|
protected function prepareListAccountAddress ( array $ addresses ) { $ prepared = array ( ) ; foreach ( $ addresses as $ address_id => $ items ) { $ prepared [ $ address_id ] [ 'items' ] = $ items ; $ prepared [ $ address_id ] [ 'locked' ] = ! $ this -> address -> canDelete ( $ address_id ) ; } return $ prepared ; }
|
Prepares an array of user addresses
|
55,367
|
protected function actionAccountAddress ( ) { $ key = 'delete' ; $ this -> controlToken ( $ key ) ; $ address_id = $ this -> getQuery ( $ key ) ; if ( ! empty ( $ address_id ) ) { if ( $ this -> address -> delete ( $ address_id ) ) { $ this -> redirect ( '' , $ this -> text ( 'Address has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Address has not been deleted' ) , 'warning' ) ; } }
|
Handles various actions
|
55,368
|
protected function setBreadcrumbListAccountAddress ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( '/' ) , 'text' => $ this -> text ( 'Shop' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Account' ) , 'url' => $ this -> url ( "account/{$this->data_user['user_id']}" ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the address overview page
|
55,369
|
public static function popBeforeSmtp ( $ host , $ port = false , $ tval = false , $ username = '' , $ password = '' , $ debug_level = 0 ) { $ pop = new POP3 ; return $ pop -> authorise ( $ host , $ port , $ tval , $ username , $ password , $ debug_level ) ; }
|
Simple static wrapper for all - in - one POP before SMTP
|
55,370
|
private function setError ( $ error ) { $ this -> errors [ ] = $ error ; if ( $ this -> do_debug >= 1 ) { echo '<pre>' ; foreach ( $ this -> errors as $ error ) { print_r ( $ error ) ; } echo '</pre>' ; } }
|
Add an error to the internal error store . Also display debug output if it s enabled .
|
55,371
|
private function catchWarning ( $ errno , $ errstr , $ errfile , $ errline ) { $ this -> setError ( array ( 'error' => "Connecting to the POP3 server raised a PHP warning: " , 'errno' => $ errno , 'errstr' => $ errstr , 'errfile' => $ errfile , 'errline' => $ errline ) ) ; }
|
POP3 connection error handler .
|
55,372
|
public function getMetadata ( $ key = null ) { if ( null === $ key ) { return stream_get_meta_data ( $ this -> resource ) ; } $ metadata = stream_get_meta_data ( $ this -> resource ) ; if ( ! array_key_exists ( $ key , $ metadata ) ) { return ; } return $ metadata [ $ key ] ; }
|
Retrieve metadata from the underlying stream .
|
55,373
|
public function route ( array $ condition ) { if ( ! in_array ( $ condition [ 'operator' ] , array ( '=' , '!=' ) ) ) { return false ; } $ route = $ this -> route -> get ( ) ; return $ this -> compare ( $ route [ 'pattern' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Returns true if route condition is met
|
55,374
|
public function path ( array $ condition ) { if ( ! in_array ( $ condition [ 'operator' ] , array ( '=' , '!=' ) ) ) { return false ; } $ path = $ this -> url -> path ( ) ; $ found = false ; foreach ( ( array ) $ condition [ 'value' ] as $ pattern ) { if ( gplcart_path_match ( $ path , $ pattern ) ) { $ found = true ; } } return $ condition [ 'operator' ] === '=' ? $ found : ! $ found ; }
|
Returns true if path condition is met
|
55,375
|
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'file.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } if ( empty ( $ data [ 'mime_type' ] ) ) { $ data [ 'mime_type' ] = mime_content_type ( gplcart_file_absolute ( $ data [ 'path' ] ) ) ; } if ( empty ( $ data [ 'file_type' ] ) ) { $ data [ 'file_type' ] = strtolower ( strtok ( $ data [ 'mime_type' ] , '/' ) ) ; } if ( empty ( $ data [ 'title' ] ) ) { $ data [ 'title' ] = basename ( $ data [ 'path' ] ) ; } $ data [ 'created' ] = $ data [ 'modified' ] = GC_TIME ; $ result = $ data [ 'file_id' ] = $ this -> db -> insert ( 'file' , $ data ) ; $ this -> setTranslations ( $ data , $ this -> translation_entity , 'file' , false ) ; $ this -> hook -> attach ( 'file.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
|
Adds a file to the database
|
55,376
|
public function delete ( $ condition , $ check = true ) { $ result = null ; $ this -> hook -> attach ( 'file.delete.before' , $ condition , $ check , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } if ( ! is_array ( $ condition ) ) { $ condition = array ( 'file_id' => $ condition ) ; } if ( $ check && isset ( $ condition [ 'file_id' ] ) && ! $ this -> canDelete ( $ condition [ 'file_id' ] ) ) { return false ; } $ result = ( bool ) $ this -> db -> delete ( 'file' , $ condition ) ; if ( $ result && isset ( $ condition [ 'file_id' ] ) ) { $ this -> deleteLinked ( $ condition [ 'file_id' ] ) ; } $ this -> hook -> attach ( 'file.delete.after' , $ condition , $ check , $ result , $ this ) ; return ( bool ) $ result ; }
|
Deletes a file from the database
|
55,377
|
public function deleteFromDisk ( $ file ) { if ( ! is_array ( $ file ) ) { $ file = $ this -> get ( $ file ) ; } $ result = null ; $ this -> hook -> attach ( 'file.delete.disk.before' , $ file , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } if ( empty ( $ file [ 'path' ] ) ) { return false ; } $ path = gplcart_file_absolute ( $ file [ 'path' ] ) ; if ( ! is_file ( $ path ) ) { return false ; } $ result = unlink ( $ path ) ; $ this -> hook -> attach ( 'file.delete.disk.after' , $ file , $ result , $ this ) ; return $ result ; }
|
Deletes a file from disk
|
55,378
|
public function deleteAll ( $ file , & $ db = 0 , & $ disk = 0 , $ check = true ) { if ( ! is_array ( $ file ) ) { $ file = $ this -> get ( $ file ) ; } if ( ! isset ( $ file [ 'file_id' ] ) ) { return false ; } if ( ! $ this -> delete ( $ file [ 'file_id' ] , $ check ) ) { return false ; } $ db ++ ; if ( ! $ this -> deleteFromDisk ( $ file ) ) { return false ; } $ disk ++ ; return true ; }
|
Deletes a file both from database and disk
|
55,379
|
public function supportedExtensions ( $ dot = false ) { $ extensions = array ( ) ; foreach ( $ this -> getHandlers ( ) as $ handler ) { if ( ! empty ( $ handler [ 'extensions' ] ) ) { $ extensions += array_merge ( $ extensions , ( array ) $ handler [ 'extensions' ] ) ; } } $ extensions = array_unique ( $ extensions ) ; if ( $ dot ) { $ extensions = array_map ( function ( $ value ) { return ".$value" ; } , $ extensions ) ; } return $ extensions ; }
|
Returns an array of all supported file extensions
|
55,380
|
public function getHandler ( $ name ) { $ handlers = $ this -> getHandlers ( ) ; if ( strpos ( $ name , '.' ) !== 0 ) { return isset ( $ handlers [ $ name ] ) ? $ handlers [ $ name ] : array ( ) ; } $ extension = ltrim ( $ name , '.' ) ; foreach ( $ handlers as $ handler ) { if ( empty ( $ handler [ 'extensions' ] ) ) { continue ; } foreach ( ( array ) $ handler [ 'extensions' ] as $ allowed_extension ) { if ( $ extension === $ allowed_extension ) { return $ handler ; } } } return array ( ) ; }
|
Returns a handler data
|
55,381
|
protected function validateData ( ) { $ field = 'data' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } if ( ! is_array ( $ value ) ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Data' ) ) ; return false ; } return true ; }
|
Validates data field
|
55,382
|
protected function validateMetaTitle ( ) { $ field = 'meta_title' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return true ; } if ( mb_strlen ( $ value ) > 60 ) { $ this -> setErrorLengthRange ( $ field , $ this -> translation -> text ( 'Meta title' ) , 0 , 60 ) ; return false ; } return true ; }
|
Validates a meta title
|
55,383
|
protected function validateBool ( $ field ) { $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ this -> setSubmitted ( $ field , ( int ) filter_var ( $ value , FILTER_VALIDATE_BOOLEAN ) ) ; return true ; }
|
Convert different values into boolean
|
55,384
|
protected function validateTranslation ( ) { $ translations = $ this -> getSubmitted ( 'translation' ) ; if ( empty ( $ translations ) ) { return null ; } $ lengths = array ( 'meta_title' => 60 , 'meta_description' => 160 ) ; foreach ( $ translations as $ lang => $ translation ) { foreach ( $ translation as $ field => $ value ) { if ( $ value === '' ) { unset ( $ translations [ $ lang ] [ $ field ] ) ; continue ; } $ max = isset ( $ lengths [ $ field ] ) ? $ lengths [ $ field ] : 255 ; if ( mb_strlen ( $ value ) > $ max ) { $ label = ucfirst ( str_replace ( '_' , ' ' , $ field ) ) ; $ this -> setErrorLengthRange ( "translation.$lang.$field" , $ label , 0 , $ max ) ; } } if ( empty ( $ translations [ $ lang ] ) ) { unset ( $ translations [ $ lang ] ) ; } } $ this -> setSubmitted ( 'translation' , $ translations ) ; return ! $ this -> isError ( 'translation' ) ; }
|
Validates category translations
|
55,385
|
protected function validateUploadImages ( $ entity ) { $ files = $ this -> request -> file ( 'files' ) ; if ( empty ( $ files [ 'name' ] [ 0 ] ) ) { return null ; } $ directory = $ this -> config -> get ( "{$entity}_image_dirname" , $ entity ) ; $ results = $ this -> file_transfer -> uploadMultiple ( $ files , 'image' , "image/upload/$directory" ) ; foreach ( $ results [ 'transferred' ] as $ key => $ path ) { $ this -> setSubmitted ( "images.$key.path" , $ path ) ; } if ( ! empty ( $ results [ 'errors' ] ) ) { $ this -> setError ( 'images' , implode ( '<br>' , ( array ) $ results [ 'errors' ] ) ) ; return false ; } return true ; }
|
Validates uploaded images
|
55,386
|
protected function validateAlias ( ) { $ field = 'alias' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Alias' ) ; if ( mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ label , 0 , 255 ) ; return false ; } if ( preg_match ( '/^[A-Za-z0-9_.-]+$/' , $ value ) !== 1 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'alias' ] ) && $ updating [ 'alias' ] === $ value ) { return true ; } if ( $ this -> alias -> exists ( $ value ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } return true ; }
|
Validates an alias
|
55,387
|
protected function validateEmail ( ) { $ field = 'email' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'E-mail' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } if ( ! filter_var ( $ value , FILTER_VALIDATE_EMAIL ) ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } return true ; }
|
Validates an E - mail
|
55,388
|
public function addData ( Serializing $ event ) { if ( $ event -> isSerializer ( ForumSerializer :: class ) && $ event -> actor -> isAdmin ( ) ) { $ event -> attributes [ 'datitisev-dashboard.data' ] = [ 'postCount' => Post :: where ( 'type' , 'comment' ) -> count ( ) , 'discussionCount' => Discussion :: count ( ) , 'userCount' => User :: where ( 'is_email_confirmed' , 1 ) -> count ( ) , ] ; } }
|
Adds settings to admin settings .
|
55,389
|
public function listReportStatus ( ) { $ this -> setTitleListReportStatus ( ) ; $ this -> setBreadcrumbListReportStatus ( ) ; $ this -> setData ( 'statuses' , $ this -> getReportStatus ( ) ) ; $ this -> outputListReportStatus ( ) ; }
|
Displays the status page
|
55,390
|
public function getVolume ( array $ order , array & $ cart ) { $ result = null ; $ this -> hook -> attach ( 'order.volume.get.before' , $ order , $ cart , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( float ) $ result ; } $ total = 0.0 ; foreach ( $ cart [ 'items' ] as & $ item ) { $ this -> sumTotalVolume ( $ total , $ item , $ order ) ; } $ result = round ( $ total , 2 ) ; $ this -> hook -> attach ( 'order.volume.get.after' , $ order , $ cart , $ result , $ this ) ; return ( float ) $ result ; }
|
Returns a total volume of all products in the order
|
55,391
|
public function getWeight ( array $ order , array & $ cart ) { $ result = null ; $ this -> hook -> attach ( 'order.weight.get.before' , $ order , $ cart , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( float ) $ result ; } $ total = 0.0 ; foreach ( $ cart [ 'items' ] as & $ item ) { $ this -> sumTotalWeight ( $ total , $ item , $ order ) ; } $ result = round ( $ total , 2 ) ; $ this -> hook -> attach ( 'order.weight.get.after' , $ order , $ cart , $ result , $ this ) ; return ( float ) $ result ; }
|
Returns a total weight of all products in the order
|
55,392
|
protected function sumTotalVolume ( & $ total , array & $ item , array $ order ) { $ product = & $ item [ 'product' ] ; if ( empty ( $ product [ 'width' ] ) || empty ( $ product [ 'height' ] ) || empty ( $ product [ 'length' ] ) ) { return null ; } if ( $ product [ 'size_unit' ] !== $ order [ 'size_unit' ] ) { try { $ product [ 'width' ] = $ this -> convertor -> convert ( $ product [ 'width' ] , $ product [ 'size_unit' ] , $ order [ 'size_unit' ] ) ; $ product [ 'height' ] = $ this -> convertor -> convert ( $ product [ 'height' ] , $ product [ 'size_unit' ] , $ order [ 'size_unit' ] ) ; $ product [ 'length' ] = $ this -> convertor -> convert ( $ product [ 'length' ] , $ product [ 'size_unit' ] , $ order [ 'size_unit' ] ) ; } catch ( Exception $ ex ) { return null ; } $ product [ 'size_unit' ] = $ order [ 'size_unit' ] ; } $ volume = ( float ) ( $ product [ 'width' ] * $ product [ 'height' ] * $ product [ 'length' ] ) ; $ total += ( float ) ( $ volume * $ item [ 'quantity' ] ) ; return null ; }
|
Sum volume totals
|
55,393
|
protected function sumTotalWeight ( & $ total , array & $ item , array $ order ) { $ product = & $ item [ 'product' ] ; if ( $ product [ 'weight_unit' ] !== $ order [ 'weight_unit' ] ) { try { $ product [ 'weight' ] = $ this -> convertor -> convert ( $ product [ 'weight' ] , $ product [ 'weight_unit' ] , $ order [ 'weight_unit' ] ) ; } catch ( Exception $ ex ) { return null ; } $ product [ 'weight_unit' ] = $ order [ 'weight_unit' ] ; } $ total += ( float ) ( $ product [ 'weight' ] * $ item [ 'quantity' ] ) ; return null ; }
|
Sum weight totals
|
55,394
|
public function getModulesPath ( ) { $ paths = $ this -> locator -> getModulesPath ( ) ; foreach ( array_keys ( $ paths ) as $ module ) { $ paths [ $ module ] .= DIRECTORY_SEPARATOR . TemplateReference :: MODULE_VIEWS_DIRECTORY ; } return $ paths ; }
|
Returns an array of paths to modules views dir .
|
55,395
|
public function listProductClass ( ) { $ this -> actionListProductClass ( ) ; $ this -> setTitleListProductClass ( ) ; $ this -> setBreadcrumbListProductClass ( ) ; $ this -> setFilterListProductClass ( ) ; $ this -> setPagerListProductClass ( ) ; $ this -> setData ( 'product_classes' , $ this -> getListProductClass ( ) ) ; $ this -> outputListProductClass ( ) ; }
|
Returns the product class overview page
|
55,396
|
public function setPagerListProductClass ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'count' ] = true ; $ pager = array ( 'query' => $ this -> query_filter , 'total' => ( int ) $ this -> product_class -> getList ( $ conditions ) ) ; return $ this -> data_limit = $ this -> setPager ( $ pager ) ; }
|
Set pager on the product class overview page
|
55,397
|
public function editProductClass ( $ product_class_id = null ) { $ this -> setProductClass ( $ product_class_id ) ; $ this -> setTitleEditProductClass ( ) ; $ this -> setBreadcrumbEditProductClass ( ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteProductClass ( ) ) ; $ this -> setData ( 'product_class' , $ this -> data_product_class ) ; $ this -> submitEditProductClass ( ) ; $ this -> outputEditProductClass ( ) ; }
|
Route callback for the edit product class page
|
55,398
|
protected function canDeleteProductClass ( ) { return isset ( $ this -> data_product_class [ 'product_class_id' ] ) && $ this -> access ( 'product_class_delete' ) && $ this -> product_class -> canDelete ( $ this -> data_product_class [ 'product_class_id' ] ) ; }
|
Whether a product class can be deleted
|
55,399
|
protected function submitEditProductClass ( ) { if ( $ this -> isPosted ( 'delete' ) && $ this -> canDeleteProductClass ( ) ) { $ this -> deleteProductClass ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditProductClass ( ) ) { if ( isset ( $ this -> data_product_class [ 'product_class_id' ] ) ) { $ this -> updateProductClass ( ) ; } else { $ this -> addProductClass ( ) ; } } }
|
Handles a submitted product class
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.