FIX: update javascript requirements so user JS doesn't error

This commit is contained in:
Dylan Wagstaff 2018-01-29 13:04:34 +13:00
parent 4bf0a83ad3
commit 7b38707fde
7 changed files with 25 additions and 37 deletions

View File

@ -30,7 +30,8 @@
},
"expose": [
"css",
"javascript"
"javascript",
"thirdparty"
]
},
"scripts": {

View File

@ -70,8 +70,10 @@ SilverStripe\CMS\Model\SiteTree:
```php
// Get the setting
$loginRequired = singleton('SilverStripe\\CMS\\Model\\SiteTree')->getCommentsOption('require_login');
use SilverStripe\CMS\Model\SiteTree;
// [...]
// Get the setting
$loginRequired = singleton(SiteTree::class)->getCommentsOption('require_login');
```
@ -87,9 +89,9 @@ In order to use this feature, you need to install the
through [Composer](http://getcomposer.org).
```json
{
"require": {"ezyang/htmlpurifier": "^4.8"}
}
{
"require": {"ezyang/htmlpurifier": "^4.8"}
}
```
**Important**: Rendering user-provided HTML on your website always risks
@ -148,7 +150,7 @@ SilverStripe\CMS\Model\SiteTree:
gravatar_rating: 'r'
```
Vald values for rating are as follows:
Valid values for rating are as follows:
* g: suitable for display on all websites with any audience type.
* pg: may contain rude gestures, provocatively dressed individuals, the lesser

View File

@ -1,26 +1,12 @@
# Installation
## Composer
Edit your project-wide composer.json file as follows; in the "require" block add:
"silverstripe/comments": "*"
Then in the root of your project run:
#> composer update silverstripe/comments
```sh
composer require silverstripe/comments`
```
## Web
To begin the installation first download the module online. You can find the version you require for your SilverStripe installation on the [silverstripe.org](http://www.silverstripe.org) website.
After you have finished downloading the file, extract the downloaded file to your site's root folder and ensure the name of the module is `comments`.
## All
Run a database rebuild by visiting *http://yoursite.com/dev/build?flush=1*. This will add the required database columns and tables for the module to function, and refresh the configuration manifest.
If you previously had SilverStripe version 2.4 installed then you'll also need to run the migration script provided. More information on this is provided in the next section.
Then run a database rebuild by visiting `dev/build`. This will add the required database columns and tables for the module to function, and refresh the configuration manifest.
## Enabling Commenting
@ -30,8 +16,6 @@ For more configuration options see [Configuration](Configuration.md).
## Upgrading
### Migrating from version 2.* SilverStripe installations
### Migrating from version SilverStripe 2 installations
This module replaces the built-in commenting system available in versions up to SilverStripe 2.4. To migrate from that you'll need to run `dev/build` after installing the module.
You can do this via sake (`sake dev/build flush=1`) or via a web browser by visiting `http://yoursite.com/dev/build?flush=1`
This module replaces the built-in commenting system available in SilverStripe 2. Running the `dev/build` task will automatically perform a migration if any comments from these old versions exist.

View File

@ -35,7 +35,7 @@ class CommentsGridFieldConfig extends GridFieldConfig_RecordEditor
$manager->addBulkAction(
'spam',
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldConfig.SPAM', 'Spam'),
_t(__CLASS__ . '.SPAM', 'Spam'),
Handler::class,
array(
'isAjax' => true,
@ -46,7 +46,7 @@ class CommentsGridFieldConfig extends GridFieldConfig_RecordEditor
$manager->addBulkAction(
'approve',
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldConfig.APPROVE', 'Approve'),
_t(__CLASS__ . '.APPROVE', 'Approve'),
Handler::class,
array(
'isAjax' => true,

View File

@ -274,7 +274,7 @@ class CommentingController extends Controller
}
}
$title = _t('SilverStripe\\Comments\\Controllers\\CommentingController.RSSTITLE', "Comments RSS Feed");
$title = _t(__CLASS__ . '.RSSTITLE', "Comments RSS Feed");
$comments = new PaginatedList($comments, $request);
$comments->setPageLength($this->getOption('comments_per_page'));

View File

@ -184,7 +184,7 @@ class CommentsExtension extends DataExtension
'None' => _t(__CLASS__ . '.MODERATIONREQUIRED_NONE', 'No moderation required'),
'Required' => _t(__CLASS__ . '.MODERATIONREQUIRED_REQUIRED', 'Moderate all comments'),
'NonMembersOnly' => _t(
'SilverStripe\\Comments\\Extensions\\CommentsExtension.MODERATIONREQUIRED_NONMEMBERSONLY',
__CLASS__ . '.MODERATIONREQUIRED_NONMEMBERSONLY',
'Only moderate non-members'
),
));
@ -450,11 +450,11 @@ class CommentsExtension extends DataExtension
// Check if enabled
$enabled = $this->getCommentsEnabled();
if ($enabled && $this->owner->getCommentsOption('include_js')) {
$adminThirdPartyDir = ModuleLoader::getModule('silverstripe/admin')->getRelativePath() . '/thirdparty';
Requirements::javascript($adminThirdPartyDir . '/jquery/jquery.js');
Requirements::javascript($adminThirdPartyDir . '/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript($adminThirdPartyDir . '/jquery-form/jquery.form.js');
Requirements::javascript('silverstripe/admin:thirdparty/jquery/jquery.js');
Requirements::javascript('silverstripe/admin:thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript('silverstripe/admin:thirdparty/jquery-form/jquery.form.js');
Requirements::javascript('silverstripe/comments:thirdparty/jquery-validate/jquery.validate.min.js');
Requirements::javascript('silverstripe/admin:client/dist/js/i18n.js');
Requirements::add_i18n_javascript('silverstripe/comments:javascript/lang');
Requirements::javascript('silverstripe/comments:javascript/CommentsInterface.js');
}

View File

@ -188,6 +188,7 @@ class Comment extends DataObject
{
parent::requireDefaultRecords();
// Upgrade from SilverStripe 2 version if necessary
if (DB::get_schema()->hasTable('PageComment')) {
$comments = DB::query('SELECT * FROM "PageComment"');