Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

FIX Remove instances of lines longer than 120c

The entire framework repo (with the exception of system-generated files) has been amended to respect the 120c line-length limit.  This is in preparation for the enforcement of this rule with PHP_CodeSniffer.
  • Loading branch information...
commit 1f7fc1f76a0931bb0aae260346dd869bbba1bfd8 1 parent 28bd939
@sminnee sminnee authored
Showing with 4,786 additions and 2,646 deletions.
  1. +12 −5 _register_database.php
  2. +21 −4 admin/_config.php
  3. +2 −1  admin/code/AdminRootController.php
  4. +6 −2 admin/code/CMSBatchActionHandler.php
  5. +2 −1  admin/code/CMSMenu.php
  6. +12 −9 admin/code/GroupImportForm.php
  7. +50 −24 admin/code/LeftAndMain.php
  8. +11 −8 admin/code/MemberImportForm.php
  9. +17 −6 admin/code/ModelAdmin.php
  10. +11 −5 admin/code/SecurityAdmin.php
  11. +27 −27 admin/javascript/LeftAndMain.FieldHelp.js
  12. +6 −3 admin/tests/CMSMenuTest.php
  13. +3 −2 admin/tests/LeftAndMainTest.php
  14. +8 −4 api/DataFormatter.php
  15. +15 −3 api/JSONDataFormatter.php
  16. +10 −4 api/RSSFeed.php
  17. +8 −3 api/RestfulService.php
  18. +2 −1  api/XMLDataFormatter.php
  19. +24 −12 cache/Cache.php
  20. +4 −2 cli-script.php
  21. +26 −12 conf/ConfigureFromEnv.php
  22. +13 −8 control/ContentNegotiator.php
  23. +24 −11 control/Controller.php
  24. +4 −2 control/Cookie.php
  25. +75 −45 control/Director.php
  26. +12 −6 control/HTTP.php
  27. +9 −6 control/HTTPRequest.php
  28. +2 −1  control/HTTPResponse.php
  29. +3 −1 control/PjaxResponseNegotiator.php
  30. +51 −29 control/RequestHandler.php
  31. +13 −8 control/Session.php
  32. +2 −1  control/injector/Injector.php
  33. +83 −45 core/Config.php
  34. +2 −1  core/Convert.php
  35. +11 −4 core/Core.php
  36. +14 −6 core/DAG.php
  37. +2 −1  core/Diff.php
  38. +39 −24 core/Object.php
  39. +57 −27 core/manifest/ConfigManifest.php
  40. +17 −8 core/manifest/TokenisedRegularExpression.php
  41. +5 −2 dev/Backtrace.php
  42. +2 −1  dev/CSSContentParser.php
  43. +8 −4 dev/Cli.php
  44. +12 −8 dev/CliTestReporter.php
  45. +6 −3 dev/CsvBulkLoader.php
  46. +23 −13 dev/Debug.php
  47. +2 −1  dev/DebugView.php
  48. +5 −2 dev/Deprecation.php
  49. +5 −3 dev/DevelopmentAdmin.php
  50. +27 −15 dev/FunctionalTest.php
  51. +6 −5 dev/JSTestRunner.php
  52. +2 −1  dev/LogErrorEmailFormatter.php
  53. +2 −1  dev/MigrationTask.php
  54. +4 −2 dev/Profiler.php
  55. +9 −3 dev/SapphireREPL.php
  56. +22 −10 dev/SapphireTest.php
  57. +16 −8 dev/SapphireTestReporter.php
  58. +4 −1 dev/TaskRunner.php
  59. +4 −2 dev/TeamCityListener.php
  60. +5 −2 dev/TestMailer.php
  61. +24 −13 dev/TestRunner.php
  62. +6 −3 dev/TestSession.php
  63. +10 −5 dev/YamlFixture.php
  64. +5 −2 dev/install/DatabaseAdapterRegistry.php
  65. +4 −1 dev/install/install.php
  66. +4 −2 dev/phpunit/PhpUnitWrapper_3_4.php
  67. +376 −376 docs/en/tutorials/_images/layout.css
  68. +30 −17 email/Email.php
  69. +36 −22 email/Mailer.php
  70. +19 −8 filesystem/File.php
  71. +2 −1  filesystem/Filesystem.php
  72. +21 −9 filesystem/Folder.php
  73. +7 −4 filesystem/GD.php
  74. +7 −3 filesystem/Upload.php
  75. +7 −3 forms/AjaxUniqueTextField.php
  76. +9 −4 forms/CheckboxSetField.php
  77. +30 −15 forms/ComplexTableField.php
  78. +7 −2 forms/CompositeField.php
  79. +11 −5 forms/ConfirmedPasswordField.php
  80. +4 −2 forms/CountryDropdownField.php
  81. +9 −5 forms/CreditCardField.php
  82. +9 −4 forms/CurrencyField.php
  83. +14 −7 forms/DateField.php
  84. +8 −4 forms/DatetimeField.php
  85. +9 −6 forms/DropdownField.php
  86. +2 −1  forms/EmailField.php
  87. +19 −10 forms/FieldList.php
  88. +2 −1  forms/FileIFrameField.php
  89. +37 −21 forms/Form.php
  90. +13 −7 forms/FormField.php
  91. +13 −4 forms/FormScaffolder.php
  92. +28 −12 forms/HasManyComplexTableField.php
  93. +13 −6 forms/HasOneComplexTableField.php
  94. +4 −3 forms/HeaderField.php
  95. +25 −12 forms/HtmlEditorConfig.php
  96. +66 −31 forms/HtmlEditorField.php
  97. +6 −3 forms/ImageField.php
  98. +8 −3 forms/ImageFormAction.php
  99. +6 −3 forms/InlineFormAction.php
  100. +5 −2 forms/ListboxField.php
  101. +11 −5 forms/ManyManyComplexTableField.php
  102. +44 −20 forms/MemberDatetimeOptionsetField.php
  103. +3 −1 forms/MoneyField.php
  104. +9 −4 forms/NullableField.php
  105. +4 −1 forms/PasswordField.php
  106. +3 −2 forms/PhoneNumberField.php
  107. +3 −1 forms/RequiredFields.php
  108. +2 −1  forms/SelectionGroup.php
  109. +8 −2 forms/SimpleImageField.php
  110. +2 −1  forms/TabSet.php
  111. +12 −8 forms/TableField.php
  112. +88 −30 forms/TableListField.php
  113. +3 −1 forms/TextareaField.php
  114. +23 −13 forms/TreeDropdownField.php
  115. +23 −8 forms/TreeMultiselectField.php
  116. +28 −15 forms/UploadField.php
  117. +8 −3 forms/Validator.php
  118. +51 −21 forms/gridfield/GridField.php
  119. +23 −10 forms/gridfield/GridFieldAddExistingAutocompleter.php
  120. +2 −1  forms/gridfield/GridFieldAddNewButton.php
  121. +2 −1  forms/gridfield/GridFieldDataColumns.php
  122. +6 −3 forms/gridfield/GridFieldDeleteAction.php
  123. +16 −7 forms/gridfield/GridFieldDetailForm.php
  124. +3 −1 forms/gridfield/GridFieldExportButton.php
  125. +4 −2 forms/gridfield/GridFieldFilterHeader.php
  126. +9 −4 forms/gridfield/GridFieldPaginator.php
  127. +3 −1 forms/gridfield/GridFieldPrintButton.php
  128. +11 −5 forms/gridfield/GridFieldSortableHeader.php
  129. +24 −13 i18n/i18n.php
  130. +25 −10 i18n/i18nTextCollector.php
  131. +16 −15 javascript/lang/nl_NL.js
  132. +6 −2 model/Aggregate.php
  133. +9 −4 model/ArrayList.php
  134. +2 −1  model/ComponentSet.php
  135. +5 −2 model/DB.php
  136. +4 −2 model/DataExtension.php
  137. +26 −14 model/DataList.php
  138. +131 −67 model/DataObject.php
  139. +2 −1  model/DataObjectDecorator.php
  140. +7 −6 model/DataObjectInterface.php
  141. +2 −1  model/DataObjectSet.php
  142. +23 −13 model/DataQuery.php
  143. +60 −29 model/Database.php
  144. +9 −4 model/DatabaseAdmin.php
  145. +4 −2 model/Filterable.php
  146. +3 −3 model/HTMLValue.php
  147. +9 −3 model/HasManyList.php
  148. +41 −17 model/Hierarchy.php
  149. +12 −6 model/Image.php
  150. +9 −3 model/ManyManyList.php
  151. +4 −2 model/Map.php
  152. +85 −34 model/MySQLDatabase.php
  153. +26 −11 model/SQLQuery.php
  154. +2 −2 model/Transliterator.php
  155. +3 −1 model/URLSegmentFilter.php
  156. +2 −1  model/ValidationResult.php
  157. +53 −20 model/Versioned.php
  158. +8 −1 model/fieldtypes/Boolean.php
  159. +4 −2 model/fieldtypes/CompositeDBField.php
  160. +13 −8 model/fieldtypes/DBField.php
  161. +2 −1  model/fieldtypes/Date.php
  162. +2 −1  model/fieldtypes/Datetime.php
  163. +6 −1 model/fieldtypes/Decimal.php
  164. +8 −3 model/fieldtypes/Enum.php
  165. +6 −1 model/fieldtypes/Float.php
  166. +21 −13 model/fieldtypes/HTMLText.php
  167. +7 −1 model/fieldtypes/Int.php
  168. +12 −5 model/fieldtypes/Money.php
  169. +15 −2 model/fieldtypes/MultiEnum.php
  170. +6 −4 model/fieldtypes/StringField.php
  171. +14 −5 model/fieldtypes/Text.php
  172. +2 −1  model/fieldtypes/Varchar.php
  173. +22 −16 oembed/Oembed.php
  174. +23 −14 parsers/ShortcodeParser.php
  175. +2 −1  search/FulltextSearchable.php
  176. +14 −4 search/SearchContext.php
  177. +7 −2 search/filters/SearchFilter.php
  178. +4 −1 security/ChangePasswordForm.php
  179. +18 −6 security/Group.php
  180. +2 −1  security/LoginForm.php
  181. +16 −6 security/Member.php
  182. +4 −1 security/MemberAuthenticator.php
  183. +4 −2 security/MemberLoginForm.php
  184. +11 −5 security/PasswordEncryptor.php
  185. +22 −4 security/PasswordValidator.php
  186. +7 −5 security/Permission.php
  187. +27 −14 security/PermissionCheckboxSetField.php
  188. +2 −1  security/PermissionProvider.php
  189. +38 −15 security/Security.php
  190. +3 −1 tasks/EncryptAllPasswordsTask.php
  191. +4 −4 tasks/ScheduledTask.php
  192. +3 −1 tests/FakeController.php
  193. +5 −3 tests/PhpSyntaxTest.php
  194. +2 −1  tests/api/RSSFeedTest.php
  195. +4 −2 tests/api/XMLDataFormatterTest.php
  196. +24 −13 tests/control/ControllerTest.php
  197. +14 −7 tests/control/DirectorTest.php
  198. +2 −1  tests/control/HTTPTest.php
  199. +12 −8 tests/control/RequestHandlingTest.php
  200. +30 −15 tests/core/ConfigTest.php
  201. +30 −15 tests/core/ConvertTest.php
  202. +6 −3 tests/core/CoreTest.php
  203. +24 −12 tests/core/ObjectTest.php
  204. +4 −2 tests/core/manifest/ConfigManifestTest.php
  205. +3 −1 tests/core/manifest/NamespacedClassManifestTest.php
  206. +8 −4 tests/dev/CSVParserTest.php
  207. +12 −6 tests/dev/CsvBulkLoaderTest.php
  208. +51 −23 tests/filesystem/FileTest.php
  209. +15 −7 tests/filesystem/FolderTest.php
  210. +6 −3 tests/forms/CheckboxFieldTest.php
  211. +1 −1  tests/forms/CheckboxSetFieldTest.php
  212. +4 −2 tests/forms/ComplexTableFieldTest.php
  213. +8 −4 tests/forms/ConfirmedPasswordFieldTest.php
  214. +4 −2 tests/forms/DatetimeFieldTest.php
  215. +4 −2 tests/forms/DropdownFieldTest.php
  216. +13 −3 tests/forms/EmailFieldTest.php
  217. +4 −3 tests/forms/FieldListTest.php
  218. +6 −6 tests/forms/FormFieldTest.php
  219. +18 −9 tests/forms/FormScaffolderTest.php
  220. +4 −2 tests/forms/FormTest.php
  221. +16 −8 tests/forms/GridFieldTest.php
  222. +2 −1  tests/forms/ListboxFieldTest.php
  223. +4 −3 tests/forms/LookupFieldTest.php
  224. +8 −4 tests/forms/MemberDatetimeOptionsetFieldTest.php
  225. +64 −33 tests/forms/RequirementsTest.php
  226. +2 −1  tests/forms/TableListFieldTest.php
  227. +2 −1  tests/forms/TextareaFieldTest.php
  228. +4 −2 tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php
  229. +2 −1  tests/forms/gridfield/GridFieldDataColumnsTest.php
  230. +16 −8 tests/forms/gridfield/GridFieldDeleteActionTest.php
  231. +10 −5 tests/forms/gridfield/GridFieldDetailFormTest.php
  232. +2 −1  tests/forms/gridfield/GridFieldEditButtonTest.php
  233. +2 −1  tests/forms/gridfield/GridFieldPaginatorTest.php
  234. +33 −14 tests/forms/uploadfield/UploadFieldTest.php
  235. +12 −6 tests/i18n/i18nTest.php
  236. +26 −16 tests/i18n/i18nTextCollectorTest.php
  237. +6 −3 tests/injector/InjectorTest.php
  238. +2 −1  tests/model/ArrayListTest.php
  239. +2 −1  tests/model/CurrencyTest.php
  240. +4 −2 tests/model/DataDifferencerTest.php
  241. +4 −2 tests/model/DataExtensionTest.php
  242. +44 −13 tests/model/DataListTest.php
  243. +15 −8 tests/model/DataObjectDuplicationTest.php
  244. +10 −6 tests/model/DataObjectLazyLoadingTest.php
  245. +2 −1  tests/model/DataObjectSchemaGenerationTest.php
  246. +131 −69 tests/model/DataObjectTest.php
  247. +16 −8 tests/model/DataQueryTest.php
  248. +8 −4 tests/model/DatabaseTest.php
  249. +17 −8 tests/model/DbDatetimeTest.php
  250. +8 −4 tests/model/DecimalTest.php
  251. +10 −5 tests/model/HTMLTextTest.php
  252. +7 −3 tests/model/ImageTest.php
  253. +32 −16 tests/model/ManyManyListTest.php
  254. +2 −1  tests/model/MoneyTest.php
  255. +2 −1  tests/model/PaginatedListTest.php
  256. +17 −6 tests/model/SQLQueryTest.php
  257. +6 −3 tests/model/TextTest.php
  258. +46 −23 tests/model/VersionedTest.php
  259. +11 −4 tests/oembed/OembedTest.php
  260. +12 −6 tests/parsers/ShortcodeParserTest.php
  261. +3 −1 tests/search/FulltextSearchableTest.php
  262. +10 −5 tests/search/SearchFilterApplyRelationTest.php
  263. +8 −4 tests/security/GroupTest.php
  264. +2 −1  tests/security/MemberAuthenticatorTest.php
  265. +10 −5 tests/security/MemberTest.php
  266. +18 −9 tests/security/PasswordEncryptorTest.php
  267. +24 −12 tests/security/PermissionCheckboxSetFieldTest.php
  268. +4 −2 tests/security/PermissionRoleTest.php
  269. +13 −7 tests/security/SecurityTest.php
  270. +2 −1  tests/testing/CSSContentParserTest.php
  271. +4 −2 tests/testing/YamlFixtureTest.php
  272. +21 −21 tests/travis/_config.php
  273. +40 −20 tests/view/SSViewerCacheBlockTest.php
  274. +103 −54 tests/view/SSViewerTest.php
  275. +6 −5 tests/view/ViewableDataTest.php
  276. +2 −1  view/GenericTemplateGlobalProvider.php
  277. +28 −16 view/Requirements.php
  278. +209 −189 view/SSTemplateParser.php
  279. +111 −79 view/SSTemplateParser.php.inc
  280. +59 −24 view/SSViewer.php
  281. +4 −3 view/TemplateGlobalProvider.php
  282. +7 −7 view/TemplateIteratorProvider.php
View
17 _register_database.php
@@ -18,7 +18,9 @@
'title' => 'SQL Server 2008',
'helperPath' => 'mssql/code/MSSQLDatabaseConfigurationHelper.php',
'supported' => (function_exists('mssql_connect') || function_exists('sqlsrv_connect')),
- 'missingExtensionText' => 'Neither the <a href="http://php.net/mssql">mssql</a> or <a href="http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx">sqlsrv</a> PHP extensions are available. Please install or enable one of them and refresh this page.'
+ 'missingExtensionText' => 'Neither the <a href="http://php.net/mssql">mssql</a> or'
+ . ' <a href="http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx">sqlsrv</a> PHP extensions are'
+ . ' available. Please install or enable one of them and refresh this page.'
)
);
@@ -28,7 +30,8 @@
'title' => 'PostgreSQL 8.3+',
'helperPath' => 'postgresql/code/PostgreSQLDatabaseConfigurationHelper.php',
'supported' => function_exists('pg_query'),
- 'missingExtensionText' => 'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not available. Please install or enable it and refresh this page.'
+ 'missingExtensionText' => 'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not available. Please'
+ . ' install or enable it and refresh this page.'
)
);
@@ -38,11 +41,15 @@
'title' => 'SQLite 3.3+',
'helperPath' => 'sqlite3/code/SQLiteDatabaseConfigurationHelper.php',
'supported' => (class_exists('SQLite3') || class_exists('PDO')),
- 'missingExtensionText' => 'The <a href="http://php.net/manual/en/book.sqlite3.php">SQLite3</a> and <a href="http://php.net/manual/en/book.pdo.php">PDO</a> classes are not available. Please install or enable one of them and refresh this page.',
+ 'missingExtensionText' => 'The <a href="http://php.net/manual/en/book.sqlite3.php">SQLite3</a> and'
+ . ' <a href="http://php.net/manual/en/book.pdo.php">PDO</a> classes are not available. Please install or'
+ . ' enable one of them and refresh this page.',
'fields' => array(
'path' => array(
- 'title' => 'Database path<br /><small>Absolute path, writeable by the webserver user.<br />Recommended to be outside of your webroot</small>',
- 'default' => realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . '.db'
+ 'title' => 'Database path<br /><small>Absolute path, writeable by the webserver user.<br />'
+ . 'Recommended to be outside of your webroot</small>',
+ 'default' => realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR . 'assets'
+ . DIRECTORY_SEPARATOR . '.db'
),
'database' => array(
'title' => 'Database name',
View
25 admin/_config.php
@@ -11,16 +11,33 @@
'cleanup_callback' => "sapphiremce_cleanup",
'use_native_selects' => true, // fancy selects are bug as of SS 2.3.0
- 'valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align],address[class|align],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]",
- 'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]",
+ 'valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title"
+ . "|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],"
+ . "-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],"
+ . "-sub[class],-sup[class],-blockquote[dir|class],"
+ . "-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],"
+ . "-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],"
+ . "tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],"
+ . "#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],"
+ . "-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],"
+ . "-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align],address[class|align],"
+ . "-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],"
+ . "-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],"
+ . "dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class]",
+ 'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name"
+ . "|usemap],iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],"
+ . "object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]",
'spellchecker_rpc_url' => THIRDPARTY_DIR . '/tinymce-spellchecker/rpc.php'
));
HtmlEditorConfig::get('cms')->enablePlugins('media', 'fullscreen', 'inlinepopups');
-HtmlEditorConfig::get('cms')->enablePlugins(array('ssbuttons' => sprintf('../../../%s/tinymce_ssbuttons/editor_plugin_src.js', THIRDPARTY_DIR)));
+HtmlEditorConfig::get('cms')->enablePlugins(array(
+ 'ssbuttons' => sprintf('../../../%s/tinymce_ssbuttons/editor_plugin_src.js', THIRDPARTY_DIR)
+));
HtmlEditorConfig::get('cms')->insertButtonsBefore('formatselect', 'styleselect');
-HtmlEditorConfig::get('cms')->addButtonsToLine(2, 'ssmedia', 'ssflash', 'sslink', 'unlink', 'anchor', 'separator','code', 'fullscreen', 'separator');
+HtmlEditorConfig::get('cms')->addButtonsToLine(2,
+ 'ssmedia', 'ssflash', 'sslink', 'unlink', 'anchor', 'separator','code', 'fullscreen', 'separator');
HtmlEditorConfig::get('cms')->removeButtons('tablecontrols');
HtmlEditorConfig::get('cms')->addButtonsToLine(3, 'tablecontrols');
View
3  admin/code/AdminRootController.php
@@ -13,7 +13,8 @@ class AdminRootController extends Controller {
/**
* @var string
* @config
- * The LeftAndMain child that will be used as the initial panel to display if none is selected (i.e. if you visit /admin)
+ * The LeftAndMain child that will be used as the initial panel to display if none is selected (i.e. if you
+ * visit /admin)
*/
static $default_panel = 'SecurityAdmin';
View
8 admin/code/CMSBatchActionHandler.php
@@ -85,7 +85,9 @@ public function handleAction($request) {
foreach($ids as $k => $v) if(!is_numeric($v)) unset($ids[$k]);
if($ids) {
- if(class_exists('Translatable') && Object::has_extension('SiteTree','Translatable')) Translatable::disable_locale_filter();
+ if(class_exists('Translatable') && Object::has_extension('SiteTree','Translatable')) {
+ Translatable::disable_locale_filter();
+ }
$pages = DataObject::get(
$this->recordClass,
@@ -96,7 +98,9 @@ public function handleAction($request) {
)
);
- if(class_exists('Translatable') && Object::has_extension('SiteTree','Translatable')) Translatable::enable_locale_filter();
+ if(class_exists('Translatable') && Object::has_extension('SiteTree','Translatable')) {
+ Translatable::enable_locale_filter();
+ }
if(Object::has_extension($this->recordClass, 'Versioned')) {
// If we didn't query all the pages, then find the rest on the live site
View
3  admin/code/CMSMenu.php
@@ -77,7 +77,8 @@ protected static function menuitem_for_controller($controllerClass) {
* @param string $code A unique identifier (used to create a CSS ID and its key in {@link $menu_items})
* @param string $menuTitle The link's title in the CMS menu
* @param string $url The url of the link
- * @param integer $priority The menu priority (sorting order) of the menu item. Higher priorities will be further left.
+ * @param integer $priority The menu priority (sorting order) of the menu item. Higher priorities will be further
+ * left.
* @return boolean The result of the operation.
*/
public static function add_link($code, $menuTitle, $url, $priority = -1) {
View
21 admin/code/GroupImportForm.php
@@ -17,7 +17,8 @@ public function __construct($controller, $name, $fields = null, $actions = null,
if(!$fields) {
$helpHtml = _t(
'GroupImportForm.Help1',
- '<p>Import one or more groups in <em>CSV</em> format (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
+ '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).'
+ . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
);
$helpHtml .= _t(
'GroupImportForm.Help2',
@@ -25,9 +26,11 @@ public function __construct($controller, $name, $fields = null, $actions = null,
<h4>Advanced usage</h4>
<ul>
<li>Allowed columns: <em>%s</em></li>
- <li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the imported file</li>
+ <li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the
+ imported file</li>
<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>
- <li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not cleared.</li>
+ <li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not
+ cleared.</li>
</ul>
</div>');
@@ -48,12 +51,12 @@ public function __construct($controller, $name, $fields = null, $actions = null,
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
- if(!$actions) $actions = new FieldList(
- $importAction = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'))
- );
-
- $importAction->addExtraClass('ss-ui-button');
-
+ if(!$actions) {
+ $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
+ $action->addExtraClass('ss-ui-button');
+ $actions = new FieldList($action);
+ }
+
if(!$validator) $validator = new RequiredFields('CsvFile');
parent::__construct($controller, $name, $fields, $actions, $validator);
View
74 admin/code/LeftAndMain.php
@@ -200,9 +200,14 @@ public function init() {
// if no alternate menu items have matched, return a permission error
$messageSet = array(
- 'default' => _t('LeftAndMain.PERMDEFAULT',"Please choose an authentication method and enter your credentials to access the CMS."),
- 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY',"I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below"),
- 'logInAgain' => _t('LeftAndMain.PERMAGAIN',"You have been logged out of the CMS. If you would like to log in again, enter a username and password below."),
+ 'default' => _t('LeftAndMain.PERMDEFAULT',
+ "Please choose an authentication method and enter your credentials to access the CMS."),
+ 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY',
+ "I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do"
+ . " so below"),
+ 'logInAgain' => _t('LeftAndMain.PERMAGAIN',
+ "You have been logged out of the CMS. If you would like to log in again, enter a username and"
+ . " password below."),
);
return Security::permissionFailure($this, $messageSet);
@@ -683,7 +688,9 @@ public function SiteTreeAsUL() {
* Children, AllChildrenIncludingDeleted, or AllHistoricalChildren
* @return String Nested unordered list with links to each page
*/
- public function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null, $filterFunction = null, $minNodeCount = 30) {
+ public function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $numChildrenMethod = null,
+ $filterFunction = null, $minNodeCount = 30) {
+
// Filter criteria
$params = $this->request->getVar('q');
if(isset($params['FilterClass']) && $filterClass = $params['FilterClass']){
@@ -696,7 +703,10 @@ public function getSiteTreeFor($className, $rootID = null, $childrenMethod = nul
}
// Default childrenMethod and numChildrenMethod
- if(!$childrenMethod) $childrenMethod = ($filter && $filter->getChildrenMethod()) ? $filter->getChildrenMethod() : 'AllChildrenIncludingDeleted';
+ if(!$childrenMethod) $childrenMethod = ($filter && $filter->getChildrenMethod())
+ ? $filter->getChildrenMethod()
+ : 'AllChildrenIncludingDeleted';
+
if(!$numChildrenMethod) $numChildrenMethod = 'numChildren';
if(!$filterFunction) $filterFunction = ($filter) ? array($filter, 'isPageIncluded') : null;
@@ -714,7 +724,8 @@ public function getSiteTreeFor($className, $rootID = null, $childrenMethod = nul
// NOTE: SiteTree/CMSMain coupling :-(
if(class_exists('SiteTree')) {
- SiteTree::prepopulate_permission_cache('CanEditType', $obj->markedNodeIDs(), 'SiteTree::can_edit_multiple');
+ SiteTree::prepopulate_permission_cache('CanEditType', $obj->markedNodeIDs(),
+ 'SiteTree::can_edit_multiple');
}
// getChildrenAsUL is a flexible and complex way of traversing the tree
@@ -789,20 +800,31 @@ public function updatetreenodes($request) {
$ids = explode(',', $request->getVar('ids'));
foreach($ids as $id) {
$record = $this->getRecord($id);
- $recordController = ($this->stat('tree_class') == 'SiteTree') ? singleton('CMSPageEditController') : $this;
+ $recordController = ($this->stat('tree_class') == 'SiteTree')
+ ? singleton('CMSPageEditController')
+ : $this;
// Find the next & previous nodes, for proper positioning (Sort isn't good enough - it's not a raw offset)
// TODO: These methods should really be in hierarchy - for a start it assumes Sort exists
$next = $prev = null;
$className = $this->stat('tree_class');
- $next = DataObject::get($className)->filter('ParentID', $record->ParentID)->filter('Sort:GreaterThan', $record->Sort)->first();
+ $next = DataObject::get($className)
+ ->filter('ParentID', $record->ParentID)
+ ->filter('Sort:GreaterThan', $record->Sort)
+ ->first();
+
if (!$next) {
- $prev = DataObject::get($className)->filter('ParentID', $record->ParentID)->filter('Sort:LessThan', $record->Sort)->reverse()->first();
+ $prev = DataObject::get($className)
+ ->filter('ParentID', $record->ParentID)
+ ->filter('Sort:LessThan', $record->Sort)
+ ->reverse()
+ ->first();
}
$link = Controller::join_links($recordController->Link("show"), $record->ID);
- $html = LeftAndMain_TreeNode::create($record, $link, $this->isCurrentPage($record))->forTemplate() . '</li>';
+ $html = LeftAndMain_TreeNode::create($record, $link, $this->isCurrentPage($record))
+ ->forTemplate() . '</li>';
$data[$id] = array(
'html' => $html,
@@ -874,7 +896,8 @@ public function savetreenode($request) {
if (!Permission::check('SITETREE_REORGANISE') && !Permission::check('ADMIN')) {
$this->response->setStatusCode(
403,
- _t('LeftAndMain.CANT_REORGANISE',"You do not have permission to rearange the site tree. Your change was not saved.")
+ _t('LeftAndMain.CANT_REORGANISE',
+ "You do not have permission to rearange the site tree. Your change was not saved.")
);
return;
}
@@ -889,7 +912,8 @@ public function savetreenode($request) {
if(($parentID == '0' || $root == 'root') && !SiteConfig::current_site_config()->canCreateTopLevel()){
$this->response->setStatusCode(
403,
- _t('LeftAndMain.CANT_REORGANISE',"You do not have permission to alter Top level pages. Your change was not saved.")
+ _t('LeftAndMain.CANT_REORGANISE',
+ "You do not have permission to alter Top level pages. Your change was not saved.")
);
return;
}
@@ -905,8 +929,7 @@ public function savetreenode($request) {
if(!$node) {
$this->response->setStatusCode(
500,
- _t(
- 'LeftAndMain.PLEASESAVE',
+ _t('LeftAndMain.PLEASESAVE',
"Please Save Page: This page could not be upated because it hasn't been saved yet."
)
);
@@ -933,7 +956,8 @@ public function savetreenode($request) {
}
}
- $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.')));
+ $this->response->addHeader('X-Status',
+ rawurlencode(_t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.')));
}
// Update sorting
@@ -950,11 +974,13 @@ public function savetreenode($request) {
// Nodes that weren't "actually moved" shouldn't be registered as
// having been edited; do a direct SQL update instead
++$counter;
- DB::query(sprintf("UPDATE \"%s\" SET \"Sort\" = %d WHERE \"ID\" = '%d'", $className, $counter, $id));
+ DB::query(sprintf("UPDATE \"%s\" SET \"Sort\" = %d WHERE \"ID\" = '%d'",
+ $className, $counter, $id));
}
}
- $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.')));
+ $this->response->addHeader('X-Status',
+ rawurlencode(_t('LeftAndMain.REORGANISATIONSUCCESSFUL', 'Reorganised the site tree successfully.')));
}
return Convert::raw2json($statusUpdates);
@@ -1527,7 +1553,8 @@ public function __construct($params = null) {
// We need to recurse up the tree,
// finding ParentIDs for each ID until we run out of parents
while (!empty($parents)) {
- $res = DB::query('SELECT "ParentID", "ID" FROM "SiteTree" WHERE "ID" in ('.implode(',',array_keys($parents)).')');
+ $res = DB::query('SELECT "ParentID", "ID" FROM "SiteTree"'
+ . ' WHERE "ID" in ('.implode(',',array_keys($parents)).')');
$parents = array();
foreach($res as $row) {
@@ -1623,12 +1650,11 @@ public function __construct($obj, $link = null, $isCurrent = false) {
*/
public function forTemplate() {
$obj = $this->obj;
- return "<li id=\"record-$obj->ID\" data-id=\"$obj->ID\" data-pagetype=\"$obj->ClassName\" class=\"" . $this->getClasses() . "\">" .
- "<ins class=\"jstree-icon\">&nbsp;</ins>" .
- "<a href=\"" . $this->getLink() . "\" title=\"" .
- _t('LeftAndMain.PAGETYPE','Page type: ') .
- "$obj->class\" ><ins class=\"jstree-icon\">&nbsp;</ins><span class=\"text\">" . ($obj->TreeTitle).
- "</span></a>";
+ return "<li id=\"record-$obj->ID\" data-id=\"$obj->ID\" data-pagetype=\"$obj->ClassName\" class=\""
+ . $this->getClasses() . "\">" . "<ins class=\"jstree-icon\">&nbsp;</ins>"
+ . "<a href=\"" . $this->getLink() . "\" title=\"" . _t('LeftAndMain.PAGETYPE','Page type: ')
+ . "$obj->class\" ><ins class=\"jstree-icon\">&nbsp;</ins><span class=\"text\">" . ($obj->TreeTitle)
+ . "</span></a>";
}
public function getClasses() {
View
19 admin/code/MemberImportForm.php
@@ -17,7 +17,8 @@ public function __construct($controller, $name, $fields = null, $actions = null,
if(!$fields) {
$helpHtml = _t(
'MemberImportForm.Help1',
- '<p>Import users in <em>CSV format</em> (comma-separated values). <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
+ '<p>Import users in <em>CSV format</em> (comma-separated values).'
+ . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>'
);
$helpHtml .= _t(
'MemberImportForm.Help2',
@@ -25,8 +26,10 @@ public function __construct($controller, $name, $fields = null, $actions = null,
<h4>Advanced usage</h4>
<ul>
<li>Allowed columns: <em>%s</em></li>
- <li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from the imported file.</li>
- <li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, multiple groups can be separated by comma. Existing group memberships are not cleared.</li>
+ <li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from
+ the imported file.</li>
+ <li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property,
+ multiple groups can be separated by comma. Existing group memberships are not cleared.</li>
</ul>
</div>');
@@ -47,11 +50,11 @@ public function __construct($controller, $name, $fields = null, $actions = null,
$fileField->getValidator()->setAllowedExtensions(array('csv'));
}
- if(!$actions) $actions = new FieldList(
- $importAction = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'))
- );
-
- $importAction->addExtraClass('ss-ui-button');
+ if(!$actions) {
+ $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
+ $action->addExtraClass('ss-ui-button');
+ $actions = new FieldList($action);
+ }
if(!$validator) $validator = new RequiredFields('CsvFile');
View
23 admin/code/ModelAdmin.php
@@ -17,7 +17,8 @@
* @todo ajax result display
* @todo relation formfield scaffolding (one tab per relation) - relations don't have DBField sublclasses, we do
* we define the scaffold defaults. can be ComplexTableField instances for a start.
- * @todo has_many/many_many relation autocomplete field (HasManyComplexTableField doesn't work well with larger datasets)
+ * @todo has_many/many_many relation autocomplete field (HasManyComplexTableField doesn't work well with larger
+ * datasets)
*
* Long term TODOs:
* @todo Hook into RESTful interface on DataObjects (yet to be developed)
@@ -150,7 +151,8 @@ public function getEditForm($id = null, $fields = null) {
);
$form->addExtraClass('cms-edit-form cms-panel-padded center');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
- $form->setFormAction(Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm'));
+ $editFormAction = Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'EditForm');
+ $form->setFormAction($editFormAction);
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
$this->extend('updateEditForm', $form);
@@ -354,7 +356,10 @@ public function ImportForm() {
))->renderWith('ModelAdmin_ImportSpec');
$fields->push(new LiteralField("SpecFor{$modelName}", $specHTML));
- $fields->push(new CheckboxField('EmptyBeforeImport', _t('ModelAdmin.EMPTYBEFOREIMPORT', 'Clear Database before import'), false));
+ $fields->push(
+ new CheckboxField('EmptyBeforeImport', _t('ModelAdmin.EMPTYBEFOREIMPORT', 'Clear Database before import'),
+ false)
+ );
$actions = new FieldList(
new FormAction('import', _t('ModelAdmin.IMPORT', 'Import from CSV'))
@@ -366,7 +371,9 @@ public function ImportForm() {
$fields,
$actions
);
- $form->setFormAction(Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'ImportForm'));
+ $form->setFormAction(
+ Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'ImportForm')
+ );
$this->extend('updateImportForm', $form);
@@ -385,7 +392,9 @@ public function ImportForm() {
* @param SS_HTTPRequest $request
*/
public function import($data, $form, $request) {
- if(!$this->showImportForm || (is_array($this->showImportForm) && !in_array($this->modelClass,$this->showImportForm))) {
+ if(!$this->showImportForm || (is_array($this->showImportForm)
+ && !in_array($this->modelClass,$this->showImportForm))) {
+
return false;
}
@@ -420,7 +429,9 @@ public function import($data, $form, $request) {
'ModelAdmin.DELETEDRECORDS', "Deleted {count} records.",
array('count' => $results->DeletedCount())
);
- if(!$results->CreatedCount() && !$results->UpdatedCount()) $message .= _t('ModelAdmin.NOIMPORT', "Nothing to import");
+ if(!$results->CreatedCount() && !$results->UpdatedCount()) {
+ $message .= _t('ModelAdmin.NOIMPORT', "Nothing to import");
+ }
$form->sessionMessage($message, 'good');
$this->redirectBack();
View
16 admin/code/SecurityAdmin.php
@@ -96,7 +96,8 @@ public function getEditForm($id = null, $fields = null) {
sprintf('<p class="caution-remove"><strong>%s</strong></p>',
_t(
'SecurityAdmin.MemberListCaution',
- 'Caution: Removing members from this list will remove them from all groups and the database'
+ 'Caution: Removing members from this list will remove them from all groups and the'
+ . ' database'
)
)
),
@@ -104,7 +105,8 @@ public function getEditForm($id = null, $fields = null) {
new LiteralField(
'MemberImportFormIframe',
sprintf(
- '<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" border="0"></iframe>',
+ '<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" border="0">'
+ . '</iframe>',
$this->Link('memberimport')
)
)
@@ -115,7 +117,8 @@ public function getEditForm($id = null, $fields = null) {
new LiteralField(
'GroupImportFormIframe',
sprintf(
- '<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" border="0"></iframe>',
+ '<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" border="0">'
+ . '</iframe>',
$this->Link('groupimport')
)
)
@@ -280,13 +283,16 @@ public function providePermissions() {
'EDIT_PERMISSIONS' => array(
'name' => _t('SecurityAdmin.EDITPERMISSIONS', 'Manage permissions for groups'),
'category' => _t('Permissions.PERMISSIONS_CATEGORY', 'Roles and access permissions'),
- 'help' => _t('SecurityAdmin.EDITPERMISSIONS_HELP', 'Ability to edit Permissions and IP Addresses for a group. Requires the "Access to \'Security\' section" permission.'),
+ 'help' => _t('SecurityAdmin.EDITPERMISSIONS_HELP',
+ 'Ability to edit Permissions and IP Addresses for a group.'
+ . ' Requires the "Access to \'Security\' section" permission.'),
'sort' => 0
),
'APPLY_ROLES' => array(
'name' => _t('SecurityAdmin.APPLY_ROLES', 'Apply roles to groups'),
'category' => _t('Permissions.PERMISSIONS_CATEGORY', 'Roles and access permissions'),
- 'help' => _t('SecurityAdmin.APPLY_ROLES_HELP', 'Ability to edit the roles assigned to a group. Requires the "Access to \'Users\' section" permission.'),
+ 'help' => _t('SecurityAdmin.APPLY_ROLES_HELP', 'Ability to edit the roles assigned to a group.'
+ . ' Requires the "Access to \'Users\' section" permission.'),
'sort' => 0
)
);
View
54 admin/javascript/LeftAndMain.FieldHelp.js
@@ -1,27 +1,27 @@
-(function($) {
- $.entwine('ss', function($) {
- /**
- * Takes form fields with a title attribute, extracts it, and displays
- * it as inline help text below the field.
- */
- $(".cms form .field .middleColumn > [title]").entwine({
- onmatch: function() {
-
- var title = this.prop("title");
- var field = this.closest(".field");
-
- if(title && title.length && field.has('.help').length == 0) {
- var span = $("<span></span>", {
- "class": "help",
- "text": title
- });
-
- field.append(span);
- this.removeProp("title");
- }
-
- this._super();
- }
- });
- });
-}(jQuery));
+(function($) {
+ $.entwine('ss', function($) {
+ /**
+ * Takes form fields with a title attribute, extracts it, and displays
+ * it as inline help text below the field.
+ */
+ $(".cms form .field .middleColumn > [title]").entwine({
+ onmatch: function() {
+
+ var title = this.prop("title");
+ var field = this.closest(".field");
+
+ if(title && title.length && field.has('.help').length == 0) {
+ var span = $("<span></span>", {
+ "class": "help",
+ "text": title
+ });
+
+ field.append(span);
+ this.removeProp("title");
+ }
+
+ this._super();
+ }
+ });
+ });
+}(jQuery));
View
9 admin/tests/CMSMenuTest.php
@@ -17,9 +17,12 @@ public function testBasicMenuHandling() {
$menuItems = CMSMenu::get_menu_items();
$menuItem = $menuItems['CMSMenuTest_LeftAndMainController'];
$this->assertInstanceOf('CMSMenuItem', $menuItem, 'Controller menu item is of class CMSMenuItem');
- $this->assertEquals($menuItem->url, singleton('CMSMenuTest_LeftAndMainController')->Link(), 'Controller menu item has the correct link');
- $this->assertEquals($menuItem->controller, 'CMSMenuTest_LeftAndMainController', 'Controller menu item has the correct controller class');
- $this->assertEquals($menuItem->priority, singleton('CMSMenuTest_LeftAndMainController')->stat('menu_priority'), 'Controller menu item has the correct priority');
+ $this->assertEquals($menuItem->url, singleton('CMSMenuTest_LeftAndMainController')->Link(),
+ 'Controller menu item has the correct link');
+ $this->assertEquals($menuItem->controller, 'CMSMenuTest_LeftAndMainController',
+ 'Controller menu item has the correct controller class');
+ $this->assertEquals($menuItem->priority, singleton('CMSMenuTest_LeftAndMainController')->stat('menu_priority'),
+ 'Controller menu item has the correct priority');
CMSMenu::clear_menu();
// Add a link to the menu
View
5 admin/tests/LeftAndMainTest.php
@@ -23,8 +23,9 @@ public function setUp() {
*/
public function testSaveTreeNodeSorting() {
$this->loginWithPermission('ADMIN');
-
- $rootPages = DataObject::get('LeftAndMainTest_Object', '"ParentID" = 0', '"ID"'); // forcing sorting for non-MySQL
+
+ // forcing sorting for non-MySQL
+ $rootPages = DataObject::get('LeftAndMainTest_Object', '"ParentID" = 0', '"ID"');
$siblingIDs = $rootPages->column('ID');
$page1 = $rootPages->offsetGet(0);
$page2 = $rootPages->offsetGet(1);
View
12 api/DataFormatter.php
@@ -1,7 +1,7 @@
<?php
/**
- * A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output format, and vice versa.
- * This is most commonly used in developing RESTful APIs.
+ * A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output
+ * format, and vice versa. This is most commonly used in developing RESTful APIs.
*
* @package framework
* @subpackage formatters
@@ -247,7 +247,9 @@ protected function getFieldsForObj($obj) {
if(is_array($this->customFields)) {
foreach($this->customFields as $fieldName) {
// @todo Possible security risk by making methods accessible - implement field-level security
- if($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) $dbFields[$fieldName] = $fieldName;
+ if($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) {
+ $dbFields[$fieldName] = $fieldName;
+ }
}
} else {
// by default, all database fields are selected
@@ -257,7 +259,9 @@ protected function getFieldsForObj($obj) {
if(is_array($this->customAddFields)) {
foreach($this->customAddFields as $fieldName) {
// @todo Possible security risk by making methods accessible - implement field-level security
- if($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) $dbFields[$fieldName] = $fieldName;
+ if($obj->hasField($fieldName) || $obj->hasMethod("get{$fieldName}")) {
+ $dbFields[$fieldName] = $fieldName;
+ }
}
}
View
18 api/JSONDataFormatter.php
@@ -74,7 +74,11 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
} else {
$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName");
}
- $serobj->$relName = ArrayData::array_to_object(array("className" => $relClass, "href" => "$href.json", "id" => $obj->$fieldName));
+ $serobj->$relName = ArrayData::array_to_object(array(
+ "className" => $relClass,
+ "href" => "$href.json",
+ "id" => $obj->$fieldName
+ ));
}
foreach($obj->has_many() as $relName => $relClass) {
@@ -89,7 +93,11 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
foreach($items as $item) {
//$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName/$item->ID");
$href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID");
- $innerParts[] = ArrayData::array_to_object(array("className" => $relClass, "href" => "$href.json", "id" => $obj->$fieldName));
+ $innerParts[] = ArrayData::array_to_object(array(
+ "className" => $relClass,
+ "href" => "$href.json",
+ "id" => $obj->$fieldName
+ ));
}
$serobj->$relName = $innerParts;
}
@@ -106,7 +114,11 @@ public function convertDataObjectToJSONObject(DataObjectInterface $obj, $fields
foreach($items as $item) {
//$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName/$item->ID");
$href = Director::absoluteURL(self::$api_base . "$relClass/$item->ID");
- $innerParts[] = ArrayData::array_to_object(array("className" => $relClass, "href" => "$href.json", "id" => $obj->$fieldName));
+ $innerParts[] = ArrayData::array_to_object(array(
+ "className" => $relClass,
+ "href" => "$href.json",
+ "id" => $obj->$fieldName
+ ));
}
$serobj->$relName = $innerParts;
}
View
14 api/RSSFeed.php
@@ -147,7 +147,8 @@ public function Entries() {
if(isset($this->entries)) {
foreach($this->entries as $entry) {
- $output->push(new RSSFeed_Entry($entry, $this->titleField, $this->descriptionField, $this->authorField));
+ $output->push(
+ new RSSFeed_Entry($entry, $this->titleField, $this->descriptionField, $this->authorField));
}
}
return $output;
@@ -329,8 +330,13 @@ public function rssField($fieldName, $defaultClass = 'Varchar') {
* @return string Returns the URL of this entry
*/
public function AbsoluteLink() {
- if($this->failover->hasMethod('AbsoluteLink')) return $this->failover->AbsoluteLink();
- else if($this->failover->hasMethod('Link')) return Director::absoluteURL($this->failover->Link());
- else user_error($this->failover->class . " object has neither an AbsoluteLink nor a Link method. Can't put a link in the RSS feed", E_USER_WARNING);
+ if($this->failover->hasMethod('AbsoluteLink')) {
+ return $this->failover->AbsoluteLink();
+ } else if($this->failover->hasMethod('Link')) {
+ return Director::absoluteURL($this->failover->Link());
+ } else {
+ user_error($this->failover->class . " object has neither an AbsoluteLink nor a Link method."
+ . " Can't put a link in the RSS feed", E_USER_WARNING);
+ }
}
}
View
11 api/RestfulService.php
@@ -94,7 +94,9 @@ protected function constructURL(){
}
/**
- * Makes a request to the RESTful server, and return a {@link RestfulService_Response} object for parsing of the result.
+ * Makes a request to the RESTful server, and return a {@link RestfulService_Response} object for parsing of the
+ * result.
+ *
* @todo Better POST, PUT, DELETE, and HEAD support
* @todo Caching of requests - probably only GET and HEAD requestst
* @todo JSON support in RestfulService_Response
@@ -102,7 +104,8 @@ protected function constructURL(){
*
* This is a replacement of {@link connect()}.
*
- * @return RestfulService_Response - If curl request produces error, the returned response's status code will be 500
+ * @return RestfulService_Response - If curl request produces error, the returned response's status code will
+ * be 500
*/
public function request($subURL = '', $method = "GET", $data = null, $headers = null, $curlOptions = array()) {
@@ -116,7 +119,9 @@ public function request($subURL = '', $method = "GET", $data = null, $headers =
$cache_path = $cachedir."/xmlresponse_$cache_file";
// Check for unexpired cached feed (unless flush is set)
- if(!isset($_GET['flush']) && @file_exists($cache_path) && @filemtime($cache_path) + $this->cache_expire > time()) {
+ if(!isset($_GET['flush']) && @file_exists($cache_path)
+ && @filemtime($cache_path) + $this->cache_expire > time()) {
+
$store = file_get_contents($cache_path);
$response = unserialize($store);
View
3  api/XMLDataFormatter.php
@@ -79,7 +79,8 @@ public function convertDataObjectWithoutHeader(DataObject $obj, $fields = null,
} else {
$href = Director::absoluteURL(self::$api_base . "$className/$id/$relName");
}
- $xml .= "<$relName linktype=\"has_one\" href=\"$href.xml\" id=\"" . $obj->$fieldName . "\"></$relName>\n";
+ $xml .= "<$relName linktype=\"has_one\" href=\"$href.xml\" id=\"" . $obj->$fieldName
+ . "\"></$relName>\n";
}
foreach($obj->has_many() as $relName => $relClass) {
View
36 cache/Cache.php
@@ -15,7 +15,8 @@
*
* USING A CACHE
*
- * $cache = SS_Cache::factory('foo') ; // foo is any name (try to be specific), and is used to get configuration & storage info
+ * $cache = SS_Cache::factory('foo') ; // foo is any name (try to be specific), and is used to get configuration &
+ * storage info
*
* if (!($result = $cache->load($cachekey))) {
* $result = caluate some how;
@@ -24,8 +25,9 @@
*
* return $result;
*
- * Normally there's no need to remove things from the cache - the cache backends clear out entries based on age & maximum
- * allocated storage. If you include the version of the object in the cache key, even object changes don't need any invalidation
+ * Normally there's no need to remove things from the cache - the cache backends clear out entries based on age &
+ * maximum allocated storage. If you include the version of the object in the cache key, even object changes don't
+ * need any invalidation
*
* DISABLING CACHING IN DEV MOVE
*
@@ -38,11 +40,13 @@
* (in _config.php)
*
* SS_Cache::add_backend('primary_memcached', 'Memcached',
- * array('host' => 'localhost', 'port' => 11211, 'persistent' => true, 'weight' => 1, 'timeout' => 5, 'retry_interval' => 15, 'status' => true, 'failure_callback' => '' )
+ * array('host' => 'localhost', 'port' => 11211, 'persistent' => true, 'weight' => 1, 'timeout' => 5,
+ * 'retry_interval' => 15, 'status' => true, 'failure_callback' => '' )
* );
*
* SS_Cache::pick_backend('primary_memcached', 'any', 10);
- * SS_Cache::pick_backend('default', 'aggregate', 20); // Aggregate needs a backend with tag support, which memcached doesn't provide
+ * // Aggregate needs a backend with tag support, which memcached doesn't provide
+ * SS_Cache::pick_backend('default', 'aggregate', 20);
* </code>
*
* USING APC AND FILE AS TWO LEVEL STORE
@@ -54,8 +58,9 @@
* 'fast_backend' => 'Apc',
* 'slow_backend_options' => array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache')
* ));
- *
- * SS_Cache::pick_backend('two-level', 'any', 10); // No need for special backend for aggregate - TwoLevels with a File slow backend supports tags
+ *
+ * // No need for special backend for aggregate - TwoLevels with a File slow backend supports tags
+ * SS_Cache::pick_backend('two-level', 'any', 10);
*
* @author hfried
* @package framework
@@ -75,7 +80,10 @@ protected static function init(){
if (!isset(self::$backends['default'])) {
$cachedir = TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache';
if (!is_dir($cachedir)) mkdir($cachedir);
- self::$backends['default'] = array('File', array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache'));
+ self::$backends['default'] = array(
+ 'File',
+ array('cache_dir' => TEMP_FOLDER . DIRECTORY_SEPARATOR . 'cache')
+ );
self::$cache_lifetime['default'] = array('lifetime' => 600, 'priority' => 1);
}
}
@@ -98,8 +106,9 @@ public static function add_backend($name, $type, $options=array()) {
*
* @param string $name The name of the backend, as passed as the first argument to add_backend
* @param string $for The name of the cache to pick this backend for (or 'any' for any backend)
- * @param integer $priority The priority of this pick - the call with the highest number will be the actual backend picked.
- * A backend picked for a specific cache name will always be used instead of 'any' if it exists, no matter the priority.
+ * @param integer $priority The priority of this pick - the call with the highest number will be the actual
+ * backend picked. A backend picked for a specific cache name will always be used instead
+ * of 'any' if it exists, no matter the priority.
* @return none
*/
public static function pick_backend($name, $for, $priority=1) {
@@ -124,7 +133,8 @@ public static function get_cache_lifetime($for) {
*
* @param string $for The name of the cache to set this lifetime for (or 'any' for all backends)
* @param integer $lifetime The lifetime of an item of the cache, in seconds, or -1 to disable caching
- * @param integer $priority The priority. The highest priority setting is used. Unlike backends, 'any' is not special in terms of priority.
+ * @param integer $priority The priority. The highest priority setting is used. Unlike backends, 'any' is not
+ * special in terms of priority.
*/
public static function set_cache_lifetime($for, $lifetime=600, $priority=1) {
self::init();
@@ -132,7 +142,9 @@ public static function set_cache_lifetime($for, $lifetime=600, $priority=1) {
$current = -1;
if (isset(self::$cache_lifetime[$for])) $current = self::$cache_lifetime[$for]['priority'];
- if ($priority >= $current) self::$cache_lifetime[$for] = array('lifetime' => $lifetime, 'priority' => $priority);
+ if ($priority >= $current) {
+ self::$cache_lifetime[$for] = array('lifetime' => $lifetime, 'priority' => $priority);
+ }
}
/**
View
6 cli-script.php
@@ -3,7 +3,8 @@
/**
* File similar to main.php designed for command-line scripts
*
- * This file lets you execute SilverStripe requests from the command-line. The URL is passed as the first argument to the scripts.
+ * This file lets you execute SilverStripe requests from the command-line. The URL is passed as the first argument to
+ * the scripts.
*
* @package framework
* @subpackage core
@@ -74,7 +75,8 @@
// Get the request URL from the querystring arguments
$url = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : null;
if(!$url) {
- echo 'Please specify an argument to cli-script.php/sake. For more information, visit http://doc.silverstripe.org/doku.php?id=sake';
+ echo 'Please specify an argument to cli-script.php/sake. For more information, visit'
+ . ' http://doc.silverstripe.org/framework/en/topics/commandline';
die();
}
View
38 conf/ConfigureFromEnv.php
@@ -18,20 +18,24 @@
* - SS_DATABASE_TIMEZONE: Set the database timezone to something other than the system timezone.
*
* There is one more setting that is intended to be used by people who work on SilverStripe.
- * - SS_DATABASE_CHOOSE_NAME: Boolean/Int. If set, then the system will choose a default database name for you if one isn't give
- * in the $database variable. The database name will be "SS_" followed by the name of the folder into which you have installed
- * SilverStripe. If this is enabled, it means that the phpinstaller will work out of the box without the installer needing to
- * alter any files. This helps prevent accidental changes to the environment.
+ * - SS_DATABASE_CHOOSE_NAME: Boolean/Int. If set, then the system will choose a default database name for you if
+ * one isn't give in the $database variable. The database name will be "SS_" followed by the name of the folder
+ * into which you have installed SilverStripe. If this is enabled, it means that the phpinstaller will work out of
+ * the box without the installer needing to alter any files. This helps prevent accidental changes to the
+ * environment.
*
- * If SS_DATABASE_CHOOSE_NAME is an integer greater than one, then an ancestor folder will be used for the database name. This
- * is handy for a site that's hosted from /sites/examplesite/www or /buildbot/allmodules-2.3/build. If it's 2, the parent folder
- * will be chosen; if it's 3 the grandparent, and so on.
+ * If SS_DATABASE_CHOOSE_NAME is an integer greater than one, then an ancestor folder will be used for the database
+ * name. This is handy for a site that's hosted from /sites/examplesite/www or /buildbot/allmodules-2.3/build. If
+ * it's 2, the parent folder will be chosen; if it's 3 the grandparent, and so on.
*
* You can configure the environment with this define:
+ *
* - SS_ENVIRONMENT_TYPE: The environment type: dev, test or live.
*
- * You can configure the default admin with these defines
- * - SS_DEFAULT_ADMIN_USERNAME: The username of the default admin - this is a non-database user with administrative privileges.
+ * You can configure the default admin with these defines:
+ *
+ * - SS_DEFAULT_ADMIN_USERNAME: The username of the default admin - this is a non-database user with administrative
+ * privileges.
* - SS_DEFAULT_ADMIN_PASSWORD: The password of the default admin.
* - SS_USE_BASIC_AUTH: Protect the site with basic auth (good for test sites)
*
@@ -46,12 +50,17 @@
* _ss_environment.php handler
*/
if(defined('SS_ENVIRONMENT_FILE')) {
- // Only perform valdiation if SS_ENVIRONMENT_FILE is actually set, which is to say, there is an _ss_environment.php file
+ // Only perform valdiation if SS_ENVIRONMENT_FILE is actually set, which is to say, there is an
+ // _ss_environment.php file
foreach(array(
'SS_DATABASE_PASSWORD',
'SS_DATABASE_USERNAME',
'SS_ENVIRONMENT_TYPE',) as $reqDefine) {
- if(!defined($reqDefine)) user_error("$reqDefine must be defined in your _ss_environment.php. See http://doc.silverstripe.org/doku.php?id=environment-management for more infomration", E_USER_ERROR);
+ if(!defined($reqDefine)) {
+ user_error("$reqDefine must be defined in your _ss_environment.php."
+ . "See http://doc.silverstripe.org/framework/en/topics/environment-management for more infomration",
+ E_USER_ERROR);
+ }
}
}
@@ -100,7 +109,12 @@
}
if(defined('SS_DEFAULT_ADMIN_USERNAME')) {
- if(!defined('SS_DEFAULT_ADMIN_PASSWORD')) user_error("SS_DEFAULT_ADMIN_PASSWORD must be defined in your _ss_environment.php, if SS_DEFAULT_ADMIN_USERNAME is defined. See http://doc.silverstripe.org/doku.php?id=environment-management for more infomration", E_USER_ERROR);
+ if(!defined('SS_DEFAULT_ADMIN_PASSWORD')) {
+ user_error("SS_DEFAULT_ADMIN_PASSWORD must be defined in your _ss_environment.php,"
+ . "if SS_DEFAULT_ADMIN_USERNAME is defined. See "
+ . "http://doc.silverstripe.org/framework/en/topics/environment-management for more infomration",
+ E_USER_ERROR);
+ }
Security::setDefaultAdmin(SS_DEFAULT_ADMIN_USERNAME, SS_DEFAULT_ADMIN_PASSWORD);
}
if(defined('SS_USE_BASIC_AUTH') && SS_USE_BASIC_AUTH) {
View
21 control/ContentNegotiator.php
@@ -33,16 +33,16 @@ class ContentNegotiator {
protected static $enabled = false;
/**
- * Set the character set encoding for this page. By default it's utf-8, but you could change it to, say, windows-1252, to
- * improve interoperability with extended characters being imported from windows excel.
+ * Set the character set encoding for this page. By default it's utf-8, but you could change it to, say,
+ * windows-1252, to improve interoperability with extended characters being imported from windows excel.
*/
public static function set_encoding($encoding) {
self::$encoding = $encoding;
}
/**
- * Return the character encoding set bhy ContentNegotiator::set_encoding(). It's recommended that all classes that need to
- * specify the character set make use of this function.
+ * Return the character encoding set bhy ContentNegotiator::set_encoding(). It's recommended that all classes
+ * that need to specify the character set make use of this function.
*/
public static function get_encoding() {
return self::$encoding;
@@ -70,7 +70,10 @@ public static function enabled_for($response) {
$contentType = $response->getHeader("Content-Type");
// Disable content negotation for other content types
- if($contentType && substr($contentType, 0,9) != 'text/html' && substr($contentType, 0,21) != 'application/xhtml+xml') return false;
+ if($contentType && substr($contentType, 0,9) != 'text/html'
+ && substr($contentType, 0,21) != 'application/xhtml+xml') {
+ return false;
+ }
if(self::$enabled) return true;
else return (substr($response->getBody(),0,5) == '<' . '?xml');
@@ -91,8 +94,8 @@ public static function process(SS_HTTPResponse $response) {
$chosenFormat = $_GET['forceFormat'];
} else {
- // The W3C validator doesn't send an HTTP_ACCEPT header, but it can support xhtml. We put this special case in here so that
- // designers don't get worried that their templates are HTML4.
+ // The W3C validator doesn't send an HTTP_ACCEPT header, but it can support xhtml. We put this special
+ // case in here so that designers don't get worried that their templates are HTML4.
if(isset($_SERVER['HTTP_USER_AGENT']) && substr($_SERVER['HTTP_USER_AGENT'], 0, 14) == 'W3C_Validator/') {
$chosenFormat = "xhtml";
@@ -175,7 +178,9 @@ public function html(SS_HTTPResponse $response) {
// Only replace the doctype in templates with the xml header
if($hasXMLHeader) {
- $content = preg_replace('/<!DOCTYPE[^>]+>/', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', $content);
+ $content = preg_replace('/<!DOCTYPE[^>]+>/',
+ '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
+ $content);
}
$content = preg_replace('/<html xmlns="[^"]+"/','<html ', $content);
View
35 control/Controller.php
@@ -76,7 +76,8 @@ public function init() {
$member = Member::currentUser();
if($member) {
if(!headers_sent()) Cookie::set("PastMember", true, 90, null, null, false, true);
- DB::query("UPDATE \"Member\" SET \"LastVisited\" = " . DB::getConn()->now() . " WHERE \"ID\" = $member->ID", null);
+ DB::query("UPDATE \"Member\" SET \"LastVisited\" = " . DB::getConn()->now()
+ . " WHERE \"ID\" = $member->ID", null);
}
}
@@ -136,7 +137,10 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
// Init
$this->baseInitCalled = false;
$this->init();
- if(!$this->baseInitCalled) user_error("init() method on class '$this->class' doesn't call Controller::init(). Make sure that you have parent::init() included.", E_USER_WARNING);
+ if(!$this->baseInitCalled) {
+ user_error("init() method on class '$this->class' doesn't call Controller::init()."
+ . "Make sure that you have parent::init() included.", E_USER_WARNING);
+ }
$this->extend('onAfterInit');
@@ -148,12 +152,18 @@ public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
$body = parent::handleRequest($request, $model);
if($body instanceof SS_HTTPResponse) {
- if(isset($_REQUEST['debug_request'])) Debug::message("Request handler returned SS_HTTPResponse object to $this->class controller; returning it without modification.");
+ if(isset($_REQUEST['debug_request'])) {
+ Debug::message("Request handler returned SS_HTTPResponse object to $this->class controller;"
+ . "returning it without modification.");
+ }
$this->response = $body;
} else {
if(is_object($body)) {
- if(isset($_REQUEST['debug_request'])) Debug::message("Request handler $body->class object to $this->class controller;, rendering with template returned by $body->class::getViewer()");
+ if(isset($_REQUEST['debug_request'])) {
+ Debug::message("Request handler $body->class object to $this->class controller;"
+ . "rendering with template returned by $body->class::getViewer()");
+ }
$body = $body->getViewer($request->latestParam('Action'))->process($body);
}
@@ -407,12 +417,12 @@ public function can($perm, $member = null) {
}
}
- //-----------------------------------------------------------------------------------
+ //---------------------------------------------------------------------------------------------------------------
/**
* Pushes this controller onto the stack of current controllers.
- * This means that any redirection, session setting, or other things that rely on Controller::curr() will now write to this
- * controller object.
+ * This means that any redirection, session setting, or other things that rely on Controller::curr() will now
+ * write to this controller object.
*/
public function pushCurrent() {
array_unshift(self::$controller_stack, $this);
@@ -433,7 +443,8 @@ public function popCurrent() {
if($this === self::$controller_stack[0]) {
array_shift(self::$controller_stack);
} else {
- user_error("popCurrent called on $this->class controller, but it wasn't at the top of the stack", E_USER_WARNING);
+ user_error("popCurrent called on $this->class controller, but it wasn't at the top of the stack",
+ E_USER_WARNING);
}
}
@@ -444,12 +455,13 @@ public function redirect($url, $code=302) {
if(!$this->response) $this->response = new SS_HTTPResponse();
if($this->response->getHeader('Location')) {
- user_error("Already directed to " . $this->response->getHeader('Location') . "; now trying to direct to $url", E_USER_WARNING);
+ user_error("Already directed to " . $this->response->getHeader('Location')
+ . "; now trying to direct to $url", E_USER_WARNING);
return;
}
// Attach site-root to relative links, if they have a slash in them
- if($url == "" || $url[0] == '?' || (substr($url,0,4) != "http" && $url[0] != "/" && strpos($url,'/') !== false)){
+ if($url=="" || $url[0]=='?' || (substr($url,0,4) != "http" && $url[0] != "/" && strpos($url,'/') !== false)) {
$url = Director::baseURL() . $url;
}
@@ -491,7 +503,8 @@ public function redirectBack() {
/**
* Tests whether a redirection has been requested.
- * @return string If redirect() has been called, it will return the URL redirected to. Otherwise, it will return null;
+ * @return string If redirect() has been called, it will return the URL redirected to. Otherwise, it will
+ * return null;
*/
public function redirectedTo() {
return $this->response && $this->response->getHeader('Location');
View
6 control/Cookie.php
@@ -23,14 +23,16 @@ class Cookie {
* @param boolean $secure See http://php.net/set_session
* @param boolean $httpOnly See http://php.net/set_session
*/
- public static function set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) {
+ public static function set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false,
+ $httpOnly = false) {
if(!headers_sent($file, $line)) {
$expiry = $expiry > 0 ? time()+(86400*$expiry) : $expiry;
$path = ($path) ? $path : Director::baseURL();
setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
} else {
if(self::$report_errors) {
- user_error("Cookie '$name' can't be set. The site started outputting was content at line $line in $file", E_USER_WARNING);
+ user_error("Cookie '$name' can't be set. The site started outputting content at line $line in $file",
+ E_USER_WARNING);
}
}
}
View
120 control/Director.php
@@ -2,10 +2,11 @@
/**
* Director is responsible for processing URLs, and providing environment information.
*
- * The most important part of director is {@link Director::direct()}, which is passed a URL and will execute the appropriate
- * controller.
+ * The most important part of director is {@link Director::direct()}, which is passed a URL and will execute the
+ * appropriate controller.
*
- * Director also has a number of static methods that provide information about the environment, such as {@link Director::set_environment_type()}.
+ * Director also has a number of static methods that provide information about the environment, such as
+ * {@link Director::set_environment_type()}.
*
* @package framework
* @subpackage control
@@ -37,12 +38,14 @@ class Director implements TemplateGlobalProvider {
*
* The director is responsible for turning URLs into Controller objects.
*
- * @param $priority The priority of the rules; higher values will get your rule checked first.
- * We recommend priority 100 for your site's rules. The built-in rules are priority 10, standard modules are priority 50.
+ * @param $priority The priority of the rules; higher values will get your rule checked first. We recommend
+ * priority 100 for your site's rules. The built-in rules are priority 10, standard modules are
+ * priority 50.
*/
public static function addRules($priority, $rules) {
if ($priority != 100) {
- Deprecation::notice('3.0', 'Priority argument is now ignored - use the default of 100. You should really be setting routes via _config yaml fragments though.', Deprecation::SCOPE_GLOBAL);
+ Deprecation::notice('3.0', 'Priority argument is now ignored - use the default of 100. You should really'
+ . ' be setting routes via _config yaml fragments though.', Deprecation::SCOPE_GLOBAL);
}
Config::inst()->update('Director', 'rules', $rules);
@@ -53,15 +56,15 @@ public static function addRules($priority, $rules) {
*
* Request processing is handled as follows:
* - Director::direct() creates a new SS_HTTPResponse object and passes this to Director::handleRequest().
- * - Director::handleRequest($request) checks each of the Director rules and identifies a controller to handle this
- * request.
- * - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, and call the rule
- * handling method.
+ * - Director::handleRequest($request) checks each of the Director rules and identifies a controller to handle
+ * this request.
+ * - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, and call the
+ * rule handling method.
* - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method returns a
* RequestHandler object.
*
- * In addition to request processing, Director will manage the session, and perform the output of the actual response
- * to the browser.
+ * In addition to request processing, Director will manage the session, and perform the output of the actual
+ * response to the browser.
*
* @param $url String, the URL the user is visiting, without the querystring.
* @uses handleRequest() rule-lookup logic is handled by this.
@@ -85,7 +88,9 @@ public static function direct($url, DataModel $model) {
}
$req = new SS_HTTPRequest(
- (isset($_SERVER['X-HTTP-Method-Override'])) ? $_SERVER['X-HTTP-Method-Override'] : $_SERVER['REQUEST_METHOD'],
+ (isset($_SERVER['X-HTTP-Method-Override']))
+ ? $_SERVER['X-HTTP-Method-Override']
+ : $_SERVER['REQUEST_METHOD'],
$url,
$_GET,
ArrayLib::array_merge_recursive((array)$_POST, (array)$_FILES),
@@ -98,7 +103,9 @@ public static function direct($url, DataModel $model) {
}
// Only resume a session if its not started already, and a session identifier exists
- if(!isset($_SESSION) && (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))) Session::start();
+ if(!isset($_SESSION) && (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))) {
+ Session::start();
+ }
// Initiate an empty session - doesn't initialize an actual PHP session until saved (see belwo)
$session = new Session(isset($_SESSION) ? $_SESSION : null);
@@ -167,14 +174,15 @@ public static function direct($url, DataModel $model) {
/**
* Test a URL request, returning a response object.
*
- * This method is the counterpart of Director::direct() that is used in functional testing. It will execute the URL given,
+ * This method is the counterpart of Director::direct() that is used in functional testing. It will execute the
+ * URL given, and return the result as an SS_HTTPResponse object.
*
* @param string $url The URL to visit
* @param array $postVars The $_POST & $_FILES variables
- * @param Session $session The {@link Session} object representing the current session. By passing the same object to multiple
- * calls of Director::test(), you can simulate a persisted session.
- * @param string $httpMethod The HTTP method, such as GET or POST. It will default to POST if postVars is set, GET otherwise.
- * Overwritten by $postVars['_method'] if present.
+ * @param Session $session The {@link Session} object representing the current session. By passing the same
+ * object to multiple calls of Director::test(), you can simulate a persisted session.
+ * @param string $httpMethod The HTTP method, such as GET or POST. It will default to POST if postVars is set,
+ * GET otherwise. Overwritten by $postVars['_method'] if present.
* @param string $body The HTTP body
* @param array $headers HTTP headers with key-value pairs
* @param array $cookies to populate $_COOKIE
@@ -184,7 +192,9 @@ public static function direct($url, DataModel $model) {
* @uses getControllerForURL() The rule-lookup logic is handled by this.
* @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call.
*/
- public static function test($url, $postVars = null, $session = null, $httpMethod = null, $body = null, $headers = null, $cookies = null, &$request = null) {
+ public static function test($url, $postVars = null, $session = null, $httpMethod = null, $body = null,
+ $headers = null, $cookies = null, &$request = null) {
+
// These are needed so that calling Director::test() doesnt muck with whoever is calling it.
// Really, it's some inappropriate coupling and should be resolved by making less use of statics
$oldStage = Versioned::current_stage();
@@ -264,8 +274,11 @@ protected static function handleRequest(SS_HTTPRequest $request, Session $sessio
foreach($rules as $pattern => $controllerOptions) {
if(is_string($controllerOptions)) {
- if(substr($controllerOptions,0,2) == '->') $controllerOptions = array('Redirect' => substr($controllerOptions,2));
- else $controllerOptions = array('Controller' => $controllerOptions);
+ if(substr($controllerOptions,0,2) == '->') {
+ $controllerOptions = array('Redirect' => substr($controllerOptions,2));
+ } else {
+ $controllerOptions = array('Controller' => $controllerOptions);
+ }
}
if(($arguments = $request->match($pattern, true)) !== false) {
@@ -359,7 +372,9 @@ public static function set_current_page($page) {
public static function absoluteURL($url, $relativeToSiteBase = false) {
if(!isset($_SERVER['REQUEST_URI'])) return false;
- if(strpos($url,'/') === false && !$relativeToSiteBase) $url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url;
+ if(strpos($url,'/') === false && !$relativeToSiteBase) {
+ $url = dirname($_SERVER['REQUEST_URI'] . 'x') . '/' . $url;
+ }
if(substr($url,0,4) != "http") {
if($url[0] != "/") $url = Director::baseURL() . $url;
@@ -373,7 +388,8 @@ public static function absoluteURL($url, $relativeToSiteBase = false) {
/**
* Returns the part of the URL, 'http://www.mysite.com'.
*
- * @return boolean|string The domain from the PHP environment. Returns FALSE is this environment variable isn't set.
+ * @return boolean|string The domain from the PHP environment. Returns FALSE is this environment variable isn't
+ * set.
*/
public static function protocolAndHost() {
if(self::$alternateBaseURL) {
@@ -392,7 +408,8 @@ public static function protocolAndHost() {
'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.com wiki';
else $errorSuggestion = "";
- user_error("Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set.$errorSuggestion", E_USER_WARNING);
+ user_error("Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set."
+ . $errorSuggestion, E_USER_WARNING);
return false;
}
@@ -404,8 +421,11 @@ public static function protocolAndHost() {
* @return String
*/
public static function protocol() {
- if(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https') return "https://";
- return (isset($_SERVER['SSL']) || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')) ? 'https://' : 'http://';
+ if(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])&&strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])=='https') {
+ return "https://";
+ }
+ return (isset($_SERVER['SSL']) || (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'))
+ ? 'https://' : 'http://';
}
/**
@@ -423,7 +443,8 @@ public static function redirect($url, $code=302) {
/**
* Tests whether a redirection has been requested.
* @deprecated 2.5 Use Controller->redirectedTo() instead
- * @return string If redirect() has been called, it will return the URL redirected to. Otherwise, it will return null;
+ * @return string If redirect() has been called, it will return the URL redirected to. Otherwise, it will
+ * return null;
*/
public static function redirected_to() {
Deprecation::notice('2.5', 'Use Controller->redirectedTo() instead.');
@@ -717,7 +738,10 @@ public static function forceSSL($patterns = null) {
$matched = true;
}
- if($matched && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') && !(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https')) {
+ if($matched && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off')
+ && !(isset($_SERVER['HTTP_X_FORWARDED_PROTOCOL'])
+ && strtolower($_SERVER['HTTP_X_FORWARDED_PROTOCOL']) == 'https')) {
+
$destURL = str_replace('http:', 'https:', Director::absoluteURL($_SERVER['REQUEST_URI']));
// This coupling to SapphireTest is necessary to test the destination URL and to not interfere with tests
@@ -725,7 +749,8 @@ public static function forceSSL($patterns = null) {
return $destURL;
} else {
if(!headers_sent()) header("Location: $destURL");
- die("<h1>Your browser is not accepting header redirects</h1><p>Please <a href=\"$destURL\">click here</a>");
+ die("<h1>Your browser is not accepting header redirects</h1>"
+ . "<p>Please <a href=\"$destURL\">click here</a>");
}
} else {
return false;
@@ -737,10 +762,12 @@ public static function forceSSL($patterns = null) {
*/
public static function forceWWW() {
if(!Director::isDev() && !Director::isTest() && strpos($_SERVER['HTTP_HOST'], 'www') !== 0) {
- $destURL = str_replace(Director::protocol(), Director::protocol() . 'www.', Director::absoluteURL($_SERVER['REQUEST_URI']));
+ $destURL = str_replace(Director::protocol(), Director::protocol() . 'www.',
+ Director::absoluteURL($_SERVER['REQUEST_URI']));
header("Location: $destURL", true, 301);