Skip to content

Commit

Permalink
Prepare for CDN, config rename cms.plugins|themes|uploadsDir -> cms.p…
Browse files Browse the repository at this point in the history
…lugins|themes|uploadsPath

Deprecate data-trigger-type on triggerapi
Fixes ref to Util class
  • Loading branch information
daftspunk committed Feb 17, 2015
1 parent 7b52e07 commit 7145aac
Show file tree
Hide file tree
Showing 25 changed files with 99 additions and 153 deletions.
21 changes: 12 additions & 9 deletions config/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,36 +154,39 @@

/*
|--------------------------------------------------------------------------
| Plugins directory
| Public plugins path
|--------------------------------------------------------------------------
|
| Specifies the plugins directory relative to the application root directory.
| Specifies the public plugins path relative to the application base URL,
| or you can specify a full URL path.
|
*/

'pluginsDir' => '/plugins',
'pluginsPath' => '/plugins',

/*
|--------------------------------------------------------------------------
| Themes directory
| Public themes path
|--------------------------------------------------------------------------
|
| Specifies the themes directory relative to the application root directory.
| Specifies the public themes path relative to the application base URL,
| or you can specify a full URL path.
|
*/

'themesDir' => '/themes',
'themesPath' => '/themes',

/*
|--------------------------------------------------------------------------
| Uploads directory
| Public uploads path
|--------------------------------------------------------------------------
|
| Specifies the uploads directory relative to the application root directory.
| Specifies the public uploads path relative to the application base URL,
| or you can specify a full URL path.
|
*/

'uploadsDir' => '/uploads',
'uploadsPath' => '/uploads',

/*
|--------------------------------------------------------------------------
Expand Down
41 changes: 2 additions & 39 deletions config/testing/cms.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return array(
return [

/*
|--------------------------------------------------------------------------
Expand All @@ -13,28 +13,6 @@

'activeTheme' => 'test',

/*
|--------------------------------------------------------------------------
| Plugins directory
|--------------------------------------------------------------------------
|
| Specifies the plugins directory relative to the application root directory.
|
*/

'pluginsDir' => '/tests/fixtures/plugins',

/*
|--------------------------------------------------------------------------
| Themes directory
|--------------------------------------------------------------------------
|
| Specifies the themes directory relative to the application root directory.
|
*/

'themesDir' => '/tests/fixtures/themes',

/*
|--------------------------------------------------------------------------
| Time to live for parsed CMS objects.
Expand Down Expand Up @@ -109,19 +87,4 @@

'convertLineEndings' => true,

/*
|--------------------------------------------------------------------------
| Linking policy
|--------------------------------------------------------------------------
|
| Controls how URL links are generated throughout the application.
|
| detect - detect hostname and use the current schema
| secure - detect hostname and force HTTPS schema
| insecure - detect hostname and force HTTP schema
| force - force hostname and schema using app.url config value
|
*/

'linkPolicy' => 'detect',
);
];
21 changes: 11 additions & 10 deletions modules/backend/assets/js/october-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ if($.oc===undefined)
$.oc={}
$.oc.escapeHtmlString=function(string){var htmlEscapes={'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#x27;','/':'&#x2F;'},htmlEscaper=/[&<>"'\/]/g
return(''+string).replace(htmlEscaper,function(match){return htmlEscapes[match];})}
+function($){"use strict";var TriggerOn=function(element,options){var $el=this.$el=$(element);this.options=options||{};if(this.options.triggerCondition===false)
+function($){"use strict";var TriggerOn=function(element,options){var $el=this.$el=$(element);this.options=options||{};if(this.options.triggerType!==false&&this.options.triggerAction===false)this.options.triggerAction=this.options.triggerType
if(this.options.triggerCondition===false)
throw new Error('Trigger condition is not specified.')
if(this.options.trigger===false)
throw new Error('Trigger selector is not specified.')
if(this.options.triggerType===false)
throw new Error('Trigger type is not specified.')
if(this.options.triggerAction===false)
throw new Error('Trigger action is not specified.')
this.triggerCondition=this.options.triggerCondition
if(this.options.triggerCondition.indexOf('value')==0){var match=this.options.triggerCondition.match(/[^[\]]+(?=])/g)
if(match){this.triggerConditionValue=match
Expand All @@ -85,23 +86,23 @@ self.onConditionChanged()})
self.onConditionChanged()}
TriggerOn.prototype.onConditionChanged=function(){if(this.triggerCondition=='checked'){this.updateTarget($(this.options.trigger+':checked').length>0)}
else if(this.triggerCondition=='value'){this.updateTarget($(this.options.trigger).val()==this.triggerConditionValue)}}
TriggerOn.prototype.updateTarget=function(status){if(this.options.triggerType=='show')
TriggerOn.prototype.updateTarget=function(status){if(this.options.triggerAction=='show')
this.$el.toggleClass('hide',!status).trigger('hide',[!status])
else if(this.options.triggerType=='hide')
else if(this.options.triggerAction=='hide')
this.$el.toggleClass('hide',status).trigger('hide',[status])
else if(this.options.triggerType=='enable')
else if(this.options.triggerAction=='enable')
this.$el.prop('disabled',!status).trigger('disable',[!status]).toggleClass('control-disabled',!status)
else if(this.options.triggerType=='disable')
else if(this.options.triggerAction=='disable')
this.$el.prop('disabled',status).trigger('disable',[status]).toggleClass('control-disabled',status)
else if(this.options.triggerType=='empty'&&status)
else if(this.options.triggerAction=='empty'&&status)
this.$el.trigger('empty').val('')
if(this.options.triggerType=='show'||this.options.triggerType=='hide')
if(this.options.triggerAction=='show'||this.options.triggerAction=='hide')
this.fixButtonClasses()
$(window).trigger('resize')}
TriggerOn.prototype.fixButtonClasses=function(){var group=this.$el.closest('.btn-group')
if(group.length>0&&this.$el.is(':last-child'))
this.$el.prev().toggleClass('last',this.$el.hasClass('hide'))}
TriggerOn.DEFAULTS={triggerCondition:false,trigger:false,triggerType:false}
TriggerOn.DEFAULTS={triggerAction:false,triggerCondition:false,trigger:false}
var old=$.fn.triggerOn
$.fn.triggerOn=function(option){return this.each(function(){var $this=$(this)
var data=$this.data('oc.triggerOn')
Expand Down
29 changes: 16 additions & 13 deletions modules/backend/assets/js/october.triggerapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* element is checked.
*
* Supported data attributes:
* - data-trigger-type, values: show, hide, enable, disable, empty
* - data-trigger-action, values: show, hide, enable, disable, empty
* - data-trigger: a CSS selector for elements that trigger the action (checkboxes)
* - data-trigger-condition, values:
* - checked: determines the condition the elements specified in the data-trigger
Expand All @@ -15,7 +15,7 @@
* the condition is considered "true".
*
* Example: <input type="button" class="btn disabled"
* data-trigger-type="enable"
* data-trigger-action="enable"
* data-trigger="#cblist input[type=checkbox]"
* data-trigger-condition="checked" ... >
*
Expand All @@ -24,7 +24,7 @@
* force it to check the condition and update itself. This is useful when the page content is updated with AJAX.
*
* JavaScript API:
* $('#mybutton').triggerOn({triggerCondition: 'checked', trigger: '#cblist input[type=checkbox]', triggerType: 'enable'})
* $('#mybutton').triggerOn({ triggerCondition: 'checked', trigger: '#cblist input[type=checkbox]', triggerAction: 'enable' })
*/
+function ($) { "use strict";

Expand All @@ -34,14 +34,17 @@

this.options = options || {};

// @deprecated remove if year >= 2016
if (this.options.triggerType !== false && this.options.triggerAction === false) this.options.triggerAction = this.options.triggerType

if (this.options.triggerCondition === false)
throw new Error('Trigger condition is not specified.')

if (this.options.trigger === false)
throw new Error('Trigger selector is not specified.')

if (this.options.triggerType === false)
throw new Error('Trigger type is not specified.')
if (this.options.triggerAction === false)
throw new Error('Trigger action is not specified.')

this.triggerCondition = this.options.triggerCondition

Expand Down Expand Up @@ -75,18 +78,18 @@
}

TriggerOn.prototype.updateTarget = function(status) {
if (this.options.triggerType == 'show')
if (this.options.triggerAction == 'show')
this.$el.toggleClass('hide', !status).trigger('hide', [!status])
else if (this.options.triggerType == 'hide')
else if (this.options.triggerAction == 'hide')
this.$el.toggleClass('hide', status).trigger('hide', [status])
else if (this.options.triggerType == 'enable')
else if (this.options.triggerAction == 'enable')
this.$el.prop('disabled', !status).trigger('disable', [!status]).toggleClass('control-disabled', !status)
else if (this.options.triggerType == 'disable')
else if (this.options.triggerAction == 'disable')
this.$el.prop('disabled', status).trigger('disable', [status]).toggleClass('control-disabled', status)
else if (this.options.triggerType == 'empty' && status)
else if (this.options.triggerAction == 'empty' && status)
this.$el.trigger('empty').val('')

if (this.options.triggerType == 'show' || this.options.triggerType == 'hide')
if (this.options.triggerAction == 'show' || this.options.triggerAction == 'hide')
this.fixButtonClasses()

$(window).trigger('resize')
Expand All @@ -100,9 +103,9 @@
}

TriggerOn.DEFAULTS = {
triggerAction: false,
triggerCondition: false,
trigger: false,
triggerType: false
trigger: false
}

// TRIGGERON PLUGIN DEFINITION
Expand Down
1 change: 0 additions & 1 deletion modules/backend/behaviors/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Backend;
use Backend\Classes\FormField;
use Backend\Classes\ControllerBehavior;
use October\Rain\Support\Util;
use October\Rain\Router\Helper as RouterHelper;
use ApplicationException;
use Exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
disabled="disabled"
data-request="onRelationButtonDelete"
data-request-confirm="<?= e(trans('backend::lang.relation.delete_confirm')) ?>"
data-trigger-type="enable"
data-trigger-action="enable"
data-trigger="#<?= $this->relationGetId('view') ?> .control-list input[type=checkbox]"
data-trigger-condition="checked"
data-stripe-load-indicator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
})"
disabled="disabled"
data-request="onRelationButtonRemove"
data-trigger-type="enable"
data-trigger-action="enable"
data-trigger="#<?= $this->relationGetId('view') ?> .control-list input[type=checkbox]"
data-trigger-condition="checked"
data-stripe-load-indicator>
Expand Down
10 changes: 0 additions & 10 deletions modules/backend/classes/ControllerBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ class ControllerBehavior extends ExtensionBase
public function __construct($controller)
{
$this->controller = $controller;

// Option A: (@todo Determine which is faster by benchmark)
// $relativePath = strtolower(str_replace('\\', '/', get_called_class()));
// $this->viewPath = $this->configPath = [
// 'modules/' . $relativePath . '/partials',
// 'plugins/' . $relativePath . '/partials'
// ];
// $this->assetPath = ['modules/' . $relativePath . '/assets', 'plugins/' . $relativePath . '/assets'];

// Option B:
$this->viewPath = $this->configPath = $this->guessViewPath('/partials');
$this->assetPath = $this->guessViewPath('/assets', true);

Expand Down
10 changes: 0 additions & 10 deletions modules/backend/classes/WidgetBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ abstract class WidgetBase
public function __construct($controller, $configuration = [])
{
$this->controller = $controller;

// Option A: (@todo Determine which is faster by benchmark)
// $relativePath = strtolower(str_replace('\\', '/', get_called_class()));
// $this->viewPath = $this->configPath = [
// 'modules/' . $relativePath . '/partials',
// 'plugins/' . $relativePath . '/partials'
// ];
// $this->assetPath = ['modules/' . $relativePath . '/assets', 'plugins/' . $relativePath . '/assets'];

// Option B:
$this->viewPath = $this->configPath = $this->guessViewPath('/partials');
$this->assetPath = $this->guessViewPath('/assets', true);

Expand Down
2 changes: 1 addition & 1 deletion modules/backend/controllers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ protected function formExtendFields($form)
-1 => 'backend::lang.user.deny',
],
'attributes' => [
'data-trigger-action' => 'disable',
'data-trigger' => "input[name='User[permissions][superuser]']",
'data-trigger-type' => 'disable',
'data-trigger-condition' => 'checked',
],
'span' => 'auto',
Expand Down
4 changes: 2 additions & 2 deletions modules/backend/controllers/users/_list_toolbar.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<button
class="btn btn-default oc-icon-ban-circle"
disabled="disabled"
data-trigger-type="enable"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked">Ban</button>
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
data-trigger-type="enable"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked">Delete</button>
</div>
Expand Down
3 changes: 1 addition & 2 deletions modules/backend/widgets/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Backend\Classes\WidgetBase;
use Backend\Classes\FilterScope;
use ApplicationException;
use October\Rain\Support\Util;

/**
* Filter Widget
Expand Down Expand Up @@ -126,7 +125,7 @@ public function onFilterUpdate()
$params = func_get_args();
$result = $this->fireEvent('filter.update', [$params]);
if ($result && is_array($result)) {
return Util::arrayMerge($result);
return call_user_func_array('array_merge', $result);
}
}

Expand Down
11 changes: 11 additions & 0 deletions modules/backend/widgets/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ protected function validateModel()
protected function prepareVars()
{
$this->defineFormFields();
$this->applyFiltersFromModel();
$this->vars['sessionKey'] = $this->getSessionKey();
$this->vars['outsideTabs'] = $this->outsideTabs;
$this->vars['primaryTabs'] = $this->primaryTabs;
Expand Down Expand Up @@ -840,6 +841,16 @@ public function getSaveData()
return $data;
}

/*
* Allow the model to filter fields.
*/
protected function applyFiltersFromModel()
{
if (method_exists($this->model, 'filterFields')) {
$this->model->filterFields((object) $this->fields);
}
}

/**
* Looks at the model for defined options.
*/
Expand Down
3 changes: 1 addition & 2 deletions modules/backend/widgets/Search.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Backend\Widgets;

use Input;
use October\Rain\Support\Util;
use Backend\Classes\WidgetBase;

/**
Expand Down Expand Up @@ -116,7 +115,7 @@ public function onSubmit()
$params = func_get_args();
$result = $this->fireEvent('search.submit', [$params]);
if ($result && is_array($result)) {
return Util::arrayMerge($result);
return call_user_func_array('array_merge', $result);
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/cms/classes/ComponentBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __construct(CodeBase $cmsObject = null, $properties = [])

$className = Str::normalizeClassName(get_called_class());
$this->dirName = strtolower(str_replace('\\', '/', $className));
$this->assetPath = Config::get('cms.pluginsDir').dirname(dirname($this->dirName));
$this->assetPath = Config::get('cms.pluginsPath', '/plugins').dirname(dirname($this->dirName));

parent::__construct();
}
Expand Down
Loading

0 comments on commit 7145aac

Please sign in to comment.