idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
54,500
protected function validateFieldIdProductClassField ( ) { $ field = 'field_id' ; if ( $ this -> isExcluded ( $ field ) || $ this -> isError ( 'product_class_id' ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Fields' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; $ product_class_id = $ this -> getSubmitted ( 'product_class_id' ) ; if ( ! isset ( $ product_class_id ) && isset ( $ updating [ 'product_class_id' ] ) ) { $ product_class_id = $ updating [ 'product_class_id' ] ; } if ( empty ( $ product_class_id ) ) { $ this -> setErrorUnavailable ( $ field , $ this -> translation -> text ( 'Unknown product class ID' ) ) ; } $ existing = $ this -> product_class_field -> getList ( array ( 'index' => 'field_id' , 'product_class_id' => $ product_class_id ) ) ; $ processed = array ( ) ; foreach ( ( array ) $ value as $ field_id ) { if ( empty ( $ field_id ) || ! is_numeric ( $ field_id ) ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } if ( in_array ( $ field_id , $ processed ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } if ( isset ( $ existing [ $ field_id ] ) ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } $ data = $ this -> field -> get ( $ field_id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } $ processed [ ] = $ field_id ; } return true ; }
Validates one or several field IDs
54,501
public function getAssetsVersion ( array $ parameters = array ( ) , \ Smarty_Internal_Template $ template ) { $ parameters = array_merge ( array ( 'package' => null , ) , $ parameters ) ; return $ this -> helper -> getVersion ( $ parameters [ 'package' ] ) ; }
Returns the version of the assets in a package .
54,502
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'user.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } if ( empty ( $ data [ 'name' ] ) ) { $ data [ 'name' ] = strtok ( $ data [ 'email' ] , '@' ) ; } $ data [ 'created' ] = $ data [ 'modified' ] = GC_TIME ; $ data [ 'hash' ] = gplcart_string_hash ( $ data [ 'password' ] ) ; $ result = $ data [ 'user_id' ] = $ this -> db -> insert ( 'user' , $ data ) ; $ this -> setAddress ( $ data ) ; $ this -> hook -> attach ( 'user.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
Adds a user
54,503
public function isSuperadmin ( $ user_id = null ) { if ( isset ( $ user_id ) ) { return $ this -> getSuperadminId ( ) == $ user_id ; } return $ this -> getSuperadminId ( ) == $ this -> uid ; }
Whether the user is super admin
54,504
public function access ( $ permission , $ user_id = null ) { if ( $ this -> isSuperadmin ( $ user_id ) ) { return true ; } if ( $ permission === GC_PERM_SUPERADMIN ) { return false ; } return in_array ( $ permission , $ this -> getPermissions ( $ user_id ) ) ; }
Whether a user has an access to do something
54,505
public function getPermissions ( $ user_id = null ) { static $ permissions = array ( ) ; if ( ! isset ( $ user_id ) ) { $ user_id = $ this -> uid ; } if ( isset ( $ permissions [ $ user_id ] ) ) { return $ permissions [ $ user_id ] ; } $ user = $ this -> get ( $ user_id ) ; if ( empty ( $ user [ 'role_id' ] ) ) { return $ permissions [ $ user_id ] = array ( ) ; } $ role = array ( ) ; if ( isset ( $ user [ 'role_permissions' ] ) ) { $ role [ 'permissions' ] = $ user [ 'role_permissions' ] ; } else { $ role = $ this -> role -> get ( $ user [ 'role_id' ] ) ; } if ( empty ( $ role [ 'permissions' ] ) ) { return $ permissions [ $ user_id ] = array ( ) ; } return $ permissions [ $ user_id ] = ( array ) $ role [ 'permissions' ] ; }
Returns user permissions
54,506
public function getSession ( $ key = null ) { $ user = $ this -> session -> get ( 'user' , array ( ) ) ; if ( isset ( $ key ) ) { return gplcart_array_get ( $ user , $ key ) ; } return $ user ; }
Returns the current user from the session
54,507
public function passwordMatches ( $ password , $ user ) { if ( ! is_array ( $ user ) ) { $ user = $ this -> get ( $ user ) ; } if ( empty ( $ user [ 'hash' ] ) ) { return false ; } return gplcart_string_equals ( $ user [ 'hash' ] , gplcart_string_hash ( $ password , $ user [ 'hash' ] , 0 ) ) ; }
Whether the password matches the user s password stored in the database
54,508
protected function deleteLinked ( $ user_id ) { $ this -> db -> delete ( 'cart' , array ( 'user_id' => $ user_id ) ) ; $ this -> db -> delete ( 'review' , array ( 'user_id' => $ user_id ) ) ; $ this -> db -> delete ( 'history' , array ( 'user_id' => $ user_id ) ) ; $ this -> db -> delete ( 'address' , array ( 'user_id' => $ user_id ) ) ; $ this -> db -> delete ( 'wishlist' , array ( 'user_id' => $ user_id ) ) ; $ this -> db -> delete ( 'rating_user' , array ( 'user_id' => $ user_id ) ) ; $ this -> db -> delete ( 'dashboard' , array ( 'user_id' => $ user_id ) ) ; }
Deletes all database records related to the user ID
54,509
public function get ( $ cid , $ options = array ( ) ) { $ options += array ( 'lifespan' => 0 , 'default' => null ) ; $ result = null ; $ this -> hook -> attach ( 'cache.get.before' , $ cid , $ options , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } if ( is_array ( $ cid ) ) { $ cid = gplcart_array_hash ( $ cid ) ; } $ this -> file = GC_DIR_CACHE . "/$cid.cache" ; $ result = $ options [ 'default' ] ; if ( is_file ( $ this -> file ) ) { $ this -> filemtime = filemtime ( $ this -> file ) ; if ( empty ( $ options [ 'lifespan' ] ) || ( ( GC_TIME - $ this -> filemtime ) < $ options [ 'lifespan' ] ) ) { $ result = unserialize ( file_get_contents ( $ this -> file ) ) ; } } $ this -> hook -> attach ( 'cache.get.after' , $ cid , $ options , $ result , $ this ) ; return $ result ; }
Returns a cached data
54,510
public function clear ( $ cache_id , $ options = array ( ) ) { $ result = null ; $ options += array ( 'pattern' => '.cache' ) ; $ this -> hook -> attach ( 'cache.clear.before' , $ cache_id , $ options , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ result = true ; if ( $ cache_id === null ) { array_map ( 'unlink' , glob ( GC_DIR_CACHE . '/*.cache' ) ) ; gplcart_static_clear ( ) ; } else { if ( is_array ( $ cache_id ) ) { $ cache_id = gplcart_array_hash ( $ cache_id ) ; } array_map ( 'unlink' , glob ( GC_DIR_CACHE . "/$cache_id{$options['pattern']}" ) ) ; gplcart_static_clear ( $ cache_id ) ; } $ this -> hook -> attach ( 'cache.clear.after' , $ cache_id , $ options , $ result , $ this ) ; return ( bool ) $ result ; }
Clears a cached data
54,511
protected function getImageStyleFieldsSettings ( ) { return array ( 'image_style_category' => $ this -> text ( 'Category page' ) , 'image_style_category_child' => $ this -> text ( 'Category page (child)' ) , 'image_style_product' => $ this -> text ( 'Product page' ) , 'image_style_page' => $ this -> text ( 'Page' ) , 'image_style_product_grid' => $ this -> text ( 'Product catalog (grid)' ) , 'image_style_product_list' => $ this -> text ( 'Product catalog (list)' ) , 'image_style_cart' => $ this -> text ( 'Cart' ) , 'image_style_option' => $ this -> text ( 'Product option' ) , 'image_style_collection_file' => $ this -> text ( 'File collection (banners)' ) , 'image_style_collection_page' => $ this -> text ( 'Page collection (news/articles)' ) , 'image_style_collection_product' => $ this -> text ( 'Product collection (featured products)' ) , ) ; }
Returns an array of image style settings keys and their corresponding field labels
54,512
protected function resetSettings ( ) { $ this -> controlAccess ( 'module_edit' ) ; $ this -> module -> setSettings ( 'frontend' , array ( ) ) ; $ this -> redirect ( '' , $ this -> text ( 'Settings have been reset to default values' ) , 'success' ) ; }
Resets module settings to default values
54,513
protected function setBreadcrumbEditSettings ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Dashboard' ) , 'url' => $ this -> url ( 'admin' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Modules' ) , 'url' => $ this -> url ( 'admin/module/list' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets bread crumbs on the module settings page
54,514
public function editUserRole ( $ role_id = null ) { $ this -> setUserRole ( $ role_id ) ; $ this -> setTitleEditUserRole ( ) ; $ this -> setBreadcrumbEditUserRole ( ) ; $ this -> setData ( 'role' , $ this -> data_role ) ; $ this -> setData ( 'permissions' , $ this -> getPermissionsUserRole ( true ) ) ; $ this -> submitEditUserRole ( ) ; $ this -> outputEditUserRole ( ) ; }
Displays the user role edit page
54,515
protected function getPermissionsUserRole ( $ chunked = false ) { $ permissions = $ this -> role -> getPermissions ( ) ; return $ chunked ? gplcart_array_split ( $ permissions , 3 ) : $ permissions ; }
Returns an array of permissions
54,516
protected function setUserRole ( $ role_id ) { $ this -> data_role = array ( ) ; if ( is_numeric ( $ role_id ) ) { $ this -> data_role = $ this -> role -> get ( $ role_id ) ; if ( empty ( $ this -> data_role ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
Returns a user role data
54,517
protected function submitEditUserRole ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteUserRole ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditUserRole ( ) ) { if ( isset ( $ this -> data_role [ 'role_id' ] ) ) { $ this -> updateUserRole ( ) ; } else { $ this -> addUserRole ( ) ; } } }
Handles a submitted user role data
54,518
protected function validateEditUserRole ( ) { $ this -> setSubmitted ( 'role' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_role ) ; if ( ! $ this -> getSubmitted ( 'permissions' ) ) { $ this -> setSubmitted ( 'permissions' , array ( ) ) ; } $ this -> validateComponent ( 'user_role' ) ; return ! $ this -> hasErrors ( ) ; }
Validates a submitted user role data
54,519
protected function deleteUserRole ( ) { $ this -> controlAccess ( 'user_role_delete' ) ; if ( $ this -> role -> delete ( $ this -> data_role [ 'role_id' ] ) ) { $ this -> redirect ( 'admin/user/role' , $ this -> text ( 'Role has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Role has not been deleted' ) , 'warning' ) ; }
Deletes a user role
54,520
protected function addUserRole ( ) { $ this -> controlAccess ( 'user_role_add' ) ; if ( $ this -> role -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/user/role' , $ this -> text ( 'Role has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Role has not been added' ) , 'warning' ) ; }
Adds a new user role
54,521
protected function setTitleEditUserRole ( ) { if ( isset ( $ this -> data_role [ 'role_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_role [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add role' ) ; } $ this -> setTitle ( $ title ) ; }
Sets titles on the user role edit page
54,522
protected function setBreadcrumbEditUserRole ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Roles' ) , 'url' => $ this -> url ( 'admin/user/role' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the user role edit page
54,523
public function listUserRole ( ) { $ this -> actionListUserRole ( ) ; $ this -> setTitleListUserRole ( ) ; $ this -> setBreadcrumbListUserRole ( ) ; $ this -> setFilterListUserRole ( ) ; $ this -> setPagerListUserRole ( ) ; $ this -> setData ( 'user_roles' , $ this -> getListUserRole ( ) ) ; $ this -> outputListUserRole ( ) ; }
Displays the user role overview page
54,524
protected function actionListUserRole ( ) { list ( $ selected , $ action , $ value ) = $ this -> getPostedAction ( ) ; $ deleted = $ updated = 0 ; foreach ( $ selected as $ role_id ) { if ( $ action === 'status' && $ this -> access ( 'user_role_edit' ) ) { $ updated += ( int ) $ this -> role -> update ( $ role_id , array ( 'status' => $ value ) ) ; } if ( $ action === 'delete' && $ this -> access ( 'user_role_delete' ) ) { $ deleted += ( int ) $ this -> role -> delete ( $ role_id ) ; } } if ( $ updated > 0 ) { $ text = $ this -> text ( 'Updated %num item(s)' , array ( '%num' => $ updated ) ) ; $ this -> setMessage ( $ text , 'success' ) ; } if ( $ deleted > 0 ) { $ text = $ this -> text ( 'Deleted %num item(s)' , array ( '%num' => $ deleted ) ) ; $ this -> setMessage ( $ text , 'success' ) ; } }
Applies an action to the selected user roles
54,525
protected function prepareListUserRole ( array & $ roles ) { $ permissions = $ this -> getPermissionsUserRole ( ) ; foreach ( $ roles as & $ role ) { if ( ! empty ( $ role [ 'permissions' ] ) ) { $ list = array_intersect_key ( $ permissions , array_flip ( $ role [ 'permissions' ] ) ) ; $ role [ 'permissions_list' ] = array_chunk ( $ list , 20 ) ; } } }
Prepare an array of user roles
54,526
public function listCity ( $ country_code , $ state_id ) { $ this -> setStateCity ( $ state_id ) ; $ this -> setCountryCity ( $ country_code ) ; $ this -> actionListCity ( ) ; $ this -> setTitleListCity ( ) ; $ this -> setBreadcrumbListCity ( ) ; $ this -> setFilterListCity ( ) ; $ this -> setPagerListCity ( ) ; $ this -> setData ( 'state' , $ this -> data_state ) ; $ this -> setData ( 'country' , $ this -> data_country ) ; $ this -> setData ( 'cities' , $ this -> getListCity ( ) ) ; $ this -> outputListCity ( ) ; }
Displays the city overview page
54,527
protected function setStateCity ( $ state_id ) { $ this -> data_state = $ this -> state -> get ( $ state_id ) ; if ( empty ( $ this -> data_state ) ) { $ this -> outputHttpStatus ( 404 ) ; } }
Sets an array of state data
54,528
protected function setCountryCity ( $ country_code ) { $ this -> data_country = $ this -> country -> get ( $ country_code ) ; if ( empty ( $ this -> data_country ) ) { $ this -> outputHttpStatus ( 404 ) ; } }
Returns an array of country data
54,529
protected function getListCity ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'limit' ] = $ this -> data_limit ; $ conditions [ 'state_id' ] = $ this -> data_state [ 'state_id' ] ; return ( array ) $ this -> city -> getList ( $ conditions ) ; }
Returns an array of cities found for the filter conditions
54,530
protected function setBreadcrumbListCity ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/country' ) , 'text' => $ this -> text ( 'Countries' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( "admin/settings/states/{$this->data_country['code']}" ) , 'text' => $ this -> text ( 'Country states of %name' , array ( '%name' => $ this -> data_country [ 'name' ] ) ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the city overview page
54,531
public function editCity ( $ country_code , $ state_id , $ city_id = null ) { $ this -> setCity ( $ city_id ) ; $ this -> setStateCity ( $ state_id ) ; $ this -> setCountryCity ( $ country_code ) ; $ this -> setTitleEditCity ( ) ; $ this -> setBreadcrumbEditCity ( ) ; $ this -> setData ( 'city' , $ this -> data_city ) ; $ this -> setData ( 'state' , $ this -> data_state ) ; $ this -> setData ( 'country' , $ this -> data_country ) ; $ this -> setData ( 'zones' , $ this -> getZonesCity ( ) ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteCity ( ) ) ; $ this -> submitEditCity ( ) ; $ this -> outputEditCity ( ) ; }
Displays the city edit page
54,532
protected function canDeleteCity ( ) { return isset ( $ this -> data_city [ 'city_id' ] ) && $ this -> access ( 'city_delete' ) && $ this -> city -> canDelete ( $ this -> data_city [ 'city_id' ] ) ; }
Whether the city can be deleted
54,533
protected function setCity ( $ city_id ) { $ this -> data_city = array ( ) ; if ( is_numeric ( $ city_id ) ) { $ this -> data_city = $ this -> city -> get ( $ city_id ) ; if ( empty ( $ this -> data_city ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
Sets an array of city data
54,534
protected function submitEditCity ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteCity ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditCity ( ) ) { if ( isset ( $ this -> data_city [ 'city_id' ] ) ) { $ this -> updateCity ( ) ; } else { $ this -> addCity ( ) ; } } }
Handles a submitted city
54,535
protected function validateEditCity ( ) { $ this -> setSubmitted ( 'city' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_city ) ; $ this -> setSubmitted ( 'country' , $ this -> data_country [ 'code' ] ) ; $ this -> setSubmitted ( 'state_id' , $ this -> data_state [ 'state_id' ] ) ; $ this -> validateComponent ( 'city' ) ; return ! $ this -> hasErrors ( ) ; }
Validates an array of submitted city data
54,536
protected function deleteCity ( ) { $ this -> controlAccess ( 'city_delete' ) ; if ( $ this -> city -> delete ( $ this -> data_city [ 'city_id' ] ) ) { $ url = "admin/settings/cities/{$this->data_country['code']}/{$this->data_state['state_id']}" ; $ this -> redirect ( $ url , $ this -> text ( 'City has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'City has not been deleted' ) , 'warning' ) ; }
Deletes a city
54,537
protected function addCity ( ) { $ this -> controlAccess ( 'city_add' ) ; if ( $ this -> city -> add ( $ this -> getSubmitted ( ) ) ) { $ url = "admin/settings/cities/{$this->data_country['code']}/{$this->data_state['state_id']}" ; $ this -> redirect ( $ url , $ this -> text ( 'City has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'City has not been added' ) , 'warning' ) ; }
Adds a new city
54,538
protected function setTitleEditCity ( ) { if ( isset ( $ this -> data_city [ 'city_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_city [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add city' ) ; } $ this -> setTitle ( $ title ) ; }
Sets page title on the city edit page
54,539
protected function setBreadcrumbEditCity ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/country' ) , 'text' => $ this -> text ( 'Countries' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( "admin/settings/states/{$this->data_country['code']}" ) , 'text' => $ this -> text ( 'Country states of %name' , array ( '%name' => $ this -> data_country [ 'name' ] ) ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( "admin/settings/cities/{$this->data_country['code']}/{$this->data_state['state_id']}" ) , 'text' => $ this -> text ( 'Cities of state %name' , array ( '%name' => $ this -> data_state [ 'name' ] ) ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the city edit page
54,540
public function getList ( array $ options = array ( ) ) { $ result = null ; $ this -> hook -> attach ( 'product.class.list.before' , $ options , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ sql = 'SELECT pc.*' ; if ( ! empty ( $ options [ 'count' ] ) ) { $ sql = 'SELECT COUNT(pc.product_class_id)' ; } $ sql .= ' FROM product_class pc WHERE pc.product_class_id IS NOT NULL' ; $ conditions = array ( ) ; if ( isset ( $ options [ 'title' ] ) ) { $ sql .= ' AND pc.title LIKE ?' ; $ conditions [ ] = "%{$options['title']}%" ; } if ( isset ( $ options [ 'status' ] ) ) { $ sql .= ' AND pc.status=?' ; $ conditions [ ] = ( int ) $ options [ 'status' ] ; } $ allowed_order = array ( 'asc' , 'desc' ) ; $ allowed_sort = array ( 'title' , 'status' , 'product_class_id' ) ; $ sql .= ' GROUP BY pc.product_class_id' ; if ( isset ( $ options [ 'sort' ] ) && in_array ( $ options [ 'sort' ] , $ allowed_sort ) && isset ( $ options [ 'order' ] ) && in_array ( $ options [ 'order' ] , $ allowed_order ) ) { $ sql .= " ORDER BY pc.{$options['sort']} {$options['order']}" ; } else { $ sql .= ' ORDER BY pc.title ASC' ; } if ( ! empty ( $ options [ 'limit' ] ) ) { $ sql .= ' LIMIT ' . implode ( ',' , array_map ( 'intval' , $ options [ 'limit' ] ) ) ; } if ( empty ( $ options [ 'count' ] ) ) { $ result = $ this -> db -> fetchAll ( $ sql , $ conditions , array ( 'index' => 'product_class_id' ) ) ; } else { $ result = ( int ) $ this -> db -> fetchColumn ( $ sql , $ conditions ) ; } $ this -> hook -> attach ( 'product.class.list.after' , $ options , $ result , $ this ) ; return $ result ; }
Returns an array of product classes or counts them
54,541
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'product.class.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } $ result = $ this -> db -> insert ( 'product_class' , $ data ) ; $ this -> hook -> attach ( 'product.class.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
Adds a product class
54,542
public function canDelete ( $ product_class_id ) { $ sql = 'SELECT product_id FROM product WHERE product_class_id=?' ; $ result = $ this -> db -> fetchColumn ( $ sql , array ( $ product_class_id ) ) ; return empty ( $ result ) ; }
Whether the product class can be deleted
54,543
public function getFields ( $ product_class_id ) { $ result = & gplcart_static ( "product.class.fields.$product_class_id" ) ; if ( isset ( $ result ) ) { return $ result ; } $ result = array ( ) ; $ fields = $ this -> field -> getList ( ) ; $ ops = array ( 'product_class_id' => $ product_class_id ) ; foreach ( ( array ) $ this -> product_class_field -> getList ( $ ops ) as $ product_class_field ) { if ( isset ( $ fields [ $ product_class_field [ 'field_id' ] ] ) ) { $ data = array ( 'values' => $ this -> field_value -> getList ( array ( 'field_id' => $ product_class_field [ 'field_id' ] ) ) ) ; $ data += $ fields [ $ product_class_field [ 'field_id' ] ] ; $ data += $ product_class_field ; $ result [ $ fields [ $ product_class_field [ 'field_id' ] ] [ 'type' ] ] [ $ product_class_field [ 'field_id' ] ] = $ data ; } } return $ result ; }
Returns an array of fields for a given product class
54,544
public function getList ( $ prodict_id ) { $ result = null ; $ this -> hook -> attach ( 'product.field.list.before' , $ prodict_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ sql = 'SELECT * FROM product_field WHERE product_id=?' ; $ fields = $ this -> db -> fetchAll ( $ sql , array ( $ prodict_id ) ) ; $ result = array ( ) ; foreach ( $ fields as $ field ) { $ result [ $ field [ 'type' ] ] [ $ field [ 'field_id' ] ] [ ] = $ field [ 'field_value_id' ] ; } $ this -> hook -> attach ( 'product.field.list.after' , $ prodict_id , $ result , $ this ) ; return $ result ; }
Returns an array of fields for a given product
54,545
public function getCode ( $ set = true ) { $ list = $ this -> getList ( ) ; $ code = $ this -> getFromUrl ( ) ; if ( empty ( $ code ) ) { $ code = $ this -> getFromCookie ( ) ; } if ( empty ( $ list [ $ code ] [ 'status' ] ) ) { $ code = $ this -> getDefault ( ) ; } if ( $ set ) { $ this -> setCookie ( $ code ) ; } return $ code ; }
Returns the current currency code
54,546
public function setCookie ( $ code ) { $ lifespan = $ this -> config -> get ( 'currency_cookie_lifespan' , 365 * 24 * 60 * 60 ) ; $ this -> request -> setCookie ( 'currency' , $ code , $ lifespan ) ; }
Saves a currency code in cookie
54,547
public function user ( array & $ submitted , array $ options ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateUser ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateName ( ) ; $ this -> validateEmail ( ) ; $ this -> validateEmailUniqueUser ( ) ; $ this -> validatePasswordUser ( ) ; $ this -> validatePasswordLengthUser ( ) ; $ this -> validatePasswordOldUser ( ) ; $ this -> validateStoreId ( ) ; $ this -> validateRoleUser ( ) ; $ this -> validateTimezoneUser ( ) ; $ this -> validateData ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full validation of submitted user data
54,548
public function login ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateEmail ( ) ; $ this -> validatePasswordUser ( ) ; return $ this -> getResult ( ) ; }
Performs full login data validation
54,549
public function resetPassword ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ email = $ this -> getSubmitted ( 'email' ) ; $ password = $ this -> getSubmitted ( 'password' ) ; if ( isset ( $ password ) ) { $ this -> validateStatusUser ( ) ; $ this -> validatePasswordLengthUser ( ) ; } else if ( isset ( $ email ) ) { $ this -> validateEmail ( ) ; $ this -> validateEmailExistsUser ( ) ; } return $ this -> getResult ( ) ; }
Performs password reset validation
54,550
protected function validateUser ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> user -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'User' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a user to be updated
54,551
protected function validateStatusUser ( ) { $ field = 'user' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( is_numeric ( $ value ) ) { $ value = $ this -> user -> get ( $ value ) ; } if ( empty ( $ value [ 'status' ] ) || empty ( $ value [ 'user_id' ] ) ) { $ this -> setErrorUnavailable ( $ field , $ this -> translation -> text ( 'User' ) ) ; return false ; } $ this -> setSubmitted ( $ field , $ value ) ; return true ; }
Validates user status
54,552
protected function validateEmailUniqueUser ( ) { $ field = 'email' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isError ( $ field ) || ! isset ( $ value ) ) { return null ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'email' ] ) && $ updating [ 'email' ] === $ value ) { return true ; } $ user = $ this -> user -> getByEmail ( $ value ) ; if ( empty ( $ user ) ) { return true ; } $ this -> setErrorExists ( $ field , $ this -> translation -> text ( 'E-mail' ) ) ; return false ; }
Validates uniqueness of submitted E - mail
54,553
protected function validateEmailExistsUser ( ) { $ field = 'email' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isError ( $ field ) || ! isset ( $ value ) ) { return null ; } $ user = $ this -> user -> getByEmail ( $ value ) ; if ( empty ( $ user [ 'status' ] ) ) { $ this -> setErrorUnavailable ( $ field , $ this -> translation -> text ( 'E-mail' ) ) ; return false ; } $ this -> setSubmitted ( $ field , $ user ) ; return true ; }
Validates an email and checks the responding user enabled
54,554
protected function validatePasswordOldUser ( ) { $ field = 'password_old' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } if ( ! $ this -> isUpdating ( ) || ! empty ( $ this -> options [ 'admin' ] ) ) { return null ; } $ password = $ this -> getSubmitted ( 'password' ) ; if ( ! isset ( $ password ) || $ password === '' ) { return null ; } $ old_password = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ old_password ) || $ old_password === '' ) { $ this -> setErrorRequired ( $ field , $ this -> translation -> text ( 'Old password' ) ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; $ hash = gplcart_string_hash ( $ old_password , $ updating [ 'hash' ] , 0 ) ; if ( ! gplcart_string_equals ( $ updating [ 'hash' ] , $ hash ) ) { $ error = $ this -> translation -> text ( 'Old and new password not matching' ) ; $ this -> setError ( $ field , $ error ) ; return false ; } return true ; }
Validates an old user password
54,555
protected function validateRoleUser ( ) { $ field = 'role_id' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ label = $ this -> translation -> text ( 'Role' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } $ role = $ this -> role -> get ( $ value ) ; if ( empty ( $ role ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
Validates a user role
54,556
protected function validateTimezoneUser ( ) { $ field = 'timezone' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ timezones = gplcart_timezones ( ) ; if ( empty ( $ timezones [ $ value ] ) ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Timezone' ) ) ; return false ; } return true ; }
Validates timezone field
54,557
public function get ( $ store = null ) { if ( ! $ this -> db -> isInitialized ( ) ) { return array ( ) ; } if ( ! isset ( $ store ) ) { $ url = $ this -> server -> httpHost ( ) ; $ basepath = trim ( $ this -> request -> base ( true ) , '/' ) ; $ store = trim ( "$url/$basepath" , '/' ) ; } $ result = & gplcart_static ( "store.get.$store" ) ; if ( isset ( $ result ) ) { return $ result ; } $ this -> hook -> attach ( 'store.get.before' , $ store , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ conditions = array ( ) ; if ( is_numeric ( $ store ) ) { $ conditions [ 'store_id' ] = $ store ; } else if ( strpos ( $ store , '/' ) === false ) { $ conditions [ 'domain' ] = $ store ; } else { list ( $ domain , $ basepath ) = explode ( '/' , $ store , 2 ) ; $ conditions [ 'domain' ] = $ domain ; $ conditions [ 'basepath' ] = $ basepath ; } $ conditions [ 'limit' ] = array ( 0 , 1 ) ; $ list = ( array ) $ this -> getList ( $ conditions ) ; $ result = empty ( $ list ) ? array ( ) : reset ( $ list ) ; if ( isset ( $ result [ 'data' ] ) ) { $ result [ 'data' ] += $ this -> getDefaultData ( ) ; } $ this -> hook -> attach ( 'store.get.after' , $ store , $ result , $ this ) ; return $ result ; }
Loads a store
54,558
public function getDefault ( $ load = false ) { $ store_id = $ this -> config -> get ( 'store' , 1 ) ; if ( $ load ) { return $ this -> get ( $ store_id ) ; } return ( int ) $ store_id ; }
Returns a default store
54,559
protected function deleteLinked ( $ store_id ) { $ this -> db -> delete ( 'triggers' , array ( 'store_id' => $ store_id ) ) ; $ this -> db -> delete ( 'wishlist' , array ( 'store_id' => $ store_id ) ) ; $ this -> db -> delete ( 'collection' , array ( 'store_id' => $ store_id ) ) ; $ this -> db -> delete ( 'product_sku' , array ( 'store_id' => $ store_id ) ) ; }
Delete all database rows related to the store
54,560
public function getTranslation ( $ item , $ langcode , $ store = null ) { $ config = $ this -> getConfig ( null , $ store ) ; if ( ! empty ( $ config [ 'translation' ] [ $ langcode ] [ $ item ] ) ) { return $ config [ 'translation' ] [ $ langcode ] [ $ item ] ; } if ( isset ( $ config [ $ item ] ) ) { return $ config [ $ item ] ; } return '' ; }
Returns a translatable store configuration item
54,561
public function getConfig ( $ item = null , $ store = null ) { if ( empty ( $ store ) ) { $ store = $ this -> get ( ) ; } elseif ( ! is_array ( $ store ) ) { $ store = $ this -> get ( $ store ) ; } if ( empty ( $ store [ 'data' ] ) ) { $ store [ 'data' ] = $ this -> getDefaultData ( ) ; } if ( ! isset ( $ item ) ) { return $ store [ 'data' ] ; } return gplcart_array_get ( $ store [ 'data' ] , $ item ) ; }
Returns a value from a given config item
54,562
public function delete ( $ address_id , $ check = true ) { $ result = null ; $ this -> hook -> attach ( 'address.delete.before' , $ address_id , $ check , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } if ( $ check && ! $ this -> canDelete ( $ address_id ) ) { return false ; } $ result = ( bool ) $ this -> db -> delete ( 'address' , array ( 'address_id' => $ address_id ) ) ; $ this -> hook -> attach ( 'address.delete.after' , $ address_id , $ check , $ result , $ this ) ; return ( bool ) $ result ; }
Deletes an address
54,563
public function get ( $ condition ) { if ( ! is_array ( $ condition ) ) { $ condition = array ( 'address_id' => $ condition ) ; } $ result = & gplcart_static ( gplcart_array_hash ( array ( 'address.get' => $ condition ) ) ) ; if ( isset ( $ result ) ) { return $ result ; } $ result = null ; $ this -> hook -> attach ( 'address.get.before' , $ condition , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( array ) $ result ; } $ condition [ 'prepare' ] = false ; $ condition [ 'limit' ] = array ( 0 , 1 ) ; $ list = ( array ) $ this -> getList ( $ condition ) ; $ result = empty ( $ list ) ? array ( ) : reset ( $ list ) ; if ( isset ( $ result [ 'country_format' ] ) ) { $ result [ 'country_format' ] += $ this -> country -> getDefaultFormat ( ) ; } $ this -> hook -> attach ( 'address.get.after' , $ condition , $ result , $ this ) ; return ( array ) $ result ; }
Loads an address from the database
54,564
public function getTranslatedList ( $ user_id , $ status = true ) { $ conditions = array ( 'status' => $ status , 'user_id' => $ user_id ) ; $ addresses = array ( ) ; foreach ( ( array ) $ this -> getList ( $ conditions ) as $ address_id => $ address ) { $ addresses [ $ address_id ] = $ this -> getTranslated ( $ address , true ) ; } return $ addresses ; }
Returns an array of addresses with translated address fields for the user
54,565
public function getTranslated ( array $ address , $ both = false ) { $ default = $ this -> country -> getDefaultFormat ( ) ; $ format = gplcart_array_merge ( $ default , $ address [ 'country_format' ] ) ; gplcart_array_sort ( $ format ) ; $ results = array ( ) ; foreach ( $ format as $ key => $ data ) { if ( ! array_key_exists ( $ key , $ address ) || empty ( $ data [ 'status' ] ) ) { continue ; } if ( $ key === 'country' ) { $ address [ $ key ] = $ address [ 'country_native_name' ] ; } if ( $ key === 'state_id' ) { $ address [ $ key ] = $ address [ 'state_name' ] ; } if ( $ key === 'city_id' && ! empty ( $ address [ 'city_name' ] ) ) { $ address [ $ key ] = $ address [ 'city_name' ] ; } if ( $ both ) { $ results [ $ data [ 'name' ] ] = $ address [ $ key ] ; continue ; } $ results [ $ key ] = $ address [ $ key ] ; } return array_filter ( $ results ) ; }
Returns an array of translated address fields
54,566
public function getExceeded ( $ user_id , $ existing = null ) { $ limit = $ this -> getLimit ( $ user_id ) ; if ( empty ( $ limit ) ) { return array ( ) ; } if ( ! isset ( $ existing ) ) { $ existing = $ this -> getList ( array ( 'user_id' => $ user_id ) ) ; } $ count = count ( $ existing ) ; if ( empty ( $ count ) || $ count <= $ limit ) { return array ( ) ; } return array_slice ( ( array ) $ existing , 0 , ( $ count - $ limit ) ) ; }
Returns an array of exceeded addresses for the user ID
54,567
public function getLimit ( $ user_id ) { if ( empty ( $ user_id ) || ! is_numeric ( $ user_id ) ) { return ( int ) $ this -> config -> get ( 'user_address_limit_anonymous' , 1 ) ; } return ( int ) $ this -> config -> get ( 'user_address_limit' , 4 ) ; }
Returns a number of addresses the user can have
54,568
protected function prepareList ( array $ addresses , array $ data ) { $ countries = $ this -> country -> getList ( ) ; $ list = array ( ) ; foreach ( $ addresses as $ address_id => $ address ) { $ list [ $ address_id ] = $ address ; if ( empty ( $ data [ 'status' ] ) ) { continue ; } if ( empty ( $ countries ) ) { continue ; } if ( $ address [ 'country' ] !== '' && $ address [ 'country_status' ] == 0 ) { unset ( $ list [ $ address_id ] ) ; continue ; } if ( ! empty ( $ address [ 'state_id' ] ) && $ address [ 'state_status' ] == 0 ) { unset ( $ list [ $ address_id ] ) ; continue ; } if ( is_numeric ( $ address [ 'city_id' ] ) && $ address [ 'city_status' ] == 0 ) { unset ( $ list [ $ address_id ] ) ; } } return $ list ; }
Returns an array of filtered addresses
54,569
public function matchRequest ( SymfonyRequest $ request ) { $ laravelRequest = LaravelRequest :: createFromBase ( $ request ) ; $ route = $ this -> findRoute ( $ laravelRequest ) ; $ route -> setParameter ( '_module' , $ this -> moduleName ) ; return $ route ; }
Given a request object find the matching route .
54,570
public function selectCompare ( ) { $ this -> controlProductsCompare ( ) ; $ this -> setTitleSelectCompare ( ) ; $ this -> setBreadcrumbSelectCompare ( ) ; $ this -> setData ( 'products' , $ this -> getProductsSelectCompare ( ) ) ; $ this -> outputSelectCompare ( ) ; }
Page callback Displays the select to compare page
54,571
protected function controlProductsCompare ( ) { $ options = array ( 'status' => 1 , 'store_id' => $ this -> store_id , 'product_id' => $ this -> product_compare -> getList ( ) ) ; if ( ! empty ( $ options [ 'product_id' ] ) ) { $ existing = array_keys ( $ this -> product -> getList ( $ options ) ) ; if ( array_diff ( $ options [ 'product_id' ] , $ existing ) ) { $ this -> product_compare -> set ( $ existing ) ; } } }
Make sure that products saved in cookie are all valid and available to the user If some products were removed disabled or moved to another store they will be removes from cookie
54,572
protected function getProductsSelectCompare ( ) { $ conditions = array ( 'product_id' => $ this -> getProductComparison ( ) ) ; $ options = array ( 'view' => $ this -> configTheme ( 'compare_view' , 'grid' ) , 'buttons' => array ( 'cart_add' , 'wishlist_add' , 'compare_remove' ) ) ; $ products = $ this -> getProducts ( $ conditions , $ options ) ; return $ this -> reindexProductsCompare ( $ products ) ; }
Returns an array of products re - indexed by a class ID
54,573
protected function reindexProductsCompare ( array $ products ) { $ prepared = array ( ) ; foreach ( $ products as $ product_id => $ product ) { $ prepared [ $ product [ 'product_class_id' ] ] [ $ product_id ] = $ product ; } return $ prepared ; }
Returns an array of products indexed by a class ID
54,574
public function compareCompare ( $ ids ) { $ this -> setProductCompare ( $ ids ) ; $ this -> controlAccessCompareCompare ( ) ; $ this -> setTitleCompareCompare ( ) ; $ this -> setBreadcrumbCompareCompare ( ) ; $ this -> setData ( 'products' , $ this -> data_products ) ; $ this -> setData ( 'fields' , $ this -> getFieldsCompare ( $ this -> data_products ) ) ; $ this -> outputCompareCompare ( ) ; }
Page callback Displays the product comparison page
54,575
protected function setProductCompare ( $ string ) { $ ids = array_filter ( array_map ( 'trim' , explode ( ',' , $ string ) ) , 'ctype_digit' ) ; $ this -> data_products = $ this -> getProductsCompare ( $ ids ) ; $ this -> prepareProductsCompare ( $ this -> data_products ) ; }
Set an array of product IDs to compare
54,576
protected function prepareProductsCompare ( array & $ products ) { foreach ( $ products as $ product_id => & $ product ) { $ product [ 'field' ] = $ this -> product_field -> getList ( $ product_id ) ; $ this -> setItemProductFields ( $ product , $ this -> image , $ this -> product_class ) ; } }
Prepare an array of products to be compared
54,577
protected function getFieldsCompare ( array $ products ) { $ labels = array ( ) ; foreach ( $ products as $ product ) { if ( ! empty ( $ product [ 'field_value_labels' ] ) ) { foreach ( $ product [ 'field_value_labels' ] as $ type => $ fields ) { foreach ( array_keys ( $ fields ) as $ field_id ) { $ labels [ $ type ] [ $ field_id ] = $ product [ 'fields' ] [ $ type ] [ $ field_id ] [ 'title' ] ; } } } } return $ labels ; }
Returns an array of all fields for the given products
54,578
protected function setBreadcrumbCompareCompare ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( '/' ) , 'text' => $ this -> text ( 'Home' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'compare' ) , 'text' => $ this -> text ( 'Select products' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the product comparison page
54,579
public function formatTemplate ( $ amount , array $ data ) { $ placeholders = array ( ) ; foreach ( array_keys ( $ data ) as $ key ) { $ placeholders [ "%$key" ] = $ key ; } $ formatted = gplcart_string_replace ( $ data [ 'template' ] , $ placeholders , $ data ) ; return $ amount < 0 ? "-$formatted" : $ formatted ; }
Format an amount using the currency template
54,580
public function formatNumber ( $ amount , array $ currency ) { $ rounded = $ this -> round ( abs ( $ amount ) , $ currency ) ; return number_format ( $ rounded , $ currency [ 'decimals' ] , $ currency [ 'decimal_separator' ] , $ currency [ 'thousands_separator' ] ) ; }
Format an amount with grouped thousands
54,581
public function decimal ( $ amount , $ currency_code ) { static $ divisors = array ( ) ; if ( empty ( $ divisors [ $ currency_code ] ) ) { $ currency = $ this -> currency -> get ( $ currency_code ) ; $ divisors [ $ currency_code ] = pow ( 10 , $ currency [ 'decimals' ] ) ; } return $ amount / $ divisors [ $ currency_code ] ; }
Converts an amount from minor to major units
54,582
public function round ( $ amount , array $ currency ) { if ( empty ( $ currency [ 'rounding_step' ] ) ) { return round ( $ amount , $ currency [ 'decimals' ] ) ; } $ modifier = 1 / $ currency [ 'rounding_step' ] ; return round ( $ amount * $ modifier ) / $ modifier ; }
Rounds an amount
54,583
public function amount ( $ decimal , $ currency_code = null , $ round = true ) { static $ factors = array ( ) ; if ( empty ( $ currency_code ) ) { $ currency_code = $ this -> currency -> getDefault ( ) ; } if ( empty ( $ factors [ $ currency_code ] ) ) { $ currency = $ this -> currency -> get ( $ currency_code ) ; $ factors [ $ currency_code ] = pow ( 10 , $ currency [ 'decimals' ] ) ; } if ( $ round ) { $ currency = $ this -> currency -> get ( $ currency_code ) ; $ decimal = $ this -> round ( $ decimal , $ currency ) ; return ( int ) round ( $ decimal * $ factors [ $ currency_code ] ) ; } return $ decimal * $ factors [ $ currency_code ] ; }
Converts a price from major to minor units
54,584
public function setItemTotalFormattedNumber ( array & $ item , $ price_model ) { $ item [ 'total_formatted_number' ] = $ price_model -> format ( $ item [ 'total' ] , $ item [ 'currency' ] , true , false ) ; }
Adds total_formatted_number key
54,585
public function setItemPriceFormatted ( array & $ item , $ price_model , $ currency = null ) { if ( ! isset ( $ currency ) ) { $ currency = $ item [ 'currency' ] ; } $ price = $ price_model -> convert ( $ item [ 'price' ] , $ item [ 'currency' ] , $ currency ) ; $ item [ 'price_formatted' ] = $ price_model -> format ( $ price , $ currency ) ; if ( isset ( $ item [ 'original_price' ] ) ) { $ price = $ price_model -> convert ( $ item [ 'original_price' ] , $ item [ 'currency' ] , $ currency ) ; $ item [ 'original_price_formatted' ] = $ price_model -> format ( $ price , $ currency ) ; } }
Add keys with formatted prices
54,586
public function setItemPriceCalculated ( array & $ item , $ product_model ) { $ calculated = $ product_model -> calculate ( $ item ) ; if ( $ item [ 'price' ] != $ calculated ) { $ item [ 'original_price' ] = $ item [ 'price' ] ; } $ item [ 'price' ] = $ calculated ; }
Adjust an original price according to applied price rules
54,587
public function page ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validatePage ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateBool ( 'blog_post' ) ; $ this -> validateTitle ( ) ; $ this -> validateDescriptionPage ( ) ; $ this -> validateMetaTitle ( ) ; $ this -> validateMetaDescription ( ) ; $ this -> validateTranslation ( ) ; $ this -> validateStoreId ( ) ; $ this -> validateCategoryPage ( ) ; $ this -> validateUserId ( false ) ; $ this -> validateImages ( ) ; $ this -> validateAlias ( ) ; $ this -> validateUploadImages ( 'page' ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs page data validation
54,588
protected function validatePage ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> page -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Page' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a page to be updated
54,589
protected function validateCategoryPage ( ) { $ field = 'category_id' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ label = $ this -> translation -> text ( 'Category' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } $ category = $ this -> category -> get ( $ value ) ; if ( empty ( $ category [ 'category_id' ] ) ) { $ this -> setErrorUnavailable ( $ field , $ label ) ; return false ; } return true ; }
Validates a category ID
54,590
public function setToken ( $ token = null ) { if ( isset ( $ token ) ) { return $ this -> token = $ token ; } return $ this -> token = gplcart_string_encode ( crypt ( session_id ( ) , $ this -> config -> getKey ( ) ) ) ; }
Sets a token
54,591
protected function setInstanceProperties ( ) { $ this -> hook = $ this -> getInstance ( 'gplcart\\core\\Hook' ) ; $ this -> route = $ this -> getInstance ( 'gplcart\\core\\Route' ) ; $ this -> module = $ this -> getInstance ( 'gplcart\\core\\Module' ) ; $ this -> config = $ this -> getInstance ( 'gplcart\\core\\Config' ) ; $ this -> library = $ this -> getInstance ( 'gplcart\\core\\Library' ) ; $ this -> cart = $ this -> getInstance ( 'gplcart\\core\\models\\Cart' ) ; $ this -> user = $ this -> getInstance ( 'gplcart\\core\\models\\User' ) ; $ this -> store = $ this -> getInstance ( 'gplcart\\core\\models\\Store' ) ; $ this -> image = $ this -> getInstance ( 'gplcart\\core\\models\\Image' ) ; $ this -> filter = $ this -> getInstance ( 'gplcart\\core\\models\\Filter' ) ; $ this -> language = $ this -> getInstance ( 'gplcart\\core\\models\\Language' ) ; $ this -> validator = $ this -> getInstance ( 'gplcart\\core\\models\\Validator' ) ; $ this -> translation = $ this -> getInstance ( 'gplcart\\core\\models\\Translation' ) ; $ this -> url = $ this -> getInstance ( 'gplcart\\core\\helpers\\Url' ) ; $ this -> asset = $ this -> getInstance ( 'gplcart\\core\\helpers\\Asset' ) ; $ this -> pager = $ this -> getInstance ( 'gplcart\\core\\helpers\\Pager' ) ; $ this -> server = $ this -> getInstance ( 'gplcart\\core\\helpers\\Server' ) ; $ this -> session = $ this -> getInstance ( 'gplcart\\core\\helpers\\Session' ) ; $ this -> request = $ this -> getInstance ( 'gplcart\\core\\helpers\\Request' ) ; $ this -> response = $ this -> getInstance ( 'gplcart\\core\\helpers\\Response' ) ; }
Sets instance properties
54,592
protected function setRouteProperties ( ) { $ this -> current_route = $ this -> route -> get ( ) ; $ this -> path = $ this -> url -> path ( ) ; $ this -> is_backend = $ this -> url -> isBackend ( ) ; $ this -> is_install = $ this -> url -> isInstall ( ) ; $ this -> host = $ this -> server -> httpHost ( ) ; $ this -> scheme = $ this -> server -> httpScheme ( ) ; $ this -> uri_path = $ this -> server -> requestUri ( ) ; $ this -> is_ajax = $ this -> server -> isAjaxRequest ( ) ; $ this -> uri = $ this -> scheme . $ this -> host . $ this -> uri_path ; $ this -> base = $ this -> request -> base ( ) ; $ this -> query = ( array ) $ this -> request -> get ( null , array ( ) , 'array' ) ; }
Sets the current route data
54,593
protected function setLanguageProperties ( ) { if ( ! $ this -> isInternalRoute ( ) ) { $ langcode = $ this -> route -> getLangcode ( ) ; if ( ! empty ( $ langcode ) ) { $ this -> langcode = $ langcode ; $ this -> translation -> set ( $ langcode , $ this -> current_route [ 'simple_pattern' ] ) ; $ this -> current_language = $ this -> language -> get ( $ this -> langcode ) ; } } }
Sets the current language data
54,594
protected function setStoreProperties ( ) { $ this -> current_store = $ this -> store -> get ( ) ; if ( isset ( $ this -> current_store [ 'store_id' ] ) ) { $ this -> store_id = $ this -> current_store [ 'store_id' ] ; $ this -> is_maintenance = empty ( $ this -> current_store [ 'status' ] ) && ! $ this -> access ( 'maintenance' ) ; } }
Sets the current store data
54,595
public function url ( $ path = '' , array $ query = array ( ) , $ absolute = false , $ exclude_lang = false ) { return $ this -> url -> get ( $ path , $ query , $ absolute , $ exclude_lang ) ; }
Returns a formatted URL
54,596
public function lurl ( $ langcode , $ path = '' , array $ query = array ( ) ) { if ( $ langcode === $ this -> language -> getDefault ( ) ) { $ langcode = '' ; } return $ this -> url -> language ( $ langcode , $ path , $ query ) ; }
Returns a formatted URL with a language code
54,597
public function image ( $ path , $ imagestyle_id = null , $ absolute = false ) { return $ this -> image -> getUrl ( $ path , $ imagestyle_id , $ absolute ) ; }
Returns an image URL
54,598
public function error ( $ key = null , $ return_error = null , $ return_no_error = '' ) { if ( isset ( $ key ) ) { $ result = gplcart_array_get ( $ this -> errors , $ key ) ; } else { $ result = empty ( $ this -> errors ) ? null : $ this -> errors ; } if ( isset ( $ result ) ) { return isset ( $ return_error ) ? $ return_error : $ result ; } return $ return_no_error ; }
Returns a value if an error occurred
54,599
public function getStore ( $ item = null ) { if ( isset ( $ item ) ) { return gplcart_array_get ( $ this -> current_store , $ item ) ; } return $ this -> current_store ; }
Returns a data of the current store