idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
55,600
|
protected function updateCountry ( ) { $ this -> controlAccess ( 'country_edit' ) ; if ( $ this -> country -> update ( $ this -> data_country [ 'code' ] , $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/settings/country' , $ this -> text ( 'Country has been updated' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Country has not been updated' ) , 'warning' ) ; }
|
Updates a country
|
55,601
|
protected function addCountry ( ) { $ this -> controlAccess ( 'country_add' ) ; if ( $ this -> country -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/settings/country' , $ this -> text ( 'Country has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Country has not been added' ) , 'warning' ) ; }
|
Adds a new country
|
55,602
|
protected function setTitleEditCountry ( ) { if ( isset ( $ this -> data_country [ 'name' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_country [ 'name' ] ) ) ; } else { $ title = $ this -> text ( 'Add country' ) ; } $ this -> setTitle ( $ title ) ; }
|
Sets titles on the country edit page
|
55,603
|
protected function setBreadcrumbEditCountry ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/settings/country' ) , 'text' => $ this -> text ( 'Countries' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the country edit page
|
55,604
|
public function formatCountry ( $ country_code ) { $ this -> setCountry ( $ country_code ) ; $ this -> setTitleFormatCountry ( ) ; $ this -> setBreadcrumbFormatCountry ( ) ; $ this -> setData ( 'format' , $ this -> data_country [ 'format' ] ) ; $ this -> submitFormatCountry ( ) ; $ this -> outputFormatCountry ( ) ; }
|
Displays address format items for the given country
|
55,605
|
protected function updateFormatCountry ( ) { $ format = $ this -> getSubmitted ( ) ; foreach ( $ format as $ id => & $ item ) { $ item [ 'status' ] = isset ( $ item [ 'status' ] ) ; $ item [ 'required' ] = isset ( $ item [ 'required' ] ) ; if ( $ id === 'country' ) { $ item [ 'status' ] = 1 ; $ item [ 'required' ] = 1 ; } if ( $ item [ 'required' ] ) { $ item [ 'status' ] = 1 ; } } if ( $ this -> country -> update ( $ this -> data_country [ 'code' ] , array ( 'format' => $ format ) ) ) { $ this -> redirect ( 'admin/settings/country' , $ this -> text ( 'Country has been updated' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Country has not been updated' ) , 'warning' ) ; }
|
Updates a country format
|
55,606
|
protected function setBreadcrumbFormatCountry ( ) { $ 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/country/edit/{$this->data_country['code']}" ) , 'text' => $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> data_country [ 'name' ] ) ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the country format edit page
|
55,607
|
public function createdToAdmin ( $ order ) { $ store = $ this -> store -> get ( $ order [ 'store_id' ] ) ; $ store_name = $ this -> store -> getTranslation ( 'title' , $ this -> translation -> getLangcode ( ) , $ store ) ; $ options = array ( 'from' => reset ( $ store [ 'data' ] [ 'email' ] ) ) ; $ default = ( array ) $ this -> store -> getDefault ( true ) ; $ url = $ this -> store -> getUrl ( $ default ) ; $ vars = array ( '@store' => $ store_name , '@order_id' => $ order [ 'order_id' ] , '@order' => "$url/admin/sale/order/{$order['order_id']}" , '@status' => $ this -> order -> getStatusName ( $ order [ 'status' ] ) , '@total' => $ this -> price -> format ( $ order [ 'total' ] , $ order [ 'currency' ] ) , ) ; $ subject = $ this -> translation -> text ( 'New order #@order_id on @store' , $ vars ) ; $ message = $ this -> translation -> text ( "Order status: @status\r\nTotal: @total\r\nView: @order" , $ vars ) ; return array ( $ options [ 'from' ] , $ subject , $ message , $ options ) ; }
|
Sends an email to admin after a customer created an order
|
55,608
|
public function createdToCustomer ( $ order ) { $ store = $ this -> store -> get ( $ order [ 'store_id' ] ) ; $ url = $ this -> store -> getUrl ( $ store ) ; $ user = $ this -> user -> get ( $ order [ 'user_id' ] ) ; $ store_name = $ this -> store -> getTranslation ( 'title' , $ this -> translation -> getLangcode ( ) , $ store ) ; $ options = $ this -> store -> getConfig ( null , $ store ) ; $ options [ 'from' ] = reset ( $ store [ 'data' ] [ 'email' ] ) ; $ vars = array ( '@store' => $ store_name , '@order_id' => $ order [ 'order_id' ] , '@order' => "$url/account/{$order['user_id']}" , '@status' => $ this -> order -> getStatusName ( $ order [ 'status' ] ) , ) ; $ subject = $ this -> translation -> text ( 'Order #@order_id on @store' , $ vars ) ; $ message = $ this -> translation -> text ( "Thank you for ordering on @store\r\n\r\nOrder ID: @order_id\r\nOrder status: @status\r\nView orders: @order" , $ vars ) ; $ message .= $ this -> getSignature ( $ options ) ; return array ( $ user [ 'email' ] , $ subject , $ message , $ options ) ; }
|
Sends an email to a logged in customer after his order has been created
|
55,609
|
public function add ( array $ product , array $ data ) { $ result = array ( ) ; $ this -> hook -> attach ( 'cart.add.product.before' , $ product , $ data , $ result , $ this ) ; if ( ! empty ( $ result ) ) { return ( array ) $ result ; } $ data += array ( 'quantity' => 1 , 'user_id' => $ this -> cart -> getUid ( ) , 'store_id' => $ product [ 'store_id' ] , 'product_id' => $ product [ 'product_id' ] ) ; $ data [ 'cart_id' ] = $ this -> set ( $ data ) ; if ( empty ( $ data [ 'cart_id' ] ) ) { return $ this -> getResultError ( ) ; } $ result = $ this -> getResultAdded ( $ data ) ; $ this -> hook -> attach ( 'cart.add.product.after' , $ product , $ data , $ result , $ this ) ; return ( array ) $ result ; }
|
Adds the product to the cart
|
55,610
|
public function toWishlist ( $ cart_id ) { $ result = null ; $ this -> hook -> attach ( 'cart.move.wishlist.before' , $ cart_id , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( array ) $ result ; } $ cart = $ this -> cart -> get ( $ cart_id ) ; if ( empty ( $ cart ) || ! $ this -> cart -> delete ( $ cart_id ) ) { return $ this -> getResultError ( ) ; } $ result = $ this -> addToWishlist ( $ cart ) ; gplcart_static_clear ( ) ; $ this -> hook -> attach ( 'cart.move.wishlist.after' , $ data , $ result , $ this ) ; return ( array ) $ result ; }
|
Moves a cart item to a wishlist
|
55,611
|
public function delete ( $ cart_id ) { $ result = array ( ) ; $ this -> hook -> attach ( 'cart.delete.item.before' , $ cart_id , $ result , $ this ) ; if ( ! empty ( $ result ) ) { return ( array ) $ result ; } $ cart = $ this -> cart -> get ( $ cart_id ) ; if ( empty ( $ cart ) || ! $ this -> cart -> delete ( $ cart_id ) ) { return $ this -> getResultError ( ) ; } $ result = $ this -> getResultDelete ( $ cart ) ; $ this -> hook -> attach ( 'cart.delete.item.after' , $ cart_id , $ result , $ this ) ; return $ result ; }
|
Deletes a cart item
|
55,612
|
public function login ( array $ user , array $ cart ) { $ result = array ( ) ; $ this -> hook -> attach ( 'cart.login.before' , $ user , $ cart , $ result , $ this ) ; if ( ! empty ( $ result ) ) { return ( array ) $ result ; } if ( ! $ this -> config -> get ( 'cart_login_merge' , 0 ) ) { $ this -> cart -> delete ( array ( 'user_id' => $ user [ 'user_id' ] ) ) ; } if ( ! empty ( $ cart [ 'items' ] ) ) { foreach ( $ cart [ 'items' ] as $ item ) { $ this -> cart -> update ( $ item [ 'cart_id' ] , array ( 'user_id' => $ user [ 'user_id' ] ) ) ; } } $ this -> cart -> deleteCookie ( ) ; $ result = $ this -> getResultLogin ( $ user ) ; $ this -> hook -> attach ( 'cart.login.after' , $ user , $ cart , $ result , $ this ) ; return ( array ) $ result ; }
|
Performs all needed tasks when customer is logging in during checkout
|
55,613
|
protected function addToWishlist ( array $ cart ) { $ data = array ( 'user_id' => $ cart [ 'user_id' ] , 'store_id' => $ cart [ 'store_id' ] , 'product_id' => $ cart [ 'product_id' ] ) ; return $ this -> wishlist_action -> add ( $ data ) ; }
|
Adds a product to the wishlist
|
55,614
|
protected function getResultDelete ( array $ cart ) { $ options = array ( 'user_id' => $ cart [ 'user_id' ] , 'store_id' => $ cart [ 'store_id' ] , ) ; $ content = $ this -> cart -> getContent ( $ options ) ; return array ( 'redirect' => '' , 'severity' => 'success' , 'quantity' => empty ( $ content [ 'quantity' ] ) ? 0 : $ content [ 'quantity' ] , 'message' => $ this -> translation -> text ( 'Product has been deleted from cart' ) ) ; }
|
Returns an array of resulting data after a product has been deleted from a cart
|
55,615
|
protected function getResultAdded ( array $ data ) { $ options = array ( 'user_id' => $ data [ 'user_id' ] , 'store_id' => $ data [ 'store_id' ] ) ; $ vars = array ( '@url' => $ this -> url -> get ( 'checkout' ) ) ; $ message = $ this -> translation -> text ( 'Product has been added to your cart. <a href="@url">Checkout</a>' , $ vars ) ; return array ( 'redirect' => '' , 'message' => $ message , 'severity' => 'success' , 'cart_id' => $ data [ 'cart_id' ] , 'quantity' => $ this -> cart -> getQuantity ( $ options , 'total' ) ) ; }
|
Returns an array of resulting data after a product has been added to a cart
|
55,616
|
public function getTriggered ( array $ data = array ( ) , array $ options = array ( ) ) { $ options += array ( 'status' => 1 ) ; $ triggers = ( array ) $ this -> getList ( $ options ) ; if ( empty ( $ triggers ) ) { return array ( ) ; } $ triggered = array ( ) ; foreach ( $ triggers as $ trigger ) { if ( $ this -> condition -> isMet ( $ trigger , $ data ) ) { $ triggered [ ] = $ trigger [ 'trigger_id' ] ; } } return $ triggered ; }
|
Returns an array of triggered IDs for the given context
|
55,617
|
protected function prepareList ( array $ list ) { foreach ( $ list as & $ item ) { if ( ! empty ( $ item [ 'data' ] [ 'conditions' ] ) ) { gplcart_array_sort ( $ item [ 'data' ] [ 'conditions' ] ) ; } } return $ list ; }
|
Prepare an array of triggers
|
55,618
|
protected function validateAddToWishlist ( ) { $ this -> setSubmitted ( 'user_id' , $ this -> getCartUid ( ) ) ; $ this -> setSubmitted ( 'store_id' , $ this -> getStoreId ( ) ) ; $ this -> validateComponent ( 'wishlist' ) ; }
|
Validates adding a submitted product to the wishlist
|
55,619
|
public function addToWishlist ( $ wishlist_action_model ) { $ errors = $ this -> error ( ) ; if ( empty ( $ errors ) ) { $ result = $ wishlist_action_model -> add ( $ this -> getSubmitted ( ) ) ; } else { $ result = array ( 'redirect' => '' , 'severity' => 'warning' , 'message' => $ this -> format ( $ errors ) ) ; } if ( $ this -> isAjax ( ) ) { $ this -> outputJson ( $ result ) ; } $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
|
Add a product to the wishlist
|
55,620
|
public function deleteFromWishlist ( $ wishlist_action_model ) { $ product = array ( 'user_id' => $ this -> getCartUid ( ) , 'store_id' => $ this -> getStoreId ( ) , 'product_id' => $ this -> getSubmitted ( 'product_id' ) ) ; $ result = $ wishlist_action_model -> delete ( $ product ) ; if ( $ this -> isAjax ( ) ) { $ this -> outputJson ( $ result ) ; } $ this -> redirect ( $ result [ 'redirect' ] , $ result [ 'message' ] , $ result [ 'severity' ] ) ; }
|
Deletes a submitted product from the wishlist
|
55,621
|
public function listReview ( ) { $ this -> actionListReview ( ) ; $ this -> setTitleListReview ( ) ; $ this -> setBreadcrumbListReview ( ) ; $ this -> setFilterListReview ( ) ; $ this -> setPagerListReview ( ) ; $ this -> setData ( 'reviews' , $ this -> getListReview ( ) ) ; $ this -> outputListReview ( ) ; }
|
Displays the reviews overview page
|
55,622
|
public function editReview ( $ review_id = null ) { $ this -> setReview ( $ review_id ) ; $ this -> setTitleEditReview ( ) ; $ this -> setBreadcrumbEditReview ( ) ; $ this -> setData ( 'review' , $ this -> data_review ) ; $ this -> submitEditReview ( ) ; $ this -> setDataUserEditReview ( ) ; $ this -> setDataProductEditReview ( ) ; $ this -> outputEditReview ( ) ; }
|
Displays the review edit form
|
55,623
|
protected function setReview ( $ review_id ) { $ this -> data_review = array ( ) ; if ( is_numeric ( $ review_id ) ) { $ this -> data_review = $ this -> review -> get ( $ review_id ) ; if ( empty ( $ this -> data_review ) ) { $ this -> outputHttpStatus ( 404 ) ; } } }
|
Set a review data
|
55,624
|
protected function submitEditReview ( ) { if ( $ this -> isPosted ( 'delete' ) ) { $ this -> deleteReview ( ) ; } else if ( $ this -> isPosted ( 'save' ) && $ this -> validateEditReview ( ) ) { if ( isset ( $ this -> data_review [ 'review_id' ] ) ) { $ this -> updateReview ( ) ; } else { $ this -> addReview ( ) ; } } }
|
Handles a submitted review
|
55,625
|
protected function validateEditReview ( ) { $ this -> setSubmitted ( 'review' ) ; $ this -> setSubmittedBool ( 'status' ) ; $ this -> setSubmitted ( 'update' , $ this -> data_review ) ; $ this -> validateComponent ( 'review' ) ; return ! $ this -> hasErrors ( ) ; }
|
Validates a submitted review
|
55,626
|
protected function addReview ( ) { $ this -> controlAccess ( 'review_add' ) ; if ( $ this -> review -> add ( $ this -> getSubmitted ( ) ) ) { $ this -> redirect ( 'admin/content/review' , $ this -> text ( 'Review has been added' ) , 'success' ) ; } $ this -> redirect ( '' , $ this -> text ( 'Review has not been added' ) , 'warning' ) ; }
|
Adds a new review
|
55,627
|
protected function setDataUserEditReview ( ) { $ user = $ this -> user -> get ( $ this -> getData ( 'review.user_id' ) ) ; if ( isset ( $ user [ 'email' ] ) ) { $ this -> setData ( 'review.email' , $ user [ 'email' ] ) ; } }
|
Set user template data
|
55,628
|
protected function setDataProductEditReview ( ) { $ product_id = $ this -> getData ( 'review.product_id' ) ; $ products = array ( ) ; if ( ! empty ( $ product_id ) ) { $ product = $ this -> product -> get ( $ product_id ) ; $ options = array ( 'entity' => 'product' , 'entity_id' => $ product_id , 'template_item' => 'backend|content/product/suggestion' ) ; $ this -> setItemThumb ( $ product , $ this -> image , $ options ) ; $ this -> setItemPriceFormatted ( $ product , $ this -> price ) ; $ this -> setItemRendered ( $ product , array ( 'item' => $ product ) , $ options ) ; $ products = array ( $ product ) ; } $ widget = array ( 'multiple' => false , 'products' => $ products , 'name' => 'review[product_id]' , 'error' => $ this -> error ( 'product_id' ) ) ; $ this -> setData ( 'product_picker' , $ this -> getWidgetProductPicker ( $ widget ) ) ; }
|
Set product template data
|
55,629
|
protected function setTitleEditReview ( ) { if ( isset ( $ this -> data_review [ 'review_id' ] ) ) { $ title = $ this -> text ( 'Edit %name' , array ( '%name' => $ this -> text ( 'Review' ) ) ) ; } else { $ title = $ this -> text ( 'Add review' ) ; } $ this -> setTitle ( $ title ) ; }
|
Sets title on the edit review page
|
55,630
|
protected function setBreadcrumbEditReview ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'text' => $ this -> text ( 'Reviews' ) , 'url' => $ this -> url ( 'admin/content/review' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the edit review page
|
55,631
|
public function zoneId ( array $ condition , array $ data , $ key ) { if ( isset ( $ data [ 'data' ] [ 'order' ] [ $ key ] ) ) { return $ this -> checkZoneIdByAddressId ( $ condition , $ data , $ key ) ; } return $ this -> checkZoneIdByAddressData ( $ condition , $ data ) ; }
|
Whether the zone ID condition is met
|
55,632
|
public function countryCode ( array $ condition , array $ data , $ key ) { if ( ! empty ( $ data [ 'data' ] [ 'address' ] [ 'country' ] ) ) { $ country = $ data [ 'data' ] [ 'address' ] [ 'country' ] ; return $ this -> compare ( $ country , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; } if ( empty ( $ data [ 'data' ] [ 'order' ] [ $ key ] ) ) { return false ; } $ address = $ this -> address -> get ( $ data [ 'data' ] [ 'order' ] [ $ key ] ) ; if ( empty ( $ address [ 'country' ] ) ) { return false ; } return $ this -> compare ( $ address [ 'country' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the country condition is met
|
55,633
|
public function stateId ( array $ condition , array $ data , $ key ) { if ( isset ( $ data [ 'data' ] [ 'address' ] [ 'state_id' ] ) ) { $ state_id = $ data [ 'data' ] [ 'address' ] [ 'state_id' ] ; return $ this -> compare ( $ state_id , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; } if ( ! isset ( $ data [ 'data' ] [ 'order' ] [ $ key ] ) ) { return false ; } $ address = $ this -> address -> get ( $ data [ 'data' ] [ 'order' ] [ $ key ] ) ; if ( empty ( $ address [ 'state_id' ] ) ) { return false ; } return $ this -> compare ( $ address [ 'state_id' ] , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the state ID condition is met
|
55,634
|
protected function checkZoneIdByAddressId ( $ condition , $ data , $ key ) { $ address = $ this -> address -> get ( $ data [ 'data' ] [ 'order' ] [ $ key ] ) ; if ( empty ( $ address ) ) { return false ; } $ fields = array ( 'country_zone_id' , 'state_zone_id' , 'city_zone_id' ) ; $ ids = array ( ) ; foreach ( $ fields as $ field ) { $ ids [ ] = $ address [ $ field ] ; } return $ this -> compare ( $ ids , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the state ID condition is met using an existing address
|
55,635
|
protected function checkZoneIdByAddressData ( $ condition , $ data ) { if ( empty ( $ data [ 'data' ] [ 'order' ] [ 'address' ] ) ) { return false ; } $ ids = $ this -> getAddressZoneId ( $ data [ 'data' ] [ 'order' ] [ 'address' ] ) ; return $ this -> compare ( $ ids , $ condition [ 'value' ] , $ condition [ 'operator' ] ) ; }
|
Whether the state ID condition is met using form fields
|
55,636
|
protected function getAddressZoneId ( array $ address ) { $ result = array ( ) ; foreach ( array ( 'state_id' , 'city_id' , 'country' ) as $ field ) { if ( empty ( $ address [ $ field ] ) ) { continue ; } if ( $ field === 'city_id' ) { $ data = $ this -> city -> get ( $ address [ $ field ] ) ; } else if ( $ field === 'state_id' ) { $ data = $ this -> state -> get ( $ address [ $ field ] ) ; } else if ( $ field === 'country' ) { $ data = $ this -> country -> get ( $ address [ $ field ] ) ; } if ( ! empty ( $ data [ 'zone_id' ] ) ) { $ result [ ] = $ data [ 'zone_id' ] ; } } return $ result ; }
|
Returns an array of zone IDs from address components
|
55,637
|
public function setRule ( $ rule , $ replacement ) { if ( is_array ( $ rule ) ) { $ this -> rules = $ rule ; return $ this ; } $ this -> rules [ $ rule ] = $ replacement ; return $ this ; }
|
Adds a rule
|
55,638
|
public function render ( $ text ) { $ text = trim ( str_replace ( array ( "\r\n" , "\r" ) , "\n" , $ text ) , "\n" ) ; foreach ( $ this -> rules as $ regex => $ replacement ) { if ( is_callable ( $ replacement ) ) { $ text = preg_replace_callback ( $ regex , $ replacement , $ text ) ; } else { $ text = preg_replace ( $ regex , $ replacement , $ text ) ; } } return trim ( $ text ) ; }
|
Renders Markdown text into HTML
|
55,639
|
protected static function p ( array $ matches ) { $ line = $ matches [ 1 ] ; $ trimmed = trim ( $ line ) ; if ( preg_match ( '/^<\/?(ul|ol|li|h|p|bl)/' , $ trimmed ) ) { return "\n$line\n" ; } return sprintf ( "\n<p>%s</p>\n" , $ trimmed ) ; }
|
Renders P tag
|
55,640
|
protected static function h ( array $ matches ) { $ level = strlen ( $ matches [ 1 ] ) ; return sprintf ( '<h%d>%s</h%d>' , $ level , trim ( $ matches [ 2 ] ) , $ level ) ; }
|
Renders H tag
|
55,641
|
public function getThumb ( array $ data , array $ options ) { $ options += array ( 'placeholder' => true , 'imagestyle' => $ this -> config -> get ( 'image_style' , 3 ) ) ; if ( empty ( $ options [ 'entity_id' ] ) ) { return empty ( $ options [ 'placeholder' ] ) ? '' : $ this -> getPlaceholder ( $ options [ 'imagestyle' ] ) ; } $ conditions = array ( 'entity' => $ options [ 'entity' ] , 'entity_id' => $ options [ 'entity_id' ] ) ; foreach ( $ this -> getList ( $ conditions ) as $ file ) { if ( isset ( $ data [ $ options [ 'entity' ] . '_id' ] ) && $ file [ 'entity_id' ] == $ data [ $ options [ 'entity' ] . '_id' ] ) { return $ this -> getUrl ( $ file [ 'path' ] , $ options [ 'imagestyle' ] ) ; } } return empty ( $ options [ 'placeholder' ] ) ? '' : $ this -> getPlaceholder ( $ options [ 'imagestyle' ] ) ; }
|
Returns a string containing a thumbnail image URL
|
55,642
|
public function getPlaceholder ( $ imagestyle_id = null , $ absolute = false ) { $ placeholder = $ this -> getPlaceholderPath ( ) ; return $ this -> getUrl ( $ placeholder , $ imagestyle_id , $ absolute ) ; }
|
Returns a string containing image placeholder URL
|
55,643
|
public function getUrl ( $ path , $ imagestyle_id = null , $ absolute = false ) { if ( empty ( $ path ) ) { return $ this -> getPlaceholder ( $ imagestyle_id , $ absolute ) ; } if ( isset ( $ imagestyle_id ) ) { $ suffix = preg_replace ( '/^image\//' , '' , gplcart_path_normalize ( $ path ) ) ; $ path = GC_DIR_IMAGE_CACHE . "/$imagestyle_id/$suffix" ; } return $ this -> url -> image ( $ path ) ; }
|
Returns a string containing the image cache URL
|
55,644
|
public function registeredToAdmin ( array $ user ) { $ store = $ this -> store -> get ( $ user [ 'store_id' ] ) ; $ vars = array ( '@name' => $ user [ 'name' ] , '@store' => $ store [ 'name' ] , '@email' => $ user [ 'email' ] , '@user_id' => $ user [ 'user_id' ] , '@status' => empty ( $ user [ 'status' ] ) ? $ this -> translation -> text ( 'Inactive' ) : $ this -> translation -> text ( 'Active' ) ) ; $ subject = $ this -> translation -> text ( 'New account on @store' , $ vars ) ; $ message = $ this -> translation -> text ( "A new account has been created on @store\r\n\r\nE-mail: @email\r\nName: @name\r\nUser ID: @user_id\r\nStatus: @status" , $ vars ) ; $ options = array ( 'from' => $ this -> store -> getConfig ( 'email.0' , $ store ) ) ; return array ( $ options [ 'from' ] , $ subject , $ message , $ options ) ; }
|
Sent to an admin when a user has been registered
|
55,645
|
public function registeredToCustomer ( array $ user ) { $ store = $ this -> store -> get ( $ user [ 'store_id' ] ) ; $ options = $ this -> store -> getConfig ( null , $ store ) ; $ store_name = $ this -> store -> getTranslation ( 'title' , $ this -> translation -> getLangcode ( ) , $ store ) ; $ base = $ this -> store -> getUrl ( $ store ) ; $ vars = array ( '@store' => $ store_name , '@name' => $ user [ 'name' ] , '@order' => "$base/account/{$user['user_id']}" , '@edit' => "$base/account/{$user['user_id']}/edit" , '@status' => empty ( $ user [ 'status' ] ) ? $ this -> translation -> text ( 'Inactive' ) : $ this -> translation -> text ( 'Active' ) ) ; $ subject = $ this -> translation -> text ( 'Account details for @name on @store' , $ vars ) ; $ message = $ this -> translation -> text ( "Thank you for registering on @store\r\n\r\nAccount status: @status\r\n\r\nEdit account: @edit\r\nView orders: @order" , $ vars ) ; $ message .= $ this -> getSignature ( $ options ) ; $ options [ 'from' ] = $ this -> store -> getConfig ( 'email.0' , $ store ) ; return array ( $ user [ 'email' ] , $ subject , $ message , $ options ) ; }
|
Sent to the user when his account has been created
|
55,646
|
public function resetPassword ( array $ user ) { $ store = $ this -> store -> get ( $ user [ 'store_id' ] ) ; $ options = $ this -> store -> getConfig ( null , $ store ) ; $ store_name = $ this -> store -> getTranslation ( 'title' , $ this -> translation -> getLangcode ( ) , $ store ) ; $ base = $ this -> store -> getUrl ( $ store ) ; $ date_format = $ this -> config -> get ( 'date_full_format' , 'd.m.Y H:i' ) ; $ vars = array ( '@name' => $ user [ 'name' ] , '@store' => $ store_name , '@expires' => date ( $ date_format , $ user [ 'data' ] [ 'reset_password' ] [ 'expires' ] ) , '@link' => "$base/forgot?" . http_build_query ( array ( 'key' => $ user [ 'data' ] [ 'reset_password' ] [ 'token' ] , 'user_id' => $ user [ 'user_id' ] ) ) , ) ; $ subject = $ this -> translation -> text ( 'Password recovery for @name on @store' , $ vars ) ; $ message = $ this -> translation -> text ( "You or someone else requested a new password on @store\r\n\r\nTo get the password please click on the following link:\r\n@link\r\n\r\nThis link expires on @expires and nothing will happen if it's not used" , $ vars ) ; $ message .= $ this -> getSignature ( $ options ) ; $ options [ 'from' ] = $ this -> store -> getConfig ( 'email.0' , $ store ) ; return array ( $ user [ 'email' ] , $ subject , $ message , $ options ) ; }
|
Sent when a user wants to reset his password
|
55,647
|
public function changedPassword ( array $ user ) { $ store = $ this -> store -> get ( $ user [ 'store_id' ] ) ; $ options = $ this -> store -> getConfig ( null , $ store ) ; $ store_name = $ this -> store -> getTranslation ( 'title' , $ this -> translation -> getLangcode ( ) , $ store ) ; $ vars = array ( '@store' => $ store_name , '@name' => $ user [ 'name' ] ) ; $ subject = $ this -> translation -> text ( 'Password has been changed for @name on @store' , $ vars ) ; $ message = $ this -> translation -> text ( 'Your password on @store has been changed' , $ vars ) ; $ message .= $ this -> getSignature ( $ options ) ; $ options [ 'from' ] = $ this -> store -> getConfig ( 'email.0' , $ store ) ; return array ( $ user [ 'email' ] , $ subject , $ message , $ options ) ; }
|
Sent to the user whose password has been changed
|
55,648
|
public function getList ( array $ options = array ( ) ) { $ options += array ( 'index' => 'product_bundle_id' ) ; $ result = & gplcart_static ( gplcart_array_hash ( array ( 'product.bundle.list' => $ options ) ) ) ; if ( isset ( $ result ) ) { return $ result ; } $ this -> hook -> attach ( 'product.bundle.list.before' , $ options , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ conditions = array ( ) ; $ sql = 'SELECT pb.*, p.store_id FROM product_bundle pb LEFT JOIN product p ON(pb.product_id = p.product_id) LEFT JOIN product p2 ON(pb.item_product_id = p2.product_id)' ; if ( isset ( $ options [ 'product_bundle_id' ] ) ) { $ sql .= ' WHERE pb.product_bundle_id = ?' ; $ conditions [ ] = $ options [ 'product_bundle_id' ] ; } else { $ sql .= ' WHERE pb.product_bundle_id IS NOT NULL' ; } if ( isset ( $ options [ 'store_id' ] ) ) { $ sql .= ' AND p.store_id = ? AND p2.store_id = ?' ; $ conditions [ ] = $ options [ 'store_id' ] ; $ conditions [ ] = $ options [ 'store_id' ] ; } if ( isset ( $ options [ 'status' ] ) ) { $ sql .= ' AND p.status = ? AND p2.status = ?' ; $ conditions [ ] = ( int ) $ options [ 'status' ] ; $ conditions [ ] = ( int ) $ options [ 'status' ] ; } if ( isset ( $ options [ 'product_id' ] ) ) { $ sql .= ' AND pb.product_id = ?' ; $ conditions [ ] = $ options [ 'product_id' ] ; } if ( ! empty ( $ options [ 'limit' ] ) ) { $ sql .= ' LIMIT ' . implode ( ',' , array_map ( 'intval' , $ options [ 'limit' ] ) ) ; } $ result = $ this -> db -> fetchAll ( $ sql , $ conditions , array ( 'index' => $ options [ 'index' ] ) ) ; $ this -> hook -> attach ( 'product.bundle.list.after' , $ options , $ result , $ this ) ; return $ result ; }
|
Returns an array of bundled products
|
55,649
|
public function set ( $ product_id , array $ products ) { $ this -> delete ( array ( 'product_id' => $ product_id ) ) ; $ added = $ count = 0 ; foreach ( $ products as $ product ) { $ count ++ ; $ data = array ( 'product_id' => $ product_id , 'item_product_id' => $ product [ 'product_id' ] ) ; if ( $ this -> add ( $ data ) ) { $ added ++ ; } } return $ count && $ added == $ count ; }
|
Delete old and add new bundled items for the product
|
55,650
|
public function getItems ( $ product_id ) { $ product_ids = array ( ) ; foreach ( $ this -> getList ( array ( 'product_id' => $ product_id ) ) as $ item ) { $ product_ids [ ] = $ item [ 'item_product_id' ] ; } return $ product_ids ; }
|
Returns an array of bundled product IDs for the product
|
55,651
|
public function outputCacheImage ( ) { try { $ this -> setUrlPathImage ( ) ; $ this -> setFileImage ( ) ; $ this -> setDirectoryImage ( ) ; $ this -> tryOutputImage ( ) ; $ this -> checkCacheDirectoryImage ( ) ; $ this -> applyActionsImage ( ) ; $ this -> tryOutputImage ( ) ; } catch ( Exception $ ex ) { $ this -> response -> outputError404 ( false ) ; } }
|
Outputs processed images
|
55,652
|
protected function setUrlPathImage ( ) { $ parts = explode ( 'files/image/cache/' , urldecode ( strtok ( $ this -> server -> requestUri ( ) , '?' ) ) ) ; if ( empty ( $ parts [ 1 ] ) ) { throw new OutOfRangeException ( 'Second segment is empty in the image cache path' ) ; } $ parts = explode ( '/' , $ parts [ 1 ] ) ; if ( empty ( $ parts [ 1 ] ) ) { throw new OutOfRangeException ( 'Second segment is empty in the image cache path' ) ; } $ this -> data_imagestyle_id = array_shift ( $ parts ) ; if ( $ parts [ 0 ] == 'image' ) { unset ( $ parts [ 0 ] ) ; } $ this -> data_path = implode ( '/' , $ parts ) ; }
|
Parse the current URL path
|
55,653
|
protected function setDirectoryImage ( ) { $ imagestyle_directory = GC_DIR_IMAGE_CACHE . "/$this->data_imagestyle_id" ; $ image_directory = pathinfo ( $ this -> data_path , PATHINFO_DIRNAME ) ; if ( ! empty ( $ image_directory ) ) { $ imagestyle_directory = GC_DIR_IMAGE_CACHE . "/$this->data_imagestyle_id/$image_directory" ; } $ this -> data_imagestyle_directory = $ imagestyle_directory ; $ this -> data_cached_file = "$imagestyle_directory/" . basename ( $ this -> data_path ) ; }
|
Set the current image style directory
|
55,654
|
protected function tryOutputImage ( ) { if ( is_file ( $ this -> data_cached_file ) ) { $ this -> response -> addHeader ( 'Last-Modified' , gmdate ( 'D, d M Y H:i:s T' , filemtime ( $ this -> data_cached_file ) ) ) -> addHeader ( 'Content-Length' , filesize ( $ this -> data_cached_file ) ) -> addHeader ( 'Content-type' , mime_content_type ( $ this -> data_cached_file ) ) -> sendHeaders ( ) ; readfile ( $ this -> data_cached_file ) ; exit ; } }
|
Try to output existing image
|
55,655
|
protected function applyActionsImage ( ) { $ actions = $ this -> image_style -> getActions ( $ this -> data_imagestyle_id ) ; if ( empty ( $ actions ) ) { throw new RuntimeException ( 'No image style actions to apply' ) ; } $ this -> image_style -> applyActions ( $ actions , $ this -> data_source_file , $ this -> data_cached_file ) ; }
|
Apply all defined actions to the source image
|
55,656
|
public function priceRule ( array & $ submitted , array $ options = array ( ) ) { $ this -> options = $ options ; $ this -> submitted = & $ submitted ; $ this -> validatePriceRule ( ) ; $ this -> validateName ( ) ; $ this -> validateWeight ( ) ; $ this -> validateBool ( 'status' ) ; $ this -> validateUsedPriceRule ( ) ; $ this -> validateTriggerPriceRule ( ) ; $ this -> validateCurrencyPriceRule ( ) ; $ this -> validateValueTypePriceRule ( ) ; $ this -> validateCodePriceRule ( ) ; $ this -> validateValuePriceRule ( ) ; $ this -> unsetSubmitted ( 'update' ) ; return $ this -> getResult ( ) ; }
|
Performs full price rule validation
|
55,657
|
protected function validatePriceRule ( ) { $ id = $ this -> getUpdatingId ( ) ; if ( $ id === false ) { return null ; } $ data = $ this -> price_rule -> get ( $ id ) ; if ( empty ( $ data ) ) { $ this -> setErrorUnavailable ( 'update' , $ this -> translation -> text ( 'Price rule' ) ) ; return false ; } $ this -> setUpdating ( $ data ) ; return true ; }
|
Validates a price rule to be updated
|
55,658
|
protected function validateValueTypePriceRule ( ) { $ field = 'value_type' ; if ( $ this -> isExcluded ( $ field ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } $ types = $ this -> price_rule -> getTypes ( ) ; if ( empty ( $ types [ $ value ] ) ) { $ this -> setErrorInvalid ( $ field , $ this -> translation -> text ( 'Value type' ) ) ; return false ; } return true ; }
|
Validates a price rule value type
|
55,659
|
protected function validateCodePriceRule ( ) { $ field = 'code' ; $ value = $ this -> getSubmitted ( $ field ) ; if ( empty ( $ value ) ) { return null ; } $ updating = $ this -> getUpdating ( ) ; if ( isset ( $ updating [ 'code' ] ) && $ updating [ 'code' ] === $ value ) { return true ; } $ label = $ this -> translation -> text ( 'Code' ) ; if ( mb_strlen ( $ value ) > 255 ) { $ this -> setErrorLengthRange ( $ field , $ label , 0 , 255 ) ; return false ; } $ rules = $ this -> price_rule -> getList ( array ( 'code' => $ value ) ) ; if ( empty ( $ rules ) ) { return true ; } foreach ( ( array ) $ rules as $ rule ) { if ( $ rule [ 'code' ] === $ value ) { $ this -> setErrorExists ( $ field , $ label ) ; return false ; } } return true ; }
|
Validates a price rule code
|
55,660
|
protected function validateValuePriceRule ( ) { $ field = 'value' ; if ( $ this -> isExcluded ( $ field ) || $ this -> isError ( 'value_type' ) ) { return null ; } $ value = $ this -> getSubmitted ( $ field ) ; if ( $ this -> isUpdating ( ) && ! isset ( $ value ) ) { $ this -> unsetSubmitted ( $ field ) ; return null ; } if ( ! isset ( $ value ) ) { $ this -> setErrorRequired ( $ field , $ this -> translation -> text ( 'Value' ) ) ; return false ; } $ updating = $ this -> getUpdating ( ) ; $ submitted_value_type = $ this -> getSubmitted ( 'value_type' ) ; if ( isset ( $ submitted_value_type ) ) { $ value_type = $ submitted_value_type ; } else if ( isset ( $ updating [ 'value_type' ] ) ) { $ value_type = $ updating [ 'value_type' ] ; } else { $ this -> setErrorUnavailable ( 'value_type' , $ this -> translation -> text ( 'Value type' ) ) ; return false ; } try { $ handlers = $ this -> price_rule -> getTypes ( ) ; return static :: call ( $ handlers , $ value_type , 'validate' , array ( $ value , $ this ) ) ; } catch ( Exception $ ex ) { $ this -> setError ( $ field , $ ex -> getMessage ( ) ) ; return false ; } }
|
Validates a price rule value
|
55,661
|
public function validateValuePercentPriceRule ( $ value ) { $ field = 'value' ; $ label = $ this -> translation -> text ( 'Value' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } if ( $ value == 0 || abs ( $ value ) > 100 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } return true ; }
|
Validates the value of percent type
|
55,662
|
public function validateValueFixedPriceRule ( $ value ) { $ field = 'value' ; $ label = $ this -> translation -> text ( 'Value' ) ; if ( ! is_numeric ( $ value ) ) { $ this -> setErrorNumeric ( $ field , $ label ) ; return false ; } if ( strlen ( $ value ) > 8 ) { $ this -> setErrorInvalid ( $ field , $ label ) ; return false ; } return true ; }
|
Validates the value of fixed type
|
55,663
|
public function listCart ( ) { $ this -> actionListCart ( ) ; $ this -> setTitleListCart ( ) ; $ this -> setBreadcrumbListCart ( ) ; $ this -> setFilterListCart ( ) ; $ this -> setPagerlListCart ( ) ; $ this -> setData ( 'carts' , $ this -> getListCart ( ) ) ; $ this -> outputListCart ( ) ; }
|
Displays the shopping cart overview page
|
55,664
|
protected function actionListCart ( ) { list ( $ selected , $ action ) = $ this -> getPostedAction ( ) ; $ deleted = 0 ; foreach ( $ selected as $ id ) { if ( $ action === 'delete' && $ this -> access ( 'cart_delete' ) ) { $ deleted += ( int ) $ this -> cart -> delete ( $ id ) ; } } if ( $ deleted > 0 ) { $ message = $ this -> text ( 'Deleted %num item(s)' , array ( '%num' => $ deleted ) ) ; $ this -> setMessage ( $ message , 'success' ) ; } }
|
Applies an action to the selected shopping cart items
|
55,665
|
protected function getListCart ( ) { $ conditions = $ this -> query_filter ; $ conditions [ 'limit' ] = $ this -> data_limit ; $ list = ( array ) $ this -> cart -> getList ( $ conditions ) ; $ this -> prepareListCart ( $ list ) ; return $ list ; }
|
Returns an array of shopping cart items
|
55,666
|
protected function prepareListCart ( array & $ items ) { foreach ( $ items as & $ item ) { $ this -> setItemUrlEntity ( $ item , $ this -> store , 'product' ) ; } }
|
Prepare an array of cart items
|
55,667
|
public function setJob ( $ job_model ) { if ( $ this -> isCanceledJob ( $ job_model ) ) { return null ; } $ job_id = $ this -> getQuery ( 'job_id' ) ; if ( empty ( $ job_id ) ) { return null ; } $ job = $ job_model -> get ( $ job_id ) ; if ( empty ( $ job [ 'status' ] ) ) { return null ; } $ this -> setJsSettings ( 'job' , $ job ) ; if ( $ this -> getQuery ( 'process_job' ) === $ job [ 'id' ] && $ this -> isAjax ( ) ) { $ this -> outputJson ( $ job_model -> process ( $ job ) ) ; } return null ; }
|
Processes the current job
|
55,668
|
public function getWidgetJob ( $ job_model , $ job = null ) { if ( ! isset ( $ job ) ) { $ job = $ job_model -> get ( $ this -> getQuery ( 'job_id' , '' ) ) ; } $ rendered = '' ; if ( ! empty ( $ job [ 'status' ] ) ) { $ job += array ( 'widget' => 'common/job' ) ; $ rendered = $ this -> render ( $ job [ 'widget' ] , array ( 'job' => $ job ) ) ; } return $ rendered ; }
|
Returns the rendered job widget
|
55,669
|
public function isCanceledJob ( $ job_model ) { $ cancel_job_id = $ this -> getQuery ( 'cancel_job' ) ; if ( empty ( $ cancel_job_id ) ) { return false ; } $ job_model -> delete ( $ cancel_job_id ) ; return true ; }
|
Whether the current job is canceled
|
55,670
|
public function getChallenge ( ) { if ( empty ( $ this -> _challenge ) ) { $ output = $ this -> postRequest ( 'identification/securitytoken/challenge' , [ 'useEasyLogin' => false , 'generateEasyLoginId' => false , 'userId' => $ this -> _username , ] ) ; if ( ! isset ( $ output -> links -> next -> uri ) ) throw new Exception ( 'Cannot fetch control number. Check if the username is correct.' , 10 ) ; $ this -> _challenge = $ output -> challenge ; $ this -> _useOneTimePassword = ( bool ) $ output -> useOneTimePassword ; } return $ this -> _challenge ; }
|
Fetch control number
|
55,671
|
public function set ( $ path , $ create = false ) { $ zip = $ this -> zip ; $ flag = $ create ? $ zip :: CREATE : null ; if ( $ this -> zip -> open ( $ path , $ flag ) !== true ) { throw new RuntimeException ( "Failed to open ZIP file $path" ) ; } return $ this ; }
|
Sets a file path
|
55,672
|
public function directory ( $ source , $ destination , $ wrapper = '' ) { $ files = gplcart_file_scan_recursive ( $ source ) ; if ( empty ( $ files ) ) { return false ; } $ this -> set ( $ destination , true ) ; $ added = 0 ; foreach ( $ files as $ file ) { if ( is_dir ( $ file ) ) { $ added ++ ; continue ; } $ prefix = $ wrapper === '' ? '' : $ wrapper . DIRECTORY_SEPARATOR ; $ relative = $ prefix . substr ( $ file , strlen ( $ source ) + 1 ) ; $ added += ( int ) $ this -> zip -> addFile ( $ file , $ relative ) ; } $ result = count ( $ files ) == $ added ; $ this -> zip -> close ( ) ; return $ result ; }
|
Zip a whole folder
|
55,673
|
public function file ( $ source , $ destination ) { settype ( $ source , 'array' ) ; $ this -> set ( $ destination , true ) ; $ added = 0 ; foreach ( $ source as $ file ) { $ added += ( int ) $ this -> zip -> addFile ( $ file , basename ( $ file ) ) ; } $ this -> zip -> close ( ) ; return count ( $ source ) == $ added ; }
|
Create a ZIP archive
|
55,674
|
public function extract ( $ path , $ files = array ( ) ) { if ( empty ( $ files ) ) { return $ this -> zip -> extractTo ( $ path ) ; } return $ this -> zip -> extractTo ( $ path , $ files ) ; }
|
Extract the complete archive or the given files to the specified destination
|
55,675
|
public function getList ( ) { $ items = array ( ) ; for ( $ i = 0 ; $ i < $ this -> zip -> numFiles ; $ i ++ ) { $ items [ ] = $ this -> zip -> getNameIndex ( $ i ) ; } return $ items ; }
|
Returns an array of files in the archive
|
55,676
|
public function getMeta ( $ file ) { $ content = file_get_contents ( $ file ) ; $ matches = array ( ) ; preg_match ( '~<!--(.*?) , $ content , $ matches ) ; if ( empty ( $ matches [ 1 ] ) ) { return array ( ) ; } $ meta = json_decode ( trim ( $ matches [ 1 ] ) , true ) ; if ( ! is_array ( $ meta ) ) { return array ( ) ; } $ meta += array ( 'title' => '' , 'teaser' => '' , 'weight' => 0 ) ; return $ meta ; }
|
Extracts meta data from a help file
|
55,677
|
public function get ( $ file ) { $ result = null ; $ this -> hook -> attach ( 'help.get.before' , $ file , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( array ) $ result ; } $ result = $ this -> getMeta ( $ file ) ; if ( empty ( $ result ) ) { return array ( ) ; } $ hash = gplcart_string_encode ( gplcart_path_relative ( $ file ) ) ; $ result += array ( 'file' => $ file , 'path' => "admin/help/$hash" ) ; $ this -> hook -> attach ( 'help.get.after' , $ file , $ result , $ this ) ; return ( array ) $ result ; }
|
Returns an array of help data from the file
|
55,678
|
public function getList ( $ langcode = '' ) { if ( empty ( $ langcode ) ) { $ langcode = 'en' ; } $ result = & gplcart_static ( "help.list.$langcode" ) ; if ( isset ( $ result ) ) { return $ result ; } $ this -> hook -> attach ( 'help.list.before' , $ langcode , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ dir = $ this -> getDirectory ( $ langcode ) ; if ( ! is_dir ( $ dir ) ) { return $ result = array ( ) ; } $ result = $ titles = $ weights = array ( ) ; foreach ( gplcart_file_scan ( $ dir , array ( 'md' ) ) as $ file ) { $ data = $ this -> get ( $ file ) ; if ( ! empty ( $ data [ 'title' ] ) ) { $ result [ ] = $ data ; $ titles [ ] = $ data [ 'title' ] ; $ weights [ ] = $ data [ 'weight' ] ; } } array_multisort ( $ weights , SORT_ASC , $ titles , SORT_ASC , $ result ) ; $ this -> hook -> attach ( 'help.list.after' , $ langcode , $ result , $ this ) ; return $ result ; }
|
Returns an array of help items
|
55,679
|
public function parse ( $ file ) { $ result = null ; $ this -> hook -> attach ( 'help.render.before' , $ file , $ result , $ this ) ; if ( isset ( $ result ) ) { return ( string ) $ result ; } $ result = $ this -> markdown -> render ( file_get_contents ( $ file ) ) ; $ this -> hook -> attach ( 'help.render.after' , $ file , $ result , $ this ) ; return ( string ) $ result ; }
|
Render a help file
|
55,680
|
public function getElements ( ) { if ( self :: $ elements === null ) { self :: $ elements = $ this -> loadJson ( $ this -> resource ( 'OptionalElements.json' ) ) -> elements ; } return self :: $ elements ; }
|
Get the optional html elments .
|
55,681
|
public static function calculateHashSecure ( $ jumpUrl , $ locationData , $ mimeType ) { $ data = [ ( string ) $ jumpUrl , ( string ) $ locationData , ( string ) $ mimeType ] ; return GeneralUtility :: hmac ( serialize ( $ data ) ) ; }
|
Calculates the hash for the given jump URL secure data .
|
55,682
|
public function process ( MinifyContext $ context ) { $ context -> setContents ( $ this -> trailingWhitespaces ( $ context -> getContents ( ) ) ) ; $ context -> setContents ( $ this -> runMinificationRules ( $ context -> getContents ( ) ) ) ; $ context -> setContents ( $ this -> removeSpacesAroundPlaceholders ( $ context -> getContents ( ) ) ) ; return $ context -> setContents ( $ this -> maxHtmlLineLength ( $ context -> getContents ( ) , $ this -> maxHtmlLineLength ) ) ; }
|
Minify redundant whitespaces .
|
55,683
|
public function runMinificationRules ( $ contents ) { do { $ originalContents = $ contents ; $ contents = preg_replace ( array_keys ( $ this -> minifyRules ) , array_values ( $ this -> minifyRules ) , $ contents ) ; } while ( $ originalContents != $ contents ) ; return $ contents ; }
|
Loop over the minification rules as long as changes in output occur .
|
55,684
|
public function maxHtmlLineLength ( $ contents , $ maxHtmlLineLength ) { if ( strlen ( $ contents ) <= $ maxHtmlLineLength ) { return $ contents ; } $ result = '' ; $ splits = str_split ( $ contents , $ maxHtmlLineLength ) ; foreach ( $ splits as $ split ) { $ pos = strrpos ( $ split , '><' ) ; if ( $ pos === false ) { $ result .= $ split ; } else { $ result .= substr_replace ( $ split , PHP_EOL , $ pos + 1 , 0 ) ; } } return $ result ; }
|
Old browsers firewalls and more can t handle to long lines . Therefore add a linebreak after specified character length .
|
55,685
|
public function process ( $ context , $ url , array $ configuration , ContentObjectRenderer $ contentObjectRenderer , & $ keepProcessing ) { if ( ! $ this -> isEnabled ( $ context , $ configuration ) ) { return $ url ; } $ this -> contentObjectRenderer = $ contentObjectRenderer ; $ urlPrefix = ( string ) $ this -> getTypoScriptFrontendController ( ) -> absRefPrefix ; if ( $ urlPrefix !== '' && StringUtility :: beginsWith ( $ url , $ urlPrefix ) ) { $ url = substr ( $ url , strlen ( $ urlPrefix ) ) ; } if ( $ context === UrlProcessorInterface :: CONTEXT_FILE ) { $ url = str_replace ( '%2F' , '/' , rawurlencode ( rawurldecode ( $ url ) ) ) ; } $ url = $ this -> build ( $ url , isset ( $ configuration [ 'jumpurl.' ] ) ? $ configuration [ 'jumpurl.' ] : [ ] ) ; if ( $ urlPrefix !== '' && ! StringUtility :: beginsWith ( $ url , $ urlPrefix ) ) { $ url = $ urlPrefix . $ url ; } return $ url ; }
|
Generates the JumpURL for the given parameters .
|
55,686
|
protected function isEnabled ( $ context , array $ configuration = [ ] ) { if ( ! empty ( $ configuration [ 'jumpurl.' ] [ 'forceDisable' ] ) ) { return false ; } $ enabled = ! empty ( $ configuration [ 'jumpurl' ] ) ; if ( ! $ enabled && $ this -> getTypoScriptFrontendController ( ) -> config [ 'config' ] [ 'jumpurl_enable' ] ) { $ enabled = ! isset ( $ configuration [ 'jumpurl' ] ) || $ configuration [ 'jumpurl' ] ; } if ( empty ( $ configuration [ 'jumpurl' ] ) && $ context === UrlProcessorInterface :: CONTEXT_MAIL && $ this -> getTypoScriptFrontendController ( ) -> config [ 'config' ] [ 'jumpurl_mailto_disable' ] ) { $ enabled = false ; } return $ enabled ; }
|
Returns TRUE if jumpurl was enabled in the global configuration or in the given configuration
|
55,687
|
protected function build ( $ url , array $ configuration ) { $ urlParameters = [ 'jumpurl' => $ url ] ; if ( ! empty ( $ configuration [ 'secure' ] ) ) { $ secureParameters = $ this -> getParametersForSecureFile ( $ url , isset ( $ configuration [ 'secure.' ] ) ? $ configuration [ 'secure.' ] : [ ] ) ; $ urlParameters = array_merge ( $ urlParameters , $ secureParameters ) ; } else { $ urlParameters [ 'juHash' ] = JumpUrlUtility :: calculateHash ( $ url ) ; } $ typoLinkConfiguration = [ 'parameter' => $ this -> getTypoLinkParameter ( $ configuration ) , 'additionalParams' => GeneralUtility :: implodeArrayForUrl ( '' , $ urlParameters ) , 'jumpurl.' => [ 'forceDisable' => '1' ] ] ; return $ this -> getContentObjectRenderer ( ) -> typoLink_URL ( $ typoLinkConfiguration ) ; }
|
Builds a jump URL for the given URL
|
55,688
|
protected function getTypoLinkParameter ( array $ configuration ) { $ linkParameter = $ this -> getContentObjectRenderer ( ) -> stdWrapValue ( 'parameter' , $ configuration ) ; if ( empty ( $ linkParameter ) ) { $ frontendController = $ this -> getTypoScriptFrontendController ( ) ; $ linkParameter = $ frontendController -> id . ',' . $ frontendController -> type ; } return $ linkParameter ; }
|
Checks if an alternative link parameter was configured and if not a default parameter will be generated based on the current page ID and type . When linking to a file this method is needed
|
55,689
|
protected function isOptionSet ( $ provides , $ options = [ ] ) { if ( isset ( $ options [ $ provides ] ) && $ options [ $ provides ] === true ) { return true ; } elseif ( ! isset ( $ options [ $ provides ] ) && Options :: options ( ) [ $ provides ] -> isDefault ( ) ) { return true ; } return false ; }
|
Check whether an option is set in the options aray .
|
55,690
|
protected function restore ( MinifyContext $ context ) { $ withoutPlaceholders = $ context -> getPlaceholderContainer ( ) -> restorePlaceholders ( $ context -> getContents ( ) ) ; return $ context -> setContents ( $ withoutPlaceholders ) ; }
|
Restore placeholders with their original content .
|
55,691
|
private function getClassName ( $ object ) { $ class = get_class ( $ object ) ; if ( ( $ index = strrpos ( $ class , '\\' ) ) ) { $ fixForTrailingBackslash = 1 ; return substr ( $ class , $ index + $ fixForTrailingBackslash ) ; } return $ class ; }
|
Get the classname without the namespace .
|
55,692
|
public function process ( MinifyContext $ context ) { return $ context -> setContents ( preg_replace_callback ( '/ <! # search for the start of a comment [^>]* # search for everything without a ">" > # match the end of the comment /xs' , function ( $ match ) { if ( Str :: contains ( strtolower ( $ match [ 0 ] ) , 'doctype' ) ) { return $ match [ 0 ] ; } return '' ; } , $ context -> getContents ( ) ) ) ; }
|
Replace remaining comments .
|
55,693
|
public function process ( $ context ) { $ contents = $ context -> getContents ( ) ; $ contents = preg_replace_callback ( '/<\?=((?!\?>).)*\?>/s' , function ( $ match ) use ( $ context ) { return $ context -> getPlaceholderContainer ( ) -> createPlaceholder ( $ match [ 0 ] ) ; } , $ contents ) ; $ contents = preg_replace_callback ( '/<\?php((?!\?>).)*(\?>)?/s' , function ( $ match ) use ( $ context ) { return $ context -> getPlaceholderContainer ( ) -> createPlaceholder ( $ match [ 0 ] ) ; } , $ contents ) ; return $ context -> setContents ( $ contents ) ; }
|
Replace PHP tags with a temporary placeholder .
|
55,694
|
public function process ( $ context ) { $ context -> setContents ( $ this -> setCDataPlaceholder ( $ context -> getContents ( ) , $ context -> getPlaceholderContainer ( ) ) ) ; return $ context -> setContents ( $ this -> setConditionalCommentsPlaceholder ( $ context -> getContents ( ) , $ context -> getPlaceholderContainer ( ) ) ) ; }
|
Replace critical content with a temp placeholder for integrity .
|
55,695
|
protected function setCDataPlaceholder ( $ contents , PlaceholderContainer $ placeholderContainer ) { return preg_replace_callback ( '/<!\[CDATA\[((?!\]\]>).)*\]\]>/s' , function ( $ match ) use ( $ placeholderContainer ) { return $ placeholderContainer -> createPlaceholder ( $ match [ 0 ] ) ; } , $ contents ) ; }
|
Replace CData with a temporary placeholder .
|
55,696
|
protected function setConditionalCommentsPlaceholder ( $ contents , PlaceholderContainer $ placeholderContainer ) { return preg_replace_callback ( '/ ( <! # Match the start of a comment (-{2})? # IE can understand comments without dashes \[ # Match the start ("[" is a metachar => escape it) (?:(?!\]>).)* # Match everything except "]>" \]> # Match end ) ( (?: (?!<!\[endif\]-{2}?>) .)* ) # Match everything except end of conditional comment ( <!\[endif\] (?:\2|(?=>)) # Use a trick to ensure that when dashes are captured they are... # matched at the end! Else make sure that the next char is a ">"! > # Match the endif with the captured dashes ) /xis' , function ( $ match ) use ( $ placeholderContainer ) { if ( ! empty ( preg_replace ( '/\s*/' , '' , $ match [ 3 ] ) ) ) { return $ placeholderContainer -> createPlaceholder ( $ match [ 1 ] ) . $ match [ 3 ] . $ placeholderContainer -> createPlaceholder ( $ match [ 4 ] ) ; } else { return '' ; } } , $ contents ) ; }
|
Replace conditional placeholders used by Internet Explorer .
|
55,697
|
public function addMinificationStep ( $ input , $ keyName = null ) { if ( $ this -> statistics === null ) { $ this -> statistics = new Statistics ( $ input , $ keyName ) ; return ; } $ this -> statistics -> createReferencePoint ( $ this -> placeholderContainer -> getContentSize ( $ input ) , $ keyName ) ; }
|
Add a minification step .
|
55,698
|
public function createPlaceholder ( $ value ) { if ( ( $ key = array_search ( $ value , $ this -> all ( ) ) ) ) { $ placeholder = $ key ; } else { $ placeholder = $ this -> createUniquePlaceholder ( ) ; } $ value = $ this -> removeNestedPlaceholders ( $ value ) ; $ this -> items [ $ placeholder ] = $ value ; return $ placeholder ; }
|
Create a unique placeholder for the given contents .
|
55,699
|
public function getContentSize ( $ contentsWithPlaceholders ) { $ placeholderSize = $ this -> map ( function ( $ value , $ key ) use ( & $ contentsWithPlaceholders ) { $ count = substr_count ( $ contentsWithPlaceholders , $ key ) ; return strlen ( $ key ) * $ count - strlen ( $ value ) * $ count ; } ) -> sum ( ) ; return strlen ( $ contentsWithPlaceholders ) - $ placeholderSize ; }
|
Calculate the byte size of the placeholders .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.