idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
55,500
protected function deleteCartCheckout ( ) { $ cart_id = $ this -> getSubmitted ( 'cart.action.delete' ) ; if ( ! empty ( $ cart_id ) ) { $ this -> setSubmitted ( 'cart.action.update' , true ) ; $ this -> cart -> delete ( $ cart_id ) ; } }
Deletes an item from the cart
55,501
protected function submitOrderCheckout ( ) { if ( ! $ this -> isPosted ( 'save' ) ) { return null ; } $ errors = array ( ) ; foreach ( array ( 'payment' , 'shipping' ) as $ type ) { $ address_errors = $ this -> validateAddressCheckout ( $ type ) ; if ( ! empty ( $ address_errors ) ) { $ errors = gplcart_array_merge ( $ errors , $ address_errors ) ; } if ( empty ( $ address_errors ) ) { $ this -> addAddressCheckout ( $ type ) ; } } $ order_errors = $ this -> validateOrderCheckout ( ) ; $ errors = gplcart_array_merge ( $ errors , $ order_errors ) ; if ( empty ( $ errors ) ) { $ this -> addOrderCheckout ( ) ; } else { $ this -> setError ( null , $ errors ) ; } }
Saves an order to the database
55,502
protected function validateOrderCheckout ( ) { if ( $ this -> same_payment_address ) { $ this -> unsetSubmitted ( 'address.payment' ) ; } $ this -> setSubmitted ( 'update' , array ( ) ) ; $ this -> setSubmitted ( 'store_id' , $ this -> store_id ) ; $ this -> setSubmitted ( 'user_id' , $ this -> order_user_id ) ; $ this -> setSubmitted ( 'creator' , $ this -> admin_user_id ) ; if ( $ this -> admin ) { $ this -> setSubmitted ( 'status' , $ this -> order -> getStatusInitial ( ) ) ; } return $ this -> validateComponent ( 'order' ) ; }
Validates an array of submitted data before creating an order
55,503
protected function addAddressCheckout ( $ type ) { $ submitted = $ this -> getSubmitted ( "address.$type" ) ; if ( $ this -> { "show_{$type}_address_form" } && ! empty ( $ submitted ) ) { $ address_id = $ this -> address -> add ( $ submitted ) ; $ this -> setSubmitted ( "{$type}_address" , $ address_id ) ; foreach ( $ this -> address -> getExceeded ( $ this -> order_user_id ) as $ address ) { $ this -> address -> delete ( $ address [ 'address_id' ] ) ; } } }
Adds a submitted address
55,504
protected function addOrderCheckout ( ) { $ submitted = $ this -> getSubmittedOrderCheckout ( ) ; $ result = $ this -> order_action -> add ( $ submitted , array ( 'admin' => $ this -> admin ) ) ; $ this -> finishOrderCheckout ( $ result ) ; }
Adds a new order
55,505
protected function finishOrderCheckout ( array $ result ) { if ( $ this -> admin === 'add' ) { $ this -> finishAddOrderCheckout ( $ result ) ; } else if ( $ this -> admin === 'clone' ) { $ this -> finishCloneOrderCheckout ( $ result ) ; } $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
Performs final tasks after an order has been created
55,506
protected function finishAddOrderCheckout ( array $ result ) { if ( ! empty ( $ result [ 'order' ] [ 'order_id' ] ) ) { $ vars = array ( '@num' => $ result [ 'order' ] [ 'order_id' ] , '@name' => $ result [ 'order' ] [ 'customer_name' ] , '@status' => $ this -> order -> getStatusName ( $ result [ 'order' ] [ 'status' ] ) ) ; $ message = $ this -> text ( 'Order #@num has been created for user @name. Order status: @status' , $ vars ) ; $ this -> redirect ( "admin/sale/order/{$result['order']['order_id']}" , $ message , 'success' ) ; } }
Performs final tasks after an order has been added for a user
55,507
protected function finishCloneOrderCheckout ( array $ result ) { if ( ! empty ( $ result [ 'order' ] [ 'order_id' ] ) ) { $ log = array ( 'user_id' => $ this -> uid , 'order_id' => $ this -> data_order [ 'order_id' ] , 'text' => $ this -> text ( 'Cloned into order #@num' , array ( '@num' => $ result [ 'order' ] [ 'order_id' ] ) ) ) ; $ this -> order_history -> add ( $ log ) ; $ vars = array ( '@num' => $ this -> data_order [ 'order_id' ] , '@url' => $ this -> url ( "admin/sale/order/{$this->order_id}" ) , '@status' => $ this -> order -> getStatusName ( $ result [ 'order' ] [ 'status' ] ) ) ; $ message = $ this -> text ( 'Order has been cloned from order <a href="@url">@num</a>. Order status: @status' , $ vars ) ; $ this -> redirect ( "admin/sale/order/{$result['order']['order_id']}" , $ message , 'success' ) ; } }
Performs final tasks after an order has been cloned
55,508
protected function getSubmittedOrderCheckout ( ) { $ submitted = $ this -> getSubmitted ( ) ; $ submitted += $ this -> data_form [ 'order' ] ; $ submitted [ 'cart' ] = $ this -> data_cart ; $ submitted [ 'data' ] [ 'user' ] = array ( 'ip' => $ this -> server -> remoteAddr ( ) , 'agent' => $ this -> server -> userAgent ( ) ) ; if ( empty ( $ this -> admin ) ) { return $ submitted ; } $ submitted [ 'total' ] = $ this -> price -> amount ( $ submitted [ 'total' ] , $ submitted [ 'currency' ] ) ; if ( empty ( $ submitted [ 'data' ] [ 'components' ] ) ) { return $ submitted ; } $ this -> prepareSubmittedOrderComponentsCheckout ( $ submitted ) ; return $ submitted ; }
Returns an array of prepared submitted order data
55,509
protected function prepareSubmittedOrderComponentsCheckout ( array & $ submitted ) { foreach ( $ submitted [ 'data' ] [ 'components' ] as $ id => & $ component ) { if ( ! isset ( $ component [ 'price' ] ) ) { continue ; } if ( empty ( $ component [ 'price' ] ) ) { unset ( $ submitted [ 'data' ] [ 'components' ] [ $ id ] ) ; continue ; } $ component [ 'currency' ] = $ submitted [ 'currency' ] ; $ component [ 'price' ] = $ this -> price -> amount ( $ component [ 'price' ] , $ submitted [ 'currency' ] ) ; } }
Prepare submitted order components
55,510
protected function prepareOrderComponentsCheckout ( $ calculated ) { $ component_types = $ this -> order -> getComponentTypes ( ) ; $ components = array ( ) ; foreach ( $ calculated [ 'components' ] as $ type => $ component ) { $ components [ $ type ] = array ( 'price' => $ component [ 'price' ] , 'price_decimal' => $ this -> price -> decimal ( $ component [ 'price' ] , $ calculated [ 'currency' ] ) , 'price_formatted' => $ this -> price -> format ( $ component [ 'price' ] , $ calculated [ 'currency' ] ) ) ; if ( empty ( $ component [ 'rule' ] ) ) { $ components [ $ type ] [ 'name' ] = $ component_types [ $ type ] ; continue ; } $ components [ $ type ] [ 'rule' ] = $ component [ 'rule' ] ; $ components [ $ type ] [ 'name' ] = $ component [ 'rule' ] [ 'name' ] ; } return $ components ; }
Prepares an array of price rule components
55,511
protected function setDataFormCheckout ( ) { $ form = $ this -> render ( 'checkout/form' , $ this -> data_form , true ) ; if ( $ this -> isAjax ( ) ) { $ this -> response -> outputHtml ( $ form ) ; } $ this -> setData ( 'checkout_form' , $ form ) ; }
Sets form on the checkout page
55,512
public static function add ( $ key , $ path ) { self :: $ _registeredNamespaces [ $ key ] = true ; self :: $ _options [ 'loader' ] -> addPsr4 ( $ key , $ path ) ; }
Add a namespace to the autoloader path .
55,513
public function setContext ( $ context , array $ options = array ( ) ) { if ( ! isset ( $ context ) ) { $ context = stream_context_create ( ( array ) $ context , $ options ) ; } if ( ! is_resource ( $ context ) ) { throw new UnexpectedValueException ( 'Stream context is not a valid resource' ) ; } $ this -> context = $ context ; return $ this ; }
Sets the context resource
55,514
public function setUri ( $ uri ) { if ( ! is_array ( $ uri ) ) { $ uri = parse_url ( $ uri ) ; } $ this -> uri = $ uri ; return $ this ; }
Sets the request URI
55,515
public function setSocket ( ) { if ( empty ( $ this -> uri [ 'scheme' ] ) ) { throw new OutOfBoundsException ( 'Unknown URL scheme' ) ; } if ( $ this -> uri [ 'scheme' ] === 'http' ) { $ port = 80 ; $ protocol = 'tcp' ; } else if ( $ this -> uri [ 'scheme' ] === 'https' ) { $ port = 443 ; $ protocol = 'ssl' ; } else { throw new UnexpectedValueException ( "Unsupported URL scheme: {$this->uri['scheme']}" ) ; } if ( isset ( $ this -> uri [ 'port' ] ) ) { $ port = $ this -> uri [ 'port' ] ; } $ this -> socket = "$protocol://{$this->uri['host']}:$port" ; if ( ! isset ( $ this -> headers [ 'Host' ] ) ) { $ this -> headers [ 'Host' ] = "{$this->uri['host']}:$port" ; } return $ this ; }
Sets a socket depending on the current URI parameters
55,516
public function exec ( ) { $ this -> response = '' ; $ errno = $ errstr = null ; if ( isset ( $ this -> context ) ) { $ this -> stream = stream_socket_client ( $ this -> socket , $ errno , $ errstr , $ this -> timeout , STREAM_CLIENT_CONNECT , $ this -> context ) ; } else { $ this -> stream = stream_socket_client ( $ this -> socket , $ errno , $ errstr , $ this -> timeout ) ; } if ( ! empty ( $ errstr ) ) { throw new UnexpectedValueException ( $ errstr ) ; } fwrite ( $ this -> stream , $ this -> getRequestBody ( ) ) ; while ( ! feof ( $ this -> stream ) ) { $ this -> response .= fgets ( $ this -> stream , 1024 ) ; } fclose ( $ this -> stream ) ; $ this -> stream = null ; return $ this ; }
Open Internet or Unix domain socket connection and execute a query
55,517
protected function getRequestBody ( ) { if ( is_array ( $ this -> data ) ) { $ this -> data = http_build_query ( $ this -> data ) ; } $ this -> prepareHeaders ( ) ; $ path = isset ( $ this -> uri [ 'path' ] ) ? $ this -> uri [ 'path' ] : '/' ; if ( isset ( $ this -> uri [ 'query' ] ) ) { $ path .= "?{$this->uri['query']}" ; } $ body = "{$this->method} $path HTTP/1.0\r\n" ; foreach ( $ this -> headers as $ name => $ value ) { $ body .= "$name: " . trim ( $ value ) . "\r\n" ; } $ body .= "\r\n{$this->data}" ; return $ body ; }
Returns the request body
55,518
protected function prepareHeaders ( ) { if ( ! isset ( $ this -> headers [ 'Content-Length' ] ) ) { $ content_length = strlen ( $ this -> data ) ; if ( $ content_length > 0 || $ this -> method === 'POST' || $ this -> method === 'PUT' ) { $ this -> headers [ 'Content-Length' ] = $ content_length ; } } if ( isset ( $ this -> uri [ 'user' ] ) && ! isset ( $ this -> headers [ 'Authorization' ] ) ) { $ pass = isset ( $ this -> uri [ 'pass' ] ) ? ':' . $ this -> uri [ 'pass' ] : ':' ; $ this -> headers [ 'Authorization' ] = 'Basic ' . base64_encode ( $ this -> uri [ 'user' ] . $ pass ) ; } }
Prepare request headers
55,519
public function getFormattedResponse ( ) { list ( $ header , $ data ) = preg_split ( "/\r\n\r\n|\n\n|\r\r/" , $ this -> response , 2 ) ; $ headers = preg_split ( "/\r\n|\n|\r/" , $ header ) ; $ status = explode ( ' ' , trim ( reset ( $ headers ) ) , 3 ) ; $ result = array ( 'status' => '' , 'http' => $ status [ 0 ] , 'code' => $ status [ 1 ] ) ; if ( isset ( $ status [ 2 ] ) ) { $ result [ 'status' ] = $ status [ 2 ] ; } return array ( 'data' => $ data , 'status' => $ result ) ; }
Returns an array of formatted response
55,520
public function request ( $ url , array $ options = array ( ) ) { $ options += array ( 'data' => null , 'timeout' => 30 , 'context' => null , 'method' => 'GET' , 'headers' => array ( ) ) ; if ( $ options [ 'method' ] === 'POST' && empty ( $ options [ 'headers' ] ) ) { $ options [ 'headers' ] = array ( 'Content-Type' => 'application/x-www-form-urlencoded' ) ; } if ( ! empty ( $ options [ 'query' ] ) ) { $ url = strtok ( $ url , '?' ) . '?' . http_build_query ( $ options [ 'query' ] ) ; } return $ this -> setUri ( $ url ) -> setHeaders ( $ options [ 'headers' ] ) -> setMethod ( $ options [ 'method' ] ) -> setData ( $ options [ 'data' ] ) -> setTimeOut ( $ options [ 'timeout' ] ) -> setContext ( $ options [ 'context' ] ) -> setSocket ( ) -> exec ( ) -> getFormattedResponse ( ) ; }
Shortcut method to perform an HTTP request
55,521
public function get ( $ condition ) { $ result = null ; $ this -> hook -> attach ( 'collection.get.before' , $ condition , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } if ( ! is_array ( $ condition ) ) { $ condition = array ( 'collection_id' => $ condition ) ; } $ condition [ 'limit' ] = array ( 0 , 1 ) ; $ list = ( array ) $ this -> getList ( $ condition ) ; $ result = empty ( $ list ) ? array ( ) : reset ( $ list ) ; $ this -> hook -> attach ( 'collection.get.after' , $ condition , $ result , $ this ) ; return $ result ; }
Loads a collection from the database
55,522
public function canDelete ( $ collection_id ) { $ sql = 'SELECT collection_item_id FROM collection_item WHERE collection_id=?' ; $ result = $ this -> db -> fetchColumn ( $ sql , array ( $ collection_id ) ) ; return empty ( $ result ) ; }
Whether a collection can be deleted
55,523
public function getTypes ( ) { $ handlers = $ this -> getHandlers ( ) ; $ types = array ( ) ; foreach ( $ handlers as $ handler_id => $ handler ) { $ types [ $ handler_id ] = $ handler [ 'title' ] ; } return $ types ; }
Returns an array of collection type names keyed by a handler ID
55,524
public function index ( $ product ) { if ( is_numeric ( $ product ) ) { $ product = $ this -> product -> get ( $ product ) ; } if ( empty ( $ product ) ) { return false ; } $ indexed = 0 ; $ indexed += ( int ) $ this -> indexProduct ( $ product ) ; $ indexed += ( int ) $ this -> indexProductTranslations ( $ product ) ; return $ indexed > 0 ; }
Indexes a product
55,525
public function search ( $ query , array $ data ) { $ sql = 'SELECT si.entity_id' ; if ( ! empty ( $ data [ 'count' ] ) ) { $ sql = 'SELECT COUNT(si.entity_id)' ; } $ conditions = array ( $ query , $ data [ 'language' ] , 'und' , 'product' ) ; $ sql .= ' FROM search_index si LEFT JOIN product p ON(p.product_id = si.entity_id) WHERE MATCH(si.text) AGAINST (? IN BOOLEAN MODE) AND (si.language=? OR si.language=?) AND si.entity=? AND p.product_id IS NOT NULL' ; if ( isset ( $ data [ 'status' ] ) ) { $ sql .= ' AND p.status=?' ; $ conditions [ ] = ( int ) $ data [ 'status' ] ; } if ( isset ( $ data [ 'store_id' ] ) ) { $ sql .= ' AND p.store_id=?' ; $ conditions [ ] = ( int ) $ data [ 'store_id' ] ; } if ( empty ( $ data [ 'count' ] ) ) { $ sql .= ' GROUP BY si.entity_id' ; } if ( ! empty ( $ data [ 'limit' ] ) ) { $ sql .= ' LIMIT ' . implode ( ',' , array_map ( 'intval' , $ data [ 'limit' ] ) ) ; } if ( ! empty ( $ data [ 'count' ] ) ) { return $ this -> config -> getDb ( ) -> fetchColumn ( $ sql , $ conditions ) ; } $ data [ 'product_id' ] = $ this -> config -> getDb ( ) -> fetchColumnAll ( $ sql , $ conditions ) ; if ( empty ( $ data [ 'product_id' ] ) ) { return array ( ) ; } unset ( $ data [ 'language' ] ) ; return $ this -> product -> getList ( $ data ) ; }
Returns an array of suggested products for a given query
55,526
protected function indexProduct ( array $ product ) { $ snippet = $ this -> search -> getSnippet ( $ product , 'und' ) ; return $ this -> search -> setIndex ( $ snippet , 'product' , $ product [ 'product_id' ] , 'und' ) ; }
Adds the main product data to the search index
55,527
protected function indexProductTranslations ( array $ product ) { if ( empty ( $ product [ 'translation' ] ) ) { return false ; } $ indexed = 0 ; foreach ( $ product [ 'translation' ] as $ language => $ translation ) { $ translation += $ product ; $ snippet = $ this -> search -> getSnippet ( $ translation , $ language ) ; $ indexed += ( int ) $ this -> search -> setIndex ( $ snippet , 'product' , $ product [ 'product_id' ] , $ language ) ; } return $ indexed > 0 ; }
Adds product translations to the search index
55,528
public function fetchColumn ( $ sql , array $ params = array ( ) , $ pos = 0 ) { return $ this -> run ( $ sql , $ params ) -> fetchColumn ( $ pos ) ; }
Returns a single column
55,529
public function run ( $ sql , array $ params = array ( ) ) { $ sth = $ this -> pdo -> prepare ( $ sql ) ; foreach ( $ params as $ key => $ value ) { $ key = is_numeric ( $ key ) ? $ key + 1 : ":$key" ; $ sth -> bindValue ( $ key , $ value ) ; } $ sth -> execute ( $ params ) ; $ this -> executed [ ] = $ sql ; return $ sth ; }
Runs a SQL query with an array of placeholders
55,530
public function fetchColumnAll ( $ sql , array $ params = array ( ) , $ pos = 0 ) { return $ this -> run ( $ sql , $ params ) -> fetchAll ( PDO :: FETCH_COLUMN , $ pos ) ; }
Returns a simple array of columns
55,531
public function fetch ( $ sql , array $ params , array $ options = array ( ) ) { $ sth = $ this -> run ( $ sql , $ params ) ; $ result = $ sth -> fetch ( PDO :: FETCH_ASSOC ) ; $ this -> prepareResult ( $ result , $ options ) ; return empty ( $ result ) ? array ( ) : ( array ) $ result ; }
Returns a single array indexed by column name
55,532
protected function prepareResult ( & $ data , array $ options ) { if ( ! empty ( $ options [ 'unserialize' ] ) && ! empty ( $ data ) ) { foreach ( ( array ) $ options [ 'unserialize' ] as $ field ) { $ data [ $ field ] = empty ( $ data [ $ field ] ) ? array ( ) : unserialize ( $ data [ $ field ] ) ; } } }
Prepares a single result
55,533
public function fetchAll ( $ sql , array $ params , array $ options = array ( ) ) { $ result = $ this -> run ( $ sql , $ params ) -> fetchAll ( PDO :: FETCH_ASSOC ) ; $ this -> prepareResults ( $ result , $ options ) ; return empty ( $ result ) ? array ( ) : ( array ) $ result ; }
Returns an array of database records
55,534
protected function prepareResults ( array & $ results , array $ options ) { $ reindexed = array ( ) ; foreach ( $ results as & $ result ) { $ this -> prepareResult ( $ result , $ options ) ; if ( ! empty ( $ options [ 'index' ] ) ) { $ reindexed [ $ result [ $ options [ 'index' ] ] ] = $ result ; } } if ( ! empty ( $ options [ 'index' ] ) ) { $ results = $ reindexed ; } }
Prepares an array of results
55,535
public function update ( $ table , array $ data , array $ conditions , $ filter = true ) { if ( $ filter ) { $ data = $ this -> filterValues ( $ table , $ data ) ; } if ( empty ( $ data ) ) { return 0 ; } $ farray = array ( ) ; foreach ( array_keys ( $ data ) as $ key ) { $ farray [ ] = "$key=:$key" ; } $ carray = array ( ) ; foreach ( array_keys ( $ conditions ) as $ key ) { $ carray [ ] = "$key=:$key" ; } $ fields = implode ( ',' , $ farray ) ; $ sql = "UPDATE $table SET $fields WHERE " . implode ( ' AND ' , $ carray ) ; $ stmt = $ this -> pdo -> prepare ( $ sql ) ; foreach ( $ data as $ key => $ value ) { $ stmt -> bindValue ( ":$key" , $ value ) ; } foreach ( $ conditions as $ key => $ value ) { $ stmt -> bindValue ( ":$key" , $ value ) ; } $ stmt -> execute ( ) ; $ this -> executed [ ] = $ sql ; return $ stmt -> rowCount ( ) ; }
Performs a UPDATE query
55,536
public function prepareInsert ( $ table , array $ data ) { $ data += $ this -> getDefaultValues ( $ table ) ; return $ this -> filterValues ( $ table , $ data ) ; }
Returns an array of prepared values ready to insert into the database
55,537
public function getDefaultValues ( $ table ) { $ scheme = $ this -> getScheme ( $ table ) ; $ values = array ( ) ; foreach ( $ scheme [ 'fields' ] as $ name => $ info ) { if ( array_key_exists ( 'default' , $ info ) ) { $ values [ $ name ] = $ info [ 'default' ] ; continue ; } if ( ! empty ( $ info [ 'serialize' ] ) ) { $ values [ $ name ] = array ( ) ; } } return $ values ; }
Returns an array of default field values for the given table
55,538
protected function filterValues ( $ table , array $ data ) { $ scheme = $ this -> getScheme ( $ table ) ; $ values = array_intersect_key ( $ data , $ scheme [ 'fields' ] ) ; if ( empty ( $ values ) ) { return array ( ) ; } foreach ( $ values as $ field => & $ value ) { if ( ! empty ( $ scheme [ 'fields' ] [ $ field ] [ 'auto_increment' ] ) ) { unset ( $ values [ $ field ] ) ; continue ; } if ( is_null ( $ value ) && ! empty ( $ scheme [ 'fields' ] [ $ field ] [ 'not_null' ] ) ) { unset ( $ values [ $ field ] ) ; continue ; } if ( ! empty ( $ scheme [ 'fields' ] [ $ field ] [ 'serialize' ] ) ) { if ( ! is_array ( $ value ) ) { $ value = array ( ) ; } $ value = serialize ( $ value ) ; } } return $ values ; }
Filters an array of data according to existing scheme for the given table
55,539
public function tableExists ( $ table ) { $ result = $ this -> query ( "SHOW TABLES LIKE " . $ this -> pdo -> quote ( $ table ) ) ; return $ result -> rowCount ( ) > 0 ; }
Check if a table already exists
55,540
public function import ( array $ tables ) { foreach ( $ tables as $ table => $ data ) { if ( ! $ this -> query ( $ this -> getSqlCreateTable ( $ table , $ data ) ) ) { throw new RuntimeException ( "Failed to import database table $table" ) ; } $ alter = $ this -> getSqlAlterTable ( $ table , $ data ) ; if ( ! empty ( $ alter ) && ! $ this -> query ( $ alter ) ) { throw new RuntimeException ( "Failed to alter table $table" ) ; } } }
Creates tables using an array of scheme data
55,541
public function importScheme ( $ table , array $ scheme ) { if ( $ this -> tableExists ( $ table ) ) { throw new RuntimeException ( 'Table already exists' ) ; } try { $ this -> import ( $ scheme ) ; } catch ( Exception $ ex ) { $ this -> deleteTable ( $ table ) ; throw new RuntimeException ( "Failed to import database table $table: " . $ ex -> getMessage ( ) ) ; } }
Install a database table using the scheme
55,542
protected function getSqlFields ( array $ fields ) { $ sql = array ( ) ; foreach ( $ fields as $ name => $ info ) { if ( strpos ( $ info [ 'type' ] , 'text' ) !== false || $ info [ 'type' ] === 'blob' ) { unset ( $ info [ 'default' ] ) ; } $ string = "{$info['type']}" ; if ( isset ( $ info [ 'length' ] ) ) { $ string .= "({$info['length']})" ; } if ( ! empty ( $ info [ 'not_null' ] ) ) { $ string .= " NOT NULL" ; } if ( isset ( $ info [ 'default' ] ) ) { $ string .= " DEFAULT '{$info['default']}'" ; } if ( ! empty ( $ info [ 'primary' ] ) ) { $ string .= " PRIMARY KEY" ; } if ( ! empty ( $ info [ 'auto_increment' ] ) ) { $ string .= " /*!40101 AUTO_INCREMENT */" ; } $ sql [ ] = $ name . ' ' . trim ( $ string ) ; } return implode ( ',' , $ sql ) ; }
Returns a SQL that describes table fields . Used to create tables
55,543
public function listZone ( ) { $ this -> actionListZone ( ) ; $ this -> setTitleListZone ( ) ; $ this -> setBreadcrumbListZone ( ) ; $ this -> setFilterListZone ( ) ; $ this -> setPagerListZone ( ) ; $ this -> setData ( 'zones' , $ this -> getListZone ( ) ) ; $ this -> outputListZone ( ) ; }
Displays the zone overview page
55,544
public function editZone ( $ zone_id = null ) { $ this -> setZone ( $ zone_id ) ; $ this -> setTitleEditZone ( ) ; $ this -> setBreadcrumbEditZone ( ) ; $ this -> setData ( 'zone' , $ this -> data_zone ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteZone ( ) ) ; $ this -> submitEditZone ( ) ; $ this -> outputEditZone ( ) ; }
Displays the zone edit page
55,545
protected function canDeleteZone ( ) { return isset ( $ this -> data_zone [ 'zone_id' ] ) && $ this -> zone -> canDelete ( $ this -> data_zone [ 'zone_id' ] ) && $ this -> access ( 'zone_delete' ) ; }
Whether the zone can be deleted
55,546
protected function setZone ( $ zone_id ) { $ this -> data_zone = array ( ) ; if ( is_numeric ( $ zone_id ) ) { $ this -> data_zone = $ this -> zone -> get ( $ zone_id ) ; if ( empty ( $ this -> data_zone ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
Sets a zone data
55,547
protected function submitEditZone ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteZone ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditZone ( ) ) { if ( isset ( $ this -> data_zone [ 'zone_id' ] ) ) { $ this -> updateZone ( ) ; } else { $ this -> addZone ( ) ; } } }
Handles a submitted zone data
55,548
protected function validateEditZone ( ) { $ this -> setSubmitted ( 'zone' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_zone ) ; $ this -> validateComponent ( 'zone' ) ; return ! $ this -> hasErrors ( ) ; }
Validates a submitted zone
55,549
protected function deleteZone ( ) { $ this -> controlAccess ( 'zone_delete' ) ; if ( $ this -> zone -> delete ( $ this -> data_zone [ 'zone_id' ] ) ) { $ this -> redirect ( 'admin/settings/zone' , $ this -> text ( 'Zone has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Zone has not been deleted' ) , 'danger' ) ; }
Deletes a zone
55,550
protected function addZone ( ) { $ this -> controlAccess ( 'zone_add' ) ; if ( $ this -> zone -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/settings/zone' , $ this -> text ( 'Zone has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Zone has not been added' ) , 'warning' ) ; }
Adds a new zone
55,551
protected function setTitleEditZone ( ) { if ( isset ( $ this -> data_zone [ 'zone_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_zone [ 'title' ] ) ) ; } else { $ title = $ this -> text ( 'Add zone' ) ; } $ this -> setTitle ( $ title ) ; }
Sets titles on the edit zone page
55,552
protected function setBreadcrumbEditZone ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Zones' ) , 'url' => $ this -> url ( 'admin/settings/zone' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the edit zone page
55,553
protected function setImage ( array $ data , $ field_value_id = null ) { if ( ! empty ( $ data [ 'images' ] ) && ! empty ( $ field_value_id ) ) { $ this -> file -> delete ( array ( 'entity' => 'field_value' , 'entity_id' => $ field_value_id ) ) ; } return $ this -> setImages ( $ data , $ this -> file , 'field_value' ) ; }
Sets a single image
55,554
protected function deleteLinked ( $ field_value_id ) { $ this -> db -> delete ( 'product_field' , array ( 'field_value_id' => $ field_value_id ) ) ; $ this -> db -> delete ( 'field_value_translation' , array ( 'field_value_id' => $ field_value_id ) ) ; $ this -> db -> delete ( 'file' , array ( 'entity' => 'field_value' , 'entity_id' => $ field_value_id ) ) ; }
Deletes all database records related to the field value ID
55,555
protected function canDelete ( $ field_value_id ) { $ sql = 'SELECT c.product_id FROM product_field pf LEFT JOIN cart c ON(pf.product_id = c.product_id) WHERE pf.field_value_id=?' ; $ result = $ this -> db -> fetchColumn ( $ sql , array ( $ field_value_id ) ) ; return empty ( $ result ) ; }
Whether the field value can be deleted
55,556
public function validatePlugin ( $ plugin ) { if ( $ plugin instanceof RouteInterface ) { return ; } throw new RuntimeException ( sprintf ( 'Plugin of type %s is invalid; must implement %s\RouteInterface' , ( is_object ( $ plugin ) ? get_class ( $ plugin ) : gettype ( $ plugin ) ) , __NAMESPACE__ ) ) ; }
Validate the plugin .
55,557
protected function createFromInvokable ( $ canonicalName , $ requestedName ) { $ invokable = $ this -> invokableClasses [ $ canonicalName ] ; if ( ! class_exists ( $ invokable ) ) { throw new RuntimeException ( sprintf ( '%s: failed retrieving "%s%s" via invokable class "%s"; class does not exist' , __METHOD__ , $ canonicalName , ( $ requestedName ? '(alias: ' . $ requestedName . ')' : '' ) , $ invokable ) ) ; } if ( ! static :: isSubclassOf ( $ invokable , __NAMESPACE__ . '\RouteInterface' ) ) { throw new RuntimeException ( sprintf ( '%s: failed retrieving "%s%s" via invokable class "%s"; class does not implement %s\RouteInterface' , __METHOD__ , $ canonicalName , ( $ requestedName ? '(alias: ' . $ requestedName . ')' : '' ) , $ invokable , __NAMESPACE__ ) ) ; } return $ invokable :: factory ( $ this -> creationOptions ) ; }
Attempt to create an instance via an invokable class .
55,558
public function date ( array $ values ) { if ( count ( $ values ) != 1 ) { $ vars = array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ; return $ this -> translation -> text ( '@field has invalid value' , $ vars ) ; } $ timestamp = strtotime ( reset ( $ values ) ) ; if ( empty ( $ timestamp ) ) { $ vars = array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ; return $ this -> translation -> text ( '@field has invalid value' , $ vars ) ; } return true ; }
Validates the date condition
55,559
public function current ( ) { if ( count ( $ this -> castRows ) > 0 ) { $ row = array_shift ( $ this -> castRows ) ; } else { $ row = $ this -> schema -> castRow ( $ this -> dataSource -> getNextLine ( ) ) ; foreach ( $ this -> schema -> fields ( ) as $ field ) { if ( $ field -> unique ( ) ) { if ( ! array_key_exists ( $ field -> name ( ) , $ this -> uniqueFieldValues ) ) { $ this -> uniqueFieldValues [ $ field -> name ( ) ] = [ ] ; } $ value = $ row [ $ field -> name ( ) ] ; if ( in_array ( $ value , $ this -> uniqueFieldValues [ $ field -> name ( ) ] ) ) { throw new DataSourceException ( 'field must be unique' , $ this -> currentLine ) ; } else { $ this -> uniqueFieldValues [ $ field -> name ( ) ] [ ] = $ value ; } } } } return $ row ; }
called on each iteration to get the next row does validation and casting on the row .
55,560
public function submitCart ( $ cart_action_model ) { $ this -> setSubmitted ( 'product' ) ; $ this -> filterSubmitted ( array ( 'product_id' ) ) ; if ( $ this -> isPosted ( 'add_to_cart' ) ) { $ this -> validateAddToCart ( ) ; $ this -> addToCart ( $ cart_action_model ) ; } else if ( $ this -> isPosted ( 'remove_from_cart' ) ) { $ this -> setSubmitted ( 'cart' ) ; $ this -> deleteFromCart ( $ cart_action_model ) ; } }
Handles product cart submissions
55,561
public function validateAddToCart ( ) { $ this -> setSubmitted ( 'user_id' , $ this -> getCartUid ( ) ) ; $ this -> setSubmitted ( 'store_id' , $ this -> getStoreId ( ) ) ; $ this -> setSubmitted ( 'quantity' , $ this -> getSubmitted ( 'quantity' , 1 ) ) ; $ this -> validateComponent ( 'cart' ) ; }
Validates adding a product to cart
55,562
public function addToCart ( $ cart_action_model ) { $ errors = $ this -> error ( ) ; if ( empty ( $ errors ) ) { $ submitted = $ this -> getSubmitted ( ) ; $ result = $ cart_action_model -> add ( $ submitted [ 'product' ] , $ submitted ) ; } else { $ result = array ( 'redirect' => '' , 'severity' => 'warning' , 'message' => $ this -> format ( $ errors ) ) ; } if ( $ this -> isAjax ( ) ) { $ result [ 'modal' ] = $ this -> getCartPreview ( ) ; $ this -> outputJson ( $ result ) ; } $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
Adds a product to the cart
55,563
public function deleteFromCart ( $ cart_action_model ) { $ result = $ cart_action_model -> delete ( $ this -> getSubmitted ( 'cart_id' ) ) ; if ( empty ( $ result [ 'quantity' ] ) ) { $ result [ 'message' ] = '' ; } if ( $ this -> isAjax ( ) ) { $ result [ 'modal' ] = $ this -> getCartPreview ( ) ; $ this -> outputJson ( $ result ) ; } $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
Deletes a submitted cart item
55,564
public function listBlog ( ) { $ this -> setTitleListBlog ( ) ; $ this -> setBreadcrumbListBlog ( ) ; $ this -> setTotalListBlog ( ) ; $ this -> setPagerListBlog ( ) ; $ this -> setData ( 'pages' , $ this -> getPagesBlog ( ) ) ; $ this -> outputListBlog ( ) ; }
Page callback Displays the blog page
55,565
protected function setTotalListBlog ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'status' ] = 1 ; $ conditions [ 'count' ] = true ; $ conditions [ 'blog_post' ] = 1 ; $ conditions [ 'store_id' ] = $ this -> store_id ; return $ this -> data_total = ( int ) $ this -> page -> getList ( $ conditions ) ; }
Sets a total number of posts found
55,566
protected function getPagesBlog ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'status' ] = 1 ; $ conditions [ 'blog_post' ] = 1 ; $ conditions [ 'limit' ] = $ this -> data_limit ; $ conditions [ 'store_id' ] = $ this -> store_id ; $ list = ( array ) $ this -> page -> getList ( $ conditions ) ; $ this -> preparePagesBlog ( $ list ) ; return $ list ; }
Returns an array of blog posts
55,567
public function review ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validateReview ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateTextReview ( ) ; $ this -> validateCreatedReview ( ) ; $ this -> validateProductReview ( ) ; $ this -> validateEmailReview ( ) ; $ this -> validateUserId ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
Performs full review data validation
55,568
protected function validateReview ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> review -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Review' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
Validates a review to be updated
55,569
protected function validateTextReview ( ) { $ field = 'text' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ label = $ this -> translation -> text ( 'Text' ) ; if ( empty ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ label ) ; return false ; } $ length = mb_strlen ( $ value ) ; list ( $ min , $ max ) = $ this -> review -> getLimits ( ) ; if ( $ length < $ min || $ length > $ max ) { $ this -> setErrorLengthRange ( $ field , $ label , $ min , $ max ) ; return false ; } return true ; }
Validates a review text
55,570
protected function validateCreatedReview ( ) { $ field = 'created' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ timestamp = strtotime ( $ value ) ; if ( empty ( $ timestamp ) ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Created' ) ) ; return false ; } $ this -> setSubmitted ( 'created' , $ timestamp ) ; return true ; }
Validates a created review date
55,571
public function executeCron ( ) { $ this -> controlAccessExecuteCron ( ) ; $ this -> cron -> run ( ) ; $ this -> response -> outputHtml ( $ this -> text ( 'Cron has started' ) ) ; }
Processes CRON requests
55,572
protected function controlAccessExecuteCron ( ) { if ( strcmp ( $ this -> getQuery ( 'key' , '' ) , $ this -> cron -> getKey ( ) ) !== 0 ) { $ this -> response -> outputError403 ( false ) ; } }
Controls access to execute CRON
55,573
public function listField ( ) { $ this -> actionListField ( ) ; $ this -> setTitleListField ( ) ; $ this -> setBreadcrumbListField ( ) ; $ this -> setFilterListField ( ) ; $ this -> setPagerListField ( ) ; $ this -> setData ( 'fields' , $ this -> getListField ( ) ) ; $ this -> setData ( 'widget_types' , $ this -> field -> getWidgetTypes ( ) ) ; $ this -> outputListField ( ) ; }
Displays the field overview page
55,574
protected function actionListField ( ) { list ( $ selected , $ action ) = $ this -> getPostedAction ( ) ; $ deleted = 0 ; foreach ( $ selected as $ field_id ) { if ( $ action === 'delete' && $ this -> access ( 'field_delete' ) ) { $ deleted += ( int ) $ this -> field -> delete ( $ field_id ) ; } } if ( $ deleted > 0 ) { $ message = $ this -> text ( 'Deleted %num item(s)' , array ( '%num' => $ deleted ) ) ; $ this -> setMessage ( $ message , 'success' ) ; } }
Applies an action to the selected fields
55,575
public function editField ( $ field_id = null ) { $ this -> setField ( $ field_id ) ; $ this -> setTitleEditField ( ) ; $ this -> setBreadcrumbEditField ( ) ; $ this -> setData ( 'field' , $ this -> data_field ) ; $ this -> setData ( 'types' , $ this -> field -> getTypes ( ) ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteField ( ) ) ; $ this -> setData ( 'widget_types' , $ this -> field -> getWidgetTypes ( ) ) ; $ this -> setData ( 'languages' , $ this -> language -> getList ( array ( 'enabled' => true ) ) ) ; $ this -> submitEditField ( ) ; $ this -> outputEditField ( ) ; }
Displays the field edit form
55,576
protected function submitEditField ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteField ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditField ( ) ) { if ( isset ( $ this -> data_field [ 'field_id' ] ) ) { $ this -> updateField ( ) ; } else { $ this -> addField ( ) ; } } }
Handles a submitted field data
55,577
protected function validateEditField ( ) { $ this -> setSubmitted ( 'field' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_field ) ; $ this -> validateComponent ( 'field' ) ; return ! $ this -> hasErrors ( ) ; }
Validates an array of submitted field data
55,578
protected function canDeleteField ( ) { return isset ( $ this -> data_field [ 'field_id' ] ) && $ this -> field -> canDelete ( $ this -> data_field [ 'field_id' ] ) && $ this -> access ( 'field_delete' ) ; }
Whether the field can be deleted
55,579
protected function deleteField ( ) { $ this -> controlAccess ( 'field_delete' ) ; if ( $ this -> field -> delete ( $ this -> data_field [ 'field_id' ] ) ) { $ this -> redirect ( 'admin/content/field' , $ this -> text ( 'Field has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Field has not been deleted' ) , 'warning' ) ; }
Deletes a field
55,580
protected function addField ( ) { $ this -> controlAccess ( 'field_add' ) ; if ( $ this -> field -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/content/field' , $ this -> text ( 'Field has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Field has not been added' ) , 'warning' ) ; }
Adds a new field
55,581
protected function setTitleEditField ( ) { if ( isset ( $ this -> data_field [ 'field_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_field [ 'title' ] ) ) ; } else { $ title = $ this -> text ( 'Add field' ) ; } $ this -> setTitle ( $ title ) ; }
Sets title on the field edit form
55,582
protected function setBreadcrumbEditField ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/content/field' ) , 'text' => $ this -> text ( 'Fields' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the field edit form
55,583
public function listCurrency ( ) { $ this -> setTitleListCurrency ( ) ; $ this -> setBreadcrumbListCurrency ( ) ; $ this -> setFilterListCurrency ( ) ; $ this -> setPagerListCurrency ( ) ; $ this -> setData ( 'currencies' , ( array ) $ this -> getListCurrency ( ) ) ; $ this -> setData ( 'default_currency' , $ this -> currency -> getDefault ( ) ) ; $ this -> outputListCurrency ( ) ; }
Displays the currency overview page
55,584
protected function getListCurrency ( $ count = false ) { $ currencies = $ this -> currency -> getList ( ) ; $ allowed = $ this -> getAllowedFiltersCurrency ( ) ; $ this -> filterList ( $ currencies , $ allowed , $ this -> query_filter ) ; $ this -> sortList ( $ currencies , $ allowed , $ this -> query_filter , array ( 'modified' => 'desc' ) ) ; if ( $ count ) { return count ( $ currencies ) ; } $ this -> limitList ( $ currencies , $ this -> data_limit ) ; return $ currencies ; }
Returns an array of sorted currencies
55,585
public function editCurrency ( $ code = null ) { $ this -> setCurrency ( $ code ) ; $ this -> setTitleEditCurrency ( ) ; $ this -> setBreadcrumbEditCurrency ( ) ; $ this -> setData ( 'edit' , isset ( $ code ) ) ; $ this -> setData ( 'currency' , $ this -> data_currency ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteCurrency ( ) ) ; $ this -> setData ( 'default_currency' , $ this -> currency -> getDefault ( ) ) ; $ this -> submitEditCurrency ( ) ; $ this -> outputEditCurrency ( ) ; }
Displays the currency edit form
55,586
protected function submitEditCurrency ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteCurrency ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditCurrency ( ) ) { if ( isset ( $ this -> data_currency [ 'code' ] ) ) { $ this -> updateCurrency ( ) ; } else { $ this -> addCurrency ( ) ; } } }
Handles a submitted currency data
55,587
protected function validateEditCurrency ( ) { $ this -> setSubmitted ( 'currency' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmittedBool ( 'default' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_currency ) ; $ this -> validateComponent ( 'currency' ) ; return ! $ this -> hasErrors ( ) ; }
Validates a submitted currency data
55,588
protected function setCurrency ( $ code ) { $ this -> data_currency = array ( ) ; if ( ! empty ( $ code ) ) { $ this -> data_currency = $ this -> currency -> get ( $ code ) ; if ( empty ( $ this -> data_currency ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
Set a currency data
55,589
protected function addCurrency ( ) { $ this -> controlAccess ( 'currency_add' ) ; if ( $ this -> currency -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/settings/currency' , $ this -> text ( 'Currency has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Currency has not been added' ) , 'warning' ) ; }
Adds a new currency
55,590
protected function setTitleEditCurrency ( ) { if ( isset ( $ this -> data_currency [ 'code' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_currency [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add currency' ) ; } $ this -> setTitle ( $ title ) ; }
Sets titles on the currency edit page
55,591
protected function setBreadcrumbEditCurrency ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/currency' ) , 'text' => $ this -> text ( 'Currencies' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
Sets breadcrumbs on the currency edit page
55,592
public function listCountry ( ) { $ this -> actionListCountry ( ) ; $ this -> setTitleListCountry ( ) ; $ this -> setBreadcrumbListCountry ( ) ; $ this -> setFilterListCountry ( ) ; $ this -> setPagerlListCountry ( ) ; $ this -> setData ( 'countries' , $ this -> getListCountry ( ) ) ; $ this -> outputListCountry ( ) ; }
Displays the country overview page
55,593
protected function actionListCountry ( ) { list ( $ selected , $ action , $ value ) = $ this -> getPostedAction ( ) ; $ updated = $ deleted = 0 ; foreach ( $ selected as $ code ) { if ( $ action === 'status' && $ this -> access ( 'country_edit' ) ) { $ updated += ( int ) $ this -> country -> update ( $ code , array ( 'status' => $ value ) ) ; } if ( $ action === 'delete' && $ this -> access ( 'country_delete' ) ) { $ deleted += ( int ) $ this -> country -> delete ( $ code ) ; } } if ( $ updated > 0 ) { $ message = $ this -> text ( 'Updated %num item(s)' , array ( '%num' => $ updated ) ) ; $ this -> setMessage ( $ message , 'success' ) ; } if ( $ deleted > 0 ) { $ message = $ this -> text ( 'Deleted %num item(s)' , array ( '%num' => $ deleted ) ) ; $ this -> setMessage ( $ message , 'success' ) ; } }
Applies an action to the selected countries
55,594
public function editCountry ( $ code = null ) { $ this -> setCountry ( $ code ) ; $ this -> setTitleEditCountry ( ) ; $ this -> setBreadcrumbEditCountry ( ) ; $ this -> setData ( 'code' , $ code ) ; $ this -> setData ( 'country' , $ this -> data_country ) ; $ this -> setData ( 'zones' , $ this -> getZonesCountry ( ) ) ; $ this -> setData ( 'can_delete' , $ this -> canDeleteCountry ( ) ) ; $ this -> submitEditCountry ( ) ; $ this -> outputEditCountry ( ) ; }
Displays the country edit form
55,595
protected function canDeleteCountry ( ) { return isset ( $ this -> data_country [ 'code' ] ) && $ this -> access ( 'country_delete' ) && $ this -> country -> canDelete ( $ this -> data_country [ 'code' ] ) ; }
Whether the current country can be deleted
55,596
protected function setCountry ( $ country_code ) { $ this -> data_country = array ( ) ; if ( ! empty ( $ country_code ) ) { $ this -> data_country = $ this -> country -> get ( $ country_code ) ; if ( empty ( $ this -> data_country ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
Set an array of country data
55,597
protected function submitEditCountry ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteCountry ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditCountry ( ) ) { if ( isset ( $ this -> data_country [ 'code' ] ) ) { $ this -> updateCountry ( ) ; } else { $ this -> addCountry ( ) ; } } }
Saves a submitted country data
55,598
protected function validateEditCountry ( ) { $ this -> setSubmitted ( 'country' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_country ) ; $ this -> validateComponent ( 'country' ) ; return ! $ this -> hasErrors ( ) ; }
Validates a submitted country data
55,599
protected function deleteCountry ( ) { $ this -> controlAccess ( 'country_delete' ) ; if ( $ this -> country -> delete ( $ this -> data_country [ 'code' ] ) ) { $ this -> redirect ( 'admin/settings/country' , $ this -> text ( 'Country has been deleted' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Country has not been deleted' ) , 'warning' ) ; }
Deletes a country