Permalink
Browse files

Major backward-compatibility break: blocks and modules moved to the r…

…oot of the project (system tries to make sure process goes smooth by correcting `fs.json` files and creating temporary symlinks in original locations).

Also events with `components/` in their name have lost this suffix, for instance, `admin/System/components/modules/default` become `admin/System/modules/default`.
  • Loading branch information...
nazar-pc committed Jul 2, 2016
1 parent de499a4 commit c55245c46a348276d4b47ad5e7da85cf2f52f536
Showing 1,074 changed files with 14,345 additions and 14,319 deletions.
File renamed without changes.
@@ -37,7 +37,7 @@ function __construct ($root, $target) {
*/
function core ($modules = [], $themes = [], $suffix = null) {
$suffix = $suffix ? "_$suffix" : '';
$version = file_get_json("$this->root/components/modules/System/meta.json")['version'];
$version = file_get_json("$this->root/modules/System/meta.json")['version'];
$target_file = "$this->target/CleverStyle_Framework_$version$suffix.phar.php";
if (file_exists($target_file)) {
unlink($target_file);
@@ -59,7 +59,7 @@ function core ($modules = [], $themes = [], $suffix = null) {
* Add modules that should be built-in into package
*/
$components_files = [];
$modules = $this->filter_and_add_components("$this->root/components/modules", $modules, $components_files);
$modules = $this->filter_and_add_components("$this->root/modules", $modules, $components_files);
$phar->addFromString('modules.json', _json_encode($modules));
/**
* Add themes that should be built-in into package
@@ -137,7 +137,7 @@ function core ($modules = [], $themes = [], $suffix = null) {
* information about available languages, themes, current version of system
*/
$phar->addFile("$this->root/license.txt", 'license.txt');
$phar->addFile("$this->root/components/modules/System/meta.json", 'meta.json');
$phar->addFile("$this->root/modules/System/meta.json", 'meta.json');
$phar->setStub(
/** @lang PHP */
<<<STUB
@@ -166,8 +166,8 @@ function core ($modules = [], $themes = [], $suffix = null) {
*/
protected function get_core_files () {
$files_to_include = [
"$this->root/components/modules/System",
"$this->root/components/blocks/.gitkept",
"$this->root/modules/System",
"$this->root/blocks/.gitkept",
"$this->root/core",
"$this->root/custom",
"$this->root/includes",
@@ -285,7 +285,7 @@ function module ($module, $suffix = null) {
if ($module == 'System') {
return "Can't build module, System module is a part of core, it is not necessary to build it as separate module";
}
return $this->generic_package_creation("$this->root/components/modules/$module", $suffix);
return $this->generic_package_creation("$this->root/modules/$module", $suffix);
}
/**
* @param string $theme
@@ -27,7 +27,7 @@ function form () {
],
[
h::{'select[name=modules[]][size=20][multiple] option'}(
get_list_for_form(DIR.'/components/modules', 'System')
get_list_for_form(DIR.'/modules', 'System')
),
h::{'select[name=themes[]][size=20][multiple] option'}(
get_list_for_form(DIR.'/themes', 'CleverStyle')
@@ -47,7 +47,7 @@
$modules = array_values(
array_filter(
get_files_list(ROOT.'/components/modules', false, 'd'),
get_files_list(ROOT.'/modules', false, 'd'),
function ($module) {
return $module != 'System';
}
@@ -18,8 +18,8 @@
*/
defined('LANGUAGES') || define('LANGUAGES', DIR.'/core/languages');
defined('CUSTOM') || define('CUSTOM', DIR.'/custom');
defined('BLOCKS') || define('BLOCKS', DIR.'/components/blocks');
defined('MODULES') || define('MODULES', DIR.'/components/modules');
defined('BLOCKS') || define('BLOCKS', DIR.'/blocks');
defined('MODULES') || define('MODULES', DIR.'/modules');
defined('STORAGE') || define('STORAGE', DIR.'/storage');
defined('PUBLIC_STORAGE') || define('PUBLIC_STORAGE', STORAGE.'/public');
defined('CACHE') || define('CACHE', STORAGE.'/cache');
@@ -34,7 +34,7 @@ protected function init () {
/**
* Add event handler
*
* @param string $event For example `admin/System/components/modules/disable`
* @param string $event For example `admin/System/modules/disable`
* @param callable $callback Callable, that will be called at event dispatching
*
* @return Event
@@ -93,7 +93,7 @@ function once ($event, $callback) {
*
* After event name it is possible to specify as many arguments as needed
*
* @param string $event For example `admin/System/components/modules/disable`
* @param string $event For example `admin/System/modules/disable`
* @param mixed[] $arguments
*
* @return bool
@@ -42,9 +42,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \

# Get list of available modules and themes

cd components/modules && \
cd modules && \
MODULES=`ls -md */ | tr -d '\n /'` && \
cd ../../themes && \
cd ../themes && \
THEMES=`ls -md */ | tr -d '\n /'` && \
cd .. && \

@@ -59,9 +59,9 @@ server {
return 404;
}
# Exclude html imports (for Web Components) from next rule
location ~ ^/components/.*includes/html/.*\.html$ {}
location ~ ^/modules/.*includes/html/.*\.html$ {}
# Deny access to other *.json, *.html, *.txt files inside components directory
location ~ ^/components/.*\.(json|html|txt)$ {
location ~ ^/modules/.*\.(json|html|txt)$ {
return 404;
}
}
@@ -1,9 +1,7 @@
### Directories tree

* **blocks**
* **build** [dev] - build tools
* **components** - different types of components
* **blocks**
* **modules**
* **config** - low level system configuration (DB connection, caching engine, etc.)
* **core**
* **classes** - basic and supplementary classes
@@ -24,6 +22,7 @@
* **js**
* **install** [dev] - installation instruments
* **DB** - SQL schemas for every supported DB type
* **modules**
* **storage**
* **cache** - FileSystem cache
* **logs** - logs
@@ -8,10 +8,10 @@ There are some general rules how system core processes routes for different page
In generic form page URL looks like `admin|api|cli/Module_name/path/sub_path/more`, while all parts except `Module_name` are optional.

Working directory (`working_dir` hereinafter) for files and controller searching depends on prefix before module name:
* no prefix - `/components/modules/Module_name`
* `admin` prefix - `/components/modules/Module_name/admin`
* `api` prefix - `/components/modules/Module_name/api`
* `cli` prefix - `/components/modules/Module_name/cli`
* no prefix - `/modules/Module_name`
* `admin` prefix - `/modules/Module_name/admin`
* `api` prefix - `/modules/Module_name/api`
* `cli` prefix - `/modules/Module_name/cli`

`path` and `sub_path` are two levels of routing supported by system core, and they should be non-numeric (purely numeric elements are ignored here and next path element will be taken), everything else might be implemented by developer if needed.

@@ -11,4 +11,4 @@ First 4 positions are obvious, they mean displaying of block around main content

Block may be presented by php files or just HTML specified in administration area of web site. In case of php file - it will be included, output will be used as block content. Obviously, file may contain only HTML without any php code.

All php blocks are located in directory **components/blocks** with names **block.{block_name}.php**. Usually blocks are used to display some information of modules, for example last news.
All php blocks are located in directory **blocks** with names **block.{block_name}.php**. Usually blocks are used to display some information of modules, for example last news.
@@ -2,4 +2,4 @@ Modules are the most functional and complex components.

Modules are used for displaying of main content on web site pages (mostly). Also they may have own API, administation pages and languages translations.

All modules are located in directory **components/modules**.
All modules are located in directory **modules**.
@@ -26,7 +26,7 @@ CleverStyle Framework uses dependencies between components to load files in foll
* theme files from `/themes/{theme_name}/{css|js|html}`
* globally used files of components (files that are not listed in [map.json](/docs/quick-start/Module-architecture.md#includesmapjson) file and included on any page)
* files from all dependencies of current module (preserving order between dependencies themselves if any as well)
* module files from `/components/modules/{module_name}/{css|js|html}`
* module files from `/modules/{module_name}/includes/{css|js|html}`

#### Optimized frontend loading
In this mode system files, theme files and globally used files of components are loaded first and when they finish loading completely the rest of files are loaded afterwards.
@@ -12,6 +12,6 @@ require(['Experiment/some-module'], function (some_module) {
});
```

So in this case you don't need to specify full path to module like `components/modules/Experiment/includes/js/some-module`, but instead can use nice short syntax.
So in this case you don't need to specify full path to module like `modules/Experiment/includes/js/some-module`, but instead can use nice short syntax.

RequireJS mappings and Bower/NPM directories can be tweaked using [special event](/docs/backend-system-objects/$Page.md#systempagerequirejs).
@@ -74,9 +74,9 @@ server {
return 404;
}
# Exclude html imports (for Web Components) from next rule
location ~ ^/components/.*includes/html/.*\.html$ {}
location ~ ^/modules/.*includes/html/.*\.html$ {}
# Deny access to other *.json, *.html, *.txt files inside components directory
location ~ ^/components/.*\.(json|html|txt)$ {
location ~ ^/modules/.*\.(json|html|txt)$ {
return 404;
}
}
@@ -14,8 +14,8 @@ Also autoloader looks for classes inside
for some thirdparty components.

Classes in namespaces `cs\modules` are used by modules:
* `cs\modules\Blogs\Posts` > `components/modules/Blogs/Posts.php`
* `cs\modules\Comments\Comments` > `components/modules/Comments/Comments.php`
* `cs\modules\Blogs\Posts` > `modules/Blogs/Posts.php`
* `cs\modules\Comments\Comments` > `modules/Comments/Comments.php`

### Composer
User's `composer.json` can be in root directory.
@@ -118,7 +118,7 @@ use
\cs\modules\Blogs\Blogs,
\cs\modules\Test\Test;
```
Following this convention will allow to use built-in class autoloader, for instance, `\cs\modules\Module_name\Class_name` class intended to be in `components/modules/Module_name/Class_name.php`.
Following this convention will allow to use built-in class autoloader, for instance, `\cs\modules\Module_name\Class_name` class intended to be in `modules/Module_name/Class_name.php`.

##### JavaScript
System functions/variables are defined inside `window.cs`.
@@ -14,7 +14,7 @@ NOTE: all examples will be shown for backend `\cs\Event` class, but are the same

All events are named like paths in file system (sometimes it corresponds to the page, on which this event is called), this allows to determine easily for what purpose by what component of system this event is used:

* admin/System/components/modules/disable
* admin/System/modules/disable
* System/Page/rebuild_cache

Usually, system events are stated with `System/`, other modules similarly starts with module name. Events, that are used in admin section are prefixed by `admin`, for api with `api` and for CLI with `cli`.
@@ -41,7 +41,7 @@ Example:
```php
<?php
\cs\Event::instance()->on(
'admin/System/components/modules/disable',
'admin/System/modules/disable',
function ($data) {
if ($data['name'] == basename(__DIR__)) {
clean_pcache();
@@ -113,19 +113,19 @@ if (!\cs\Event::instance()->fire(
Backend events:
* System/robots.txt
* admin/System/general/optimization/clean_pcache
* admin/System/components/modules/default
* admin/System/components/modules/update/before
* admin/System/components/modules/update/after
* admin/System/components/modules/update_system/before
* admin/System/components/modules/update_system/after
* admin/System/components/modules/enable/before
* admin/System/components/modules/enable/after
* admin/System/components/modules/disable/before
* admin/System/components/modules/disable/after
* admin/System/components/modules/install/before
* admin/System/components/modules/install/after
* admin/System/components/modules/uninstall/before
* admin/System/components/modules/uninstall/after
* admin/System/modules/default
* admin/System/modules/update/before
* admin/System/modules/update/after
* admin/System/modules/update_system/before
* admin/System/modules/update_system/after
* admin/System/modules/enable/before
* admin/System/modules/enable/after
* admin/System/modules/disable/before
* admin/System/modules/disable/after
* admin/System/modules/install/before
* admin/System/modules/install/after
* admin/System/modules/uninstall/before
* admin/System/modules/uninstall/after
* admin/System/Menu
* System/App/render/before
* System/App/execute_router/before
@@ -159,24 +159,24 @@ Backend events:
* System/User/Group/del/after

Frontend events:
* admin/System/components/modules/default/before
* admin/System/components/modules/default/after
* admin/System/components/modules/disable/before
* admin/System/components/modules/disable/after
* admin/System/components/modules/enable/before
* admin/System/components/modules/enable/after
* admin/System/components/modules/update/before
* admin/System/components/modules/update/after
* admin/System/components/modules/uninstall/before
* admin/System/components/modules/uninstall/after
* admin/System/components/modules/install/before
* admin/System/components/modules/install/after
* admin/System/components/modules/update_system/before
* admin/System/components/modules/update_system/after
* admin/System/components/themes/current/before
* admin/System/components/themes/current/after
* admin/System/components/themes/update/before
* admin/System/components/themes/update/after
* admin/System/modules/default/before
* admin/System/modules/default/after
* admin/System/modules/disable/before
* admin/System/modules/disable/after
* admin/System/modules/enable/before
* admin/System/modules/enable/after
* admin/System/modules/update/before
* admin/System/modules/update/after
* admin/System/modules/uninstall/before
* admin/System/modules/uninstall/after
* admin/System/modules/install/before
* admin/System/modules/install/after
* admin/System/modules/update_system/before
* admin/System/modules/update_system/after
* admin/System/themes/current/before
* admin/System/themes/current/after
* admin/System/themes/update/before
* admin/System/themes/update/after
* cs-system-sign-in

For more details look corresponding classes and source files. It is easy to find any of these events by name.
@@ -1,4 +1,4 @@
Every described below element is optional, even empty directory in `components/modules` will be considered as module. You are free to use only features you need.
Every described below element is optional, even empty directory in `modules` will be considered as module. You are free to use only features you need.

### File system structure of module
* admin
@@ -92,7 +92,7 @@ Describes module routing for administration pages. May have:
For example, if module name is *System* (real example), then urls will look as following:
* System/admin/general/site_info
* System/admin/general/system
* System/admin/components/modules
* System/admin/modules

If some part of URL is not specified, the first element of corresponding level will be taken. Next urls will open the same page:
* System/admin
@@ -101,7 +101,7 @@ If some part of URL is not specified, the first element of corresponding level w

Similarly:
* System/components
* System/components/modules
* System/modules

Route may be accessed and read/changed through `$Request->route`. This property contains array of route parts without module name and `admin|api|cli` prefix.

@@ -1,6 +1,6 @@
Steps to create the simplest block:

1. Create block file in **components/blocks** with name **block.{block_name_here}.php**
1. Create block file in **blocks** with name **block.{block_name_here}.php**
2. Add some HTML content or PHP code with direct output through **echo**, **print()**, etc.
3. Go to Administration >> Components >> Blocks
4. Click **Add block**
@@ -1,6 +1,6 @@
Steps to create the simplest module:

1. Create module subdirectory in **components/modules**
1. Create module subdirectory in **modules**
2. Create index.html or index.php inside created directory with any content
3. Go to Administration >> Components >> Modules
4. Click **Update modules list**, created module will appear in modules list
@@ -158,7 +158,7 @@ function ($class) use ($file_index_map, $source) {
strlen($file = @$file_index_map[str_replace('//', '/', "core/thirdparty/$namespace/$class_name.php")]) || //Third party classes
strlen($file = @$file_index_map[str_replace('//', '/', "core/traits/$namespace/$class_name.php")]) || //Core traits
strlen($file = @$file_index_map[str_replace('//', '/', "core/engines/$namespace/$class_name.php")]) || //Core engines
strlen($file = @$file_index_map[str_replace('//', '/', "components/$namespace/$class_name.php")]) //Classes in modules
strlen($file = @$file_index_map[str_replace('//', '/', "$namespace/$class_name.php")]) //Classes in modules
) {
require_once "$source/fs/$file";
return true;
@@ -78,7 +78,7 @@ function () {
}
)
->on(
'admin/System/components/modules/install/after',
'admin/System/modules/install/after',
function ($data) {
if ($data['name'] != 'Blockchain_payment') {
return;
@@ -1,7 +1,7 @@
{
"package" : "Blockchain_payment",
"category" : "modules",
"version" : "0.41.0+build-66",
"version" : "0.42.0+build-67",
"description" : "Payment though blockchain.info in Bitcoin",
"author" : "Nazar Mokrynskyi",
"website" : "cleverstyle.org/Framework",
@@ -136,7 +136,7 @@ function () {
}
)
->on(
'admin/System/components/modules/uninstall/before',
'admin/System/modules/uninstall/before',
function ($data) {
if ($data['name'] != 'Blogs') {
return;
@@ -160,7 +160,7 @@ function ($data) {
}
)
->on(
'admin/System/components/modules/install/after',
'admin/System/modules/install/after',
function ($data) {
if ($data['name'] != 'Blogs') {
return;
Oops, something went wrong.

0 comments on commit c55245c

Please sign in to comment.