From bd71d7c88d3b7d396cb0009cb22303c2d6080a60 Mon Sep 17 00:00:00 2001 From: eZees Date: Wed, 25 Jun 2014 16:15:05 +0400 Subject: [PATCH 1/5] Update RU lang (build 110) --- modules/backend/lang/ru/lang.php | 37 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/modules/backend/lang/ru/lang.php b/modules/backend/lang/ru/lang.php index a12abee8a..e9a99ca7b 100644 --- a/modules/backend/lang/ru/lang.php +++ b/modules/backend/lang/ru/lang.php @@ -12,9 +12,9 @@ return [ 'page' => [ 'untitled' => "Без названия", 'access_denied' => [ - 'label' => "доступ запрещен", - 'help' => "Вы не должны необходимые разрешения для просмотра этой страницы.", - 'cms_link' => "К CMS серверной", + 'label' => "Доступ запрещен", + 'help' => "У вас нет необходимых прав для просмотра этой страницы.", + 'cms_link' => "Перейти к CMS", ], ], 'partial' => [ @@ -89,7 +89,7 @@ return [ 'missing_columns' => 'Список используемый в :class не имеет никаких столбцов.', 'missing_definition' => "Поведение списка не содержит столбец для ':field'.", 'behavior_not_ready' => 'Поведение списка не было инициализировано, проверьте вызов makeLists() в вашем контроллере.', - 'invalid_column_datetime' => "Column value ':column' is not a DateTime object, are you missing a \$dates reference in the Model?", + 'invalid_column_datetime' => "Значение столбца ':column' не является объектом DateTime. Отсутствует \$dates ссылка в модели?", ], 'form' => [ 'create_title' => "Создание :name", @@ -120,7 +120,10 @@ return [ 'or' => 'или', 'confirm_tab_close' => 'Закрыть вкладку? Несохраненные изменения будут потеряны.', 'behavior_not_ready' => 'Поведение формы не было инициализировано, проверьте вызов initForm() в вашем контроллере.', - 'preview_no_files_message' => 'Файлы не загружены' + 'preview_no_files_message' => 'Файлы не загружены', + 'select' => 'Выбрать', + 'select_all' => 'все', + 'select_none' => 'ничего', ], 'relation' => [ 'missing_definition' => "Поведение отношения не содержит определения для ':field'.", @@ -144,7 +147,7 @@ return [ 'missing_id' => "Нет идентификатора для поиска модели записи.", 'missing_relation' => "Модель ':class' не содержит определения для ':relation'", 'invalid_class' => "Модель :model используемая в :class не допустима, она должна наследовать класс \Model.", - 'mass_assignment_failed' => "Mass assignment failed for Model attribute ':attribute'.", + 'mass_assignment_failed' => "Массовое заполнение недоступно для атрибута модели ':attribute'.", ], 'warnings' => [ 'tips' => 'Подсказки по конфигурации системы', @@ -153,16 +156,16 @@ return [ 'extension' => 'Расширение PHP :name не установлено. Установите эту библиотеку и активируйте расширение.' ], 'editor' => [ - 'menu_label' => 'Editor Configuration', - 'menu_description' => 'Manage editor configuration.', - 'font_size' => 'Font size', - 'tab_size' => 'Tab size', - 'use_hard_tabs' => 'Indent using tabs', - 'code_folding' => 'Code folding', - 'word_wrap' => 'Word wrap', - 'highlight_active_line' => 'Highlight active line', - 'show_invisibles' => 'Show invisible characters', - 'show_gutter' => 'Show gutter', - 'theme' => 'Color scheme', + 'menu_label' => 'Настройки редактора', + 'menu_description' => 'Управление настройками редактора кода.', + 'font_size' => 'Размер шрифта', + 'tab_size' => 'Размер табуляции', + 'use_hard_tabs' => 'Использовать табуляцию для индентации', + 'code_folding' => 'Свертывание кода', + 'word_wrap' => 'Перенос слов', + 'highlight_active_line' => 'Подсвечивать активную строку', + 'show_invisibles' => 'Показывать невидимые символы', + 'show_gutter' => 'Показывать нумерацию строк', + 'theme' => 'Цветовая схема', ], ]; From 9d2d9b621f6692b9053689379d377551229812d3 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Thu, 26 Jun 2014 17:32:12 +1000 Subject: [PATCH 2/5] Create a System Twig extension, for shared features --- modules/cms/classes/Controller.php | 6 ++- modules/cms/twig/Extension.php | 11 ----- modules/system/ServiceProvider.php | 5 +- modules/system/twig/Extension.php | 76 ++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 modules/system/twig/Extension.php diff --git a/modules/cms/classes/Controller.php b/modules/cms/classes/Controller.php index ff0b8cd31..a6f82b257 100644 --- a/modules/cms/classes/Controller.php +++ b/modules/cms/classes/Controller.php @@ -14,7 +14,8 @@ use Exception; use Twig_Environment; use Controller as BaseController; use Cms\Twig\Loader as TwigLoader; -use Cms\Twig\Extension as TwigExtension; +use Cms\Twig\Extension as CmsTwigExtension; +use System\Twig\Extension as SystemTwigExtension; use Cms\Classes\FileHelper as CmsFileHelper; use System\Classes\ErrorHandler; use October\Rain\Support\Markdown; @@ -229,7 +230,8 @@ class Controller extends BaseController $options['cache'] = storage_path().'/twig'; $this->twig = new Twig_Environment($this->loader, $options); - $this->twig->addExtension(new TwigExtension($this)); + $this->twig->addExtension(new CmsTwigExtension($this)); + $this->twig->addExtension(new SystemTwigExtension); } /** diff --git a/modules/cms/twig/Extension.php b/modules/cms/twig/Extension.php index 768940586..c91caed9d 100644 --- a/modules/cms/twig/Extension.php +++ b/modules/cms/twig/Extension.php @@ -86,7 +86,6 @@ class Extension extends Twig_Extension public function getFilters() { $filters = [ - new Twig_SimpleFilter('app', [$this, 'appFilter'], ['is_safe' => ['html']]), new Twig_SimpleFilter('page', [$this, 'pageFilter'], ['is_safe' => ['html']]), new Twig_SimpleFilter('theme', [$this, 'themeFilter'], ['is_safe' => ['html']]), ]; @@ -211,16 +210,6 @@ class Extension extends Twig_Extension return $this->controller->themeUrl($url); } - /** - * Converts supplied URL to one relative to the website root. - * @param mixed $url Specifies the application-relative URL - * @return string - */ - public function appFilter($url) - { - return URL::to($url); - } - /** * Looks up the URL for a supplied page and returns it relative to the website root. * @param mixed $name Specifies the Cms Page file name. diff --git a/modules/system/ServiceProvider.php b/modules/system/ServiceProvider.php index a1aae7bfd..620ef7c2b 100644 --- a/modules/system/ServiceProvider.php +++ b/modules/system/ServiceProvider.php @@ -13,6 +13,7 @@ use System\Classes\PluginManager; use System\Classes\SettingsManager; use System\Twig\Engine as TwigEngine; use System\Twig\Loader as TwigLoader; +use System\Twig\Extension as TwigExtension; use System\Models\EmailSettings; use System\Models\EmailTemplate; use Backend\Classes\WidgetManager; @@ -74,7 +75,9 @@ class ServiceProvider extends ModuleServiceProvider * Register basic twig */ App::bindShared('twig', function($app) { - return new Twig_Environment(new TwigLoader(), ['auto_reload' => true]); + $twig = new Twig_Environment(new TwigLoader(), ['auto_reload' => true]); + $twig->addExtension(new TwigExtension); + return $twig; }); /* diff --git a/modules/system/twig/Extension.php b/modules/system/twig/Extension.php new file mode 100644 index 000000000..7b413c76d --- /dev/null +++ b/modules/system/twig/Extension.php @@ -0,0 +1,76 @@ + ['html']]), + ]; + + return $filters; + } + + /** + * Returns a list of token parsers this extensions provides. + * + * @return array An array of token parsers + */ + public function getTokenParsers() + { + return []; + } + + /** + * Converts supplied URL to one relative to the website root. + * @param mixed $url Specifies the application-relative URL + * @return string + */ + public function appFilter($url) + { + return URL::to($url); + } +} \ No newline at end of file From 907da61254ee0b1f96a3a2fa2f5d1b138d64e96e Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Thu, 26 Jun 2014 19:12:27 +1000 Subject: [PATCH 3/5] Refs #350 - add default sender address --- app/config/mail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/mail.php b/app/config/mail.php index a7151a067..0c675ef81 100644 --- a/app/config/mail.php +++ b/app/config/mail.php @@ -54,7 +54,7 @@ return array( | */ - 'from' => array('address' => null, 'name' => null), + 'from' => array('address' => 'noreply@site.com', 'name' => 'October'), /* |-------------------------------------------------------------------------- From 99ef8f52b837b12510610a28ea20110e4a75231c Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Thu, 26 Jun 2014 19:12:52 +1000 Subject: [PATCH 4/5] Minor text updates --- modules/backend/lang/de/lang.php | 4 ++-- modules/backend/lang/en/lang.php | 4 ++-- modules/backend/lang/ja/lang.php | 4 ++-- modules/backend/lang/nl/lang.php | 4 ++-- modules/system/controllers/updates/_project_form.htm | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/backend/lang/de/lang.php b/modules/backend/lang/de/lang.php index 7a560bdec..26866c549 100644 --- a/modules/backend/lang/de/lang.php +++ b/modules/backend/lang/de/lang.php @@ -152,8 +152,8 @@ return [ 'extension' => 'The PHP extension :name is not installed. Please install this library and activate the extension.' ], 'editor' => [ - 'menu_label' => 'Editor Configuration', - 'menu_description' => 'Manage editor configuration.', + 'menu_label' => 'Editor Preferences', + 'menu_description' => 'Manage code editor preferences.', 'font_size' => 'Font size', 'tab_size' => 'Tab size', 'use_hard_tabs' => 'Indent using tabs', diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 5424f1d03..d8026d39a 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -156,8 +156,8 @@ return [ 'extension' => 'The PHP extension :name is not installed. Please install this library and activate the extension.' ], 'editor' => [ - 'menu_label' => 'Editor Configuration', - 'menu_description' => 'Manage editor configuration.', + 'menu_label' => 'Editor Preferences', + 'menu_description' => 'Manage code editor preferences.', 'font_size' => 'Font size', 'tab_size' => 'Tab size', 'use_hard_tabs' => 'Indent using tabs', diff --git a/modules/backend/lang/ja/lang.php b/modules/backend/lang/ja/lang.php index 1b1324336..a6697996e 100644 --- a/modules/backend/lang/ja/lang.php +++ b/modules/backend/lang/ja/lang.php @@ -152,8 +152,8 @@ return [ 'extension' => 'The PHP extension :name is not installed. Please install this library and activate the extension.' ], 'editor' => [ - 'menu_label' => 'Editor Configuration', - 'menu_description' => 'Manage editor configuration.', + 'menu_label' => 'Editor Preferences', + 'menu_description' => 'Manage code editor preferences.', 'font_size' => 'Font size', 'tab_size' => 'Tab size', 'use_hard_tabs' => 'Indent using tabs', diff --git a/modules/backend/lang/nl/lang.php b/modules/backend/lang/nl/lang.php index 53f422af3..f14ced3e7 100644 --- a/modules/backend/lang/nl/lang.php +++ b/modules/backend/lang/nl/lang.php @@ -152,8 +152,8 @@ return [ 'extension' => 'The PHP extension :name is not installed. Please install this library and activate the extension.' ], 'editor' => [ - 'menu_label' => 'Editor Configuration', - 'menu_description' => 'Manage editor configuration.', + 'menu_label' => 'Editor Preferences', + 'menu_description' => 'Manage code editor preferences.', 'font_size' => 'Font size', 'tab_size' => 'Tab size', 'use_hard_tabs' => 'Indent using tabs', diff --git a/modules/system/controllers/updates/_project_form.htm b/modules/system/controllers/updates/_project_form.htm index a68ef7105..d5e2a178f 100644 --- a/modules/system/controllers/updates/_project_form.htm +++ b/modules/system/controllers/updates/_project_form.htm @@ -11,7 +11,7 @@
- + Date: Thu, 26 Jun 2014 20:37:55 +1000 Subject: [PATCH 5/5] Fixes #55 - Assets are now referenced correctly as Assets instead of URLs --- modules/backend/assets/js/october.utils.js | 4 +- modules/backend/classes/BackendHelper.php | 4 +- .../codeeditor/partials/_codeeditor.htm | 2 +- modules/backend/layouts/_head.htm | 118 +++++++++--------- modules/cms/classes/CombineAssets.php | 24 +++- modules/cms/classes/Controller.php | 13 +- modules/cms/twig/FrameworkNode.php | 6 +- modules/system/models/File.php | 4 +- modules/system/traits/AssetMaker.php | 2 +- tests/unit/cms/classes/CombineAssetsTest.php | 11 ++ tests/unit/cms/classes/ControllerTest.php | 24 +++- 11 files changed, 134 insertions(+), 78 deletions(-) diff --git a/modules/backend/assets/js/october.utils.js b/modules/backend/assets/js/october.utils.js index e7d1d5e26..80129263c 100644 --- a/modules/backend/assets/js/october.utils.js +++ b/modules/backend/assets/js/october.utils.js @@ -74,7 +74,7 @@ AssetManager = function() { callback && callback() return } - + o.loadJavaScript(jsList, function(){ jsLoaded = true checkLoaded() @@ -99,7 +99,7 @@ AssetManager = function() { if (!jsLoaded) return false - if (cssCounter < cssList.length) + if (cssCounter < cssList.length) return false callback && callback() diff --git a/modules/backend/classes/BackendHelper.php b/modules/backend/classes/BackendHelper.php index 45357d87d..cc1a8b5db 100644 --- a/modules/backend/classes/BackendHelper.php +++ b/modules/backend/classes/BackendHelper.php @@ -27,11 +27,11 @@ class BackendHelper /** * Returns a URL in context of the active Backend skin */ - public function skinUrl($path = null) + public function skinAsset($path = null) { $path = RouterHelper::normalizeUrl($path); $skinPath = Skin::getActive()->skinPath; - return URL::to($skinPath . $path); + return URL::asset($skinPath . $path); } /** diff --git a/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm b/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm index 857fa7cfe..82001334a 100644 --- a/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm +++ b/modules/backend/formwidgets/codeeditor/partials/_codeeditor.htm @@ -16,7 +16,7 @@ data-show-gutter="" data-language="" data-margin="" - data-vendor-path="/"> + data-vendor-path="/">
  • diff --git a/modules/backend/layouts/_head.htm b/modules/backend/layouts/_head.htm index 487c74f20..578d24fba 100644 --- a/modules/backend/layouts/_head.htm +++ b/modules/backend/layouts/_head.htm @@ -4,69 +4,69 @@ pageTitle ?> | October CMS - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '.PHP_EOL;" . PHP_EOL) + ->write("echo ''.PHP_EOL;" . PHP_EOL) ; if ($includeExtras) { $compiler - ->write("echo ''.PHP_EOL;" . PHP_EOL) - ->write("echo ''.PHP_EOL;" . PHP_EOL) + ->write("echo ''.PHP_EOL;" . PHP_EOL) + ->write("echo ''.PHP_EOL;" . PHP_EOL) ; } } diff --git a/modules/system/models/File.php b/modules/system/models/File.php index c1b8d5d19..4bcfe3b22 100644 --- a/modules/system/models/File.php +++ b/modules/system/models/File.php @@ -40,8 +40,8 @@ class File extends FileBase { $uploadsDir = Config::get('cms.uploadsDir'); if ($this->isPublic()) - return Request::getBaseUrl() . $uploadsDir . '/public/'; + return Request::getBasePath() . $uploadsDir . '/public/'; else - return Request::getBaseUrl() . $uploadsDir . '/protected/'; + return Request::getBasePath() . $uploadsDir . '/protected/'; } } diff --git a/modules/system/traits/AssetMaker.php b/modules/system/traits/AssetMaker.php index b7ac1571c..74c0236b8 100644 --- a/modules/system/traits/AssetMaker.php +++ b/modules/system/traits/AssetMaker.php @@ -240,7 +240,7 @@ trait AssetMaker return $asset; if (substr($asset, 0, 1) == '/') - $asset = Request::getBaseUrl() . $asset; + $asset = Request::getBasePath() . $asset; return $asset; } diff --git a/tests/unit/cms/classes/CombineAssetsTest.php b/tests/unit/cms/classes/CombineAssetsTest.php index 2d3e93738..ad49107be 100644 --- a/tests/unit/cms/classes/CombineAssetsTest.php +++ b/tests/unit/cms/classes/CombineAssetsTest.php @@ -114,6 +114,17 @@ class CombineAssetsTest extends TestCase $this->markTestIncomplete('TODO'); } + public function testGetTargetPath() + { + $combiner = new CombineAssets; + + $value = self::callProtectedMethod($combiner, 'getTargetPath', ['/combine']); + $this->assertEquals('combine/', $value); + + $value = self::callProtectedMethod($combiner, 'getTargetPath', ['/index.php/combine']); + $this->assertEquals('index-php/combine/', $value); + } + public function testMakeCacheId() { $sampleResources = ['assets/css/style1.css', 'assets/css/style2.css']; diff --git a/tests/unit/cms/classes/ControllerTest.php b/tests/unit/cms/classes/ControllerTest.php index e34646b30..4c04e7f2f 100644 --- a/tests/unit/cms/classes/ControllerTest.php +++ b/tests/unit/cms/classes/ControllerTest.php @@ -350,4 +350,26 @@ ESC; $this->assertArrayHasKey('ajax-result', $content); $this->assertEquals('page', $content['ajax-result']); } -} \ No newline at end of file + + public function testThemeUrl() + { + $theme = new Theme(); + $theme->load('test'); + $controller = new Controller($theme); + + $url = $controller->themeUrl(); + $this->assertEquals('/tests/fixtures/cms/themes/test', $url); + + $url = $controller->themeUrl('foo/bar.css'); + $this->assertEquals('/tests/fixtures/cms/themes/test/foo/bar.css', $url); + + $url = $controller->themeUrl(['assets/css/style1.css', 'assets/css/style2.css']); + $url = substr($url, 0, strpos($url, '-')); + $this->assertEquals('/combine/88634b8fa6f4f6442ce830d38296640a', $url); + + $url = $controller->themeUrl(['assets/js/script1.js', 'assets/js/script2.js']); + $url = substr($url, 0, strpos($url, '-')); + $this->assertEquals('/combine/860afc990164a60a8e90682d04da27ee', $url); + } + +}