Skip to content

Commit 3b02d22

Browse files
committed
Merge remote-tracking branch 'origin/3.0' into 3.1
Conflicts: dev/CsvBulkLoader.php
2 parents 9672a22 + ced199b commit 3b02d22

38 files changed

+243
-132
lines changed

api/JSONDataFormatter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
9797
$innerParts[] = ArrayData::array_to_object(array(
9898
"className" => $relClass,
9999
"href" => "$href.json",
100-
"id" => $obj->$fieldName
100+
"id" => $item->$fieldName
101101
));
102102
}
103103
$serobj->$relName = $innerParts;
@@ -118,7 +118,7 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
118118
$innerParts[] = ArrayData::array_to_object(array(
119119
"className" => $relClass,
120120
"href" => "$href.json",
121-
"id" => $obj->$fieldName
121+
"id" => $item->$fieldName
122122
));
123123
}
124124
$serobj->$relName = $innerParts;

dev/CsvBulkLoader.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,22 @@ protected function processRecord($record, $columnMap, &$results, $preview = fals
9494
$obj->{"{$relationName}ID"} = $relationObj->ID;
9595
//write if we are not previewing
9696
if (!$preview) {
97-
$obj->write();
98-
$obj->flushCache(); // avoid relation caching confusion
97+
$obj->write();
98+
$obj->flushCache(); // avoid relation caching confusion
9999
}
100100

101101
} elseif(strpos($fieldName, '.') !== false) {
102102
// we have a relation column with dot notation
103-
list($relationName, $columnName) = explode('.', $fieldName);
103+
list($relationName,$columnName) = explode('.', $fieldName);
104104
// always gives us an component (either empty or existing)
105105
$relationObj = $obj->getComponent($relationName);
106106
if (!$preview) $relationObj->write();
107107
$obj->{"{$relationName}ID"} = $relationObj->ID;
108108
//write if we are not previewing
109109
if (!$preview) {
110-
$obj->write();
111-
$obj->flushCache(); // avoid relation caching confusion
112-
}
110+
$obj->write();
111+
$obj->flushCache(); // avoid relation caching confusion
112+
}
113113
}
114114

115115
}
@@ -166,10 +166,12 @@ public function findExistingObject($record) {
166166
foreach($this->duplicateChecks as $fieldName => $duplicateCheck) {
167167
if(is_string($duplicateCheck)) {
168168
$SQL_fieldName = Convert::raw2sql($duplicateCheck);
169-
if(!isset($record[$SQL_fieldName]) || empty($record[$SQL_fieldName])) { //skip current duplicate check if field value is empty
170-
continue;
169+
if(!isset($record[$SQL_fieldName])) {
170+
return false;
171+
//user_error("CsvBulkLoader:processRecord: Couldn't find duplicate identifier '{$fieldName}'
172+
//in columns", E_USER_ERROR);
171173
}
172-
$SQL_fieldValue = Convert::raw2sql($record[$fieldName]);
174+
$SQL_fieldValue = Convert::raw2sql($record[$SQL_fieldName]);
173175
$existingRecord = DataObject::get_one($this->objectClass, "\"$SQL_fieldName\" = '{$SQL_fieldValue}'");
174176
if($existingRecord) return $existingRecord;
175177
} elseif(is_array($duplicateCheck) && isset($duplicateCheck['callback'])) {

dev/DevelopmentAdmin.php

+17-9
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,23 @@ public function generatesecuretoken() {
177177
$generator = Injector::inst()->create('RandomGenerator');
178178
$token = $generator->randomToken('sha1');
179179

180-
echo <<<TXT
181-
182-
Token: $token
183-
184-
Please add this to your mysite/_config.php with the following code:
185-
Config::inst()->update('Security', 'token', '$token');
186-
187-
188-
TXT;
180+
$path = $this->request->getVar('path');
181+
if($path) {
182+
if(file_exists(BASE_PATH . '/' . $path)) {
183+
echo sprintf(
184+
"Configuration file '%s' exists, can't merge. Please choose a new file.\n",
185+
BASE_PATH . '/' . $path
186+
);
187+
exit(1);
188+
}
189+
$yml = "Security:\n token: $token";
190+
file_put_contents(BASE_PATH . '/' . $path, $yml);
191+
echo "Configured token in $path\n";
192+
} else {
193+
echo "Generated new token. Please add the following code to your YAML configuration:\n\n";
194+
echo "Security:\n";
195+
echo " token: $token\n";
196+
}
189197
}
190198

191199
public function errors() {

docs/en/changelogs/3.0.6.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 3.0.6 (Not yet released)
2+
3+
## Upgrading
4+
5+
* If you have created your own composite database fields, then you shoulcd amend the setValue() to allow the passing of an object (usually DataObject) as well as an array.

docs/en/howto/extend-cms-interface.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ and replace it with the following:
126126

127127
:::ss
128128
<ul>
129-
<% loop BookmarkedPages %>
129+
<% loop $BookmarkedPages %>
130130
<li><a href="admin/pages/edit/show/$ID">Edit "$Title"</a></li>
131131
<% end_loop %>
132132
</ul>

docs/en/howto/grouping-dataobjectsets.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ In this case, the `getTitleFirstLetter()` method defined earlier is used to brea
7474
:::ss
7575
<%-- Modules list grouped by TitleFirstLetter --%>
7676
<h2>Modules</h2>
77-
<% loop GroupedModules.GroupedBy(TitleFirstLetter) %>
77+
<% loop $GroupedModules.GroupedBy(TitleFirstLetter) %>
7878
<h3>$TitleFirstLetter</h3>
7979
<ul>
80-
<% loop Children %>
80+
<% loop $Children %>
8181
<li>$Title</li>
8282
<% end_loop %>
8383
</ul>
@@ -133,10 +133,10 @@ The final step is the render this into the template using the [api:GroupedList->
133133
:::ss
134134
// Modules list grouped by the Month Posted
135135
<h2>Modules</h2>
136-
<% loop GroupedModulesByDate.GroupedBy(MonthCreated) %>
136+
<% loop $GroupedModulesByDate.GroupedBy(MonthCreated) %>
137137
<h3>$MonthCreated</h3>
138138
<ul>
139-
<% loop Children %>
139+
<% loop $Children %>
140140
<li>$Title ($Created.Nice)</li>
141141
<% end_loop %>
142142
</ul>

docs/en/howto/navigation-menu.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ located in `themes/<mytheme>/templates/Page.ss`.
99

1010
:::ss
1111
<ul>
12-
<% loop Menu(1) %>
12+
<% loop $Menu(1) %>
1313
<li>
1414
<a href="$Link" title="Go to the $Title page" class="$LinkingMode">
1515
<span>$MenuTitle</span>

docs/en/howto/pagination.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The first step is to simply list the objects in the template:
3636

3737
:::ss
3838
<ul>
39-
<% loop PaginatedPages %>
39+
<% loop $PaginatedPages %>
4040
<li><a href="$Link">$Title</a></li>
4141
<% end_loop %>
4242
</ul>
@@ -45,22 +45,22 @@ By default this will display 10 pages at a time. The next step is to add paginat
4545
controls below this so the user can switch between pages:
4646

4747
:::ss
48-
<% if PaginatedPages.MoreThanOnePage %>
49-
<% if PaginatedPages.NotFirstPage %>
48+
<% if $PaginatedPages.MoreThanOnePage %>
49+
<% if $PaginatedPages.NotFirstPage %>
5050
<a class="prev" href="$PaginatedPages.PrevLink">Prev</a>
5151
<% end_if %>
52-
<% loop PaginatedPages.Pages %>
53-
<% if CurrentBool %>
52+
<% loop $PaginatedPages.Pages %>
53+
<% if $CurrentBool %>
5454
$PageNum
5555
<% else %>
56-
<% if Link %>
56+
<% if $Link %>
5757
<a href="$Link">$PageNum</a>
5858
<% else %>
5959
...
6060
<% end_if %>
6161
<% end_if %>
6262
<% end_loop %>
63-
<% if PaginatedPages.NotLastPage %>
63+
<% if $PaginatedPages.NotLastPage %>
6464
<a class="next" href="$PaginatedPages.NextLink">Next</a>
6565
<% end_if %>
6666
<% end_if %>

docs/en/installation/composer.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ Composer isn't only used to download SilverStripe CMS, it can also be used to ma
6666

6767
composer require silverstripe/forum:*
6868

69-
This command has two parts. First is `silverstripe/forum`. This is the name of the package. You can find other packages with the following command:
69+
This will install the forum module in the latest compatible version.
70+
By default, Composer updates other existing modules (like `framework` and `cms`),
71+
and installs "dev" dependencies like PHPUnit. In case you don't need those dependencies,
72+
use the following command instead:
73+
74+
composer require --no-update silverstripe/forum:*
75+
composer update --no-dev
76+
77+
The `require` command has two parts. First is `silverstripe/forum`. This is the name of the package.
78+
You can find other packages with the following command:
7079

7180
composer search silverstripe
7281

@@ -84,7 +93,7 @@ Except for the control code of the Voyager space probe, every piece of code in t
8493

8594
To get the latest updates of the modules in your project, run this command:
8695

87-
composer update
96+
composer update --no-dev
8897

8998
Updates to the required modules will be installed, and the `composer.lock` file will get updated with the specific commits of each of those.
9099

docs/en/misc/coding-conventions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ Put code into the classes in the following order (where applicable).
427427
* Commonly used methods like `getCMSFields()`
428428
* Accessor methods (`getMyField()` and `setMyField()`)
429429
* Controller action methods
430-
* Template data-access methods (methods that will be called by a `$MethodName` or `<% loop MethodName %>` construct in a template somewhere)
430+
* Template data-access methods (methods that will be called by a `$MethodName` or `<% loop $MethodName %>` construct in a template somewhere)
431431
* Object methods
432432

433433
### SQL Format

docs/en/reference/partial-caching.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Failing example:
215215
:::ss
216216
<% cached LastEdited %>
217217

218-
<% loop Children %>
218+
<% loop $Children %>
219219
<% cached LastEdited %>
220220
$Name
221221
<% end_cached %>
@@ -231,7 +231,7 @@ Can be re-written as:
231231
<% cached LastEdited %>
232232

233233
<% cached Children.max(LastEdited) %>
234-
<% loop Children %>
234+
<% loop $Children %>
235235
$Name
236236
<% end_loop %>
237237
<% end_cached %>

docs/en/reference/searchcontext.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -139,29 +139,29 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
139139

140140

141141
:::ss
142-
<% if Results %>
142+
<% if $Results %>
143143
<ul>
144-
<% loop Results %>
144+
<% loop $Results %>
145145
<li>$Title, $Autor</li>
146146
<% end_loop %>
147147
</ul>
148148
<% else %>
149149
<p>Sorry, your search query did not return any results.</p>
150150
<% end_if %>
151151

152-
<% if Results.MoreThanOnePage %>
152+
<% if $Results.MoreThanOnePage %>
153153
<div id="PageNumbers">
154154
<p>
155-
<% if Results.NotFirstPage %>
155+
<% if $Results.NotFirstPage %>
156156
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
157157
<% end_if %>
158158
159159
<span>
160-
<% loop Results.PaginationSummary(4) %>
161-
<% if CurrentBool %>
160+
<% loop $Results.PaginationSummary(4) %>
161+
<% if $CurrentBool %>
162162
$PageNum
163163
<% else %>
164-
<% if Link %>
164+
<% if $Link %>
165165
<a href="$Link" title="View page number $PageNum">$PageNum</a>
166166
<% else %>
167167
&hellip;
@@ -170,7 +170,7 @@ Results.PaginationSummary(4) defines how many pages the search will show in the
170170
<% end_loop %>
171171
</span>
172172
173-
<% if Results.NotLastPage %>
173+
<% if $Results.NotLastPage %>
174174
<a class="next" href="$Results.NextLink" title="View the next page">Next</a>
175175
<% end_if %>
176176
</p>

docs/en/reference/siteconfig.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can access `[api:SiteConfig]` options from any SS template by using the func
1515

1616
// or
1717

18-
<% loop SiteConfig %>
18+
<% loop $SiteConfig %>
1919
$Title $AnotherField
2020
<% end_loop %>
2121

docs/en/reference/templates-upgrading-guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ These are the main changes to the SiverStripe 3 template language.
44

55
## Control blocks: Loops vs. Scope
66

7-
The `<% control var %>...<% end_control %>` in SilverStripe prior to version 3 has two different meanings. Firstly, if the control variable is a collection (e.g. DataList), then `<% control %>` iterates over that set. If it's a non-iteratable object, however, `<% control %>` introduces a new scope, which is used to render the inner template code. This dual-use is confusing to some people, and doesn't allow a collection of objects to be used as a scope.
7+
The `<% control $var %>...<% end_control %>` in SilverStripe prior to version 3 has two different meanings. Firstly, if the control variable is a collection (e.g. DataList), then `<% control %>` iterates over that set. If it's a non-iteratable object, however, `<% control %>` introduces a new scope, which is used to render the inner template code. This dual-use is confusing to some people, and doesn't allow a collection of objects to be used as a scope.
88

9-
In SilverStripe 3, the first usage (iteration) is replaced by `<% loop var %>`. The second usage (scoping) is replaced by `<% with var %>`
9+
In SilverStripe 3, the first usage (iteration) is replaced by `<% loop $var %>`. The second usage (scoping) is replaced by `<% with $var %>`
1010

1111
## Literals in Expressions
1212

0 commit comments

Comments
 (0)