From 1f7fc1f76a0931bb0aae260346dd869bbba1bfd8 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 27 Sep 2012 09:34:00 +1200 Subject: [PATCH] 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. --- _register_database.php | 17 +- admin/_config.php | 25 +- admin/code/AdminRootController.php | 3 +- admin/code/CMSBatchActionHandler.php | 8 +- admin/code/CMSMenu.php | 3 +- admin/code/GroupImportForm.php | 21 +- admin/code/LeftAndMain.php | 74 +- admin/code/MemberImportForm.php | 19 +- admin/code/ModelAdmin.php | 23 +- admin/code/SecurityAdmin.php | 16 +- admin/javascript/LeftAndMain.FieldHelp.js | 54 +- admin/tests/CMSMenuTest.php | 9 +- admin/tests/LeftAndMainTest.php | 5 +- api/DataFormatter.php | 12 +- api/JSONDataFormatter.php | 18 +- api/RSSFeed.php | 14 +- api/RestfulService.php | 11 +- api/XMLDataFormatter.php | 3 +- cache/Cache.php | 36 +- cli-script.php | 6 +- conf/ConfigureFromEnv.php | 38 +- control/ContentNegotiator.php | 21 +- control/Controller.php | 35 +- control/Cookie.php | 6 +- control/Director.php | 120 +-- control/HTTP.php | 18 +- control/HTTPRequest.php | 15 +- control/HTTPResponse.php | 3 +- control/PjaxResponseNegotiator.php | 4 +- control/RequestHandler.php | 80 +- control/Session.php | 21 +- control/injector/Injector.php | 3 +- core/Config.php | 128 +-- core/Convert.php | 3 +- core/Core.php | 15 +- core/DAG.php | 20 +- core/Diff.php | 3 +- core/Object.php | 63 +- core/manifest/ConfigManifest.php | 84 +- core/manifest/TokenisedRegularExpression.php | 25 +- dev/Backtrace.php | 7 +- dev/CSSContentParser.php | 3 +- dev/Cli.php | 12 +- dev/CliTestReporter.php | 20 +- dev/CsvBulkLoader.php | 9 +- dev/Debug.php | 36 +- dev/DebugView.php | 3 +- dev/Deprecation.php | 7 +- dev/DevelopmentAdmin.php | 8 +- dev/FunctionalTest.php | 42 +- dev/JSTestRunner.php | 11 +- dev/LogErrorEmailFormatter.php | 3 +- dev/MigrationTask.php | 3 +- dev/Profiler.php | 6 +- dev/SapphireREPL.php | 12 +- dev/SapphireTest.php | 32 +- dev/SapphireTestReporter.php | 24 +- dev/TaskRunner.php | 5 +- dev/TeamCityListener.php | 6 +- dev/TestMailer.php | 7 +- dev/TestRunner.php | 37 +- dev/TestSession.php | 9 +- dev/YamlFixture.php | 15 +- dev/install/DatabaseAdapterRegistry.php | 7 +- dev/install/install.php | 5 +- dev/phpunit/PhpUnitWrapper_3_4.php | 6 +- docs/en/tutorials/_images/layout.css | 752 +++++++++--------- email/Email.php | 47 +- email/Mailer.php | 58 +- filesystem/File.php | 27 +- filesystem/Filesystem.php | 3 +- filesystem/Folder.php | 30 +- filesystem/GD.php | 11 +- filesystem/Upload.php | 10 +- forms/AjaxUniqueTextField.php | 10 +- forms/CheckboxSetField.php | 13 +- forms/ComplexTableField.php | 45 +- forms/CompositeField.php | 9 +- forms/ConfirmedPasswordField.php | 16 +- forms/CountryDropdownField.php | 6 +- forms/CreditCardField.php | 14 +- forms/CurrencyField.php | 13 +- forms/DateField.php | 21 +- forms/DatetimeField.php | 12 +- forms/DropdownField.php | 15 +- forms/EmailField.php | 3 +- forms/FieldList.php | 29 +- forms/FileIFrameField.php | 3 +- forms/Form.php | 58 +- forms/FormField.php | 20 +- forms/FormScaffolder.php | 17 +- forms/HasManyComplexTableField.php | 40 +- forms/HasOneComplexTableField.php | 19 +- forms/HeaderField.php | 7 +- forms/HtmlEditorConfig.php | 37 +- forms/HtmlEditorField.php | 97 ++- forms/ImageField.php | 9 +- forms/ImageFormAction.php | 11 +- forms/InlineFormAction.php | 9 +- forms/ListboxField.php | 7 +- forms/ManyManyComplexTableField.php | 16 +- forms/MemberDatetimeOptionsetField.php | 64 +- forms/MoneyField.php | 4 +- forms/NullableField.php | 13 +- forms/PasswordField.php | 5 +- forms/PhoneNumberField.php | 5 +- forms/RequiredFields.php | 4 +- forms/SelectionGroup.php | 3 +- forms/SimpleImageField.php | 10 +- forms/TabSet.php | 3 +- forms/TableField.php | 20 +- forms/TableListField.php | 118 ++- forms/TextareaField.php | 4 +- forms/TreeDropdownField.php | 36 +- forms/TreeMultiselectField.php | 31 +- forms/UploadField.php | 43 +- forms/Validator.php | 11 +- forms/gridfield/GridField.php | 72 +- .../GridFieldAddExistingAutocompleter.php | 33 +- forms/gridfield/GridFieldAddNewButton.php | 3 +- forms/gridfield/GridFieldDataColumns.php | 3 +- forms/gridfield/GridFieldDeleteAction.php | 9 +- forms/gridfield/GridFieldDetailForm.php | 23 +- forms/gridfield/GridFieldExportButton.php | 4 +- forms/gridfield/GridFieldFilterHeader.php | 6 +- forms/gridfield/GridFieldPaginator.php | 13 +- forms/gridfield/GridFieldPrintButton.php | 4 +- forms/gridfield/GridFieldSortableHeader.php | 16 +- i18n/i18n.php | 37 +- i18n/i18nTextCollector.php | 35 +- javascript/lang/nl_NL.js | 31 +- model/Aggregate.php | 8 +- model/ArrayList.php | 13 +- model/ComponentSet.php | 3 +- model/DB.php | 7 +- model/DataExtension.php | 6 +- model/DataList.php | 40 +- model/DataObject.php | 198 +++-- model/DataObjectDecorator.php | 3 +- model/DataObjectInterface.php | 13 +- model/DataObjectSet.php | 3 +- model/DataQuery.php | 36 +- model/Database.php | 89 ++- model/DatabaseAdmin.php | 13 +- model/Filterable.php | 6 +- model/HTMLValue.php | 6 +- model/HasManyList.php | 12 +- model/Hierarchy.php | 58 +- model/Image.php | 18 +- model/ManyManyList.php | 12 +- model/Map.php | 6 +- model/MySQLDatabase.php | 119 ++- model/SQLQuery.php | 37 +- model/Transliterator.php | 4 +- model/URLSegmentFilter.php | 4 +- model/ValidationResult.php | 3 +- model/Versioned.php | 73 +- model/fieldtypes/Boolean.php | 9 +- model/fieldtypes/CompositeDBField.php | 6 +- model/fieldtypes/DBField.php | 21 +- model/fieldtypes/Date.php | 3 +- model/fieldtypes/Datetime.php | 3 +- model/fieldtypes/Decimal.php | 7 +- model/fieldtypes/Enum.php | 11 +- model/fieldtypes/Float.php | 7 +- model/fieldtypes/HTMLText.php | 34 +- model/fieldtypes/Int.php | 8 +- model/fieldtypes/Money.php | 17 +- model/fieldtypes/MultiEnum.php | 17 +- model/fieldtypes/StringField.php | 10 +- model/fieldtypes/Text.php | 19 +- model/fieldtypes/Varchar.php | 3 +- oembed/Oembed.php | 38 +- parsers/ShortcodeParser.php | 37 +- search/FulltextSearchable.php | 3 +- search/SearchContext.php | 18 +- search/filters/SearchFilter.php | 9 +- security/ChangePasswordForm.php | 5 +- security/Group.php | 24 +- security/LoginForm.php | 3 +- security/Member.php | 22 +- security/MemberAuthenticator.php | 5 +- security/MemberLoginForm.php | 6 +- security/PasswordEncryptor.php | 16 +- security/PasswordValidator.php | 26 +- security/Permission.php | 12 +- security/PermissionCheckboxSetField.php | 41 +- security/PermissionProvider.php | 3 +- security/Security.php | 53 +- tasks/EncryptAllPasswordsTask.php | 4 +- tasks/ScheduledTask.php | 8 +- tests/FakeController.php | 4 +- tests/PhpSyntaxTest.php | 8 +- tests/api/RSSFeedTest.php | 3 +- tests/api/XMLDataFormatterTest.php | 6 +- tests/control/ControllerTest.php | 37 +- tests/control/DirectorTest.php | 21 +- tests/control/HTTPTest.php | 3 +- tests/control/RequestHandlingTest.php | 20 +- tests/core/ConfigTest.php | 45 +- tests/core/ConvertTest.php | 45 +- tests/core/CoreTest.php | 9 +- tests/core/ObjectTest.php | 36 +- tests/core/manifest/ConfigManifestTest.php | 6 +- .../manifest/NamespacedClassManifestTest.php | 4 +- tests/dev/CSVParserTest.php | 12 +- tests/dev/CsvBulkLoaderTest.php | 18 +- tests/filesystem/FileTest.php | 74 +- tests/filesystem/FolderTest.php | 22 +- tests/forms/CheckboxFieldTest.php | 9 +- tests/forms/CheckboxSetFieldTest.php | 2 +- tests/forms/ComplexTableFieldTest.php | 6 +- tests/forms/ConfirmedPasswordFieldTest.php | 12 +- tests/forms/DatetimeFieldTest.php | 6 +- tests/forms/DropdownFieldTest.php | 6 +- tests/forms/EmailFieldTest.php | 16 +- tests/forms/FieldListTest.php | 7 +- tests/forms/FormFieldTest.php | 12 +- tests/forms/FormScaffolderTest.php | 27 +- tests/forms/FormTest.php | 6 +- tests/forms/GridFieldTest.php | 24 +- tests/forms/ListboxFieldTest.php | 3 +- tests/forms/LookupFieldTest.php | 7 +- .../MemberDatetimeOptionsetFieldTest.php | 12 +- tests/forms/RequirementsTest.php | 97 ++- tests/forms/TableListFieldTest.php | 3 +- tests/forms/TextareaFieldTest.php | 3 +- .../GridFieldAddExistingAutocompleterTest.php | 6 +- .../gridfield/GridFieldDataColumnsTest.php | 3 +- .../gridfield/GridFieldDeleteActionTest.php | 24 +- .../gridfield/GridFieldDetailFormTest.php | 15 +- .../gridfield/GridFieldEditButtonTest.php | 3 +- .../gridfield/GridFieldPaginatorTest.php | 3 +- tests/forms/uploadfield/UploadFieldTest.php | 47 +- tests/i18n/i18nTest.php | 18 +- tests/i18n/i18nTextCollectorTest.php | 42 +- tests/injector/InjectorTest.php | 9 +- tests/model/ArrayListTest.php | 3 +- tests/model/CurrencyTest.php | 3 +- tests/model/DataDifferencerTest.php | 6 +- tests/model/DataExtensionTest.php | 6 +- tests/model/DataListTest.php | 57 +- tests/model/DataObjectDuplicationTest.php | 21 +- tests/model/DataObjectLazyLoadingTest.php | 16 +- .../model/DataObjectSchemaGenerationTest.php | 3 +- tests/model/DataObjectTest.php | 200 +++-- tests/model/DataQueryTest.php | 24 +- tests/model/DatabaseTest.php | 12 +- tests/model/DbDatetimeTest.php | 25 +- tests/model/DecimalTest.php | 12 +- tests/model/HTMLTextTest.php | 15 +- tests/model/ImageTest.php | 10 +- tests/model/ManyManyListTest.php | 48 +- tests/model/MoneyTest.php | 3 +- tests/model/PaginatedListTest.php | 3 +- tests/model/SQLQueryTest.php | 23 +- tests/model/TextTest.php | 9 +- tests/model/VersionedTest.php | 69 +- tests/oembed/OembedTest.php | 15 +- tests/parsers/ShortcodeParserTest.php | 18 +- tests/search/FulltextSearchableTest.php | 4 +- .../search/SearchFilterApplyRelationTest.php | 15 +- tests/security/GroupTest.php | 12 +- tests/security/MemberAuthenticatorTest.php | 3 +- tests/security/MemberTest.php | 15 +- tests/security/PasswordEncryptorTest.php | 27 +- .../PermissionCheckboxSetFieldTest.php | 36 +- tests/security/PermissionRoleTest.php | 6 +- tests/security/SecurityTest.php | 20 +- tests/testing/CSSContentParserTest.php | 3 +- tests/testing/YamlFixtureTest.php | 6 +- tests/travis/_config.php | 42 +- tests/view/SSViewerCacheBlockTest.php | 60 +- tests/view/SSViewerTest.php | 147 ++-- tests/view/ViewableDataTest.php | 11 +- view/GenericTemplateGlobalProvider.php | 3 +- view/Requirements.php | 44 +- view/SSTemplateParser.php | 398 ++++----- view/SSTemplateParser.php.inc | 190 +++-- view/SSViewer.php | 83 +- view/TemplateGlobalProvider.php | 7 +- view/TemplateIteratorProvider.php | 14 +- 282 files changed, 4780 insertions(+), 2640 deletions(-) diff --git a/_register_database.php b/_register_database.php index a99a52b7e..963b6f349 100644 --- a/_register_database.php +++ b/_register_database.php @@ -18,7 +18,9 @@ DatabaseAdapterRegistry::register( 'title' => 'SQL Server 2008', 'helperPath' => 'mssql/code/MSSQLDatabaseConfigurationHelper.php', 'supported' => (function_exists('mssql_connect') || function_exists('sqlsrv_connect')), - 'missingExtensionText' => 'Neither the mssql or sqlsrv PHP extensions are available. Please install or enable one of them and refresh this page.' + 'missingExtensionText' => 'Neither the mssql or' + . ' sqlsrv PHP extensions are' + . ' available. Please install or enable one of them and refresh this page.' ) ); @@ -28,7 +30,8 @@ DatabaseAdapterRegistry::register( 'title' => 'PostgreSQL 8.3+', 'helperPath' => 'postgresql/code/PostgreSQLDatabaseConfigurationHelper.php', 'supported' => function_exists('pg_query'), - 'missingExtensionText' => 'The pgsql PHP extension is not available. Please install or enable it and refresh this page.' + 'missingExtensionText' => 'The pgsql PHP extension is not available. Please' + . ' install or enable it and refresh this page.' ) ); @@ -38,11 +41,15 @@ DatabaseAdapterRegistry::register( 'title' => 'SQLite 3.3+', 'helperPath' => 'sqlite3/code/SQLiteDatabaseConfigurationHelper.php', 'supported' => (class_exists('SQLite3') || class_exists('PDO')), - 'missingExtensionText' => 'The SQLite3 and PDO classes are not available. Please install or enable one of them and refresh this page.', + 'missingExtensionText' => 'The SQLite3 and' + . ' PDO classes are not available. Please install or' + . ' enable one of them and refresh this page.', 'fields' => array( 'path' => array( - 'title' => 'Database path
Absolute path, writeable by the webserver user.
Recommended to be outside of your webroot
', - 'default' => realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . '.db' + 'title' => 'Database path
Absolute path, writeable by the webserver user.
' + . 'Recommended to be outside of your webroot
', + 'default' => realpath(dirname($_SERVER['SCRIPT_FILENAME'])) . DIRECTORY_SEPARATOR . 'assets' + . DIRECTORY_SEPARATOR . '.db' ), 'database' => array( 'title' => 'Database name', diff --git a/admin/_config.php b/admin/_config.php index 9c22216d3..a84be6703 100644 --- a/admin/_config.php +++ b/admin/_config.php @@ -11,16 +11,33 @@ HtmlEditorConfig::get('cms')->setOptions(array( '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'); diff --git a/admin/code/AdminRootController.php b/admin/code/AdminRootController.php index caea502f2..3e203d857 100644 --- a/admin/code/AdminRootController.php +++ b/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'; diff --git a/admin/code/CMSBatchActionHandler.php b/admin/code/CMSBatchActionHandler.php index 45401cb31..2615a0e60 100644 --- a/admin/code/CMSBatchActionHandler.php +++ b/admin/code/CMSBatchActionHandler.php @@ -85,7 +85,9 @@ class CMSBatchActionHandler extends RequestHandler { 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 @@ class CMSBatchActionHandler extends RequestHandler { ) ); - 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 diff --git a/admin/code/CMSMenu.php b/admin/code/CMSMenu.php index 3f7d50992..54cb7337c 100644 --- a/admin/code/CMSMenu.php +++ b/admin/code/CMSMenu.php @@ -77,7 +77,8 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider * @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) { diff --git a/admin/code/GroupImportForm.php b/admin/code/GroupImportForm.php index 277764f9e..e4271f002 100644 --- a/admin/code/GroupImportForm.php +++ b/admin/code/GroupImportForm.php @@ -17,7 +17,8 @@ class GroupImportForm extends Form { if(!$fields) { $helpHtml = _t( 'GroupImportForm.Help1', - '

Import one or more groups in CSV format (comma-separated values). Show advanced usage

' + '

Import one or more groups in CSV format (comma-separated values).' + . ' Show advanced usage

' ); $helpHtml .= _t( 'GroupImportForm.Help2', @@ -25,9 +26,11 @@ class GroupImportForm extends Form {

Advanced usage

'); @@ -48,12 +51,12 @@ class GroupImportForm extends Form { $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); diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index 6da92af9a..c660bae7f 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -200,9 +200,14 @@ class LeftAndMain extends Controller implements PermissionProvider { // 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 @@ class LeftAndMain extends Controller implements PermissionProvider { * 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 @@ class LeftAndMain extends Controller implements PermissionProvider { } // 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 @@ class LeftAndMain extends Controller implements PermissionProvider { // 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 @@ class LeftAndMain extends Controller implements PermissionProvider { $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() . ''; + $html = LeftAndMain_TreeNode::create($record, $link, $this->isCurrentPage($record)) + ->forTemplate() . ''; $data[$id] = array( 'html' => $html, @@ -874,7 +896,8 @@ class LeftAndMain extends Controller implements PermissionProvider { 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 @@ class LeftAndMain extends Controller implements PermissionProvider { 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 @@ class LeftAndMain extends Controller implements PermissionProvider { 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 @@ class LeftAndMain extends Controller implements PermissionProvider { } } - $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 @@ class LeftAndMain extends Controller implements PermissionProvider { // 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 @@ class LeftAndMainMarkingFilter { // 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 @@ class LeftAndMain_TreeNode extends ViewableData { */ public function forTemplate() { $obj = $this->obj; - return "
  • ID\" data-id=\"$obj->ID\" data-pagetype=\"$obj->ClassName\" class=\"" . $this->getClasses() . "\">" . - " " . - "getLink() . "\" title=\"" . - _t('LeftAndMain.PAGETYPE','Page type: ') . - "$obj->class\" > " . ($obj->TreeTitle). - ""; + return "
  • ID\" data-id=\"$obj->ID\" data-pagetype=\"$obj->ClassName\" class=\"" + . $this->getClasses() . "\">" . " " + . "getLink() . "\" title=\"" . _t('LeftAndMain.PAGETYPE','Page type: ') + . "$obj->class\" > " . ($obj->TreeTitle) + . ""; } public function getClasses() { diff --git a/admin/code/MemberImportForm.php b/admin/code/MemberImportForm.php index f71b91972..d47fbc901 100644 --- a/admin/code/MemberImportForm.php +++ b/admin/code/MemberImportForm.php @@ -17,7 +17,8 @@ class MemberImportForm extends Form { if(!$fields) { $helpHtml = _t( 'MemberImportForm.Help1', - '

    Import users in CSV format (comma-separated values). Show advanced usage

    ' + '

    Import users in CSV format (comma-separated values).' + . ' Show advanced usage

    ' ); $helpHtml .= _t( 'MemberImportForm.Help2', @@ -25,8 +26,10 @@ class MemberImportForm extends Form {

    Advanced usage

    '); @@ -47,11 +50,11 @@ class MemberImportForm extends Form { $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'); diff --git a/admin/code/ModelAdmin.php b/admin/code/ModelAdmin.php index 63b6efc6e..15accc263 100644 --- a/admin/code/ModelAdmin.php +++ b/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 @@ abstract class ModelAdmin extends LeftAndMain { ); $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 @@ abstract class ModelAdmin extends LeftAndMain { ))->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 @@ abstract class ModelAdmin extends LeftAndMain { $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 @@ abstract class ModelAdmin extends LeftAndMain { * @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 @@ abstract class ModelAdmin extends LeftAndMain { '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(); diff --git a/admin/code/SecurityAdmin.php b/admin/code/SecurityAdmin.php index 9c861c69a..5ab801373 100755 --- a/admin/code/SecurityAdmin.php +++ b/admin/code/SecurityAdmin.php @@ -96,7 +96,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { sprintf('

    %s

    ', _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 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { new LiteralField( 'MemberImportFormIframe', sprintf( - '', + '', $this->Link('memberimport') ) ) @@ -115,7 +117,8 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { new LiteralField( 'GroupImportFormIframe', sprintf( - '', + '', $this->Link('groupimport') ) ) @@ -280,13 +283,16 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { '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 ) ); diff --git a/admin/javascript/LeftAndMain.FieldHelp.js b/admin/javascript/LeftAndMain.FieldHelp.js index ca1546fca..a773cd437 100644 --- a/admin/javascript/LeftAndMain.FieldHelp.js +++ b/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 = $("", { - "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 = $("", { + "class": "help", + "text": title + }); + + field.append(span); + this.removeProp("title"); + } + + this._super(); + } + }); + }); +}(jQuery)); diff --git a/admin/tests/CMSMenuTest.php b/admin/tests/CMSMenuTest.php index 8a3dcbf0d..bc3c7a4e1 100644 --- a/admin/tests/CMSMenuTest.php +++ b/admin/tests/CMSMenuTest.php @@ -17,9 +17,12 @@ class CMSMenuTest extends SapphireTest implements TestOnly { $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 diff --git a/admin/tests/LeftAndMainTest.php b/admin/tests/LeftAndMainTest.php index 4c115d991..e5bc9c11b 100644 --- a/admin/tests/LeftAndMainTest.php +++ b/admin/tests/LeftAndMainTest.php @@ -23,8 +23,9 @@ class LeftAndMainTest extends FunctionalTest { */ 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); diff --git a/api/DataFormatter.php b/api/DataFormatter.php index 3c74175c8..c86800f69 100644 --- a/api/DataFormatter.php +++ b/api/DataFormatter.php @@ -1,7 +1,7 @@ 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 @@ abstract class DataFormatter extends Object { 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; + } } } diff --git a/api/JSONDataFormatter.php b/api/JSONDataFormatter.php index bbc54119d..f2ce27341 100644 --- a/api/JSONDataFormatter.php +++ b/api/JSONDataFormatter.php @@ -74,7 +74,11 @@ class JSONDataFormatter extends DataFormatter { } 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 @@ class JSONDataFormatter extends DataFormatter { 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 @@ class JSONDataFormatter extends DataFormatter { 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; } diff --git a/api/RSSFeed.php b/api/RSSFeed.php index 7ea6ff5fb..c565310ec 100644 --- a/api/RSSFeed.php +++ b/api/RSSFeed.php @@ -147,7 +147,8 @@ class RSSFeed extends ViewableData { 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 @@ class RSSFeed_Entry extends ViewableData { * @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); + } } } diff --git a/api/RestfulService.php b/api/RestfulService.php index 03d2cbab0..569026ec6 100644 --- a/api/RestfulService.php +++ b/api/RestfulService.php @@ -94,7 +94,9 @@ class RestfulService extends ViewableData { } /** - * 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 @@ class RestfulService extends ViewableData { * * 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 @@ class RestfulService extends ViewableData { $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); diff --git a/api/XMLDataFormatter.php b/api/XMLDataFormatter.php index 29584613d..205488d92 100644 --- a/api/XMLDataFormatter.php +++ b/api/XMLDataFormatter.php @@ -79,7 +79,8 @@ class XMLDataFormatter extends DataFormatter { } else { $href = Director::absoluteURL(self::$api_base . "$className/$id/$relName"); } - $xml .= "<$relName linktype=\"has_one\" href=\"$href.xml\" id=\"" . $obj->$fieldName . "\">\n"; + $xml .= "<$relName linktype=\"has_one\" href=\"$href.xml\" id=\"" . $obj->$fieldName + . "\">\n"; } foreach($obj->has_many() as $relName => $relClass) { diff --git a/cache/Cache.php b/cache/Cache.php index a3f05f313..da1259728 100644 --- a/cache/Cache.php +++ b/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); * * * 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 @@ class SS_Cache { 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 @@ class SS_Cache { * * @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 @@ class SS_Cache { * * @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 @@ class SS_Cache { $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); + } } /** diff --git a/cli-script.php b/cli-script.php index 2534bf688..93e009c49 100755 --- a/cli-script.php +++ b/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 @@ DB::connect($databaseConfig); // 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(); } diff --git a/conf/ConfigureFromEnv.php b/conf/ConfigureFromEnv.php index d51cbd0c4..f07e39fa7 100644 --- a/conf/ConfigureFromEnv.php +++ b/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_SEND_ALL_EMAILS_TO')) { } 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) { diff --git a/control/ContentNegotiator.php b/control/ContentNegotiator.php index 6fabc39f2..515489777 100644 --- a/control/ContentNegotiator.php +++ b/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 @@ class ContentNegotiator { $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 @@ class ContentNegotiator { $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 @@ class ContentNegotiator { // Only replace the doctype in templates with the xml header if($hasXMLHeader) { - $content = preg_replace('/]+>/', '', $content); + $content = preg_replace('/]+>/', + '', + $content); } $content = preg_replace('/ID", null); + DB::query("UPDATE \"Member\" SET \"LastVisited\" = " . DB::getConn()->now() + . " WHERE \"ID\" = $member->ID", null); } } @@ -136,7 +137,10 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { // 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 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { $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 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { } } - //----------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------------------------------------- /** * 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 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { 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 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { 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 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { /** * 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'); diff --git a/control/Cookie.php b/control/Cookie.php index 87032ac74..6fd9ad804 100644 --- a/control/Cookie.php +++ b/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); } } } diff --git a/control/Director.php b/control/Director.php index 2a4d60236..023433c17 100644 --- a/control/Director.php +++ b/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 @@ class Director implements TemplateGlobalProvider { * * 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 @@ class Director implements TemplateGlobalProvider { } $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 @@ class Director implements TemplateGlobalProvider { } // 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 @@ class Director implements TemplateGlobalProvider { /** * 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 @@ class Director implements TemplateGlobalProvider { * @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 @@ class Director implements TemplateGlobalProvider { 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 @@ class Director implements TemplateGlobalProvider { 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 @@ class Director implements TemplateGlobalProvider { /** * 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 @@ class Director implements TemplateGlobalProvider { '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 @@ class Director implements TemplateGlobalProvider { * @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 @@ class Director implements TemplateGlobalProvider { /** * 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 @@ class Director implements TemplateGlobalProvider { $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 @@ class Director implements TemplateGlobalProvider { return $destURL; } else { if(!headers_sent()) header("Location: $destURL"); - die("

    Your browser is not accepting header redirects

    Please click here"); + die("

    Your browser is not accepting header redirects

    " + . "

    Please click here"); } } else { return false; @@ -737,10 +762,12 @@ class Director implements TemplateGlobalProvider { */ 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); - die("

    Your browser is not accepting header redirects

    Please click here"); + die("

    Your browser is not accepting header redirects

    " + . "

    Please click here"); } } @@ -783,31 +810,34 @@ class Director implements TemplateGlobalProvider { * - test sites, such as the one you show the client before going live. * - the live site itself. * - * The behaviour of these environments often varies slightly. For example, development sites may have errors dumped to the screen, - * and order confirmation emails might be sent to the developer instead of the client. + * The behaviour of these environments often varies slightly. For example, development sites may have errors + * dumped to the screen, and order confirmation emails might be sent to the developer instead of the client. * - * To help with this, SilverStripe supports the notion of an environment type. The environment type can be dev, test, or live. + * To help with this, SilverStripe supports the notion of an environment type. The environment type can be dev, + * test, or live. * - * You can set it explicitly with Director::set_environment_tpye(). Or you can use {@link Director::set_dev_servers()} and {@link Director::set_test_servers()} - * to set it implicitly, based on the value of $_SERVER['HTTP_HOST']. If the HTTP_HOST value is one of the servers listed, then - * the environment type will be test or dev. Otherwise, the environment type will be live. + * You can set it explicitly with Director::set_environment_tpye(). Or you can use + * {@link Director::set_dev_servers()} and {@link Director::set_test_servers()} to set it implicitly, based on the + * value of $_SERVER['HTTP_HOST']. If the HTTP_HOST value is one of the servers listed, then the environment type + * will be test or dev. Otherwise, the environment type will be live. * - * Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the site into dev - * mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back. + * Dev mode can also be forced by putting ?isDev=1 in your URL, which will ask you to log in and then push the + * site into dev mode for the remainder of the session. Putting ?isDev=0 onto the URL can turn it back. * - * Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and then push the site into test - * mode for the remainder of the session. Putting ?isTest=0 onto the URL can turn it back. + * Test mode can also be forced by putting ?isTest=1 in your URL, which will ask you to log in and then push the + * site into test mode for the remainder of the session. Putting ?isTest=0 onto the URL can turn it back. * * Generally speaking, these methods will be called from your _config.php file. * - * Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, and - * {@link Director::isLive()}. + * Once the environment type is set, it can be checked with {@link Director::isDev()}, {@link Director::isTest()}, + * and {@link Director::isLive()}. * * @param $et string The environment type: dev, test, or live. */ public static function set_environment_type($et) { if($et != 'dev' && $et != 'test' && $et != 'live') { - user_error("Director::set_environment_type passed '$et'. It should be passed dev, test, or live", E_USER_WARNING); + user_error("Director::set_environment_type passed '$et'. It should be passed dev, test, or live", + E_USER_WARNING); } else { self::$environment_type = $et; } diff --git a/control/HTTP.php b/control/HTTP.php index 9082a5d1f..e85daa8bd 100644 --- a/control/HTTP.php +++ b/control/HTTP.php @@ -41,7 +41,8 @@ class HTTP { */ public static function absoluteURLs($html) { $html = str_replace('$CurrentPageURL', $_SERVER['REQUEST_URI'], $html); - return HTTP::urlRewriter($html, '(substr($URL,0,1) == "/") ? ( Director::protocolAndHost() . $URL ) : ( (preg_match("/^[A-Za-z]+:/", $URL)) ? $URL : Director::absoluteBaseURL() . $URL )' ); + return HTTP::urlRewriter($html, '(substr($URL,0,1) == "/") ? ( Director::protocolAndHost() . $URL ) :' + . ' ( (preg_match("/^[A-Za-z]+:/", $URL)) ? $URL : Director::absoluteBaseURL() . $URL )' ); } /* @@ -252,8 +253,8 @@ class HTTP { /** * Add the appropriate caching headers to the response, including If-Modified-Since / 304 handling. * - * @param SS_HTTPResponse The SS_HTTPResponse object to augment. Omitted the argument or passing a string is deprecated; in these - * cases, the headers are output directly. + * @param SS_HTTPResponse The SS_HTTPResponse object to augment. Omitted the argument or passing a string is + * deprecated; in these cases, the headers are output directly. */ public static function add_cache_headers($body = null) { // Validate argument @@ -266,16 +267,21 @@ class HTTP { // below. if(Director::isDev()) return; - // The headers have been sent and we don't have an SS_HTTPResponse object to attach things to; no point in us trying. + // The headers have been sent and we don't have an SS_HTTPResponse object to attach things to; no point in + // us trying. if(headers_sent() && !$body) return; // Popuplate $responseHeaders with all the headers that we want to build $responseHeaders = array(); if(function_exists('apache_request_headers')) { $requestHeaders = apache_request_headers(); - if(isset($requestHeaders['X-Requested-With']) && $requestHeaders['X-Requested-With'] == 'XMLHttpRequest') self::$cache_age = 0; + if(isset($requestHeaders['X-Requested-With']) && $requestHeaders['X-Requested-With']=='XMLHttpRequest') { + self::$cache_age = 0; + } // bdc: now we must check for DUMB IE6: - if(isset($requestHeaders['x-requested-with']) && $requestHeaders['x-requested-with'] == 'XMLHttpRequest') self::$cache_age = 0; + if(isset($requestHeaders['x-requested-with']) && $requestHeaders['x-requested-with']=='XMLHttpRequest') { + self::$cache_age = 0; + } } if(self::$cache_age > 0) { diff --git a/control/HTTPRequest.php b/control/HTTPRequest.php index 4b14f8a4f..210c4af9b 100644 --- a/control/HTTPRequest.php +++ b/control/HTTPRequest.php @@ -1,15 +1,15 @@ dirParts[$i])) return false; $arguments[$varName] = isset($this->dirParts[$i]) ? $this->dirParts[$i] : null; - if($part == '$Controller' && (!ClassInfo::exists($arguments['Controller']) || !is_subclass_of($arguments['Controller'], 'Controller'))) { + if($part == '$Controller' && (!ClassInfo::exists($arguments['Controller']) + || !is_subclass_of($arguments['Controller'], 'Controller'))) { + return false; } @@ -570,7 +572,8 @@ class SS_HTTPRequest implements ArrayAccess { * Returns all mimetypes from the HTTP "Accept" header * as an array. * - * @param boolean $includeQuality Don't strip away optional "quality indicators", e.g. "application/xml;q=0.9" (Default: false) + * @param boolean $includeQuality Don't strip away optional "quality indicators", e.g. "application/xml;q=0.9" + * (Default: false) * @return array */ public function getAcceptMimetypes($includeQuality = false) { diff --git a/control/HTTPResponse.php b/control/HTTPResponse.php index ff8289ac6..24cf76b7b 100644 --- a/control/HTTPResponse.php +++ b/control/HTTPResponse.php @@ -215,7 +215,8 @@ class SS_HTTPResponse { if(in_array($this->statusCode, self::$redirect_codes) && headers_sent($file, $line)) { $url = $this->headers['Location']; echo - "

    Redirecting to $url... (output started on $file, line $line)

    + "

    Redirecting to " + . "$url... (output started on $file, line $line)

    "; } else { diff --git a/control/PjaxResponseNegotiator.php b/control/PjaxResponseNegotiator.php index 0d4fbde0f..3d6b499f0 100644 --- a/control/PjaxResponseNegotiator.php +++ b/control/PjaxResponseNegotiator.php @@ -69,7 +69,9 @@ class PjaxResponseNegotiator { } elseif ($fragmentStr = $request->getHeader('X-Pjax')) { $fragments = explode(',', $fragmentStr); } else { - if($request->isAjax()) throw new SS_HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400); + if($request->isAjax()) { + throw new SS_HTTPResponse_Exception("Ajax requests to this URL require an X-Pjax header.", 400); + } $response->setBody(call_user_func($callbacks['default'])); return $response; } diff --git a/control/RequestHandler.php b/control/RequestHandler.php index 9e994c664..aecabf90b 100644 --- a/control/RequestHandler.php +++ b/control/RequestHandler.php @@ -5,22 +5,27 @@ * * Any RequestHandler object can be made responsible for handling its own segment of the URL namespace. * The {@link Director} begins the URL parsing process; it will parse the beginning of the URL to identify which - * controller is being used. It will then call {@link handleRequest()} on that Controller, passing it the parameters that it - * parsed from the URL, and the {@link SS_HTTPRequest} that contains the remainder of the URL to be parsed. + * controller is being used. It will then call {@link handleRequest()} on that Controller, passing it the parameters + * that it parsed from the URL, and the {@link SS_HTTPRequest} that contains the remainder of the URL to be parsed. * * You can use ?debug_request=1 to view information about the different components and rule matches for a specific URL. * - * In SilverStripe, URL parsing is distributed throughout the object graph. For example, suppose that we have a search form - * that contains a {@link TreeMultiSelectField} named "Groups". We want to use ajax to load segments of this tree as they are needed - * rather than downloading the tree right at the beginning. We could use this URL to get the tree segment that appears underneath + * In SilverStripe, URL parsing is distributed throughout the object graph. For example, suppose that we have a + * search form that contains a {@link TreeMultiSelectField} named "Groups". We want to use ajax to load segments of + * this tree as they are needed rather than downloading the tree right at the beginning. We could use this URL to get + * the tree segment that appears underneath + * * Group #36: "admin/crm/SearchForm/field/Groups/treesegment/36" * - Director will determine that admin/crm is controlled by a new ModelAdmin object, and pass control to that. * Matching Director Rule: "admin/crm" => "ModelAdmin" (defined in mysite/_config.php) - * - ModelAdmin will determine that SearchForm is controlled by a Form object returned by $this->SearchForm(), and pass control to that. + * - ModelAdmin will determine that SearchForm is controlled by a Form object returned by $this->SearchForm(), and + * pass control to that. * Matching $url_handlers: "$Action" => "$Action" (defined in RequestHandler class) - * - Form will determine that field/Groups is controlled by the Groups field, a TreeMultiselectField, and pass control to that. + * - Form will determine that field/Groups is controlled by the Groups field, a TreeMultiselectField, and pass + * control to that. * Matching $url_handlers: 'field/$FieldName!' => 'handleField' (defined in Form class) - * - TreeMultiselectField will determine that treesegment/36 is handled by its treesegment() method. This method will return an HTML fragment that is output to the screen. + * - TreeMultiselectField will determine that treesegment/36 is handled by its treesegment() method. This method + * will return an HTML fragment that is output to the screen. * Matching $url_handlers: "$Action/$ID" => "handleItem" (defined in TreeMultiSelectField class) * * {@link RequestHandler::handleRequest()} is where this behaviour is implemented. @@ -54,10 +59,11 @@ class RequestHandler extends ViewableData { * The default URL handling rules. This specifies that the next component of the URL corresponds to a method to * be called on this RequestHandlingData object. * - * The keys of this array are parse rules. See {@link SS_HTTPRequest::match()} for a description of the rules available. + * The keys of this array are parse rules. See {@link SS_HTTPRequest::match()} for a description of the rules + * available. * - * The values of the array are the method to be called if the rule matches. If this value starts with a '$', then the - * named parameter of the parsed URL wil be used to determine the method name. + * The values of the array are the method to be called if the rule matches. If this value starts with a '$', then + * the named parameter of the parsed URL wil be used to determine the method name. */ static $url_handlers = array( '$Action' => '$Action', @@ -70,10 +76,14 @@ class RequestHandler extends ViewableData { * * * array( - * 'someaction', // someaction can be accessed by anyone, any time - * 'otheraction' => true, // So can otheraction - * 'restrictedaction' => 'ADMIN', // restrictedaction can only be people with ADMIN privilege - * 'complexaction' '->canComplexAction' // complexaction can only be accessed if $this->canComplexAction() returns true + * // someaction can be accessed by anyone, any time + * 'someaction', + * // So can otheraction + * 'otheraction' => true, + * // restrictedaction can only be people with ADMIN privilege + * 'restrictedaction' => 'ADMIN', + * // complexaction can only be accessed if $this->canComplexAction() returns true + * 'complexaction' '->canComplexAction' * ); * * @@ -141,13 +151,16 @@ class RequestHandler extends ViewableData { $urlHandlers = Config::inst()->get($handlerClass, 'url_handlers', Config::FIRST_SET); if($urlHandlers) foreach($urlHandlers as $rule => $action) { - if(isset($_REQUEST['debug_request'])) Debug::message("Testing '$rule' with '" . $request->remaining() . "' on $this->class"); + if(isset($_REQUEST['debug_request'])) { + Debug::message("Testing '$rule' with '" . $request->remaining() . "' on $this->class"); + } if($params = $request->match($rule, true)) { // Backwards compatible setting of url parameters, please use SS_HTTPRequest->latestParam() instead //Director::setUrlParams($request->latestParams()); if(isset($_REQUEST['debug_request'])) { - Debug::message("Rule '$rule' matched to action '$action' on $this->class. Latest request params: " . var_export($request->latestParams(), true)); + Debug::message("Rule '$rule' matched to action '$action' on $this->class." + . " Latest request params: " . var_export($request->latestParams(), true)); } // Actions can reference URL parameters, eg, '$Action/$ID/$OtherID' => '$Action', @@ -155,7 +168,9 @@ class RequestHandler extends ViewableData { if($this->checkAccessAction($action)) { if(!$action) { - if(isset($_REQUEST['debug_request'])) Debug::message("Action not set; using default action method name 'index'"); + if(isset($_REQUEST['debug_request'])) { + Debug::message("Action not set; using default action method name 'index'"); + } $action = "index"; } else if(!is_string($action)) { user_error("Non-string method name: " . var_export($action, true), E_USER_ERROR); @@ -163,14 +178,15 @@ class RequestHandler extends ViewableData { try { if(!$this->hasMethod($action)) { - return $this->httpError(404, "Action '$action' isn't available on class " . get_class($this) . "."); + return $this->httpError(404, "Action '$action' isn't available on class " + . get_class($this) . "."); } $result = $this->$action($request); } catch(SS_HTTPResponse_Exception $responseException) { $result = $responseException->getResponse(); } } else { - return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this) . "."); + return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this)); } if($result instanceof SS_HTTPResponse && $result->isError()) { @@ -178,11 +194,13 @@ class RequestHandler extends ViewableData { return $result; } - // If we return a RequestHandler, call handleRequest() on that, even if there is no more URL to parse. - // It might have its own handler. However, we only do this if we haven't just parsed an empty rule ourselves, - // to prevent infinite loops. Also prevent further handling of controller actions which return themselves - // to avoid infinite loops. - if($this !== $result && !$request->isEmptyPattern($rule) && is_object($result) && $result instanceof RequestHandler) { + // If we return a RequestHandler, call handleRequest() on that, even if there is no more URL to + // parse. It might have its own handler. However, we only do this if we haven't just parsed an + // empty rule ourselves, to prevent infinite loops. Also prevent further handling of controller + // actions which return themselves to avoid infinite loops. + if($this !== $result && !$request->isEmptyPattern($rule) && is_object($result) + && $result instanceof RequestHandler) { + $returnValue = $result->handleRequest($request, $model); // Array results can be used to handle @@ -256,7 +274,9 @@ class RequestHandler extends ViewableData { if($isKey || $isValue || $isWildcard) return true; } - if(!is_array($actions) || !$this->config()->get('allowed_actions', Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES)) { + if(!is_array($actions) || !$this->config()->get('allowed_actions', + Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES)) { + if($action != 'init' && $action != 'run' && method_exists($this, $action)) return true; } @@ -300,9 +320,11 @@ class RequestHandler extends ViewableData { // it should be allowed. if($action == 'index' || empty($action)) return true; - if($allowedActions === null || !$this->config()->get('allowed_actions', Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES)) { - // If no allowed_actions are provided, then we should only let through actions that aren't handled by magic methods - // we test this by calling the unmagic method_exists. + if($allowedActions === null || !$this->config()->get('allowed_actions', + Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES)) { + + // If no allowed_actions are provided, then we should only let through actions that aren't handled by + // magic methods we test this by calling the unmagic method_exists. if(method_exists($this, $action)) { // Disallow any methods which aren't defined on RequestHandler or subclasses // (e.g. ViewableData->getSecurityID()) diff --git a/control/Session.php b/control/Session.php index e9476c5c8..e86616da7 100644 --- a/control/Session.php +++ b/control/Session.php @@ -5,21 +5,24 @@ * The static methods are used to manipulate the currently active controller's session. * The instance methods are used to manipulate a particular session. There can be more than one of these created. * - * In order to support things like testing, the session is associated with a particular Controller. In normal usage, this is loaded from - * and saved to the regular PHP session, but for things like static-page-generation and unit-testing, you can create multiple Controllers, - * each with their own session. + * In order to support things like testing, the session is associated with a particular Controller. In normal usage, + * this is loaded from and saved to the regular PHP session, but for things like static-page-generation and + * unit-testing, you can create multiple Controllers, each with their own session. * - * The instance object is basically just a way of manipulating a set of nested maps, and isn't specific to session data. + * The instance object is basically just a way of manipulating a set of nested maps, and isn't specific to session + * data. * * Saving Data * - * You can write a value to a users session from your PHP code using the static function {@link Session::set()}. You can add this line in any function or file you wish to save the value. + * You can write a value to a users session from your PHP code using the static function {@link Session::set()}. You + * can add this line in any function or file you wish to save the value. * * * Session::set('MyValue', 6); * * - * Saves the value of "6" to the MyValue session data. You can also save arrays or serialized objects in session (but note there may be size restrictions as to how much you can save) + * Saves the value of "6" to the MyValue session data. You can also save arrays or serialized objects in session (but + * note there may be size restrictions as to how much you can save) * * * // save a variable @@ -59,13 +62,15 @@ * * Clearing Data * - * Once you have accessed a value from the Session it doesn't automatically wipe the value from the Session, you have to specifically remove it. To clear a value you can either delete 1 session value by the name that you saved it + * Once you have accessed a value from the Session it doesn't automatically wipe the value from the Session, you have + * to specifically remove it. To clear a value you can either delete 1 session value by the name that you saved it * * * Session::clear('MyValue'); // myvalue is no longer 6. * * - * Or you can clear every single value in the session at once. Note SilverStripe stores some of its own session data including form and page comment information. None of this is vital but clear_all will clear everything. + * Or you can clear every single value in the session at once. Note SilverStripe stores some of its own session data + * including form and page comment information. None of this is vital but clear_all will clear everything. * * * Session::clear_all(); diff --git a/control/injector/Injector.php b/control/injector/Injector.php index 58c1aff17..e5a776fcc 100644 --- a/control/injector/Injector.php +++ b/control/injector/Injector.php @@ -62,7 +62,8 @@ * // but has a lower priority, it is NOT overridden * 'class' => 'ClassName', // the name of the PHP class * 'src' => '/path/to/file' // the location of the class - * 'type' => 'singleton|prototype' // if you want prototype object generation, set it as the type + * 'type' => 'singleton|prototype' // if you want prototype object generation, set it as the + * // type * // By default, singleton is assumed * * 'construct' => array( // properties to set at construction diff --git a/core/Config.php b/core/Config.php index 416ad8e58..c6b08daac 100644 --- a/core/Config.php +++ b/core/Config.php @@ -13,55 +13,64 @@ * If the value is an array, each value in the array may also be one of those three types * * A property can have a value specified in multiple locations, each of which have a hardcoded or explicit priority. - * We combine all these values together into a "composite" value using rules that depend on the priority order of the locations - * to give the final value, using these rules: + * We combine all these values together into a "composite" value using rules that depend on the priority order of the + * locations to give the final value, using these rules: * - * - If the value is an array, each array is added to the _beginning_ of the composite array in ascending priority order. - * If a higher priority item has a non-integer key which is the same as a lower priority item, the value of those items - * is merged using these same rules, and the result of the merge is located in the same location the higher priority item - * would be if there was no key clash. Other than in this key-clash situation, within the particular array, order is preserved. + * - If the value is an array, each array is added to the _beginning_ of the composite array in ascending priority + * order. If a higher priority item has a non-integer key which is the same as a lower priority item, the value of + * those items is merged using these same rules, and the result of the merge is located in the same location the + * higher priority item would be if there was no key clash. Other than in this key-clash situation, within the + * particular array, order is preserved. * * - If the value is not an array, the highest priority value is used without any attempt to merge * - * It is an error to have mixed types of the same named property in different locations (but an error will not necessarily - * be raised due to optimisations in the lookup code) + * It is an error to have mixed types of the same named property in different locations (but an error will not + * necessarily be raised due to optimisations in the lookup code) * - * The exception to this is "false-ish" values - empty arrays, empty strings, etc. When merging a non-false-ish value with a - * false-ish value, the result will be the non-false-ish value regardless of priority. When merging two false-sh values - * the result will be the higher priority false-ish value. + * The exception to this is "false-ish" values - empty arrays, empty strings, etc. When merging a non-false-ish value + * with a false-ish value, the result will be the non-false-ish value regardless of priority. When merging two + * false-ish values the result will be the higher priority false-ish value. * * The locations that configuration values are taken from in highest -> lowest priority order * * - Any values set via a call to Config#update * - * - The configuration values taken from the YAML files in _config directories (internally sorted in before / after order, where - * the item that is latest is highest priority) + * - The configuration values taken from the YAML files in _config directories (internally sorted in before / after + * order, where the item that is latest is highest priority) * - * - Any static set on an "additional static source" class (such as an extension) named the same as the name of the property + * - Any static set on an "additional static source" class (such as an extension) named the same as the name of the + * property * * - Any static set on the class named the same as the name of the property * * - The composite configuration value of the parent class of this class * - * At some of these levels you can also set masks. These remove values from the composite value at their priority point rather than add. - * They are much simpler. They consist of a list of key / value pairs. When applied against the current composite value + * At some of these levels you can also set masks. These remove values from the composite value at their priority + * point rather than add. They are much simpler. They consist of a list of key / value pairs. When applied against the + * current composite value: * - * - If the composite value is a sequential array, any member of that array that matches any value in the mask is removed + * - If the composite value is a sequential array, any member of that array that matches any value in the mask is + * removed * - * - If the composite value is an associative array, any member of that array that matches both the key and value of any pair in the mask is removed + * - If the composite value is an associative array, any member of that array that matches both the key and value of + * any pair in the mask is removed * * - If the composite value is not an array, if that value matches any value in the mask it is removed - * - * */ class Config { - /** @var Object - A marker instance for the "anything" singleton value. Don't access directly, even in-class, always use self::anything() */ + /** + * [A marker instance for the "anything" singleton value. Don't access directly, even in-class, always use + * self::anything() + * @var Object + */ static private $_anything = null; /** - * Get a marker class instance that is used to do a "remove anything with this key" by adding $key => Config::anything() to the suppress array - * todo: Does this follow the SS coding conventions? Config::get_anything_marker_instance() is a lot less elegant. + * Get a marker class instance that is used to do a "remove anything with this key" by adding + * $key => Config::anything() to the suppress array + * + * @todo Does this follow the SS coding conventions? Config::get_anything_marker_instance() is a lot less elegant. * @return Object */ static public function anything() { @@ -71,25 +80,41 @@ class Config { // -- Source options bitmask -- - /** @const source options bitmask value - merge all parent configuration in as lowest priority */ + /** + * source options bitmask value - merge all parent configuration in as lowest priority + * @const + */ const INHERITED = 0; - /** @const source options bitmask value - only get configuration set for this specific class, not any of it's parents */ + /** + * source options bitmask value - only get configuration set for this specific class, not any of it's parents + * @const + */ const UNINHERITED = 1; - /** @const source options bitmask value - inherit, but stop on the first class that actually provides a value (event an empty value) */ + /** + * source options bitmask value - inherit, but stop on the first class that actually provides a value (event an + * empty value) + * @const + */ const FIRST_SET = 2; /** @const source options bitmask value - do not use additional statics sources (such as extension) */ const EXCLUDE_EXTRA_SOURCES = 4; // -- get_value_type response enum -- - /** @const Return flag for get_value_type indicating value is a scalar (or really just not-an-array, at least ATM)*/ + /** + * Return flag for get_value_type indicating value is a scalar (or really just not-an-array, at least ATM) + * @const + */ const ISNT_ARRAY = 1; - /** @const Return flag for get_value_type indicating value is an array */ + /** + * Return flag for get_value_type indicating value is an array + * @const + */ const IS_ARRAY = 2; /** - * Get whether the value is an array or not. Used to be more complicated, but still nice sugar to have an enum to compare - * and not just a true/false value + * Get whether the value is an array or not. Used to be more complicated, but still nice sugar to have an enum + * to compare and not just a true/false value * @param $val any - The value * @return int - One of ISNT_ARRAY or IS_ARRAY */ @@ -103,7 +128,8 @@ class Config { * @throws UnexpectedValueException */ static protected function type_mismatch() { - throw new UnexpectedValueException('Type mismatch in configuration. All values for a particular property must contain the same type (or no value at all).'); + throw new UnexpectedValueException('Type mismatch in configuration. All values for a particular property must' + . ' contain the same type (or no value at all).'); } /* @todo If we can, replace next static & static methods with DI once that's in */ @@ -320,11 +346,14 @@ class Config { * Get the config value associated for a given class and property * * This merges all current sources and overrides together to give final value - * todo: Currently this is done every time. This function is an inner loop function, so we really need to be caching heavily here. + * todo: Currently this is done every time. This function is an inner loop function, so we really need to be + * caching heavily here. * * @param $class string - The name of the class to get the value for * @param $name string - The property to get the value for - * @param int $sourceOptions - Bitmask which can be set to some combintain of Config::UNINHERITED, Config::FIRST_SET, and Config::EXCLUDE_EXTENSIONS. + * @param int $sourceOptions Bitmask which can be set to some combintain of Config::UNINHERITED, + * Config::FIRST_SET, and Config::EXCLUDE_EXTENSIONS. + * * Config::UNINHERITED does not include parent classes when merging configuration fragments * Config::FIRST_SET stops inheriting once the first class that sets a value (even an empty value) is encoutered * Config::EXCLUDE_EXTRA_SOURCES does not include any additional static sources (such as extensions) @@ -333,9 +362,12 @@ class Config { * Setting both Config::UNINHERITED and Config::FIRST_SET behaves the same as just Config::UNINHERITED * * should the parent classes value be merged in as the lowest priority source? - * @param null $result array|scalar - Reference to a variable to put the result in. Also returned, so this can be left as null safely. If you do pass a value, it will be treated as the highest priority value in the result chain - * @param null $suppress array - Internal use when called by child classes. Array of mask pairs to filter value by - * @return array|scalar - The value of the config item, or null if no value set. Could be an associative array, sequential array or scalar depending on value (see class docblock) + * @param $result array|scalar Reference to a variable to put the result in. Also returned, so this can be left + * as null safely. If you do pass a value, it will be treated as the highest priority + * value in the result chain + * @param $suppress array Internal use when called by child classes. Array of mask pairs to filter value by + * @return array|scalar The value of the config item, or null if no value set. Could be an associative array, + * sequential array or scalar depending on value (see class docblock) */ public function get($class, $name, $sourceOptions = 0, &$result = null, $suppress = null) { // If result is already not something to merge into, just return it @@ -351,7 +383,9 @@ class Config { } if (isset($this->suppresses[$k][$class][$name])) { - $suppress = $suppress ? array_merge($suppress, $this->suppresses[$k][$class][$name]) : $this->suppresses[$k][$class][$name]; + $suppress = $suppress + ? array_merge($suppress, $this->suppresses[$k][$class][$name]) + : $this->suppresses[$k][$class][$name]; } } @@ -384,7 +418,8 @@ class Config { } // Finally, merge in the values from the parent class - if (($sourceOptions & self::UNINHERITED) != self::UNINHERITED && (($sourceOptions & self::FIRST_SET) != self::FIRST_SET || $result === null)) { + if (($sourceOptions & self::UNINHERITED) != self::UNINHERITED + && (($sourceOptions & self::FIRST_SET) != self::FIRST_SET || $result === null)) { $parent = get_parent_class($class); if ($parent) $this->get($parent, $name, $sourceOptions, $result, $suppress); } @@ -399,8 +434,8 @@ class Config { /** * Update a configuration value * - * Configuration is modify only. The value passed is merged into the existing configuration. If you want to replace the - * current value, you'll need to call remove first. + * Configuration is modify only. The value passed is merged into the existing configuration. If you want to + * replace the current value, you'll need to call remove first. * * @param $class string - The class to update a configuration value for * @param $name string - The configuration property name to update @@ -429,12 +464,13 @@ class Config { * * Works like this: * - Check the current override array, and remove any values that match the arguments provided - * - Keeps track of the arguments passed to this method, and in get filters everything _except_ the current override array to - * exclude any match + * - Keeps track of the arguments passed to this method, and in get filters everything _except_ the current + * override array to exclude any match * * This way we can re-set anything removed by a call to this function by calling set. Because the current override - * array is only filtered immediately on calling this remove method, that value will then be exposed. However, every - * other source is filtered on request, so no amount of changes to parent's configuration etc can override a remove call. + * array is only filtered immediately on calling this remove method, that value will then be exposed. However, + * every other source is filtered on request, so no amount of changes to parent's configuration etc can override a + * remove call. * * @param $class string - The class to remove a configuration value from * @param $name string - The configuration name @@ -462,7 +498,9 @@ class Config { $this->overrides[0][$class][$name] = self::filter_array_by_suppress_array($value, array($suppress)); } else { - if (self::check_value_contained_in_suppress_array($value, array($suppress))) unset($this->overrides[0][$class][$name]); + if (self::check_value_contained_in_suppress_array($value, array($suppress))) { + unset($this->overrides[0][$class][$name]); + } } } diff --git a/core/Convert.php b/core/Convert.php index 870b5535a..205a95040 100644 --- a/core/Convert.php +++ b/core/Convert.php @@ -244,7 +244,8 @@ class Convert { // Expand hyperlinks if(!$preserveLinks && !$config['PreserveLinks']) { - $data = preg_replace('/]*href\s*=\s*"([^"]*)">(.*?)<\/a>/ie', "Convert::html2raw('\\2').'[\\1]'", $data); + $data = preg_replace('/]*href\s*=\s*"([^"]*)">(.*?)<\/a>/ie', "Convert::html2raw('\\2').'[\\1]'", + $data); $data = preg_replace('/]*href\s*=\s*([^ ]*)>(.*?)<\/a>/ie', "Convert::html2raw('\\2').'[\\1]'", $data); } diff --git a/core/Core.php b/core/Core.php index 415604a57..38e44299d 100644 --- a/core/Core.php +++ b/core/Core.php @@ -28,8 +28,9 @@ * - THIRDPARTY_PATH: Absolute filepath, e.g. "/var/www/my-webroot/framework/thirdparty" * * @todo This file currently contains a lot of bits and pieces, and its various responsibilities should probably be - * moved into different subsystems. - * @todo A lot of this stuff is very order-independent; for example, the require_once calls have to happen after the defines.' + * moved into different subsystems. + * @todo A lot of this stuff is very order-independent; for example, the require_once calls have to happen after the + * defines.' * This could be decoupled. * @package framework * @subpackage core @@ -45,7 +46,12 @@ error_reporting(E_ALL | E_STRICT); /** * Include _ss_environment.php files */ -$envFiles = array('_ss_environment.php', '../_ss_environment.php', '../../_ss_environment.php', '../../../_ss_environment.php'); +$envFiles = array( + '_ss_environment.php', + '../_ss_environment.php', + '../../_ss_environment.php', + '../../../_ss_environment.php'); + foreach($envFiles as $envFile) { if(@file_exists($envFile)) { define('SS_ENVIRONMENT_FILE', $envFile); @@ -324,7 +330,8 @@ function getClassFile($className) { function singleton($className) { if($className == "Config") user_error("Don't pass Config to singleton()", E_USER_ERROR); if(!isset($className)) user_error("singleton() Called without a class", E_USER_ERROR); - if(!is_string($className)) user_error("singleton() passed bad class_name: " . var_export($className,true), E_USER_ERROR); + if(!is_string($className)) user_error("singleton() passed bad class_name: " . var_export($className,true), + E_USER_ERROR); return Injector::inst()->get($className); } diff --git a/core/DAG.php b/core/DAG.php index 96790a59c..a4c7fae41 100644 --- a/core/DAG.php +++ b/core/DAG.php @@ -5,10 +5,16 @@ * in config yaml fragments */ class SS_DAG implements IteratorAggregate { - /** @var array|null - The nodes/vertices in the graph. Should be a numeric sequence of items (no string keys, no gaps). */ + /** + * The nodes/vertices in the graph. Should be a numeric sequence of items (no string keys, no gaps). + * @var array|null + */ protected $data; - /** @var array - The edges in the graph, in $to_idx => [$from_idx1, $from_idx2, ...] format */ + /** + * The edges in the graph, in $to_idx => [$from_idx1, $from_idx2, ...] format + * @var array + */ protected $dag; public function __construct($data = null) { @@ -28,11 +34,13 @@ class SS_DAG implements IteratorAggregate { } /** - * Add an edge from one vertex to another - * @param $from integer|any - The index in $data of the node/vertex, or the node/vertex itself, that the edge goes from - * @param $to integer|any - The index in $data of the node/vertex, or the node/vertex itself, that the edge goes to - * + * Add an edge from one vertex to another. + * * When passing actual nodes (as opposed to indexes), uses array_search with strict = true to find + * + * @param $from integer|any The index in $data of the node/vertex, or the node/vertex itself, that the edge + * goes from + * @param $to integer|any - The index in $data of the node/vertex, or the node/vertex itself, that the edge goes to */ public function addedge($from, $to) { $i = is_numeric($from) ? $from : array_search($from, $this->data, true); diff --git a/core/Diff.php b/core/Diff.php index 4705be310..1bfcd07f0 100644 --- a/core/Diff.php +++ b/core/Diff.php @@ -749,7 +749,8 @@ class Diff if($tagStack[$listName]) $rechunked[$listName][sizeof($rechunked[$listName])-1] .= ' ' . $item; else $rechunked[$listName][] = $item; - if($lookForTag && !$tagStack[$listName] && isset($item[0]) && $item[0] == "<" && substr($item,0,2) != "getStaticProperties(); } - if (!isset($static_properties[$parent][$name]) || $static_properties[$parent][$name] !== $value) return $value; + if (!isset($static_properties[$parent][$name]) || $static_properties[$parent][$name] !== $value) { + return $value; + } } } @@ -321,8 +330,8 @@ abstract class Object { * up the extra static var chain until it reaches the top, or it reaches a replacement static. * * If any extra values are discovered, they are then merged with the default PHP static values, or in some cases - * completely replace the default PHP static when you set $replace = true, and do not define extra data on any child - * classes + * completely replace the default PHP static when you set $replace = true, and do not define extra data on any + * child classes * * @param string $class * @param string $name the property name @@ -447,11 +456,13 @@ abstract class Object { } $extensionClass = $matches[1]; if(!class_exists($extensionClass)) { - user_error(sprintf('Object::add_extension() - Can\'t find extension class for "%s"', $extensionClass), E_USER_ERROR); + user_error(sprintf('Object::add_extension() - Can\'t find extension class for "%s"', $extensionClass), + E_USER_ERROR); } if(!is_subclass_of($extensionClass, 'Extension')) { - user_error(sprintf('Object::add_extension() - Extension "%s" is not a subclass of Extension', $extensionClass), E_USER_ERROR); + user_error(sprintf('Object::add_extension() - Extension "%s" is not a subclass of Extension', + $extensionClass), E_USER_ERROR); } // unset some caches @@ -529,7 +540,7 @@ abstract class Object { } } - // ----------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------- private static $extension_sources = array(); @@ -560,7 +571,8 @@ abstract class Object { $sources[] = $extensionClass; if(!ClassInfo::has_method_from($extensionClass, 'add_to_class', 'Extension')) { - Deprecation::notice('3.1.0', "add_to_class deprecated on $extensionClass. Use get_extra_config instead"); + Deprecation::notice('3.1.0', + "add_to_class deprecated on $extensionClass. Use get_extra_config instead"); } call_user_func(array($extensionClass, 'add_to_class'), $class, $extensionClass, $extensionArgs); @@ -582,7 +594,8 @@ abstract class Object { foreach(ClassInfo::ancestry(get_called_class()) as $class) { if(in_array($class, self::$unextendable_classes)) continue; - $extensions = Config::inst()->get($class, 'extensions', Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES); + $extensions = Config::inst()->get($class, 'extensions', + Config::UNINHERITED | Config::EXCLUDE_EXTRA_SOURCES); if($extensions) foreach($extensions as $extension) { $instance = self::create_from_string($extension); @@ -638,8 +651,8 @@ abstract class Object { ); } else { throw new Exception ( - "Object->__call(): $this->class cannot pass control to $config[property]($config[index])." . - ' Perhaps this object was mistakenly destroyed?' + "Object->__call(): $this->class cannot pass control to $config[property]($config[index])." + . ' Perhaps this object was mistakenly destroyed?' ); } @@ -652,7 +665,8 @@ abstract class Object { default : throw new Exception ( - "Object->__call(): extra method $method is invalid on $this->class:" . var_export($config, true) + "Object->__call(): extra method $method is invalid on $this->class:" + . var_export($config, true) ); } } else { @@ -662,7 +676,7 @@ abstract class Object { } } - // ----------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------- /** * Return TRUE if a method exists on this object @@ -780,7 +794,8 @@ abstract class Object { * * @param string $method the method name * @param string $code the PHP code - arguments will be in an array called $args, while you can access this object - * by using $obj. Note that you cannot call protected methods, as the method is actually an external function + * by using $obj. Note that you cannot call protected methods, as the method is actually an external + * function */ protected function createMethod($method, $code) { self::$extra_methods[$this->class][strtolower($method)] = array ( @@ -788,7 +803,7 @@ abstract class Object { ); } - // ----------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------- /** * @see Object::get_static() @@ -818,7 +833,7 @@ abstract class Object { Deprecation::notice('2.4', 'Use a custom static on your object instead.'); } - // ----------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------- /** * Return true if this object "exists" i.e. has a sensible value @@ -856,7 +871,7 @@ abstract class Object { return $this->class; } - // ----------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------- /** * Calls a method if available on both this object and all applied {@link Extensions}, and then attempts to merge @@ -945,7 +960,7 @@ abstract class Object { return $this->extension_instances; } - // ----------------------------------------------------------------------------------------------------------------- + // -------------------------------------------------------------------------------------------------------------- /** * Cache the results of an instance method in this object to a file, or if it is already cache return the cached diff --git a/core/manifest/ConfigManifest.php b/core/manifest/ConfigManifest.php index 0f85056c9..be8477123 100644 --- a/core/manifest/ConfigManifest.php +++ b/core/manifest/ConfigManifest.php @@ -9,20 +9,36 @@ */ class SS_ConfigManifest { - /** @var array All the values needed to be collected to determine the correct combination of fragements for the current environment. */ + /** + * All the values needed to be collected to determine the correct combination of fragements for + * the current environment. + * @var array + */ protected $variantKeySpec = array(); - /** @var array All the _config.php files. Need to be included every request & can't be cached. Not variant specific. */ + /** + * All the _config.php files. Need to be included every request & can't be cached. Not variant specific. + * @var array + */ protected $phpConfigSources = array(); - /** @var array All the _config/*.yml fragments pre-parsed and sorted in ascending include order. Not variant specific. */ + /** + * All the _config/*.yml fragments pre-parsed and sorted in ascending include order. Not variant specific. + * @var array + */ protected $yamlConfigFragments = array(); - /** @var array The calculated config from _config/*.yml, sorted, filtered and merged. Variant specific. */ + /** + * The calculated config from _config/*.yml, sorted, filtered and merged. Variant specific. + * @var array + */ public $yamlConfig = array(); - /** @var array A side-effect of collecting the _config fragments is the calculation of all module directories, since the definition - * of a module is "a directory that contains either a _config.php file or a _config directory */ + /** + * A side-effect of collecting the _config fragments is the calculation of all module directories, since + * the definition of a module is "a directory that contains either a _config.php file or a _config directory + * @var array + */ public $modules = array(); /** Adds a path as a module */ @@ -63,7 +79,8 @@ class SS_ConfigManifest { $this->variantKeySpec = $this->cache->load('variant_key_spec'); // Try getting the pre-filtered & merged config for this variant if (!($this->yamlConfig = $this->cache->load('yaml_config_'.$this->variantKey()))) { - // Otherwise, if we do have the yaml config fragments (and we should since we have a variant key spec) work out the config for this variant + // Otherwise, if we do have the yaml config fragments (and we should since we have a variant key spec) + // work out the config for this variant if ($this->yamlConfigFragments = $this->cache->load('yaml_config_fragments')) { $this->buildYamlConfigVariant(); } @@ -88,8 +105,9 @@ class SS_ConfigManifest { } /** - * Returns the string that uniquely identifies this variant. The variant is the combination of classes, modules, environment, - * environment variables and constants that selects which yaml fragments actually make it into the configuration because of "only" + * Returns the string that uniquely identifies this variant. The variant is the combination of classes, modules, + * environment, environment variables and constants that selects which yaml fragments actually make it into the + * configuration because of "only" * and "except" rules. * * @return string @@ -97,7 +115,9 @@ class SS_ConfigManifest { public function variantKey() { $key = $this->variantKeySpec; // Copy to fill in actual values - if (isset($key['environment'])) $key['environment'] = Director::isDev() ? 'dev' : (Director::isTest() ? 'test' : 'live'); + if (isset($key['environment'])) { + $key['environment'] = Director::isDev() ? 'dev' : (Director::isTest() ? 'test' : 'live'); + } if (isset($key['envvars'])) foreach ($key['envvars'] as $variable => $foo) { $key['envvars'][$variable] = isset($_ENV[$variable]) ? $_ENV[$variable] : null; @@ -111,9 +131,9 @@ class SS_ConfigManifest { } /** - * Completely regenerates the manifest file. Scans through finding all php _config.php and yaml _config/*.ya?ml files, - * parses the yaml files into fragments, sorts them and figures out what values need to be checked to pick the - * correct variant. + * Completely regenerates the manifest file. Scans through finding all php _config.php and yaml _config/*.ya?ml + * files,parses the yaml files into fragments, sorts them and figures out what values need to be checked to pick + * the correct variant. * * Does _not_ build the actual variant * @@ -177,7 +197,8 @@ class SS_ConfigManifest { $this->addModule(dirname(dirname($pathname))); // Use the Zend copy of this script to prevent class conflicts when RailsYaml is included - require_once 'thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/sfYamlParser.php'; + require_once 'thirdparty/zend_translate_railsyaml/library/Translate/Adapter/thirdparty/sfYaml/lib/' + . 'sfYamlParser.php'; $parser = new sfYamlParser(); // The base header @@ -203,7 +224,9 @@ class SS_ConfigManifest { // Otherwise it's a set of header/document pairs else { // If we got an odd number of parts the config file doesn't have a header for every document - if (count($parts) % 2 != 0) user_error("Configuration file $basename does not have an equal number of headers and config blocks"); + if (count($parts) % 2 != 0) { + user_error("Configuration file $basename does not have an equal number of headers and config blocks"); + } // Step through each pair for ($i = 0; $i < count($parts); $i+=2) { @@ -223,7 +246,8 @@ class SS_ConfigManifest { // For each, parse out into module/file#name, and set any missing to "*" $header[$order] = array(); foreach($orderparts as $part) { - preg_match('! (?P\*|\w+)? (\/ (?P\*|\w+))? (\# (?P\*|\w+))? !x', $part, $match); + preg_match('! (?P\*|\w+)? (\/ (?P\*|\w+))? (\# (?P\*|\w+))? !x', + $part, $match); $header[$order][] = array( 'module' => isset($match['module']) && $match['module'] ? $match['module'] : '*', @@ -279,7 +303,8 @@ class SS_ConfigManifest { $res .= '
    '; foreach ($e->dag as $node) { - $res .= "
    {$node['from']['module']}/{$node['from']['file']}#{$node['from']['name']} marked to come after