Skip to content

Commit

Permalink
Merge branch '2.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bummzack committed Jul 6, 2016
2 parents 0233505 + 73bd3a8 commit 680e98b
Show file tree
Hide file tree
Showing 175 changed files with 5,921 additions and 2,777 deletions.
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ language: php
sudo: false

php:
- 5.3
- 5.5

env:
- DB=MYSQL CORE_RELEASE=3.2

matrix:
include:
- php: 5.4
env: DB=MYSQL CORE_RELEASE=3.1
- php: 5.5
env: DB=SQLITE CORE_RELEASE=3.2
- php: 5.6
env: DB=PGSQL CORE_RELEASE=3.2 COVERAGE=1
- php: 5.6
env: DB=PGSQL CORE_RELEASE=3.2 COVERAGE=2
- php: 5.6
env: DB=PGSQL CORE_RELEASE=3.2 COVERAGE=3
- php: 5.6
- php: 5.6
env: DB=PGSQL CORE_RELEASE=3.3
- php: 5.5
env: DB=SQLITE CORE_RELEASE=3.1
- php: 5.6
env: DB=PGSQL CORE_RELEASE=master
allow_failures:
Expand Down
8 changes: 8 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[main]
host = https://www.transifex.com

[silverstripe-shop.lang_2-0]
file_filter = lang/<lang>.yml
source_file = lang/en.yml
source_lang = en
type = YML
12 changes: 12 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# SilverStripe Shop Change Log

## 2.0

* Overhaul of the localization of the module. (#379, #381, #383, #384, #408, #410, #411, #451, #453, #456, #457, #470, #486)
* Better Addressbook UI (#452)
* Use `::create` syntax for object instantiation (#415)
* Shop Emails use inline CSS by using Emogrifier (#466)
* Order-calculations and order-placement are now wrapped in Database transactions (#506)
* Products that have Variations can not be added to cart, only a Variation can (#516)
* Products with no price (`0.0`) will now be displayed if they have Variations (#516)
* Variations without a price will no longer show up, unless `Product.allow_zero_price` is set to `true` (#516)
* Updated codebase to use the 2.0 version of silverstripe-omnipay

## 1.3.1

* Improve variation-form performance (#512)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A tremendous thanks to [everyone that has already contributed](https://github.co
## Requirements

* SilverStripe 3.1 or higher [framework](https://github.com/silverstripe/silverstripe-framework) & [cms](https://github.com/silverstripe/silverstripe-cms)
* [Omnipay Module](https://github.com/burnbright/silverstripe-omnipay) + it's dependencies.
* [Omnipay Module](https://github.com/burnbright/silverstripe-omnipay) + its dependencies.

See `composer.json` for exact set of dependencies.

Expand All @@ -41,7 +41,7 @@ See `composer.json` for exact set of dependencies.
To install silverstripe + shop into a directory called 'myshop', using [composer](http://doc.silverstripe.org/framework/en/installation/composer), run the following commands:
```
composer create-project silverstripe/installer myshop
composer require -d myshop "silvershop/core:dev-master"
composer require -d myshop "silvershop/core"
```

### Build Tasks
Expand Down
2 changes: 2 additions & 0 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ OrderProcessor:
Injector:
CheckoutComponentConfig:
class: SinglePageCheckoutComponentConfig
ShopEmail:
class: StyledHtmlEmail

LeftAndMain:
extra_requirements_css:
Expand Down
3 changes: 3 additions & 0 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ Payment:
Order:
extensions:
- Payable
SilverStripe\Omnipay\Service\PaymentService:
extensions:
- ShopPaymentService
29 changes: 29 additions & 0 deletions code/ShopTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
*/
class ShopTools
{
/**
* Get the DB connection in a SS 3.1 and 3.2+ compatible way
* @param string $name
* @return SS_Database
*/
public static function DBConn($name = 'default')
{
if (method_exists('DB', 'get_conn')) {
return DB::get_conn($name);
}
return DB::getConn($name);
}

/**
* Convert a numeric price to the shop currency
* @param mixed $price the price to convert
* @return Money the price wrapped in a Money DBField to be used for templates or similar
*/
public static function price_for_display($price)
{
$currency = ShopConfig::get_site_currency();
Expand All @@ -14,6 +32,11 @@ public static function price_for_display($price)
return $field;
}

/**
* Get the current locale.
* Tries to get the locale from Translatable, Fluent or the default i18n (depending on what is installed)
* @return string the locale in use
*/
public static function get_current_locale()
{
if (class_exists('Translatable')) {
Expand All @@ -27,6 +50,12 @@ public static function get_current_locale()
return i18n::get_locale();
}

/**
* Set/Install the given locale.
* This does set the i18n locale as well as the Translatable or Fluent locale (if any of these modules is installed)
* @param string $locale the locale to install
* @throws Zend_Locale_Exception @see Zend_Locale_Format::getDateFormat and @see Zend_Locale_Format::getTimeFormat
*/
public static function install_locale($locale)
{
// If the locale isn't given, silently fail (there might be carts that still have locale set to null)
Expand Down
78 changes: 62 additions & 16 deletions code/account/AccountPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public function canCreate($member = null, $context = array())
* Returns the link or the URLSegment to the account page on this site
*
* @param boolean $urlSegment Return the URLSegment only
*
* @return mixed
*/
public static function find_link($urlSegment = false)
{
Expand All @@ -31,19 +33,25 @@ public static function find_link($urlSegment = false)
*
* @param int|string $orderID ID of the order
* @param boolean $urlSegment Return the URLSegment only
*
* @return string
*/
public static function get_order_link($orderID, $urlSegment = false)
{
$page = self::get_if_account_page_exists();
return ($urlSegment ? $page->URLSegment . '/' : $page->Link()) . 'order/' . $orderID;
}

/**
* @return AccountPage
*/
protected static function get_if_account_page_exists()
{
if ($page = DataObject::get_one('AccountPage')) {
return $page;
}
user_error(_t('AccountPage.NO_PAGE', 'No AccountPage was found. Please create one in the CMS!'), E_USER_ERROR);
user_error(_t('AccountPage.NoPage', 'No AccountPage was found. Please create one in the CMS!'), E_USER_ERROR);
return null; // just to keep static analysis happy
}

/**
Expand All @@ -53,6 +61,7 @@ public function requireDefaultRecords()
{
parent::requireDefaultRecords();
if (!self::get()->exists() && $this->config()->create_default_pages) {
/** @var AccountPage $page */
$page = self::create(
array(
'Title' => 'Account',
Expand Down Expand Up @@ -80,39 +89,43 @@ class AccountPage_Controller extends Page_Controller
'EditAccountForm',
'ChangePasswordForm',
'changepassword', // redirects to editprofile
'deleteaddress',
'setdefaultbilling',
'setdefaultshipping',
);

protected $member;
/** @var Member|ShopMember */
protected $member;

public function init()
{
parent::init();
if (!Member::currentUserID()) {
$messages = array(
'default' => _t(
'AccountPage.LOGIN',
'AccountPage.Login',
'You\'ll need to login before you can access the account page.
If you are not registered, you won\'t be able to access it until
you make your first order, otherwise please enter your details below.'
),
'logInAgain' => _t(
'AccountPage.LOGINAGAIN',
'AccountPage.LoginAgain',
'You have been logged out. If you would like to log in again,
please do so below.'
),
);
Security::permissionFailure($this, $messages);
return false;
} else {
$this->member = Member::currentUser();
}
$this->member = Member::currentUser();
}

public function getTitle()
{
if ($this->dataRecord && $title = $this->dataRecord->Title) {
return $title;
}
return _t('AccountPage.Title', "Account");
return _t('AccountPage.DefaultTitle', "Account");
}

public function getMember()
Expand Down Expand Up @@ -201,7 +214,7 @@ public function saveaddress($data, $form)
$member->DefaultBillingAddressID = $address->ID;
$member->write();
}
$form->sessionMessage(_t("CreateAddressForm.SAVED", "Your address has been saved"), "good");
$form->sessionMessage(_t("CreateAddressForm.AddressSaved", "Your address has been saved"), "good");

$this->extend('updateCreateAddressFormResponse', $form, $data, $response);

Expand All @@ -213,6 +226,47 @@ public function editprofile()
return array();
}

/**
* @param SS_HTTPRequest $req
* @return SS_HTTPResponse
*/
function deleteaddress($req)
{
// NOTE: we don't want to fully delete the address because it's presumably still
// attached to an order. Setting MemberID to 0 means it won't show up in the address
// book any longer.
$address = $this->member->AddressBook()->byID($req->param('ID'));
if ($address) {
$address->MemberID = 0;
$address->write();
} else {
$this->httpError(404, 'Address not found');
}
return $this->redirectBack();
}

/**
* @param SS_HTTPRequest $req
* @return SS_HTTPResponse
*/
function setdefaultbilling($req)
{
$this->member->DefaultBillingAddressID = $req->param('ID');
$this->member->write();
return $this->redirectBack();
}

/**
* @param SS_HTTPRequest $req
* @return SS_HTTPResponse
*/
function setdefaultshipping($req)
{
$this->member->DefaultShippingAddressID = $req->param('ID');
$this->member->write();
return $this->redirectBack();
}

/**
* Return a form allowing the user to edit their details.
*
Expand All @@ -237,14 +291,6 @@ public function ChangePasswordForm()
$backURL->setValue($this->Link('editprofile'));

$this->extend('updateChangePasswordForm', $form);
$this->data()->extend('updateChangePasswordForm', $form);

if ($this->data()->hasMethod('updateChangePasswordForm')) { // if accessing through the model
Deprecation::notice(
'2.0',
'Please access updateChangePasswordForm through AccountPage_Controller instead of AccountPage (this extension point is due to be removed)'
);
}

return $form;
}
Expand Down
Loading

0 comments on commit 680e98b

Please sign in to comment.