idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
55,000
|
public function base ( $ exclude_langcode = false ) { $ base = GC_BASE ; if ( $ base !== '/' ) { $ base .= '/' ; } if ( ! empty ( $ this -> langcode ) ) { $ suffix = "{$this->langcode}/" ; $ base .= $ suffix ; } if ( $ exclude_langcode && ! empty ( $ suffix ) ) { $ base = substr ( $ base , 0 , - strlen ( $ suffix ) ) ; } return $ base ; }
|
Returns the current base path
|
55,001
|
public function post ( $ name = null , $ default = null , $ filter = true , $ type = null ) { $ post = $ this -> request [ 'post' ] ; if ( $ filter !== 'raw' ) { gplcart_array_trim ( $ post , ( bool ) $ filter ) ; } if ( isset ( $ name ) ) { $ result = gplcart_array_get ( $ post , $ name ) ; $ return = isset ( $ result ) ? $ result : $ default ; } else { $ return = $ post ; } gplcart_settype ( $ return , $ type , $ default ) ; return $ return ; }
|
Returns a data from POST request
|
55,002
|
public function get ( $ name = null , $ default = null , $ type = null ) { $ get = $ this -> request [ 'get' ] ; gplcart_array_trim ( $ get , true ) ; if ( isset ( $ name ) ) { $ result = gplcart_array_get ( $ get , $ name ) ; $ return = isset ( $ result ) ? $ result : $ default ; } else { $ return = $ get ; } gplcart_settype ( $ return , $ type , $ default ) ; return $ return ; }
|
Returns a data from GET request
|
55,003
|
public function file ( $ name = null , $ default = null ) { $ files = $ this -> request [ 'files' ] ; if ( isset ( $ name ) ) { return ! empty ( $ files [ $ name ] [ 'name' ] ) ? $ files [ $ name ] : $ default ; } return $ files ; }
|
Returns a data from FILES request
|
55,004
|
public function cookie ( $ name = null , $ default = null , $ type = null ) { $ cookie = $ this -> request [ 'cookie' ] ; gplcart_array_trim ( $ cookie , true ) ; if ( isset ( $ name ) ) { $ return = isset ( $ cookie [ $ name ] ) ? $ cookie [ $ name ] : $ default ; } else { $ return = $ cookie ; } gplcart_settype ( $ return , $ type , $ default ) ; return $ return ; }
|
Returns a data from COOKIE
|
55,005
|
public function getWidgetTypes ( ) { $ types = & gplcart_static ( 'field.widget.types' ) ; if ( isset ( $ types ) ) { return $ types ; } $ types = array ( 'button' => $ this -> translation -> text ( 'Button' ) , 'radio' => $ this -> translation -> text ( 'Radio buttons' ) , 'select' => $ this -> translation -> text ( 'Dropdown list' ) ) ; $ this -> hook -> attach ( 'field.widget.types' , $ types , $ this ) ; return $ types ; }
|
Returns an array of widget types
|
55,006
|
protected function deleteLinkedFieldValues ( $ field_id ) { $ sql = 'DELETE fvt FROM field_value_translation AS fvt WHERE fvt.field_value_id IN (SELECT DISTINCT(fv.field_value_id) FROM field_value AS fv INNER JOIN field_value AS fv2 ON (fv.field_value_id = fv2.field_value_id) WHERE fv.field_id = ?)' ; return ( bool ) $ this -> db -> run ( $ sql , array ( $ field_id ) ) -> rowCount ( ) ; }
|
Delete all field values and their translations related to the field
|
55,007
|
protected function deleteLinked ( $ field_id ) { $ this -> db -> delete ( 'field_value' , array ( 'field_id' => $ field_id ) ) ; $ this -> db -> delete ( 'field_translation' , array ( 'field_id' => $ field_id ) ) ; $ this -> db -> delete ( 'product_class_field' , array ( 'field_id' => $ field_id ) ) ; }
|
Delete all database tables related to the field
|
55,008
|
public function update ( $ module_id , array $ data ) { $ data [ 'modified' ] = GC_TIME ; $ this -> db -> update ( 'module' , $ data , array ( 'module_id' => $ module_id ) ) ; }
|
Updates a module
|
55,009
|
public function getActiveThemes ( ) { $ themes = & gplcart_static ( 'module.active.themes' ) ; if ( isset ( $ themes ) ) { return $ themes ; } $ themes = array ( $ this -> config -> get ( 'theme_backend' , 'backend' ) ) ; if ( ! $ this -> db -> isInitialized ( ) ) { return $ themes ; } $ stores = $ this -> db -> fetchAll ( 'SELECT * FROM store' , array ( ) ) ; foreach ( $ stores as $ store ) { $ data = unserialize ( $ store [ 'data' ] ) ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , 'theme' ) === 0 ) { $ themes [ ] = $ value ; } } } return $ themes ; }
|
Returns an array of active theme modules
|
55,010
|
public function getList ( ) { $ modules = & gplcart_static ( 'module.list' ) ; if ( isset ( $ modules ) ) { return $ modules ; } $ installed = $ this -> getInstalled ( ) ; $ modules = array ( ) ; foreach ( $ this -> scan ( ) as $ module_id => $ info ) { $ modules [ $ module_id ] = $ this -> prepareInfo ( $ module_id , $ info , $ installed ) ; } gplcart_array_sort ( $ modules ) ; return $ modules ; }
|
Returns an array of all available modules
|
55,011
|
public function scan ( $ directory = GC_DIR_MODULE ) { $ modules = array ( ) ; foreach ( scandir ( $ directory ) as $ module_id ) { if ( ! $ this -> isValidId ( $ module_id ) ) { continue ; } $ info = $ this -> getInfo ( $ module_id ) ; if ( ! isset ( $ info [ 'core' ] ) ) { continue ; } $ modules [ $ module_id ] = $ info ; } return $ modules ; }
|
Returns an array of scanned module IDs
|
55,012
|
protected function prepareInfo ( $ module_id , array $ info , array $ installed ) { $ info [ 'directory' ] = $ this -> getDirectory ( $ module_id ) ; $ info += array ( 'type' => 'module' , 'name' => $ module_id , 'version' => null ) ; if ( isset ( $ info [ 'status' ] ) && ! empty ( $ info [ 'lock' ] ) ) { unset ( $ installed [ $ module_id ] [ 'status' ] ) ; } if ( $ info [ 'version' ] === 'core' ) { $ info [ 'version' ] = GC_VERSION ; } if ( ! empty ( $ info [ 'dependencies' ] ) ) { foreach ( ( array ) $ info [ 'dependencies' ] as $ dependency_module_id => $ dependency_version ) { if ( $ dependency_version === 'core' ) { $ info [ 'dependencies' ] [ $ dependency_module_id ] = GC_VERSION ; } } } if ( isset ( $ info [ 'weight' ] ) && ! empty ( $ info [ 'lock' ] ) ) { unset ( $ installed [ $ module_id ] [ 'weight' ] ) ; } if ( isset ( $ installed [ $ module_id ] ) ) { $ info [ 'installed' ] = true ; if ( empty ( $ installed [ $ module_id ] [ 'settings' ] ) ) { unset ( $ installed [ $ module_id ] [ 'settings' ] ) ; } $ info = array_replace ( $ info , $ installed [ $ module_id ] ) ; } if ( ! empty ( $ info [ 'status' ] ) ) { try { $ instance = $ this -> getInstance ( $ module_id ) ; $ info [ 'hooks' ] = $ this -> getHooks ( $ instance ) ; $ info [ 'class' ] = get_class ( $ instance ) ; } catch ( Exception $ exc ) { return $ info ; } } return $ info ; }
|
Prepare module info
|
55,013
|
public function getInfo ( $ module_id ) { static $ information = array ( ) ; if ( isset ( $ information [ $ module_id ] ) ) { return $ information [ $ module_id ] ; } $ file = $ this -> getModuleInfoFile ( $ module_id ) ; $ decoded = null ; if ( is_file ( $ file ) ) { $ decoded = json_decode ( file_get_contents ( $ file ) , true ) ; } if ( is_array ( $ decoded ) ) { $ decoded [ 'id' ] = $ decoded [ 'module_id' ] = $ module_id ; $ information [ $ module_id ] = $ decoded ; } else { $ information [ $ module_id ] = array ( ) ; } return $ information [ $ module_id ] ; }
|
Returns an array of module data from module . json file
|
55,014
|
public function getInstalled ( ) { if ( ! $ this -> db -> isInitialized ( ) ) { return array ( ) ; } $ modules = & gplcart_static ( 'module.installed.list' ) ; if ( isset ( $ modules ) ) { return $ modules ; } $ options = array ( 'index' => 'module_id' , 'unserialize' => 'settings' ) ; return $ modules = $ this -> db -> fetchAll ( 'SELECT * FROM module' , array ( ) , $ options ) ; }
|
Returns an array of all installed modules
|
55,015
|
public function getHooks ( $ class ) { $ hooks = array ( ) ; foreach ( get_class_methods ( $ class ) as $ method ) { if ( strpos ( $ method , 'hook' ) === 0 ) { $ hooks [ ] = $ method ; } } return $ hooks ; }
|
Returns an array of class methods which are hooks
|
55,016
|
public function getByType ( $ type , $ enabled = false ) { $ modules = $ enabled ? $ this -> getEnabled ( ) : $ this -> getList ( ) ; foreach ( $ modules as $ id => $ info ) { if ( $ type !== $ info [ 'type' ] ) { unset ( $ modules [ $ id ] ) ; } } return $ modules ; }
|
Returns an array of modules by the type
|
55,017
|
public function get ( $ product_class_field_id ) { $ result = null ; $ this -> hook -> attach ( 'product.class.field.get.before' , $ product_class_field_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ sql = 'SELECT * FROM product_class_field WHERE product_class_field_id=?' ; $ result = $ this -> db -> fetch ( $ sql , array ( $ product_class_field_id ) ) ; $ this -> hook -> attach ( 'product.class.field.get.after' , $ result , $ this ) ; return $ result ; }
|
Loads a product class field from the database
|
55,018
|
public function delete ( $ condition ) { $ result = null ; $ this -> hook -> attach ( 'product.class.field.delete.before' , $ condition , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( bool ) $ result ; } if ( ! is_array ( $ condition ) ) { $ condition = array ( 'product_class_field_id' => $ condition ) ; } $ result = ( bool ) $ this -> db -> delete ( 'product_class_field' , $ condition ) ; $ this -> hook -> attach ( 'product.class.field.delete.after' , $ condition , $ result , $ this ) ; return ( bool ) $ result ; }
|
Deletes a product class field
|
55,019
|
public static function inferDescriptor ( $ descriptor ) { if ( isset ( $ descriptor -> type ) && $ descriptor -> type == static :: type ( ) ) { return new static ( $ descriptor ) ; } else { return false ; } }
|
try to create a field object based on the descriptor by default uses the type attribute return the created field object or false if the descriptor does not match this field .
|
55,020
|
public static function infer ( $ val , $ descriptor = null , $ lenient = false ) { $ field = new static ( $ descriptor ) ; try { $ field -> castValue ( $ val ) ; } catch ( FieldValidationException $ e ) { return false ; } $ field -> inferProperties ( $ val , $ lenient ) ; return $ field ; }
|
try to create a new field object based on the given value .
|
55,021
|
public function listSearch ( ) { $ this -> setTermSearch ( ) ; $ this -> setTitleListSearch ( ) ; $ this -> setBreadcrumbListSearch ( ) ; $ this -> setFilterQueryListSearch ( ) ; $ this -> setPagerListSearch ( ) ; $ this -> setResultsSearch ( ) ; $ this -> setDataNavbarListSearch ( ) ; $ this -> setDataProductsListSearch ( ) ; $ this -> outputListSearch ( ) ; }
|
Displays the search page
|
55,022
|
protected function setDataNavbarListSearch ( ) { $ options = array ( 'total' => $ this -> data_limit , 'view' => $ this -> query_filter [ 'view' ] , 'quantity' => count ( $ this -> data_results ) , 'sort' => "{$this->query_filter['sort']}-{$this->query_filter['order']}" ) ; $ this -> setData ( 'navbar' , $ this -> render ( 'category/navbar' , $ options ) ) ; }
|
Sets the navbar on the search page
|
55,023
|
protected function setFilterQueryListSearch ( ) { $ default = array ( 'view' => $ this -> configTheme ( 'catalog_view' , 'grid' ) , 'sort' => $ this -> configTheme ( 'catalog_sort' , 'price' ) , 'order' => $ this -> configTheme ( 'catalog_order' , 'asc' ) ) ; $ this -> setFilter ( array ( ) , $ this -> getFilterQuery ( $ default ) ) ; }
|
Sets filter on the search page
|
55,024
|
protected function setResultsSearch ( ) { $ options = array ( 'status' => 1 , 'entity' => 'product' , 'limit' => $ this -> data_limit , 'language' => $ this -> langcode , 'store_id' => $ this -> store_id ) ; $ options += $ this -> query_filter ; $ this -> data_results = $ this -> search -> search ( 'product' , $ this -> data_term , $ options ) ; if ( ! empty ( $ this -> data_results ) ) { settype ( $ this -> data_results , 'array' ) ; $ options [ 'placeholder' ] = true ; $ this -> prepareEntityItems ( $ this -> data_results , $ options ) ; } }
|
Sets an array of search results
|
55,025
|
public function editLanguage ( $ code = null ) { $ this -> setLanguage ( $ code ) ; $ this -> setTitleEditLanguage ( ) ; $ this -> setBreadcrumbEditLanguage ( ) ; $ this -> setData ( 'edit' , isset ( $ code ) ) ; $ this -> setData ( 'language' , $ this -> data_language ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteLanguage ( ) ) ; $ this -> setData ( 'default_language' , $ this -> language -> getDefault ( ) ) ; $ this -> submitEditLanguage ( ) ; $ this -> outputEditLanguage ( ) ; }
|
Displays the language edit form
|
55,026
|
protected function canDeleteLanguage ( ) { return isset ( $ this -> data_language [ 'code' ] ) && $ this -> access ( 'language_delete' ) && $ this -> language -> canDelete ( $ this -> data_language [ 'code' ] ) ; }
|
Whether the language can be deleted
|
55,027
|
protected function setLanguage ( $ code ) { $ this -> data_language = array ( ) ; if ( ! empty ( $ code ) ) { $ this -> data_language = $ this -> language -> get ( $ code ) ; if ( empty ( $ this -> data_language ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
|
Set a language data
|
55,028
|
protected function submitEditLanguage ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteLanguage ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateLanguage ( ) ) { if ( isset ( $ this -> data_language [ 'code' ] ) ) { $ this -> updateLanguage ( ) ; } else { $ this -> addLanguage ( ) ; } } }
|
Handles a submitted language data
|
55,029
|
protected function deleteLanguage ( ) { $ this -> controlAccess ( 'language_delete' ) ; if ( $ this -> language -> delete ( $ this -> data_language [ 'code' ] ) ) { $ this -> redirect ( 'admin/settings/language' , $ this -> text ( 'Language has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Language has not been deleted' ) , 'warning' ) ; }
|
Deletes a language
|
55,030
|
protected function validateLanguage ( ) { $ this -> setSubmitted ( 'language' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmittedBool ( 'default' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_language ) ; $ this -> validateComponent ( 'language' ) ; return ! $ this -> hasErrors ( ) ; }
|
Validates a language
|
55,031
|
protected function setTitleEditLanguage ( ) { if ( isset ( $ this -> data_language [ 'code' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_language [ 'native_name' ] ) ) ; } else { $ title = $ this -> text ( 'Add language' ) ; } $ this -> setTitle ( $ title ) ; }
|
Sets titles on the edit language page
|
55,032
|
protected function setBreadcrumbEditLanguage ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/language' ) , 'text' => $ this -> text ( 'Languages' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the edit language page
|
55,033
|
public function listLanguage ( ) { $ this -> refreshLanguage ( ) ; $ this -> setTitleListLanguage ( ) ; $ this -> setBreadcrumbListLanguage ( ) ; $ this -> setFilterListLanguage ( ) ; $ this -> setPagerListLanguage ( ) ; $ this -> setData ( 'languages' , ( array ) $ this -> getListLanguage ( ) ) ; $ this -> outputListLanguage ( ) ; }
|
Displays the language overview page
|
55,034
|
protected function getListLanguage ( $ count = false ) { $ list = $ this -> language -> getList ( ) ; $ allowed = $ this -> getAllowedFiltersLanguage ( ) ; $ this -> filterList ( $ list , $ allowed , $ this -> query_filter ) ; $ this -> sortList ( $ list , $ allowed , $ this -> query_filter , array ( 'code' => 'asc' ) ) ; if ( $ count ) { return count ( $ list ) ; } $ this -> limitList ( $ list , $ this -> data_limit ) ; $ this -> prepareListLanguage ( $ list ) ; return $ list ; }
|
Returns an array of prepared languages
|
55,035
|
protected function prepareListLanguage ( array & $ list ) { foreach ( $ list as $ id => & $ item ) { $ item [ 'file_exists' ] = is_file ( $ this -> translation -> getFile ( $ id ) ) ; } }
|
Prepare an array of languages
|
55,036
|
protected function refreshLanguage ( ) { $ this -> controlToken ( 'refresh' ) ; $ code = $ this -> getQuery ( 'refresh' ) ; if ( ! empty ( $ code ) && $ this -> access ( 'language_edit' ) && $ this -> translation -> refresh ( $ code ) ) { $ this -> redirect ( '' , $ this -> text ( 'Language has been refreshed' ) , 'success' ) ; } }
|
Removes a cached translation
|
55,037
|
protected function addOptionalHeaders ( $ options ) { if ( ! empty ( $ options [ 'headers' ] ) ) { foreach ( ( array ) $ options [ 'headers' ] as $ header ) { list ( $ name , $ value ) = array_pad ( ( array ) $ header , 2 , null ) ; $ this -> addHeader ( $ name , $ value ) ; } } return $ this ; }
|
Adds headers from options
|
55,038
|
public function getStatus ( $ status = null ) { $ statuses = array ( 100 => 'Continue' , 101 => 'Switching Protocols' , 200 => 'OK' , 201 => 'Created' , 202 => 'Accepted' , 203 => 'Non-Authoritative Information' , 204 => 'No Content' , 205 => 'Reset Content' , 206 => 'Partial Content' , 300 => 'Multiple Choices' , 301 => 'Moved Permanently' , 302 => 'Found' , 303 => 'See Other' , 304 => 'Not Modified' , 305 => 'Use Proxy' , 307 => 'Temporary Redirect' , 400 => 'Bad Request' , 401 => 'Unauthorized' , 402 => 'Payment Required' , 403 => 'Forbidden' , 404 => 'Not Found' , 405 => 'Method Not Allowed' , 406 => 'Not Acceptable' , 407 => 'Proxy Authentication Required' , 408 => 'Request Time-out' , 409 => 'Conflict' , 410 => 'Gone' , 411 => 'Length Required' , 412 => 'Precondition Failed' , 413 => 'Request Entity Too Large' , 414 => 'Request-URI Too Large' , 415 => 'Unsupported Media Type' , 416 => 'Requested range not satisfiable' , 417 => 'Expectation Failed' , 500 => 'Internal Server Error' , 501 => 'Not Implemented' , 502 => 'Bad Gateway' , 503 => 'Service Unavailable' , 504 => 'Gateway Time-out' , 505 => 'HTTP Version not supported' ) ; if ( ! isset ( $ status ) ) { return $ statuses ; } return isset ( $ statuses [ $ status ] ) ? $ statuses [ $ status ] : '' ; }
|
Returns a single status message or an array of HTTP statuses keyed by code
|
55,039
|
public function outputHtml ( $ html , $ options = array ( ) ) { $ this -> addHeader ( 'Content-Type' , 'text/html; charset=utf-8' ) -> addOptionalHeaders ( $ options ) -> sendHeaders ( ) ; echo $ html ; exit ; }
|
Output HTML page
|
55,040
|
public function outputJson ( $ data , $ options = array ( ) ) { $ this -> addHeader ( 'Content-Type' , 'application/json' ) -> addOptionalHeaders ( $ options ) -> sendHeaders ( ) ; echo gplcart_json_encode ( $ data ) ; exit ; }
|
Output JSON string
|
55,041
|
public function outputStatus ( $ code , $ message = null ) { $ this -> addHeader ( $ code ) -> sendHeaders ( ) ; if ( isset ( $ message ) ) { echo $ message ; } exit ; }
|
Output an HTTP status and abort script execution
|
55,042
|
public function outputError403 ( $ show_message = true ) { $ message = $ show_message ? $ this -> getError403 ( ) : null ; $ this -> outputStatus ( 403 , $ message ) ; }
|
Output 403 error page
|
55,043
|
public function outputError404 ( $ show_message = true ) { $ message = $ show_message ? $ this -> getError404 ( ) : null ; $ this -> outputStatus ( 404 , $ message ) ; }
|
Output 404 error page
|
55,044
|
public function outputError500 ( $ show_message = true , $ error = '' ) { $ message = $ show_message ? $ this -> getError500 ( $ error ) : null ; $ this -> outputStatus ( 500 , $ message ) ; }
|
Output 500 error page
|
55,045
|
public function listImageStyle ( ) { $ this -> clearCacheImageStyle ( ) ; $ this -> setTitleListImageStyle ( ) ; $ this -> setBreadcrumbListImageStyle ( ) ; $ this -> setFilterListImageStyle ( ) ; $ this -> setPagerListImageStyle ( ) ; $ this -> setData ( 'image_styles' , ( array ) $ this -> getListImageStyle ( ) ) ; $ this -> outputListImageStyle ( ) ; }
|
Displays the image style overview page
|
55,046
|
protected function prepareListImageStyle ( array & $ list ) { foreach ( $ list as $ id => & $ item ) { $ item [ 'directory_exists' ] = is_dir ( $ this -> image_style -> getDirectory ( $ id ) ) ; } }
|
Prepare an array of image styles
|
55,047
|
protected function clearCacheImageStyle ( ) { $ this -> controlToken ( 'clear' ) ; $ style_id = $ this -> getQuery ( 'clear' ) ; if ( ! empty ( $ style_id ) ) { if ( $ this -> image_style -> clearCache ( $ style_id ) ) { $ this -> redirect ( '' , $ this -> text ( 'Cache has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Cache has not been deleted' ) , 'warning' ) ; } }
|
Clear cached images
|
55,048
|
public function editImageStyle ( $ style_id = null ) { $ this -> setImageStyle ( $ style_id ) ; $ this -> setTitleEditImageStyle ( ) ; $ this -> setBreadcrumbEditImageStyle ( ) ; $ this -> setData ( 'imagestyle' , $ this -> data_imagestyle ) ; $ this -> setData ( 'actions' , $ this -> getActionsImageStyle ( ) ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteImageStyle ( ) ) ; $ this -> submitEditImageStyle ( ) ; $ this -> setDataEditImageStyle ( ) ; $ this -> outputEditImageStyle ( ) ; }
|
Displays the imagestyle edit form
|
55,049
|
public function canDeleteImageStyle ( ) { return isset ( $ this -> data_imagestyle [ 'imagestyle_id' ] ) && $ this -> access ( 'image_style_delete' ) && $ this -> image_style -> canDelete ( $ this -> data_imagestyle [ 'imagestyle_id' ] ) ; }
|
Whether an image style can be deleted
|
55,050
|
protected function setImageStyle ( $ style_id ) { $ this -> data_imagestyle = array ( ) ; if ( is_numeric ( $ style_id ) ) { $ this -> data_imagestyle = $ this -> image_style -> get ( $ style_id ) ; if ( empty ( $ this -> data_imagestyle ) ) { $ this -> outputHttpStatus ( 404 ) ; } } $ this -> prepareImageStyle ( $ this -> data_imagestyle ) ; }
|
Sets an image style data
|
55,051
|
protected function validateEditImageStyle ( ) { $ this -> setSubmitted ( 'imagestyle' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmittedArray ( 'actions' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_imagestyle ) ; $ this -> validateComponent ( 'image_style' ) ; return ! $ this -> hasErrors ( ) ; }
|
Validates a submitted image style
|
55,052
|
protected function addImageStyle ( ) { $ this -> controlAccess ( 'image_style_add' ) ; if ( $ this -> image_style -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/settings/imagestyle' , $ this -> text ( 'Image style has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Image style has not been added' ) , 'warning' ) ; }
|
Adds a new image style
|
55,053
|
protected function setDataEditImageStyle ( ) { $ actions = $ this -> getData ( 'imagestyle.actions' ) ; if ( ! $ this -> isError ( ) ) { gplcart_array_sort ( $ actions ) ; } $ modified = array ( ) ; foreach ( $ actions as $ action_id => $ info ) { if ( is_string ( $ info ) ) { $ modified [ ] = $ info ; continue ; } $ action = $ action_id ; if ( ! empty ( $ info [ 'value' ] ) ) { $ action .= ' ' . implode ( ',' , $ info [ 'value' ] ) ; } $ modified [ ] = $ action ; } $ this -> setData ( 'imagestyle.actions' , implode ( PHP_EOL , $ modified ) ) ; }
|
Sets template data on the edit image style page
|
55,054
|
protected function setTitleEditImageStyle ( ) { if ( isset ( $ this -> data_imagestyle [ 'imagestyle_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_imagestyle [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add image style' ) ; } $ this -> setTitle ( $ title ) ; }
|
Sets title on the edit image style page
|
55,055
|
protected function setBreadcrumbEditImageStyle ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/imagestyle' ) , 'text' => $ this -> text ( 'Image styles' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the edit image style page
|
55,056
|
protected function loginUser ( ) { $ user = $ this -> getSubmitted ( ) ; $ result = $ this -> user_action -> login ( $ user ) ; if ( empty ( $ result [ 'user' ] ) ) { $ this -> setData ( 'user' , $ user ) ; $ this -> setMessage ( $ result [ 'message' ] , $ result [ 'severity' ] ) ; } else { $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; } }
|
Log in a user
|
55,057
|
protected function validateUserLogin ( ) { $ this -> setSubmitted ( 'user' , null , false ) ; $ this -> filterSubmitted ( array ( 'email' , 'password' ) ) ; $ this -> validateComponent ( 'user_login' ) ; return ! $ this -> hasErrors ( ) ; }
|
Validates submitted login credentials
|
55,058
|
public function indexOrder ( $ order_id ) { $ this -> setOrder ( $ order_id ) ; $ this -> submitIndexOrder ( ) ; $ this -> setTitleIndexOrder ( ) ; $ this -> setBreadcrumbIndexOrder ( ) ; $ this -> setData ( 'order' , $ this -> data_order ) ; $ this -> setDataPanelLogsIndexOrder ( ) ; $ this -> setDataPanelSummaryIndexOrder ( ) ; $ this -> setDataPanelCommentIndexOrder ( ) ; $ this -> setDataPanelCustomerIndexOrder ( ) ; $ this -> setDataPanelComponentsIndexOrder ( ) ; $ this -> setDataPanelPaymentAddressIndexOrder ( ) ; $ this -> setDataPanelShippingAddressIndexOrder ( ) ; $ this -> outputIndexOrder ( ) ; }
|
Displays the order overview page
|
55,059
|
protected function submitIndexOrder ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteOrder ( ) ; } else if ( $ this -> isPosted ( 'status' ) && $ this -> validateIndexOrder ( ) ) { $ this -> updateStatusOrder ( ) ; } else if ( $ this -> isPosted ( 'clone' ) && $ this -> validateIndexOrder ( ) ) { $ this -> cloneOrder ( ) ; } }
|
Handles a submitted order
|
55,060
|
protected function updateStatusOrder ( ) { $ this -> controlAccess ( 'order_edit' ) ; $ submitted = array ( 'status' => $ this -> getSubmitted ( 'status' ) ) ; if ( $ this -> order -> update ( $ this -> data_order [ 'order_id' ] , $ submitted ) ) { $ submitted [ 'notify' ] = $ this -> setNotificationUpdateOrder ( $ this -> data_order [ 'order_id' ] ) ; $ this -> logUpdateStatusOrder ( $ submitted ) ; $ messages = $ this -> getMassagesUpdateOrder ( ) ; list ( $ severity , $ text ) = $ messages [ $ submitted [ 'notify' ] ] ; $ this -> redirect ( '' , $ this -> text ( $ text ) , $ severity ) ; } $ this -> redirect ( '' , $ this -> text ( 'Order has not been updated' ) , 'warning' ) ; }
|
Update an order status
|
55,061
|
protected function logUpdateStatusOrder ( array $ submitted ) { if ( $ this -> data_order [ 'status' ] != $ submitted [ 'status' ] ) { $ log = array ( 'user_id' => $ this -> uid , 'order_id' => $ this -> data_order [ 'order_id' ] , 'text' => $ this -> text ( 'Update order status to @status' , array ( '@status' => $ submitted [ 'status' ] ) ) ) ; $ this -> order_history -> add ( $ log ) ; } }
|
Log the status updated event
|
55,062
|
protected function setNotificationUpdateOrder ( $ order_id ) { if ( ! $ this -> config ( 'order_update_notify_customer' , 1 ) ) { return static :: NOTIFICATION_DISABLED ; } $ order = $ this -> order -> get ( $ order_id ) ; if ( $ this -> order_action -> notifyUpdated ( $ order ) === true ) { return static :: NOTIFICATION_SENT ; } return static :: NOTIFICATION_ERROR ; }
|
Notify a customer when an order has been updated
|
55,063
|
protected function cloneOrder ( ) { $ this -> controlAccess ( 'order_edit' ) ; $ this -> controlAccess ( 'order_add' ) ; $ update = array ( 'status' => $ this -> order -> getStatusCanceled ( ) ) ; if ( $ this -> createTempCartOrder ( ) && $ this -> order -> update ( $ this -> data_order [ 'order_id' ] , $ update ) ) { $ this -> logUpdateStatusOrder ( $ update ) ; $ this -> redirect ( "checkout/clone/{$this->data_order['order_id']}" ) ; } $ this -> redirect ( '' , $ this -> text ( 'Order has not been cloned' ) , 'warning' ) ; }
|
Copy an order
|
55,064
|
protected function createTempCartOrder ( ) { $ this -> cart -> delete ( array ( 'user_id' => $ this -> uid ) ) ; $ added = $ count = 0 ; foreach ( $ this -> data_order [ 'cart' ] as $ item ) { $ count ++ ; unset ( $ item [ 'cart_id' ] ) ; $ item [ 'user_id' ] = $ this -> uid ; $ item [ 'order_id' ] = 0 ; if ( $ this -> cart -> add ( $ item ) ) { $ added ++ ; } } return $ count && $ count == $ added ; }
|
Creates temporary cart for the current admin
|
55,065
|
protected function getTotalLogOrder ( ) { $ conditions = array ( 'count' => true , 'order_id' => $ this -> data_order [ 'order_id' ] ) ; return ( int ) $ this -> order_history -> getList ( $ conditions ) ; }
|
Returns a total log records found for the order Used for pager
|
55,066
|
protected function getListLogOrder ( array $ limit ) { $ conditions = array ( 'limit' => $ limit , 'order_id' => $ this -> data_order [ 'order_id' ] ) ; return ( array ) $ this -> order_history -> getList ( $ conditions ) ; }
|
Returns an array of log records for the order
|
55,067
|
protected function setBreadcrumbIndexOrder ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Orders' ) , 'url' => $ this -> url ( 'admin/sale/order' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets bread crumbs on the order overview page
|
55,068
|
protected function setOrder ( $ order_id ) { $ this -> data_order = array ( ) ; if ( is_numeric ( $ order_id ) ) { $ this -> data_order = $ this -> order -> get ( $ order_id ) ; if ( empty ( $ this -> data_order ) ) { $ this -> outputHttpStatus ( 404 ) ; } $ this -> order_history -> setViewed ( $ this -> data_order ) ; $ this -> prepareOrder ( $ this -> data_order ) ; } }
|
Returns an order
|
55,069
|
protected function setDataPanelLogsIndexOrder ( ) { $ pager_options = array ( 'total' => $ this -> getTotalLogOrder ( ) , 'limit' => $ this -> config ( 'order_log_limit' , 5 ) ) ; $ pager = $ this -> getPager ( $ pager_options ) ; $ data = array ( 'order' => $ this -> data_order , 'pager' => $ pager [ 'rendered' ] , 'items' => $ this -> getListLogOrder ( $ pager [ 'limit' ] ) ) ; $ this -> setData ( 'pane_log' , $ this -> render ( 'sale/order/panes/log' , $ data ) ) ; }
|
Adds the order logs panel on the order overview page
|
55,070
|
protected function setDataPanelSummaryIndexOrder ( ) { $ data = array ( 'order' => $ this -> data_order , 'statuses' => $ this -> order -> getStatuses ( ) ) ; $ this -> setData ( 'pane_summary' , $ this -> render ( 'sale/order/panes/summary' , $ data ) ) ; }
|
Adds the summary panel on the order overview page
|
55,071
|
protected function setDataPanelComponentsIndexOrder ( ) { if ( ! empty ( $ this -> data_order [ 'data' ] [ 'components' ] ) ) { $ this -> setItemOrderCartComponent ( $ this -> data_order , $ this -> price ) ; $ this -> setItemOrderPriceRuleComponent ( $ this -> data_order , $ this -> price , $ this -> pricerule ) ; $ this -> setItemOrderPaymentComponent ( $ this -> data_order , $ this -> price , $ this -> payment , $ this -> order ) ; $ this -> setItemOrderShippingComponent ( $ this -> data_order , $ this -> price , $ this -> shipping , $ this -> order ) ; ksort ( $ this -> data_order [ 'data' ] [ 'components' ] ) ; } $ this -> setData ( 'pane_components' , $ this -> render ( 'sale/order/panes/components' , array ( 'order' => $ this -> data_order ) ) ) ; }
|
Adds the order components panel on the order overview page
|
55,072
|
public function listOrder ( ) { $ this -> actionListOrder ( ) ; $ this -> setTitleListOrder ( ) ; $ this -> setBreadcrumbListOrder ( ) ; $ this -> setData ( 'statuses' , $ this -> order -> getStatuses ( ) ) ; $ this -> setFilterListOrder ( ) ; $ this -> setPagerListOrder ( ) ; $ this -> setData ( 'orders' , $ this -> getListOrder ( ) ) ; $ this -> outputListOrder ( ) ; }
|
Displays the order list page
|
55,073
|
protected function actionListOrder ( ) { list ( $ selected , $ action , $ value ) = $ this -> getPostedAction ( ) ; $ deleted = $ updated = 0 ; $ failed_notifications = array ( ) ; foreach ( $ selected as $ id ) { if ( $ action === 'status' && $ this -> access ( 'order_edit' ) ) { $ updated = ( bool ) $ this -> order -> update ( $ id , array ( 'status' => $ value ) ) ; if ( $ updated && $ this -> setNotificationUpdateOrder ( $ id ) == static :: NOTIFICATION_ERROR ) { $ failed_notifications [ ] = $ this -> text ( '<a href="@url">@text</a>' , array ( '@url' => $ this -> url ( "admin/sale/order/$id" ) , '@text' => $ id ) ) ; } $ updated ++ ; } if ( $ action === 'delete' && $ this -> access ( 'order_delete' ) ) { $ deleted += ( int ) $ this -> order -> delete ( $ id ) ; } } if ( $ updated > 0 ) { $ message = $ this -> text ( 'Updated %num item(s)' , array ( '%num' => $ updated ) ) ; $ this -> setMessage ( $ message , 'success' ) ; } if ( ! empty ( $ failed_notifications ) ) { $ vars = array ( '!list' => implode ( ', ' , $ failed_notifications ) ) ; $ message = $ this -> text ( 'Failed to notify customers in orders: !list' , $ vars ) ; $ this -> setMessage ( $ message , 'warning' ) ; } if ( $ deleted > 0 ) { $ message = $ this -> text ( 'Deleted %num item(s)' , array ( '%num' => $ deleted ) ) ; $ this -> setMessage ( $ message , 'success' ) ; } }
|
Applies an action to the selected orders
|
55,074
|
protected function loadSymfonyRoutes ( $ path ) { if ( $ this -> routes === null ) { $ loader = new YamlFileLoader ( new FileLocator ( array ( dirname ( $ path ) ) ) ) ; $ loader -> setDefaults ( array ( '_module' => $ this -> getName ( ) ) ) ; $ routesCollection = $ loader -> load ( pathinfo ( $ path , PATHINFO_FILENAME ) . '.' . pathinfo ( $ path , PATHINFO_EXTENSION ) ) ; $ this -> routes = $ routesCollection ; } return $ this -> routes ; }
|
Load up our routes .
|
55,075
|
public function mergeConfig ( $ resources ) { $ configs = array ( ) ; foreach ( is_array ( $ resources ) ? $ resources : func_get_args ( ) as $ resource ) { $ configs = ArrayUtils :: merge ( $ configs , $ this -> loadConfig ( $ resource ) ) ; } return $ configs ; }
|
Loads and merges the configuration .
|
55,076
|
public function getName ( ) { if ( null !== $ this -> name ) { return $ this -> name ; } $ this -> name = str_replace ( '\\' , '' , $ this -> getNamespace ( ) ) ; return $ this -> name ; }
|
Returns the module name . Defaults to the module namespace stripped of backslashes .
|
55,077
|
public function getNamespace ( ) { if ( null === $ this -> reflected ) { $ this -> reflected = new \ ReflectionObject ( $ this ) ; } return $ this -> reflected -> getNamespaceName ( ) ; }
|
Gets the Module namespace .
|
55,078
|
protected function getConfigLoader ( ) { if ( null === $ this -> configLoader ) { $ this -> configLoader = new ConfigLoader ( $ this -> getPath ( ) . '/resources/config' ) ; } return $ this -> configLoader ; }
|
Returns a ConfigLoader instance .
|
55,079
|
public function total ( array $ condition , array $ data ) { if ( ! isset ( $ data [ 'cart' ] [ 'total' ] ) || empty ( $ data [ 'cart' ] [ 'currency' ] ) ) { return false ; } $ condition_value = explode ( '|' , reset ( $ condition [ 'value' ] ) , 2 ) ; $ condition_currency = $ data [ 'cart' ] [ 'currency' ] ; if ( ! empty ( $ condition_value [ 1 ] ) ) { $ condition_currency = $ condition_value [ 1 ] ; } $ condition_value [ 0 ] = $ this -> price -> amount ( $ condition_value [ 0 ] , $ condition_currency ) ; $ value = $ this -> currency -> convert ( $ condition_value [ 0 ] , $ condition_currency , $ data [ 'cart' ] [ 'currency' ] ) ; return $ this -> compare ( $ data [ 'cart' ] [ 'total' ] , $ value , $ condition [ 'operator' ] ) ; }
|
Whether the cart total condition is met
|
55,080
|
public function productId ( array $ condition , array $ data ) { if ( empty ( $ data [ 'cart' ] [ 'items' ] ) || ! in_array ( $ condition [ 'operator' ] , array ( '=' , '!=' ) ) ) { return false ; } $ ids = array ( ) ; foreach ( $ data [ 'cart' ] [ 'items' ] as $ item ) { $ ids [ ] = $ item [ 'product_id' ] ; } return $ this -> compare ( $ ids , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the cart product ID condition is met
|
55,081
|
public function sku ( array $ condition , array $ data ) { if ( empty ( $ data [ 'cart' ] [ 'items' ] ) || ! in_array ( $ condition [ 'operator' ] , array ( '=' , '!=' ) ) ) { return false ; } return $ this -> compare ( array_keys ( $ data [ 'cart' ] [ 'items' ] ) , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the cart product SKU condition is met
|
55,082
|
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'product.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( int ) $ result ; } $ data [ 'created' ] = $ data [ 'modified' ] = GC_TIME ; $ data += array ( 'currency' => $ this -> config -> get ( 'currency' , 'USD' ) ) ; $ this -> setPrice ( $ data ) ; $ result = $ data [ 'product_id' ] = $ this -> db -> insert ( 'product' , $ data ) ; $ this -> setTranslations ( $ data , $ this -> translation_entity , 'product' , false ) ; $ this -> setImages ( $ data , $ this -> file , 'product' ) ; $ this -> setSku ( $ data , false ) ; $ this -> setSkuCombinations ( $ data , false ) ; $ this -> setOptions ( $ data , false ) ; $ this -> setAttributes ( $ data , false ) ; $ this -> setAlias ( $ data , $ this -> alias , 'product' , false ) ; $ this -> setRelated ( $ data , false ) ; $ this -> search -> index ( 'product' , $ data ) ; $ this -> hook -> attach ( 'product.add.after' , $ data , $ result , $ this ) ; return ( int ) $ result ; }
|
Adds a product
|
55,083
|
public function generateSku ( array $ data ) { $ data += array ( 'placeholders' => $ this -> sku -> getPatternPlaceholders ( ) ) ; return $ this -> sku -> generate ( $ this -> sku -> getPattern ( ) , $ data ) ; }
|
Generate a product SKU
|
55,084
|
public function calculate ( array $ product , array $ options = array ( ) ) { $ options += array ( 'status' => 1 , 'store_id' => $ product [ 'store_id' ] ) ; $ components = array ( ) ; $ total = $ product [ 'price' ] ; foreach ( $ this -> price_rule -> getTriggered ( $ product , $ options ) as $ price_rule ) { $ this -> price_rule -> calculate ( $ total , $ product , $ components , $ price_rule ) ; } return $ total ; }
|
Calculates the product price
|
55,085
|
protected function deleteLinked ( $ product_id ) { $ conditions = array ( 'product_id' => $ product_id ) ; $ conditions2 = array ( 'entity' => 'product' , 'entity_id' => $ product_id ) ; $ this -> db -> delete ( 'cart' , $ conditions ) ; $ this -> db -> delete ( 'review' , $ conditions ) ; $ this -> db -> delete ( 'rating' , $ conditions ) ; $ this -> db -> delete ( 'wishlist' , $ conditions ) ; $ this -> db -> delete ( 'rating_user' , $ conditions ) ; $ this -> db -> delete ( 'product_sku' , $ conditions ) ; $ this -> db -> delete ( 'product_field' , $ conditions ) ; $ this -> db -> delete ( 'product_translation' , $ conditions ) ; $ this -> db -> delete ( 'product_view' , $ conditions ) ; $ this -> db -> delete ( 'product_related' , $ conditions ) ; $ this -> db -> delete ( 'product_related' , array ( 'item_product_id' => $ product_id ) ) ; $ this -> db -> delete ( 'product_bundle' , $ conditions ) ; $ this -> db -> delete ( 'file' , $ conditions2 ) ; $ this -> db -> delete ( 'alias' , $ conditions2 ) ; $ this -> db -> delete ( 'search_index' , $ conditions2 ) ; $ sql = 'DELETE ci FROM collection_item ci INNER JOIN collection c ON(ci.collection_id = c.collection_id) WHERE c.type = ? AND ci.entity_id = ?' ; $ this -> db -> run ( $ sql , array ( 'product' , $ product_id ) ) ; }
|
Delete all database records associated with the product ID
|
55,086
|
protected function setPrice ( array & $ data ) { if ( ! empty ( $ data [ 'price' ] ) && ! empty ( $ data [ 'currency' ] ) ) { $ data [ 'price' ] = $ this -> price -> amount ( $ data [ 'price' ] , $ data [ 'currency' ] ) ; } }
|
Converts a price value to minor units
|
55,087
|
protected function attachFields ( array & $ product ) { if ( empty ( $ product ) ) { return $ product ; } $ product [ 'field' ] = $ this -> product_field -> getList ( $ product [ 'product_id' ] ) ; if ( empty ( $ product [ 'field' ] [ 'option' ] ) ) { return $ product ; } foreach ( $ product [ 'field' ] [ 'option' ] as & $ field_values ) { $ field_values = array_unique ( $ field_values ) ; } return $ product ; }
|
Adds fields to the product
|
55,088
|
protected function attachSku ( array & $ product ) { if ( empty ( $ product ) ) { return $ product ; } $ product [ 'default_field_values' ] = array ( ) ; $ codes = ( array ) $ this -> sku -> getList ( array ( 'product_id' => $ product [ 'product_id' ] ) ) ; foreach ( $ codes as $ code ) { if ( $ code [ 'combination_id' ] === '' ) { $ product [ 'sku' ] = $ code [ 'sku' ] ; $ product [ 'price' ] = $ code [ 'price' ] ; $ product [ 'stock' ] = $ code [ 'stock' ] ; continue ; } $ product [ 'combination' ] [ $ code [ 'combination_id' ] ] = $ code ; if ( ! empty ( $ code [ 'is_default' ] ) ) { $ product [ 'default_field_values' ] = $ code [ 'fields' ] ; } } return $ product ; }
|
Adds option combinations to the product
|
55,089
|
protected function addSkuCombinations ( array $ data ) { if ( empty ( $ data [ 'combination' ] ) ) { return false ; } foreach ( $ data [ 'combination' ] as $ combination ) { if ( empty ( $ combination [ 'fields' ] ) ) { continue ; } if ( ! empty ( $ combination [ 'price' ] ) ) { $ combination [ 'price' ] = $ this -> price -> amount ( $ combination [ 'price' ] , $ data [ 'currency' ] ) ; } $ this -> setCombinationFileId ( $ combination , $ data ) ; $ combination [ 'store_id' ] = $ data [ 'store_id' ] ; $ combination [ 'product_id' ] = $ data [ 'product_id' ] ; $ combination [ 'combination_id' ] = $ this -> sku -> getCombinationId ( $ combination [ 'fields' ] , $ data [ 'product_id' ] ) ; if ( empty ( $ combination [ 'sku' ] ) ) { $ combination [ 'sku' ] = $ this -> sku -> generate ( $ data [ 'sku' ] , array ( 'store_id' => $ data [ 'store_id' ] ) ) ; } $ this -> sku -> add ( $ combination ) ; } return true ; }
|
Add SKUs for an array of product combinations
|
55,090
|
protected function setCombinationFileId ( array & $ combination , array $ data ) { foreach ( $ data [ 'images' ] as $ image ) { if ( $ image [ 'path' ] === $ combination [ 'path' ] ) { $ combination [ 'file_id' ] = $ image [ 'file_id' ] ; } } return $ combination ; }
|
Adds a file ID from uploaded images to the combination item
|
55,091
|
protected function addOptions ( array $ data ) { if ( empty ( $ data [ 'combination' ] ) ) { return false ; } foreach ( $ data [ 'combination' ] as $ combination ) { if ( empty ( $ combination [ 'fields' ] ) ) { continue ; } foreach ( $ combination [ 'fields' ] as $ field_id => $ field_value_id ) { $ options = array ( 'type' => 'option' , 'field_id' => $ field_id , 'product_id' => $ data [ 'product_id' ] , 'field_value_id' => $ field_value_id ) ; $ this -> product_field -> add ( $ options ) ; } } return true ; }
|
Adds multiple options
|
55,092
|
protected function addAttributes ( array $ data ) { if ( empty ( $ data [ 'field' ] [ 'attribute' ] ) ) { return false ; } foreach ( $ data [ 'field' ] [ 'attribute' ] as $ field_id => $ field_value_ids ) { foreach ( ( array ) $ field_value_ids as $ field_value_id ) { $ options = array ( 'type' => 'attribute' , 'field_id' => $ field_id , 'product_id' => $ data [ 'product_id' ] , 'field_value_id' => $ field_value_id ) ; $ this -> product_field -> add ( $ options ) ; } } return true ; }
|
Adds multiple attributes
|
55,093
|
final protected function validateBool ( $ value , array $ allowed ) : bool { if ( true === in_array ( 'bool' , $ allowed ) ) { if ( true === is_bool ( $ value ) ) { return true ; } } return false ; }
|
Validates an bool setting .
|
55,094
|
final protected function validateString ( $ value , array $ allowed ) : bool { if ( true === in_array ( 'string' , $ allowed ) ) { if ( true === is_string ( $ value ) ) { return true ; } } return false ; }
|
Validates an string setting .
|
55,095
|
final protected function validateCallable ( $ value , array $ allowed ) : bool { if ( true === in_array ( 'callable' , $ allowed ) ) { if ( true === is_callable ( $ value ) ) { return true ; } } return false ; }
|
Validates an callable setting .
|
55,096
|
final protected function validateInt ( string $ name , $ value , array $ allowed ) : bool { if ( true === in_array ( 'int' , $ allowed ) ) { if ( true === is_int ( $ value ) ) { if ( $ value >= 0 ) { return true ; } else { throw new \ InvalidArgumentException ( 'Int value for ' . $ name . ' is too low' ) ; } } } return false ; }
|
Validates an int setting .
|
55,097
|
final protected function validateArray ( string $ name , $ value , array $ allowed ) : bool { if ( true === in_array ( 'array' , $ allowed ) ) { if ( true === is_array ( $ value ) ) { if ( true === empty ( $ value ) ) { throw new \ InvalidArgumentException ( 'Array for ' . $ name . ' is empty' ) ; } else { foreach ( $ value as $ line ) { if ( false === is_string ( $ line ) ) { throw new \ InvalidArgumentException ( 'Array for ' . $ name . ' contains a non-string item' ) ; } } return true ; } } } return false ; }
|
Validates an array setting .
|
55,098
|
public function listCollectionItem ( $ collection_id ) { $ this -> setCollectionCollection ( $ collection_id ) ; $ this -> actionListCollectionItem ( ) ; $ this -> setTitleListCollectionItem ( ) ; $ this -> setBreadcrumbListCollectionItem ( ) ; $ this -> setFilterListCollectionItem ( ) ; $ this -> setPagerListCollectionItem ( ) ; $ this -> setData ( 'collection' , $ this -> data_collection ) ; $ this -> setData ( 'items' , $ this -> getListCollectionItem ( ) ) ; $ this -> outputListCollectionItem ( ) ; }
|
Displays the collection item overview page
|
55,099
|
protected function setCollectionCollectionItem ( $ collection_item_id ) { $ this -> data_collection_item = array ( ) ; if ( is_numeric ( $ collection_item_id ) ) { $ this -> data_collection_item = $ this -> collection_item -> get ( $ collection_item_id ) ; if ( empty ( $ this -> data_collection_item ) ) { $ this -> outputHttpStatus ( 404 ) ; } $ this -> prepareCollectionItem ( $ this -> data_collection_item ) ; } }
|
Sets a collection item data
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.