::main_controller()¶
- static Nos\Nos::main_controller¶
Returns: Instance of the main controller.
PK àèDU‰kºŒ˜ Œ˜ / novius-os-api-documentation-dubrovka/index.html
Welcome to Novius OS API documentation. It is hosted and generated by Read The Docs.
All contributions are welcome: Reporting or fixing errors or submitting improvements.
Sources are on Git Hub, we look forward to your Pull Request. Contact us if you need help with your contribution.
To change the contexts of your Novius OS instance, edit the local/config/contexts.config.php file.
After installation, Novius OS is configured with three contexts, one site in three languages:
<?php
return array(
'sites' => array(
'main' => array(
'title' => 'Main site',
'alias' => 'Main',
),
),
'locales' => array(
'fr_FR' => array(
'title' => 'Français',
'flag' => 'fr',
),
'en_GB' => array(
'title' => 'English',
'flag' => 'gb',
),
'ja_JP' => array(
'title' => '日本語',
'flag' => 'jp',
),
),
'contexts' => array(
'main::en_GB' => array(),
'main::fr_FR' => array(),
'main::ja_JP' => array(),
),
);
Here is an example configuration with five contexts across three sites and three languages:
<?php
return array(
'sites' => array(
'main' => array(
'title' => 'Main site',
'alias' => 'main',
),
'mobile' => array(
'title' => 'Mobile site',
'alias' => 'Mobile',
),
'event' => array(
'title' => 'Event site',
'alias' => 'Event',
),
),
'locales' => array(
'en_GB' => array(
'title' => 'English',
'flag' => 'gb',
),
'fr_FR' => array(
'title' => 'Français',
'flag' => 'fr',
),
'es_ES' => array(
'title' => 'Español',
'flag' => 'es',
),
),
'contexts' => array(
'main::en_GB' => array(),
'main::fr_FR' => array(),
'main::es_ES' => array(),
'mobile::fr_FR' => array(),
'event::en_GB' => array(),
),
);
Here is an example configuration for just one site in one language:
<?php
return array(
'sites' => array(
'main' => array(
'title' => 'Main site',
'alias' => 'main',
),
),
'locales' => array(
'en_GB' => array(
'title' => 'English',
'flag' => 'gb',
),
),
'contexts' => array(
'main::en_GB' => array(),
),
);
By default, the first context will answer to the root of your domain, the following contexts in a site_code/language_code/ subdirectory (e.g.: main/es_ES/).
But for each context, you can choose the URI (including a domain and optionally a directory) it will answer to, by specifying it the the associated configuration array.
<?php
'contexts' => array(
'main::en_GB' => array(), // Uses the default domain
'main::fr_FR' => array(
'http://www.mysite.com/fr/',
),
'main::es_ES' => array(
'http://www.mysite.com/es/',
),
'mobile::fr_FR' => array(
'http://www.mysite.com/mobile/',
),
'event::en_GB' => array(
'http://www.mysite.com/event/',
),
),
Warning
If your main context (the first) has a fr/example.html page and your main::fr_FR context has an example.html page, their URLs are identical (ie: http://www.mysite.com/fr/example.html). In this situation, only the page of your main context will be accessible.
<?php
'contexts' => array(
'main::en_GB' => array(
'http://www.monsite.com/',
),
'main::fr_FR' => array(
'http://www.mysite.fr/',
),
'main::es_ES' => array(
'http://www.monsite.es/',
),
'mobile::fr_FR' => array(
'http://mobile.monsite.fr/',
),
'event::en_GB' => array(
'http://event.monsite.com/',
),
),
Note
Of course, your domains should also be properly configured in Apache.
<?php
'contexts' => array(
'main::en_GB' => array(
'http://www.monsite.com/',
),
'main::fr_FR' => array(
'http://www.mysite.fr/',
),
'main::es_ES' => array(
'http://www.monsite.es/',
),
'mobile::fr_FR' => array(
'http://mobile.monsite.fr/',
'http://www.monsite-mobile.fr/',
'http://www.mysite.com/mobile/',
),
'event::en_GB' => array(
'http://event.monsite.en/',
),
),
You will probably need to define, for each of your contexts, different URLs between your local (development) and production instances. You can do that using environment-specific config files.
A sample configuration file is available in local/config/config.php.sample. Just rename (or copy) it to local/config/config.php, and update it to your case.
Boolean for use of cache on front. By default is true, except in DEVELOPMENT environment.
New in version 0.2.0.2.
Int, number of seconds of cache validity. By default is 60.
Boolean for use of cache on Nos\Orm\Model properties. By default is false. If is true, all models properties will be cached with a auto-refresh mechanism : if you add a column on a model which has properties defined, the cache will be refreshed by a DB list_columns request when you access this column with get() or set().
New in version Chiba: 1.0.1
Array :
Parameters: |
|
---|
Boolean for use of assets minified in back-office. By default is true, except in DEVELOPMENT environment.
Path of a temp directory. Set to local/data/temp by default.
The DB configuration was initially created by the installation wizard. But you can (and you must to go live) update it after installation.
The DB configuration is in local/config/db.php.
See also
FuelPHP Database documentation for details.
By default, your Novius OS is not configured to send mail, because it’s too dependent on the server.
A sample configuration file is available in local/config/email.config.php.sample. Just rename (or copy) it to local/config/email.config.php, and update it to your case.
See also
FuelPHP email package documentation for details.
You can modify default configuration of WYSIWYGs in your Novius OS. You can also have multiple configurations, especially configurations for contexts.
A sample configuration file is available in local/config/wysiwyg.config.php.sample. Just rename (or copy) it to local/config/wysiwyg.config.php, and update it to your case.
To set a configuration for a context, set a key with the context id in the array setups:
<?php
return array(
'default' => array(
),
'active_setup' => 'default',
'setups' => array(
'default' => array(),
'main::en_GB' => array(
//... Set here your specific configuration for context main::en_GB
),
//'main::fr_FR' => array(),
//'main::ja_JP' => array(),
),
);
See also
TinyMCE documentation for details.
All segments of URLs builded in Novius OS are cleaned by the friendly slug mechanism.
A sample configuration file is available in local/config/friendly_slug.config.php.sample. Just rename (or copy) it to local/config/friendly_slug.config.php, and update it to your case.
active_setup: | The active setup key. This key must be present in setups. Execute in all case. Default value: default. |
---|---|
setups: | Array of different setups. |
In setups, key can be a context ID. In this case, this setup is excute for slugs in this context.
Four setups of rules are defined:
A setup value is an array. This array can contains :
Sample:
<?php
return array(
'setups' => array(
'my_default' => array(
// Use the 'no_accent' setup
'no_accent',
// Replace space by '_'
' ' => '_',
// All characters that are not a word character, a '-' or a '_' or a '*' are replaced by '-'.
'[^\w\*\-_]' => array('replacement' => '-', 'flags' => 'i'),
),
),
);
Application configuration is mostly done in PHP, but a lot of code also runs in the browser, and is powered by JavaScript.
Some PHP configuration patterns have been created to define JavaScript behaviours from a PHP configuration file.
$container.nosAction() executes an action bound to a DOM element.
To define an action in PHP:
<?php
'action' => array(
'action' => 'actionName', // nosTabs, nosDialog, confirmationDialog, nosAjax, window.open, document.location...
// Other keys are array and depends on the actionName
),
// Example with nostabs
'action' => array(
'action' => 'nosTabs',
'tab' => array(
'url' => 'admin/nos/page/page/insert_update/{{id}}',
'label' => '{{title}}',
),
),
This syntax is used to define actions for:
Used to format the value displayed in a column of a grid in the Appdesk.
type: | The cellFormatter type. Can one of bold, css, icon, iconClasses or link. |
---|---|
replace: | If true, cellFormatter empties the current content. |
ignore: | Column name to check if we should ignore this cellFormatter for the current item. If '1' (the string containing the digit 1), the cellFormatter will be ignored for this item. |
Formats the text in bold. No additional key.
Apply CSS styles to the content.
css: | An associative array of all CSS styles to apply. |
---|
<?php
array(
'type' => 'css',
'css' => array(
'text-align' => 'center',
),
),
Prepends an icon to the text, using an URL.
column: | Use a data_mapping column to fetch the icon URL. |
---|---|
src: | The icon URL. |
mapping: | A mapping array to fetch URL depending on the value of the column. |
size: | Force a size in pixels for the icon. Used for both width and height. |
<?php
array(
'type' => 'icon',
'column' => 'column_icon', // URL is retrieved from the 'column_icon' column
'size' => 16
),
// Or
array(
'type' => 'icon',
'src' => 'static/path/icon.png',
),
// Or
array(
'type' => 'icon',
'mapping' => array(
'1' => 'static/path/icon-1.png', // If column value is '1', use this URL
'2' => 'static/path/icon-2.png',
),
),
Prepends an icon to the text, using CSS classes.
column: | Use a data_mapping column to fetch the icon CSS classes. |
---|---|
classes: | The icon CSS classes. |
<?php
array(
'type' => 'iconClasses',
'column' => 'column_icon_classes', // CSS classes are fetch from the 'column_icon_classes' column
),
// Or
array(
'type' => 'iconClasses',
'classes' => 'icon icon-foo',
),
Wraps a link to the text (which performs an action upon click).
action: | Action to perform when the link is clicked. Can be default to use the default action of the item, an action name of the item or a nosAction. |
---|
<?php
array(
'type' => 'link',
'action' => 'default', // Binds the default action (e.g.: 'edit the item' in the most of the cases)
),
// Or
array(
'type' => 'link',
'action' => 'Namespace\Model_Example.result', // Binds the 'result' action of the item, which is a Namespace\Model_Example instance.
),
// Or
array(
'type' => 'link',
'action' => array(
'action' => 'nosTabs', // Open a new tab
'tab' => array(
'url' => 'admin/nos/page/page/insert_update/{{_id}}', // {{_id}} will be replaced by the item's ID
'label' => '{{_title}}', // {{_title}} will be replaced by the item's title
),
),
),
It is possible to create custom cellFormatters. You just have to indicate your javascript url in the type key.
Here is a cellFormatter sample allowing you to change the font size of a column.
define(function(require, exports) {
exports.format = function(formatter, args) {
args.$container.css({
'font-size': 20
});
}
});
<?php
'data_mapping' => array(
'column_a' => array(
'title' => 'Column a'
'cellFormatters' => array(
'bold' => array(
'type' => 'bold',
),
'center' => array(
'type' => 'css',
'css' => array(
'text-align' => 'center',
),
),
),
),
'column_b' => array(
'title' => 'Column b'
'cellFormatters' => array(
'icon' => array(
'type' => 'icon',
'column' => 'column_icon',
'size' => 16
),
),
),
'column_icon' => array(
value => function($item) {
return $item->icon();
},
),
),
The metadata.config.php file is how an application is defined. It tells what contains the application and what it does.
The most important keys are:
name: | The name of the application. |
---|---|
namespace: | In which PHP namespace all the classes of the application must be defined. |
icons: | In the 3 standard sizes 16*16, 32*32 and 64*64. |
requires: | Optional. Which applications does your application requires. Array or string (in the last case, considered as an array with a unique element). |
extends: | Optional. Application can extend other applications. Extend mechanism can extended config file, lang file and views. |
<?php
return array(
'name' => 'Webpages',
'namespace' => 'Nos\Page',
'version' => '0.2',
'provider' => array(
'name' => 'Novius OS',
),
'extends' => array(
// Optional,
),
'requires' => array(
// Optional
),
'icons' => array(
64 => 'static/apps/noviusos_page/img/64/page.png',
32 => 'static/apps/noviusos_page/img/32/page.png',
16 => 'static/apps/noviusos_page/img/16/page.png',
),
'permission' => array(
// Empty array for now. Leave it.
),
'i18n_file' => 'noviusos_page::metadata',
'launchers' => array(
// Optional
),
'enhancers' => array(
// Optional
),
'templates' => array(
// Optional
),
'data_catchers' => array(
// Optional
),
);
An application provides:
An application can extend multiple others applications.
An application that extends an other application will be loaded when the extended application is loaded.
Configuration and language files of an extended application can be extended by an application that extends. Views can be replaced.
To proceed, put extended files in subdirectory apps/application_extended.
local/applications/app_a/
- config/apps/app_b/common.config.php
- lang/apps/app_b/common.lang.php
- views/apps/app_b/common.view.php
A launcher is an icon on the home tab.
A launcher is defined by an associative array. Key is launcher ID, launcher properties is an associative array:
name: | Text to display for the icon. |
---|---|
icon: | Optional. URL to a 64*64 image, default will use the 64*64 icon of the app. |
action: | What is done when clicking on the launcher. See PHP nosActions. |
<?php
return array(
'launchers' => array(
'noviusos_page' => array(
'name' => 'Webpages',
// 'icon' is not set, so the default icon will be used
'action' => array(
// open a tab
'action' => 'nosTabs',
'tab' => array(
'url' => 'admin/noviusos_page/appdesk/index',
// 'iconUrl' is not set, so the default icon will be used
),
),
),
),
);
Enhancers are used in WYSIWYG editors. They provide functionalities for the front-office.
For example, the ‘Forms’ application allows users to insert forms in their web pages (using an enhancer).
URL enhancers, a specific type of enhancers, handle their own URLs. For example, every blog post has an URL.
An enhancer is defined with:
title: | Title of the enhancer displayed when opening the ‘Application’ menu from the wysiwyg. |
---|---|
desc: | Optional. Description of the enhancer. |
iconUrl: | Optional. URL to a 16*16 icon, displayed when opening the ‘Application’ menu from the wysiwyg, default will use the 16*16 icon of the app ; |
enhancer: | URL of the front-office controller used to render the enhancer. |
urlEnhancer: | Same that enhancer.Only one of the two keys can is used, depending if you want an URL enhancer or just a plain regular enhancer. |
previewUrl: | Optional. URL of the controller used to render the preview in the wysiwyg. |
dialog: | Optional. If you want a configuration popup, URL of the controller used to display and save the enhancer configuration. See $container.nosDialog() for the list of parameters. |
valid_container: | |
Optional. A callback function to check
if the enhancer is available for a specific container.
If the function returns false, the enhancer won’t be available.
The function takes two parameters: the enhancer’s configuration and the container instance.
|
<?php
return array(
'noviusos_form' => array(
'title' => 'Form',
'desc' => '',
// Here it's just a regular enhancer
'enhancer' => 'noviusos_form/front/main',
//'urlEnhancer' => 'noviusos_form/front/main',
'iconUrl' => 'static/apps/noviusos_form/img/icons/form-16.png',
// We'll use our controller to generate the preview
'previewUrl' => 'admin/noviusos_form/enhancer/preview',
// And the user has to configure it
'dialog' => array(
'contentUrl' => 'admin/noviusos_form/enhancer/popup',
'width' => 450,
'height' => 400,
'ajax' => true,
),
// The callback function which check availability of the enhancer
'valid_container' => 'validContainer',
),
);
// In this example, the enhancer won't be available in WYSIWYGs of monkeys.
function validContainer($enhencer, $container)
{
$container_class = get_class($container);
return $container_class !== 'Nos\Monkey\Model_Monkey';
}
Templates are similar to other CMS’ templates or themes. They provide a layout for the front-office.
In Novius OS, a template contains one or more WYSIWYG editable area(s), which are is placed inside a grid.
The grid has a size of cols * rows, and each editable area is positioned using absolute coordinates (it’s similar to position: absolute in CSS).
Each WYSIWYG editable area has:
In the end, a template is defined with:
file: | path to the template file (it’s a view) |
---|---|
title: | title of the template, it’s shown when selecting a template for a page |
cols: | grid width (in units) |
rows: | grid height (in units) |
layout: | list of the WYSIWYG editors inside the grid :
|
Here’s an example:
<?php
return array(
'templates' => array(
'top_menu' => array(
'file' => 'noviusos_templates_basic::top_menu',
'title' => 'Default template with a top menu',
'cols' => 1,
'rows' => 1,
'layout' => array(
// There is one WYSIWYG named 'content'
// Position inside the grid: <left>,<top>,<width>,<height>
'content' => '0,0,1,1',
),
),
),
);
Configuration for Nos\Orm\Model, used in Appdesk, Crud Controller or Inspectors.
Associative array:
data_mapping: | columns on Appdesk and Inspectors. |
---|---|
i18n: | Optional, common translation |
actions: | Optional, common actions on the Nos\Orm\Model. |
icons: | Optional, common icons related to the Nos\Orm\Model. |
Associative array where each key => value defines a column, all keys are optionals.
title: | Title of the grid column. If not set, column will not be displayed. |
---|---|
column: | Default value is same as key. |
search_column: | Default value is column key value. Defines on which SQL column search / order. |
search_relation: | |
Default value is deduced from key (ex: rel->col). Relation to load (via related function on query). | |
sorting_callback: | |
A closure function taking two parameters: the $query object and the $sortDirection. | |
multiContextHide: | |
Hide grid column when items are filtered on more than one contexts. | |
isSafeHtml: | If true, the content won’t be escaped when displayed (inside the grid). |
value: | A closure function taking current item Nos\Orm\Model in first parameter. Overloads value displayed in the grid. |
cellFormatters: | Associative array of cellFormatters for formatting column display. |
<?php
return array(
'data_mapping' => array(
'column_a' => array(
'title' => 'Column A',
'column' => 'col_a',
'multiContextHide' => true,
'cellFormatters' => array(
'center' => array(
'type' => 'css',
'css' => array('text-align' => 'center'),
),
),
),
'column_b' => array(
'title' => 'B',
'search_column' => 'col_b_search',
'search_relation' => 'rel',
'value' => function($item) {
return 'test';
},
),
// ...
),
);
In the following example, column_a is sent in json but is not displayed in the grid.
<?php
return array(
'data_mapping' => array(
'column_a',
),
);
In the following example, col_b is sent in json under the column_b key but is not displayed in the grid.
<?php
return array(
'data_mapping' => array(
'column_b' => 'col_b',
),
);
If the Model has the Orm_Behaviour_Twinnable behaviour, a pseudo column context is automatically added at the end of the data_mapping. But, if you want to place it elsewhere, you can force its position like this:
<?php
return array(
'data_mapping' => array(
'column_a' => array(
'title' => 'Column a'
),
'context',
'column_b' => array(
'title' => 'Column b'
),
),
// ...
);
This key contains all the common translations.
<?php
return array(
'i18n' => array(
// Crud
'notification item added' => __('Done! The item has been added.'),
'notification item saved' => __('OK, all changes are saved.'),
'notification item deleted' => __('The item has been deleted.'),
// General errors
'notification item does not exist anymore' => __('This item doesn’t exist any more. It has been deleted.'),
'notification item not found' => __('We cannot find this item.'),
// ... see the 'framework/config/i18n_common.config.php' file to include the appropriate keys depending on your item
),
);
This key contains all the common actions related to the model. 5 actions are automatically added:
add: | The Add model button located on the appdesk’s toolbar |
---|---|
edit: | The Edit button located on the grids and the crud’s toolbar |
delete: | The Delete button located on the grids and the crud’s toolbar |
visualise: | The Visualise button located on the grids and crud’s toolbar, if the item can be displayed in front-office. |
share: | The Share button located on the crud’s toolbar, if the item has the Nos\Orm_Behaviour_Sharable behaviour. |
The action key can be filled in two different ways.
The most common way is to use an associative array:
<?php
return array(
// ...
'actions' => array(
'action_1' => array(/* configuration */),
'action_2' => array(/* configuration */),
// ...
),
);
If you want to change the order in which the actions are displayed, two keys are to be defined:
list: | associative array of actions (similar to the previous actions key) |
---|---|
order: | array of action’s key defining their order |
<?php
return array(
// ...
'actions' => array(
'list' => array(
'action_1' => array(/* configuration */),
'action_2' => array(/* configuration */),
// ...
),
'order' => array(
'action_2',
'action_1'
),
),
);
Each action is an associative array. Key is the action ID, and value is an array defining the action configuration:
action: | which action is executed when clicking on the button (using nosAction). |
||||||||
---|---|---|---|---|---|---|---|---|---|
label: | Text associated with the action (either shown as text or in a tooltip). |
||||||||
primary: | Is it a primary action? Primary actions have a dedicated button, and secondary actions appears in the action drop down. |
||||||||
icon: | Icon of the action. It’s a jquery ui icon class, but without the leading ui-icon- string. |
||||||||
red: | Is it a red action? (especially used for ‘Delete’) |
||||||||
align: | Alignment of the button. Can be a string (begin or end) or a number (begin is equivalent to -10 and end is equivalent to 10). Defines actions default order (align in ascending order). |
||||||||
targets: | Where is the action displayed? This has no effect if the action is not visible (see below). There are 3 locations available:
|
||||||||
disabled: | Callback function or array of callback functions (the one taken into account is the first which doesn’t return false) that returns a boolean or a string defining if the action is disabled or not for an item (a string disable the action and the value is used as title). There is two sent parameters: the current $item, and $params containing the common configuration. |
||||||||
visible: | Callback function or array of callback functions (the one taken into account is the first which doesn’t return true) that returns a boolean defining if the action is visible or not on a context. There is only one parameter sent, an associative array:
|
<?php
return array(
'actions '=> array(
'action_id' => array(
'action' => array(
'action' => 'confirmationDialog',
'dialog' => array(
'contentUrl' => '{{controller_base_url}}delete/{{_id}}',
'title' => 'Delete',
),
),
'label' => __('Delete'),
'primary' => true,
'icon' => 'trash',
'red' => true,
'targets' => array(
'grid' => true,
'toolbar-edit' => true,
),
'disabled' => function($item) {
return false;
},
'visible' => function($params) {
return !isset($params['item']) || !$params['item']->is_new();
},
),
),
);
Default actions (such as add or edit) can be overloaded with this actions key. Arr::merge is used to merge defined actions with default actions.
To hide an action, set its value to false:
<?php
return array(
// ...
'actions '=> array(
'add' => false,
),
);
Placeholders are available in order to simplify action targets and labels. First, some placeholders are always available:
Additionally, all dataset keys can be used as placeholders.
This key contains all common icons related to the model. Structure is similar to the icons key of the Metadata configuration file :
<?php
return array(
'icons' => array(
64 => 'static/apps/noviusos_page/img/64/page.png',
32 => 'static/apps/noviusos_page/img/32/page.png',
16 => 'static/apps/noviusos_page/img/16/page.png',
),
);
Configuration for Nos\Orm\Model‘s appdesk.
Associative array:
model: | Model name. |
---|---|
css: | Optional. List of css file to load in order to add specific styles. |
notify: | Optional. Allows you to notify the user when displaying the appdesk. |
query: | Optional. Additional informations about the query. |
search_text: | Optional. Array of columns in which we search when the user fills appdesk’s search bar. |
data_mapping: | Optional. Defines which data_mapping items are displayed. |
inspectors: | Optional. |
views: | Optional. |
selectedView: | Optional. Default selected view identifier. |
inputs: | Optional. How to process additional parameters sent to the appdesk. |
i18n: | Optional. Extends default text items. |
thumbnails: | Optional, boolean. Can the appdesk display items as thumbnails ? |
tree: | Optional (automatically filled when model has the Tree behaviour enabled). |
appdesk: | Optional. Additional display information about the appdesk. |
Allows you to notify the user when displaying the appdesk.
message: | Message you want to display. |
---|---|
type: | Type of notification. |
Associative array. All keys are optional. Most keys are similar than the find function second parameters.
model: | Model on which query is executed. |
---|---|
limit: | |
order: | |
related: | |
callback: | Array of callback functions allowing you to customize the query (first parameter is the current query, must return the modified query). |
Associative or simple array. Defines which data_mapping items from Common configuration we display (mostly filtering).
Is is also possible to define new custom data_mapping items which will be only used on the appdesk.
If only value is defined, appdesk will display the data_mapping item from common configuration.
If it is a key => value association (value must then be an array), then the data_mapping item from common configuration is extended by the value.
<?php
return array(
// ...
'data_mapping '=> array(
'col1', // will display the col1 data_mapping item from common configuration.
'col2' => array( // if col2 exists on common configuration data_mapping key then it is extended ; otherwise, the item is added to appdesk.
// ...
),
),
);
Associative or simple array. Defines which inspectors are used on appdesk.
If is also possible to define new custom inspectors which will be only used on the appdesk.
If only value is defined: * appdesk will display the inspector located at inspector/inspector_name if the value is inspector_name. * it also supports inspector class names (MyAppController_Admin_Inspector_Name).
If it is a key => value association (value must then be an array), then the inspector configuration is extended by the value.
<?php
return array(
// ...
'inspectors '=> array(
'inspector1', // will display the inspector located at inspector/inspector1.
'\My\App\Controller_Admin_Inspector_Name', // will display the inspector which class is \My\App\Controller_Admin_Inspector_Name
'inspector2' => array( // if inspector/inspector2 exists, then it is extended ; otherwise it creates a new inspector
// ...
),
),
);
Associative array defining different way of displaying the appdesk. The key is the view identifier. Value is view configuration:
name: | Optionnal. Display view name in view selector |
---|---|
virtual: | Optionnal. Is the view present on the view selector ? |
json: | Array of javascript files to load. These javascript extends appdesk configuration. |
How to process additional parameters sent to the appdesk. Associative array, to define a callback for each parameter.
<?php
return array(
// ...
'inputs' => array(
'monk_species_id' => function($value, $query) {
// ...
return $query;
},
),
);
Can the appdesk display items as thumbnails ?
If defined to true, data_mapping has to define two keys:
thumbnail: | url of item thumbnail. |
---|---|
thumbnailAlternate: | |
Default thumbnail when there is no thumbnails or thumbnail can’t be found. |
Defines how the model tree is constructed on the appdesk. It is automatically filled when model has the Tree behaviour. Associative array:
models: | Models to be loaded on the tree. Array of associative array:
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
roots: |
|
Associative array describing how appdesk interacts and is displayed. All items are automatically generated, but can be overloaded.
appdesk: | Defines how appdesk is displayed. Associative array:
|
||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tab: | Tab information (see nosTabs). |
||||||||||||||||||||||
reloadEvent: | Event name that will reload appdesk. |
||||||||||||||||||||||
actions: | Associative array containing main grid actions information. See Actions. |
Configuration for an inspector. Associative array depending on inspector type.
The only common keys are input, which describes how the inspector will affect the main grid, and appdesk, which defines how it is displayed.
Associative array:
key: | Key name on which the main grid will be filtered. By default, if query key is not defined, must be the column name on which you want to filter the model. |
---|---|
query: | Optional. Callback function defining how to interact with the main grid query. The function gets two parameters ; the first is the value sent by the inspectors (when items are selected), and the second is the current query. The function must return the transformed query. |
Associative array. All keys are optional:
label: | Main label of the inspector. |
---|---|
contextChange: | Does the inspector reloads when user selects an other context. |
reloadEvent: | Event name that will reload the inspector? |
vertical: | Is the appdesk vertical or horizontal ? |
inputName: | Key on which selected values are sent. |
multiContextHide: | |
Hide inspector when appdesk filtered on more than one contexts. |
Associative array:
model: | Model class name |
---|---|
query: | Optional. Additional informations about the query. See query in appdesk configuration. |
data_mapping: | Optional. Defines which data_mapping items are displayed. See data_mapping in appdesk configuration. |
appdesk: | Optional. Additional display information about the appdesk. |
Associative array:
grid: | Optional. Grids informations. Associative array:
|
---|
Associative array:
model: | Model class name |
---|---|
data_mapping: | Optional. Defines which data_mapping items are displayed. See data_mapping in appdesk configuration. |
appdesk: | Optional. Additional display information about the appdesk. |
models: | Optional. See appdesk tree configuration. |
roots: | Optional. See appdesk tree configuration. |
root_node: | Optional. Add a global root node. Associative array containing dataset values (columns to be displayed). |
Associative array:
treeGrid: | Optional. Grids informations. Associative array:
|
---|
Associative array:
input_begin: | Name of the input for the begin date. Default value: date_begin. |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
input_end: | Name of the input for the end date. Default value: date_end. |
||||||||||
labels: |
|
||||||||||
options: | Array of options displayed by inspector. Default value: array('custom', 'since', 'month', 'year').
|
||||||||||
since: |
|
||||||||||
month: |
|
||||||||||
year: |
|
Displays static data. Associative array:
data: | Array of items. Each item is an associative array:
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
input: |
|
||||||||||||
appdesk: |
|
The CRUD controller is in charge of generating the forms (add, edit & delete) related to an item / model and handling automatically the multilingual / translation problematic.
controller_url: | Url of the CRUD controller. |
---|---|
css: | Optional. List of css file to load in order to add specific styles. |
model: | Which model it generates the form for. |
environment_relation: | |
Relation name. Allows to define a children / parent relationship. | |
tab: | Tab informations (such as the icon & label), see nosTabs |
views: | Optional. Views locations. |
layout: | How the form looks like and where fields are displayed inside it. Optional if layout_insert and layout_update are defined. |
layout_insert: | Optional. Specific layout for insert. Will use layout as default value. |
layout_update: | Optional. Specific layour for update. Will use layout as default value. |
fields: | All fields displayed in the form. |
<?php
return array(
'controller_url' => '',
'environment_relation' => null,
'model' => '',
'tab' => array(
'iconUrl' => '',
'labels' => array(
'update' => null,
'insert' => 'New item',
'blankSlate' => 'Translate an item',
),
),
'layout' => array(),
'fields' => array(),
'require_js' => array(),
'views' => array(
'form' => 'nos::crud/form',
'delete' => 'nos::crud/delete_popup',
),
);
The environment_relation must contain a relation name of type Orm\\BelongsTo.
It allows to use the GET['environment_id'] in an action of this model.
It will be used to populate the column associated with the relation. Examples include:
Some examples:
<?php
// Add a sub-page action
'action' => array(
'action' => 'nosTabs',
'tab' => array(
// The 'page_parent_id' will be populated with $_GET['environment_id'] from the action
'url' => '{{controller_base_url}}insert_update?environment_id={{_id}}&context={{_context}}',
),
),
// Add a media in this folder action
'action' => array(
'action' => 'nosTabs',
'tab' => array(
// The 'media_folder_id' will be populated with $_GET['environment_id'] from the action
'url' => '{{controller_base_url}}insert_update?environment_id={{id}}',
),
),
See also
The tab configuration array has a special labels key, to handle several label depending on the case.
insert: | Adding an new item |
---|---|
blankSlate: | Translating an existing item |
update: | Editing an existing item |
<?php
return array(
'tab' => array(
'iconUrl' => 'static/apps/noviusos_monkey/img/16/monkey.png',
// Add form will user 'insert'
// Edit form will use item's title
// Translate form (multilingual) will use 'blankSlate'
'labels' => array(
'insert' => __('Add a monkey'),
'blankSlate' => __('Translate a monkey'),
),
),
);
form: | View for the form (both insert and update). Default is nos::crud/form. |
---|---|
delete: | View for the delete popup. Default is nos::crud/delete_popup. |
insert: | Optional. View for the insert form (will use form value as default) |
update: | Optional. View for the update form (will use form value as default) |
The layout is a data passed to the parameters of the view. It list all the views needed to render the form.
There are two syntaxes:
The full syntax for using a layout is the following:
<?php
'layout' => array(
'first_view' => array(
'view' => 'nos::form/layout_standard',
'params' => array(
// View data (depends on the view).
'title' => '',
'content' => '',
),
),
'second_view' => array(
'view' => 'noviusos_page::admin/page_form',
// No 'params'
),
// More views can be used here.
),
In addition to view-specific params / data, Novius OS always include the following vars:
Because 90% of the time, we want to use nos::form/layout_standard as the view for the layout, a simplified syntax was created: only write the view params of the standard layout.
It’s much more limitating because you can only use one view to render the layout, and it has to be nos::form/layout_standard. But that’s what should be used 90% of the time.
<?php
'layout' => array(
// View data
'title' => '',
'content' => '',
),
We only need to define the view data for the standard layout, and it will be wrapped like so:
<?php
$layout = array(
array(
'view' => 'nos::form/layout_standard',
'params' => $layout,
),
);
<?php
// The following...
return array(
'layout' => array(
'view_1' => array(
'view' => 'nos::form/layout_standard',
'params' => array(
// View data (depends on the view).
),
),
),
);
// ... is the same as this:
return array(
'layout' => array(
// View params for ``nos::form/layout_standard``.
),
);
Used as container for other layouts / views
- Standard layout: used as a container for other views ;
- Expander: used inside layout_standard.content in the Pages application ;
Used as final views:
See also
Contains the fields definition array.
The fields syntax is based on an existing FuelPHP feature, which is used to configure form attributes for each column of a Model :
In addition to standard form fields, Novius OS has renderers, which are a bit more advanced. For instance, they allow to select a media, a page, a date...
The field name is determined using the key. Then, for each field:
label: | Text for the label. Won’t be shown for hidden fields |
---|---|
form: | array Attributes of the <input> tag |
renderer: | Class name of a renderer |
renderer_options: | |
(optional) array Options for the renderer | |
validation: | (optional) array rules used to validate the field. |
expert: | (optional) boolean Should the field be visible only to expert users? Default false. |
show_when: | (optional) callable Custom callback function to alter the visibility of the field. Must return true for the field to be shown. |
populate: | (optional) callable Custom callback function to set value(s) of the field. Takes the item as param. |
before_save: | (optional) callable Custom callback function to perform changes on the field before saving it. Takes the item and validated POST content as params. |
To choose how the field is displayed, you only need to specify either form (a native HTML <input>) or a renderer (like a date picker or a wysiwyg), you don’t need both. If both keys are filled, the renderer will be used to display the field (and the form key will be ignored).
Configuration example:
<?php
return array(
'name' => array(
'label' => 'Text shown next to the field',
'form' => array(
'type' => 'text',
'value' => 'Default value',
),
'validation' => array(),
);
Advanced configuration example:
<?php
$options = array(
$value => $label
...
);
return array(
'name' => array(
'label' => 'Text shown next to the field',
'form' => array(
'type' => 'select',
'options' => $options,
),
'populate' => function($item) {
//example: returns the id of a related model
return $item->relation->rel_id;
},
'before_save' => function($item, $data) {
//example: set relation properly
unset($item->relation);
if (!empty($data['name']) {
$item->relation = Model::find($data['name']);
}
}
);
Bold text is the value for the type property.
<?php
return array(
'gender' => array(
'label' => 'Gender',
'form' => array(
'type' => 'select',
'options' => array(
'm' => 'Male',
'f' => 'Female',
)
),
'validation' => array('required'),
),
);
The tag property can be used to force a precise HTML tag, it’s useful for a submit button.
FuelPHP will automatically use the value as the button’s text.
<?php
return array(
'save' => array(
'form' => array(
'type' => 'submit',
'tag' => 'button',
'value' => 'Save',
),
),
);
New in version Chiba2.1.
The save key no longer required in CRUD fields configuration.
The renderer list is available in a dedicated page.
This configuration file is used to define the permissions used in your application.
It has the same syntax as the full version of the crud layout.
i.e. You need to configure one or several (view + params) pair(s), like so:
<?php
return array(
'all' => array(
'view' => 'nos::form/accordion',
'params' => array(
'accordions' => array(
'standalone' => array(
'title' => __('Permissions for this application'),
'view' => 'nos::admin/permissions/standalone',
'params' => array(
'list' => array(
'noviusos_app::create' => array(
'label' => __('Can create new items'),
'checked' => true,
),
'noviusos_app::delete_locked' => array(
'label' => __('Can delete locked item'),
),
),
),
),
),
),
),
);
In addition to view-specific params / data, Novius OS always include the following vars:
We (kindly) provide a native view to cover basic usage: Permissions standalone.
All native constants of FuelPHP are available but links to specific Novius OS directories.
See also
Path where Novius OS is installed.
Contains the name of the public directory. Initialized to public if not set.
New in version 4.2.
Path of Novius OS core: NOSROOT/novius-os/framework/.
Overload of the native FuelPHP’s constant. Path to the application directory: NOSROOT/local/.
Overload of the native FuelPHP’s constant. Path to the FuelPHP core directory: NOSROOT/novius-os/fuel-core/.
Overload of the native FuelPHP’s constant. Path to the location where the startup script is: NOSROOT/public/.
Overload of the native FuelPHP’s constant. Path to the packages directory: NOSROOT/novius-os/packages/.
Retrieves a translation from the last loaded dictionary.
Parameters: |
|
---|---|
Returns: | The translation or null if not founded |
The plural version of __. Some languages have more than one form for plural messages dependent on the count.
Parameters: |
|
---|---|
Returns: | The translation or, if not founded, $singular is returned if n == 1, otherwise $plural
If third parameter is ommited and translation founded, return an array of singular and plural forms
|
Retrieves a translation from a specific dictionary.
Parameters: |
|
---|---|
Returns: | The translation or null if not founded |
Extends Model of FuelPHP ORM.
Novius OS Model have some differences compare with FuelPHP Model :
- Novius OS implements a cache mechanism for properties when they are fetched from the database. By default, cache files are save in NOSPATH/local/cache/fuelphp/list_columns.
- In property definition, put convert_empty_to_null key to true if you want that this property stores a null value when it receives empty string.
Defines the attachments of a model. Attachment is a special type of relations created for Novius OS. See Nos\Attachment.
Array of WYSIWYG keys which are shared by context twins. See WYSIWYG accessor.
Array of media keys which are shared by context twins. See Media accessor.
In Novius OS, you can configure model by a file configuration. For sample: if in your application you define a Model_Monkey class, you can create a file config/model/monkey.config.php to extend configuration. All this attributes can be defined in configuration file : properties, table_name, title_property, observers, behaviours, shared_wysiwygs_context, shared_medias_context and all relations types (has_many, belongs_to, has_one, many_many, twinnable_has_many, twinnable_belongs_to, twinnable_has_one, twinnable_many_many and attachment).
Example in the class definition:
<?php
class Model_Example extends \Nos\Orm\Model
{
// In this example, attachments use defaults properties
protected static $_attachment = array(
'avatar' => array(),
'cv' => array(),
);
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Contextable' => array(
'events' => array('before_insert'),
'context_property' => 'ex_context',
),
);
// In this example, use a column name for defined title_property
protected static $_title_property = 'ex_reference';
Example in configuration file:
<?php
return array(
'attachment' => array(
'avatar' => array(
'dir' => 'namespace/model_name/avatar/',
'image' => true,
'alias' => 'avatar',
),
'curriculum_vitae' => array(
'dir' => 'namespace/model_name/curriculum_vitae/',
'alias' => 'cv',
'extensions' => array('doc', 'odt', 'pdf'),
'check' => array('ClassName', 'methodName'),
),
),
'behaviours' => array(
'Nos\Orm_Behaviour_Contextable' => array(
'events' => array('before_insert'),
'context_property' => 'ex_context',
),
),
// In this example, use a closure for defined title_property
'title_property' => function($item) {
return $item->ex_reference;
},
);
Warning
Don’t use these relations directly, we created accessors for them.
Accessor for Nos\Media\Model_Link linked to model.
<?php
$item->medias->avatar; // Get a Model_Link named 'avatar'
$item->medias->avatar->media; // Get Model_Media named 'avatar'
$item->medias->cv = $Model_Media; // Attach a Model_Media named 'cv'
$item->medias->cv = null; // Detach a media from an item
// or
unset($item->medias->cv);
Accessor for Nos\Model_Wysiwyg linked to model.
<?php
$item->wysiwygs->content; // Get a Model_Wysiwyg named 'content'
$item->wysiwygs->content->wysiwyg_text; // Get content of Model_Wysiwyg named 'content'
$item->wysiwygs->summary = 'foo'; // Set a Model_Wysiwyg named 'content', with content 'foo'.
$item->medias->summary = null; // Remove a wysiwyg from an item
// or
unset($item->wysiwygs->summary);
Returns: | Title property of model. See Model::$title_property. |
---|
Returns: | The DB table name of model. |
---|
Parameters: |
|
---|
Add a relation to model
Parameters: |
|
---|---|
Throws: | \FuelException if $type is not a valid one. |
Returns: | Array configurations of the model. |
---|
Returns: | Application name of the model. |
---|
Trigger an event (caught by behaviours) on the item.
Parameters: |
|
---|
Trigger an event (caught by behaviours) on the model class.
Parameters: |
|
---|
Returns: | Prefix of column name. Computed from the primary key name (everything before the first _ character). |
---|
Returns: | Returns the item’s title, calculated from Model::$title_property. |
---|
Parameters: |
|
---|---|
Returns: | Returns the first non empty column. Will add column prefix (see Model::prefix) when needed. |
Extends Nos\Orm\Model.
Possible values of the page_type column.
Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, page URL in href and page title in text. |
Parameters: |
|
||
---|---|---|---|
Returns: | The absolute URL of the page |
Extends Nos\Orm\Model.
Delete the original media file from the disk.
Delete all the cached versions (thumbnails) of the media files from the disk.
Returns: | Private absolute media file path. |
---|
Parameters: |
|
---|---|
Returns: | If the media file is an image, return an html image tag of the media. |
Sets width, height, alt attributes is not supplied.
Parameters: |
|
---|---|
Returns: | If the media file is an image, return an html image tag of the media resized. |
Sets width, height, alt attributes is not supplied.
Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, media URL in href and media title in text. |
Parameters: |
|
---|
Parameters: |
|
---|---|
Returns: | If the media file is an image, media URL for specify size parameters. False otherwise. |
Returns: | True or false, depend if media is an image. |
---|
Returns: | Returns a Nos\Toolkit_Image based on the media if is an image, False otherwise. |
---|
medil_id: | Model_Link primary key. |
---|---|
medil_from_table: | |
DB table name of the model which the media is linked to. | |
medil_foreign_id: | |
ID of the model which the media is linked to. | |
medil_foreign_context_common_id: | |
Common ID of the model which the media is linked to. | |
medil_key: | string key identifying the linked media. |
medil_media_id: | ID of the linked media. |
One of medil_foreign_id and medil_foreign_context_common_id columns is NULL for each row.
Extends Nos\Orm\Model.
Delete the folder and all its content (recursively).
Delete all the public and cached entries (image thumbnails) of this folder
Parameters: |
|
---|---|
Returns: | Absolute folder path. |
Returns: | Number of media contained in the folder and all its sub-folders. |
---|
Returns: | Number of media in use (by the applications) contained in this folder and all its sub-folders. |
---|
Extend Nos\Orm\Model.
Parameters: |
|
---|---|
Returns: | True if the user has the required authorisation, false otherwise |
Extend Nos\Orm\Model.
Check whether a permissions exists with the given category.
Parameters: |
|
---|---|
Returns bool: | true or false |
List all the categories of a given permission name. Returns an array of string or false when the role has not access, or the permission name does not exists.
Parameters: |
|
---|---|
Returns: | array|false An array containing the list of categories (values) for the request permission name |
Alias to Nos\User\Model_Role::checkPermission with $allow_empty = true.
Alias to Nos\User\Model_Role::checkPermission.
Alias to Nos\User\Model_Role::checkPermission with $allow_empty = true.
Check against a binary permission (without categories).
Parameters: |
|
---|---|
Returns bool: | true or false |
Check against a numeric / range permission.
You can use string for the 2nd and 3rd parameters, they will be casted to (int). i.e. '2_write' === 2.
Parameters: |
|
---|---|
Returns bool: | true or false |
Check against a numeric / range permission.
You can use string for the 2nd and 3rd parameters, they will be casted to (int). i.e. '2_write' === 2.
Parameters: |
|
---|---|
Returns bool: | true or false |
Retrieve the value of a given permission.
Parameters: |
|
---|---|
Returns string: |
Extend Nos\Orm\Model.
wysiwyg_id: | Model_Wysiwyg primary key. |
---|---|
wysiwyg_join_table: | |
DB table name of the model which the wysiwyg is linked to. | |
wysiwyg_foreign_id: | |
ID of the model which the wysiwyg is linked to. | |
wysiwyg_foreign_context_common_id: | |
Common ID of the model which the wysiwyg is linked to. | |
wysiwyg_key: | string key identifying the linked wysiwyg. |
wysiwyg_text: | Wysiwyg content. |
One of wysiwyg_foreign_id and wysiwyg_foreign_context_common_id columns is NULL for each row.
Extends Nos\Orm\Model.
Default value for the content_catcher column.
content_id: | Model_Content_Nuggets primary key. |
---|---|
content_catcher: | |
Data catcher name. | |
content_model_name: | |
Name of the model this content nuggets originates from. | |
content_model_id: | |
ID of the model this content nuggets originates from. | |
content_data: | The content nuggets. Stored as a serialized associative array. |
Keeps track of who created an item and who updated it. Great to use in combination of Observer_CreatedAt and Observer_UpdatedAt.
Column used to store the user ID when the item is created. Its data type must be unsigned int.
Column used to store the user ID when the item is updated (also used upon creation). Its data type must be unsigned int.
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_properties = array(
// ...
'page_created_by_id' => array(
'default' => null,
'data_type' => 'int unsigned',
'null' => true,
'convert_empty_to_null' => true,
),
'page_updated_by_id' => array(
'default' => null,
'data_type' => 'int unsigned',
'null' => true,
'convert_empty_to_null' => true,
),
);
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Author' => array(
'created_by_property' => 'page_created_by_id',
'updated_by_property' => 'page_updated_by_id',
),
);
}
Allows a Nos\Orm\Model to be bound to a context.
See also
Required. Column used to store the item’s context. Its data type must be varchar(25).
Default context to use if not set when creating an item.
This behaviour extends Model->find().
Add option to where array passed to method: you can use the context key as an alias to search in the column Orm_Behaviour_Contextable::$context_property.
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Contextable' => array(
'events' => array('before_insert'),
'context_property' => 'form_context',
),
);
}
Adds a publication status on a Nos\Orm\Model. 2 modes are available:
Always required, both for the yes/no and the date range modes.
Column used to store the publication state. Its data type must be int:
Required for date range mode. Column used to store the publication start date. Its data type must be datetime.
Required for date range mode. Column used to store the publication end date. Its data type must be datetime.
allow_publish: | Callback function or array of callback functions. If any returns false then the item will be restricted from publication. |
---|
Returns: | true or false depending on whether the item is currently published or not. |
---|
Returns: | 0 (not published), 1 (published) or 2 (scheduled). |
---|
Returns: | the publication start date, MySQL format. |
---|
Returns: | the publication end date, MySQL format. |
---|
This behaviour extends Model->find().
You can use the published key in the where array. Appropriate conditions will be added, according to the configuration of the behaviour. Especially useful with the date range mode (and start / end dates).
If you’re using the standard_layout included in Novius OS, this behaviour will automatically prepend a field in the subtitle section to select publication status and/or dates (according to the behaviour configuration).
<?php
// Yes/No state
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Publishable' => array(
'publication_state_property' => 'page_published',
),
);
}
$page = Model_Page::find(1);
if ($page->published()) {
// Do something
}
<?php
// Date range mode (combined with Yes/No state)
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Publishable' => array(
'publication_state_property' => 'page_published',
'publication_start_property' => 'page_publication_start',
'publication_end_property' => 'page_publication_end',
),
);
}
Adds the sharable behaviour on a Nos\Orm\Model.
Associative array of different types of data forming a content nuggets.
Keys can be one of DataCatcher constants.
Values are associative array.
value: A column name or a closure. See Examples. useTitle: Help label indicate which property of item is use as default value. options: Associative array of different options. Only for DataCatcher::TYPE_URL. possibles: Associative array of possibles values. Only for DataCatcher::TYPE_IMAGE.
Returns: | Array containing the default content nuggets of an item. |
---|
Parameters: |
|
---|---|
Returns: | The Model_Content_Nuggets of this item for the specified data catcher. |
Parameters: |
|
---|---|
Returns: | Orm_Behaviour_Sharable::$data if $property is null. Otherwise, property value with default fallback. |
Retrieves all the data catchers that can use the content nugget of this item (checks the required_data of a data catcher and ).
returns: All the valid data catchers for this item (keys are the data catcher names).
Retrieves all possible medias that can be associated with the item. Search for linked medias and images inserted in the WYSIWYGs.
returns: Associative array of all Model_Media, Model_Media ID in keys, of item.
Retrieves the personalised content nugget of a data catcher, merged with the default content nugget of the item.
param string $catcher: Data catchers ID. returns: Array A content nugget.
<?php
array(
\Nos\DataCatcher::TYPE_TITLE => array(
'value' => 'monk_name',
),
);
<?php
array(
\Nos\DataCatcher::TYPE_TITLE => array(
'value' => function($monkey) {
return $monkey->monk_name;
},
),
);
From the Monkey example application. config/model/monkey.config.php (we’re using a config file here, because we can’t put functions in a class property):
<?php
return array(
'behaviours' => array(
'Nos\Orm_Behaviour_Sharable' => array(
'data' => array(
\Nos\DataCatcher::TYPE_TITLE => array(
'value' => 'monk_name',
'useTitle' => __('Use monkey name'),
),
\Nos\DataCatcher::TYPE_URL => array(
'value' => function($monkey) {
$urls = $monkey->urls();
if (empty($urls)) {
return null;
}
reset($urls);
return key($urls);
},
'options' => function($monkey) {
return $monkey->urls();
},
),
\Nos\DataCatcher::TYPE_TEXT => array(
'value' => function($monkey) {
return $monkey->monk_summary;
},
'useTitle' => __('Use monkey summary'),
),
\Nos\DataCatcher::TYPE_IMAGE => array(
'value' => function($monkey) {
$possible = $monkey->possible_medias();
return Arr::get(array_keys($possible), 0, null);
},
'possibles' => function($monkey) {
return $monkey->possible_medias();
},
),
),
),
),
);
Makes a Nos\Orm\Model sortable.
Required. Column name use for save sort index. Column must have type double.
ASC (default) ou DESC
True by default. If false and the model is twinnable, the sorting won’t be common to all contexts.
Parameters: |
|
---|
Parameters: |
|
---|
Moves the current item to the last position (of its siblings).
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Sortable' => array(
'events' => array('after_sort', 'before_insert'),
'sort_property' => 'page_sort',
),
);
}
$page_1 = Model_Page::find(1);
$page_2 = Model_Page::find(2);
$page_2->move_after($page_1);
Column used to store the item’s depth inside the tree. Data type must be int.
Returns: | Model parent item, if it exists, null otherwise. |
---|
Set a new parent for the item.
If the item is twinnable and if it exists in several contexts, all contexts will be moved synchronously.
Parameters: |
|
---|---|
Throws: | Exception when:
|
Returns: | All direct children of item. |
---|
Children can be filter and / or sort by parameters.
<?php
$options = \Arr::merge($options, array(
'where' => $where,
'order_by' => $order_by,
));
Parameters: |
|
---|---|
Returns: | All children of item and their descendants. |
Returns: | First ascendant of item in tree or null if item has no parent. |
---|
This behaviour extends Model->find().
Add option to where array passed to method : you can use parent key as alias for search in Orm_Behaviour_Tree::$parent_relation relation.
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Tree' => array(
'events' => array('before_query', 'after_delete'),
'parent_relation' => 'parent',
'children_relation' => 'children',
'level_property' => 'page_level',
),
);
protected static $_has_many = array(
'children' => array(
'key_from' => 'page_id',
'model_to' => 'Nos\Model_Page',
'key_to' => 'page_parent_id',
'cascade_save' => false,
'cascade_delete' => false,
),
);
protected static $_belongs_to = array(
'parent' => array(
'key_from' => 'page_parent_id',
'model_to' => 'Nos\Model_Page',
'key_to' => 'page_id',
'cascade_save' => false,
'cascade_delete' => false,
),
);
}
Required. Column used to store the common ID between twinned items. Data type must be int.
Required. Column used to store if the item is the main item among twin items. Data type must be boolean.
Array of fields which are common to all context twins.
Returns: | True if model has common fields, medias or WYSIWYGs. |
---|
Parameters: |
|
---|---|
Returns: | True if the field name is a common field or, media or WYSIWYG. |
Removes all items twinned to the current item, including the current item itself.
Returns: | True if item is the main among twin items. |
---|
Parameters: |
|
---|---|
Returns: | A twinned item, or an array of twinned items, null or array() if none. |
Returns: | The main item among the twins. |
---|
Alias for ->find_context('main').
Parameters: |
|
---|---|
Returns: | Array of twin items, current item exclude. |
Returns: | Array of all twinned contexts, including the one of the current item. |
---|
Parameters: |
|
---|---|
Returns: | Array of all twinned contexts ID, excluding the one of the current item. |
Returns: | Array of possible contexts ID for current item. |
---|
Parameters: |
|
---|---|
Returns: | Array of items, like find(), either in the given context, either the main. |
See also
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Twinnable' => array(
'events' => array('before_insert', 'after_insert', 'before_save', 'after_delete', 'change_parent'),
'context_property' => 'page_context',
'common_id_property' => 'page_context_common_id',
'is_main_property' => 'page_context_is_main',
'common_fields' => array(),
),
);
}
Parameters: | |
---|---|
Returns: | Associative array of all possibles URLs for this item
|
Parameters: |
|
||||
---|---|---|---|---|---|
Returns: | Absolute URL of item or null if item can’t be displayed in front. |
Parameters: |
|
---|---|
Returns: | Absolute canonical URL of item or null if item can’t be displayed in front. |
Alias for ->url(array('canonical' => true)).
If the item is sharable, returns the URL set in the shared data (content nugget).
Returns: | Absolute canonical URL of item, even if it’s not published, or null if item can’t be displayed in the front-office. |
---|
Alias for ->url_canonical(array('preview' => true)).
Delete the cache of the pages containing this item only (this will not delete the cache for the whole enhancer).
Delete the cache of the pages containing an URL enhancer for the item. Warning: this will delete for all the enhancer, not only the pages containing the item.
Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, item URL in href and item title in text. |
<?php
class Model_Monkey extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Urlenhancer' => array(
'enhancers' => array('noviusos_monkey'),
),
);
}
If Orm_Behaviour_Virtualname::$unique is set, ->save() method can throw an Exception if slug already in use.
Required. Column used to store the slug.
true, false or 'context' if uniqueness must be checked by context.
Getter and setter for the virtual_name. Setter if a $slug is passed in parameters.
When use as setter, the new virtual name is transform to friendly slug.
Parameters: |
|
---|---|
Returns: | The item slug. |
Parameters: |
|
---|---|
Returns: | A clean slug, lowercase, without forbidden characters. |
<?php
class Model_Monkey extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Virtualname' => array(
'events' => array('before_save', 'after_save'),
'virtual_name_property' => 'monk_virtual_name',
),
);
}
See also
Nos\Orm_Behaviour_Virtualname for configuration and methods.
Required. Column name use for save virtual path.
Required. If it’s a string, it will be appended to the virtual path. If it’s an array:
before: String to add to extension start. after: String to add to extension end. property: Column name used to store the extension.
Required. Name of the parent relation use to generate the first part of the virtual path.
Parameters: |
|
---|---|
Returns: | Virtual path of the item. |
Returns: | Return extension part of the virtual path. |
---|
<?php
class Model_Page extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Orm_Behaviour_Virtualpath' => array(
'events' => array('before_save', 'after_save', 'change_parent'),
'virtual_name_property' => 'page_virtual_name',
'virtual_path_property' => 'page_virtual_url',
'extension_property' => '.html',
'parent_relation' => 'parent',
),
);
}
Behaviours can catch events triggered on a Nos\Orm\Model or on a instance of Nos\Orm\Model.
Trigger when fill dataset of an item.
Parameters: |
|
---|
Trigger when build a fieldset from an item.
Parameters: |
|
---|
Trigger when receive a form response.
Parameters: |
|
---|
Trigger when construct WYSIWYG options for an item.
Parameters: |
|
---|
Trigger when building a query configuration for a grid of model’s items.
Parameters: |
|
---|
New in version 4.3.
Trigger when building a query for a grid of model’s items.
Parameters: |
|
---|
Trigger when building a grid’s item.
Parameters: |
|
---|
Trigger after execute query for a grid of model’s items.
Parameters: |
|
---|
Trigger when building a common configuration of a model.
Parameters: |
|
---|
Trigger when building the configuration of the CRUD controller of the model.
Parameters: |
|
---|
Trigger when building the fields for the CRUD controller of the model.
Parameters: |
|
---|
Trigger when building relations of the model.
Trigger before execute a query build on the model.
Parameters: |
|
---|
Novius OS adds relation types to FuelPHP native relations (belongs_to, has_one, has_many and many_many).
See also
The twinnable_belongs_to relation is the equivalent of the FuelPHP native belongs_to relation (moreover, it extends belongs_to). The difference is that the link is not made on the primary key but on the context common ID.
If you use the twinnable_belongs_to relation, the model must implement Twinnable behaviour. The field key_from must be declared common field in the twinnable behaviour.
Changed in version 4.2: Before the 4.2 (Dubrovka) version, the linked model also need to implement Twinnable behaviour.
key_from: | The key used for the relation in the current model. |
---|---|
model_to: | The full class name of the target model. Calculated from alias. |
key_to: | Calculated from the behaviour Twinnable if model_to is twinnable. |
column_context_from: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_is_main_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. |
The Model_Monkey belongs to a Model_Species independently of context. A monkey, in one context, has the same species than in other, just the translation can be changed. If the species not exists in the same context that the monkey, the relation returns the species in the main context.
<?php
protected static $_twinnable_belongs_to = array(
'species' => array(
'key_from' => 'monk_species_common_id',
'model_to' => 'Nos\Monkey\Model_Species',
'cascade_save' => false,
'cascade_delete' => false,
),
);
The twinnable_has_one relation is the equivalent of the FuelPHP native has_one relation (moreover, it extends has_one). The difference is that the link is not made on the primary key but on the context common ID.
If you use the twinnable_has_one relation, the model must implement Twinnable behaviour.
Changed in version 4.2: Before the 4.2 (Dubrovka) version, the linked model also need to implement Twinnable behaviour.
key_from: | Calculated from the behaviour Twinnable. |
---|---|
model_to: | The full class name of the target model. Calculated from alias. |
key_to: | The key used for the relation in the linked model if model_to is twinnable. |
column_context_from: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_is_main_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. |
The twinnable_has_many relation is the equivalent of the FuelPHP native has_many relation (moreover, it extends has_many). The difference is that the link is not made on the primary key but on the context common ID.
If you use the twinnable_has_many relation, the model must implement Twinnable behaviour.
Changed in version 4.2: Before the 4.2 (Dubrovka) version, the linked model also need to implement Twinnable behaviour.
key_from: | Calculated from the behaviour Twinnable. |
---|---|
model_to: | The full class name of the target model. Calculated from alias. |
key_to: | The key used for the relation in the linked model if model_to is twinnable. |
column_context_from: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_is_main_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. |
The twinnable_many_many relation is the equivalent of the FuelPHP native many_many relation (moreover, it extends many_many). The difference is that the link is not made on primary keys but on context common IDs.
If you use the twinnable_many_many relation, the model must implement Twinnable behaviour.
Changed in version 4.2: Before the 4.2 (Dubrovka) version, the linked model also need to implement Twinnable behaviour.
key_from: | The key used for the relation in the current model |
---|---|
model_to: | The full class name of the target model. Calculated from alias. |
key_to: | Calculated from the behaviour Twinnable if model_to is twinnable. |
table_through: | This is the table that connects the 2 models and has both their common IDs in it. |
key_through_from: | |
The key that matches the current model’s common ID. | |
key_through_to: | The key that matches the related model’s common ID. |
column_context_from: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_common_id_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. | |
column_context_is_main_to: | |
Calculated from the behaviour Twinnable if model_to is twinnable. |
When you use the relation in a find, you can add main context in conditions. If it’s set to false, relation only retrieves related items of the same context.
<?php
Model_Example::find('all', array(
'related' => array(
'manymany_twinnable' => array(
'main_context' => false,
),
),
);
Binds files to model instances. Based on the attachment class.
key_from: | Calculated from the primary key. |
---|---|
attachment_config: | |
Array for attachment configuration. dir key is optional, calculated from model and relation names. See also |
In this case, each item of the model have 2 attachments: avatar and cv.
<?php
protected static $_attachment = array(
'avatar' => array(),
'cv' => array(),
);
Binds a file to an object.
Required. The attached ID.
Required. Directory path, where the attachment is stored. Relative to local/data/files.
An URL alias to access the directory path.
Array of valid files extensions.
If true, accepts only files with an image extension. Same that extensions set to array('jpg', 'gif', 'png', 'jpeg').
Used it to make the attachment private. A callback function to check permissions against. It takes a single parameter: Attachement instance.
Parameters: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns: | A new Nos\Attachment. |
Returns: | Get the new attachment file path if one, false if no file exists. |
---|
Returns: | Get the attachment file path or false if no file exists. |
---|
Returns: | Get the attachment filename or false if no file exists. |
---|
Returns: | Get the attachment extension or false if no file exists. |
---|
Returns: | True if the Attachment is an image, false otherwise. |
---|
Parameters: |
|
---|---|
Returns: | Get the attachment url or false if no file exists. |
Parameters: |
|
---|---|
Returns: | Get the resized url for the Attachment or false if no file exists or it’s not an image. |
Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, attachment URL in href and attachment filename in text. |
Returns: | Returns a Nos\Toolkit_Image based on the attachment if is an image, False otherwise. |
---|
Parameters: |
|
---|---|
Returns: | Set a new Attachment file. |
Throws: | FuelCoreFileAccessException if new file have a not allowed extension. |
Save a new Attachment file
Returns: | True if the Attachment have been saved, false otherwise. |
---|
Delete the Attachment file
Returns: | True if the Attachment have been deleted, false otherwise. |
---|
<?php
$attachment = \Nos\Attachment::forge('my_id', array(
'dir' => 'apps'.DS.'myapps',
'alias' => 'myapps-attachment',
'extensions' => array('pdf'),
'check' => 'check_attachment',
));
// It's for example
$_SESSION['user_connected'] = true;
function check_attachment($attachment) {
return $GLOBALS['user_connected'];
}
try {
$attachment->set('/path/a_doc.doc');
} catch (\Fuel\Core\FileAccessException $e) {
// Exception will be throw, extension is doc, not a pdf.
}
$attachment->set('/path/a_pdf.pdf');
$attachment->save();
// Now file saved in local/data/files/apps/myapps/my_id/a_pdf.pdf
echo $attachment->url();
// Echo http://wwww.domain.ext/data/files/myapps-attachment/my_id/a_pdf.pdf
$_SESSION['user_connected'] = false;
// Now URL http://wwww.domain.ext/data/files/myapps-attachment/my_id/a_pdf.pdf return 404
$attachment->delete();
Extends FuelPHP config class and provides new functionalities.
Parameters: |
|
---|---|
Returns: | The configuration merged. |
Merge configuration with the one saved in user in the key $key.
Parameters: |
|
---|---|
Returns: | Valid user configuration key. |
Parameters: |
|
---|---|
Returns: | Returns a two element array: first element is the class’s application, and the second element is the relative path of the configuration file. |
Parameters: |
|
---|---|
Returns: | The metadata configuration. |
Parameters: |
|
---|---|
Returns: | The global configuration. |
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | The filtered actions. |
Parameters: |
|
---|---|
Returns: | The processed disabled value. |
Parameters: |
|
---|---|
Returns: | The first value which is different of $positive_value, otherwise $positive_value. |
For instance:
<?php
// ----- With a simple value
getActionDisabledState(true, true); // returns true
getActionDisabledState(true, false); // returns true
// ----- With a callback
$value = function() {
return true;
}
getActionDisabledState($value, true); // returns true
getActionDisabledState($value, false); // returns true
// ----- With a list of callbacks
$value = array(
function() {
return true;
},
function() {
return false;
}
);
getActionDisabledState($value, true); // returns false, since second callback is different from positive_value
getActionDisabledState($value, false); // returns true, since first callback is different from positive_value
// ----- With a list of mixed values
$value = array(
true,
function() {
return false;
}
);
// the first value is equivalent to a callback returning true, so there is no difference with previous example
getActionDisabledState($value, true); // returns false, since second value is different from positive_value
getActionDisabledState($value, false); // returns true, since first callback is different from positive_value
// ----- With additionnal parameters
$value = array(
function($param1, $param2) {
return $param1 == $param2;
},
function ($param1, $param2) {
return $param1 != $param2;
}
);
getActionDisabledState($value, true, 1, 1); // returns false, since second value is different from positive_value
getActionDisabledState($value, true, 1, 2); // returns false, since first value is different from positive_value
getActionDisabledState($value, false, 1, 1); // returns false, since first value is different from positive_value
getActionDisabledState($value, false, 1, 2); // returns false, since second value is different from positive_value
Parameters: |
|
---|---|
Returns: | The replaced value. |
Novius OS front-office controller
Use Nos::main_controller to retrieve its instance and call the methods.
Returns: | Current Model_Page displayed. |
---|
Returns: | Current absolute URL. |
---|
Returns: | Relative (to Controller_Front::getContextUrl) URL of the current page. |
---|
Returns: | Relative (to Controller_Front::getContextUrl) URL of the current URL enhancer.
False if no current URL enhancer.
|
---|
Same that Controller_Front::getPageUrl ending with / instead of .html.
Returns: | Part of the URL processed by the URL enhancer.
False if no current URL enhancer.
|
---|
Returns: | The current item displayed. |
---|
New in version 4.1.
param Model $item: The current Model instance displayed. param array $properties: Array of properties param array $templates: Array of templates use to set properties
New in version 4.1: Set de current item displayed, by default this item is the page displayed, but can be call by an URL enhancer. This method set automatically title, h1, meta_description and meta_keywords for the current HTML.
Parameters: |
|
---|
Parameters: |
|
---|
param string $title: Set a new H1 for the current HTML. param string $template: If set, use it to calculate the H1. Placeholders :h1 will be replaced by $h1.
New in version 4.1.
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Returns: | Boolean, true if current page is requested in the preview mode. |
---|
Disable caching and cache retrieve of the current page.
Parameters: |
|
---|
Parameters: |
|
---|
Add or replace a header to current response. Headers will be saved in cache.
Parameters: |
|
---|
Returns a (dot notated) custom data of the current process.
Parameters: |
|
---|---|
Returns: | The custom data or default if not found. |
Sets a (dot notated) custom data to the current process.
Parameters: |
|
---|
Replace the template by a specific content and stop treatments
Parameters: |
|
---|
Add a cache suffix handler for the current page
Parameters: |
|
---|---|
Returns: | The cache instance if the cache path have changed, null otherwise. |
Manage front cache
Write a HMVC call in cache for after cache execution.
Parameters: |
|
---|
See also
Write a View forge in cache for after cache execution.
Parameters: |
|
---|
Provides the translation related functions.
Configure the locale to use for translations.
Parameters: |
|
---|
Loads a dictionary for the current locale.
Parameters: |
|
---|
Retrieves a translation from the last loaded dictionary.
Parameters: |
|
---|---|
Returns: | The translation or null if not founded |
Retrieves a translation from a specific dictionary.
Parameters: |
|
---|---|
Returns: | The translation or null if not founded |
Warning
The dictionary must have been loaded manually before.
The plural version of I18n::get. Some languages have more than one form for plural messages dependent on the count.
Parameters: |
|
---|---|
Returns: | The translation or, if not founded, $singular is returned if n == 1, otherwise $plural |
Retrieves a plural translation from a specific dictionary.
Parameters: |
|
---|---|
Returns: | The translation or, if not founded, $singular is returned if n == 1, otherwise $plural |
Warning
The dictionary must have been loaded manually before.
Set the current dictionary
Parameters: |
|
---|
Returns a closure that translate messages from a specific dictionary.
Parameters: |
|
---|---|
Returns: | A callable to translate a message |
<?php
// Retrieves an anonymous function
$dictionary = Nos\I18n::dictionary('mon_appli::common');
echo $dictionary('Translate this');
Provides migration automation and methods useful for migrations.
All you need is to declare the class in the right namespace.
<?php
namespace Nos\Monkey\Migrations;
class Install extends \Nos\Migration
{
}
If the migration name is 001_install.php it will try to execute 001_install.sql.
If you want a more complex migration (e.g. update files), you can overload up and down functions.
Tries to execute a sql file with same path (if migration filename is 001_install.php, it will try to execute 001_install.sql).
Provides static methods useful in Novius OS.
The Novius OS entry point. Equal to one of the following constants.
New in version 0.2.0.1.
Returns: | Instance of the main controller. |
---|
Parameters: |
|
---|---|
Returns: | Prepare wysiwyg content for display. |
This class checks the permissions for the current logged in user.
When multiple roles are enable, if any role has the requested permission, it means the user is authorised to do it.
Alias to Nos\User\Permission::exists
Check whether a permissions exists (against all the roles of the current logged in user).
Parameters: |
|
---|---|
Returns bool: | true or false |
Alias to Nos\User\Permission::exists with the optional parameter $alowEmpty = true.
Parameters: |
|
---|---|
Returns bool: | true or false |
Check against a binary permission (without categories) against all the roles of the current logged in user.
Parameters: |
|
---|---|
Returns bool: | true or false |
Check against a numeric / range permission (for all the roles of the current logged in user).
You can use string for the 2nd and 3rd parameters, they will be casted to (int). i.e. '2_write' === 2.
Parameters: |
|
---|---|
Returns bool: | true or false |
Check against a numeric / range permission (for all the roles of the current logged in user).
You can use string for the 2nd and 3rd parameters, they will be casted to (int). i.e. '2_write' === 2.
Parameters: |
|
---|---|
Returns bool: | true or false |
List all the categories of a given permission name (merged values from all the roles of the current logged in user).
Returns an array of string or false when access is denied, or the permission name does not exists.
Parameters: |
|
---|---|
Returns array|false: | |
An array containing the list of categories (values) for the requested permission name |
Check whether a user can access a particular application
Parameters: |
|
---|
See also
Returns an array of all the contexts the user can access.
See also
Returns an array of all the locales the user can access.
See also
Returns an array of all the sites the user can access.
Extends the class Fieldset_Field of FuelPHP.
Toolkit for image manipulation.
To get a Toolkit_Image, use method getToolkitImage on classes supporting it.
Add multiple transformations to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Add a crop transformation to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Resizes the image only if too big
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Resizes the image. If the width or height is null, it will resize retaining the original aspect ratio.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Rotates the image
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Creates a vertical / horizontal or both mirror image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Adds a watermark to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Adds a border to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Masks the image using the alpha channel of the image input.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Adds rounded corners to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Turns the image into a grayscale version
Returns: | The current Toolkit_Image for chaining. |
---|
Build and return the URL of the modify image
Parameters: |
|
---|---|
Returns: | The URL of the modify image. |
Returns: | The dimensions of the modify image (an object containing width and height variables). |
---|
Creates an html image tag of the modify image
Sets width, height, alt attributes if not supplied.
Parameters: |
|
---|---|
Returns: | The image tag |
Apply transformations of the Image_URL instance on a file and save it
Returns: | The save file path |
---|
Parse an existing modify URL and set transformations in queue. Check if the hash part of the URL match.
Parameters: |
|
---|---|
Returns: | True or false if the hash part of the URL not match. |
<?php
$all_media_png = \Nos\Media\Model_Media::find('all', array(
'where' => array(
array('media_ext', 'png'),
),
)); // Get all images PNG in media
// Display all PNG, shrinked in 200x100, grayscale and rounded with a 5px radius, in a <img class="css_class" /> tag.
foreach ($all_media_png as $media) {
echo $media->getToolkitImage()->shrink(200, 100)->grayscale()->rounded(5)->html(array(
'class' => 'css_class',
));
}
Provides static methods to work with yours contexts, sites and languages.
See also
Returns: | An array of all your valid contexts. |
---|
<?php
$contexts = \Nos\Tools_Context::contexts();
foreach ($contexts as $context_code => $context_urls) {
// ....
}
Returns: | An array of all your valid sites. Each site has a title and an alias. |
---|
<?php
$sites = \Nos\Tools_Context::sites();
foreach ($sites as $site_key => $site_params) {
$title = $site_params['title'];
$alias = $site_params['alias'];
}
Returns: | An array of all your valid locales. Each locale has a title and a flag’s code flag. |
---|
<?php
$locales = \Nos\Tools_Context::locales();
foreach ($locales as $locale_key => $locale_params) {
$title = $locale_params['title'];
$flag = $locale_params['flag'];
}
Returns: | The code of default context of your Novius OS instance. |
---|
<?php
$default_context_code = \Nos\Tools_Context::defaultContext();
Used to build a RSS feed.
Parameters: |
|
---|---|
Encoding: | Default UTF-8. Used for the XML encoding attribute. |
Version: | Default 2.0. Used for XML version attribute (<rss> tag). You can define any other key, which will be transformed into XML tag in the <channel /> |
Returns: | A instance of Tools_RSS. |
Parameters: |
|
---|
Set one or multiple channel properties.
Parameters: |
|
---|
Set a new array of items.
Parameters: |
|
---|
Add a new item to the $items array.
Parameters: |
|
---|---|
Returns: | The XML description of the RSS |
See Tools_RSS::forge for parameters.
The pubDate key can be a Fuel\\Core\\Date instance, or a string (date representation) or a timestamp.
<?php
$rss = \Nos\Tools_RSS::forge('RSS title');
$rss->set_items(array(
'title' => 'Item title',
'link' => 'http://www.mydomain.com/item_url.html',
'description' => '<p>A description of item </p>',
'pubDate' => '2012-08-16',
'author' => 'Me',
));
$xml = $rss->build();
$rss->set('subtitle', 'A subtitle for ma RSS');
echo $rss; // Call $rss->build() with magic method __ toString()
Provides static methods for URL.
Parameters: |
|
---|---|
Returns: | URL of the specified page. |
Parameters: |
|
---|---|
Returns: | Home URL of the specified context. |
Extends FuelPHP view class and provides new functionalities.
Same specifications as in FuelPHP view class, except when you prefix the view name by !, view redirections are ignored.
Parameters: |
|
---|
The function can redirect views: you can, for instance, make View::forge(‘a’) return the content of view b.
Usages examples:
<?php
View::redirect('a', 'b'); // redirects view `a` to `b`
View::redirect('a', 'b', function($data, $filter) { return false; }); // won't have any effect
View::redirect('a', 'b', function($data, $filter) { return false; });
View::redirect('a', 'c', function($data, $filter) { return true; });
// will redirect `a` to `c`
View::redirect('a', false, function($data, $filter) { return 'd'; })
// or
View::redirect('a', function($data, $filter) { return 'd'; })
// will redirect `a` to `d`
Extends Nos\Renderer_Datetime_Picker.
Since Chiba 2.2, this renderer is just an alias of Nos\Renderer_Datetime_Picker with format set to date.
New in version chiba.2.2.
HTML string to wrap the <input> + the generated image to open the datetimepicker
(Default: datetime). Format saved and displayed : date or datetime
New in version chiba.2.2.
(Default: false). Set to true if the date can be null.
New in version chiba.2.3.
Options for the datepicker widget used to render the UI. See the jQuery UI documentation for all available options.
Default values below:
showOn: both buttonImage: static/novius-os/admin/novius-os/img/icons/date-picker.png buttonImageOnly: true autoSize: true hiddenTimeFormat: HH:mm:ss hiddenDateFormat: yy-mm-dd dateFormat: HH:mm:ss timeFormat: HH:mm dateFormat: dd/mm/yy altFieldTimeOnly: false showButtonPanel: true changeMonth: true changeYear: true showOtherMonths: true selectOtherMonths: true gotoCurrent: true firstDay: 1 showAnim: slideDown
(Datetime default: %Y-%m-%d %H:%M:%S, Date default: %Y-%m-%d). Defines how to decode input value
New in version chiba.2.2.
(Datetime default: mysql, Date default: mysql_date). Defines how to store value in the database
New in version chiba.2.2.
(Datetime default: datetimepicker, Date default: datepicker). Defines which jquery ui plugin to call on the form input
New in version chiba.2.2.
Parameters: |
|
---|---|
Returns: | The <input> tag with JavaScript to initialise it |
Displays a date time picker in a standalone manner.
Adding a date time picker in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Datetime_Picker',
'renderer_options' => array(
'datepicker' => array(),
'wrapper' => '<div class="datetimepicker-customwrapper"></div>',
),
);
Displaying a date time picker:
<?php
echo Nos\Renderer_Datetime_Picker::renderer(array(
'name' => 'my_datetime',
'class' => 'some_class',
'value' => '2013-02-13',
'renderer_options' => array(
'datetimepicker' => array(),
'wrapper' => '<div class="datetimepicker-customwrapper"></div>',
),
));
Default UI: | |
---|---|
Hover state UI: | |
Hover state with a selected media UI: | |
Possible values are image (default) or all.
Options for the inputFileThumb widget used to render the UI. See the inputFileThumb documentation for all available options.
Note
The inputFileThumb.file key will automatically be populated with the URL of the media if a value is provided in the renderer.
Parameters: |
|
---|---|
Returns: | The <input> tag with JavaScript to initialise it |
Displays a media selector in a standalone manner.
Adding a media in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Media\Renderer_Media',
'renderer_options' => array(
'mode' => 'image',
'inputFileThumb' => array(
'title' => 'Title of the image',
),
),
);
Displaying a media selector:
<?php
echo Nos\Media\Renderer_Media::renderer(array(
'name' => 'my_image',
'class' => 'some_class',
'value' => 2, // ID of the previously selected media
'renderer_options' => array(
'mode' => 'image',
'inputFileThumb' => array(
'title' => 'Title of the image',
),
),
));
Name for the radio input.
Set to true if you want to select multiple pages. Default false.
An array, or an array of array iff multiple is true, containning:
id: Pre-selected page id (value). model: Nos\Page\Model_Page
Array
Context: | Context of the pages displayed in the page selector. |
---|
Height of the renderer. Default is 150px.
Width of the renderer. Default is none.
Parameters: |
|
---|---|
Returns: | The <input> tag with JavaScript to initialise it |
Displays a page selector renderer in a standalone manner.
Adding a page in a CRUD form configuration:
<?php
return array(
'label' => __('Location:'),
'renderer' => 'Nos\Page\Renderer_Selector',
'renderer_options' => array(
'height' => '250px',
),
);
Displaying a media selector:
<?php
echo Nos\Page\Renderer_Selector::renderer(array(
'input_name' => 'my_page',
'selected' => array(
'id' => 2, // ID of the previously selected page
),
'treeOptions' => array(
'context' => 'main::en_GB',
),
'height' => '250px',
));
Name for the radio input.
List of radio buttons. Key is the value and value is an array.
label: Text or image to display around the radio button side_label: Text on the side for the selected option
Value of the selected input.
Class for the container div.
Adding set of radio button in a CRUD form configuration:
<?php
return array(
'label' => __('Status:'),
'renderer' => '\Nos\Renderer_Radioset',
'renderer_options' => array(
'choices' => array(
'refused' => array(
'label' => '<img src="static/novius-os/admin/novius-os/img/icons/status-red.png" />',
'side_label' => __('Refused'),
),
'pending' => array(
'label' => '<img src="static/apps/noviusos_comments/img/status-orange.png" />',
'side_label' => __('Pending'),
),
'published' => array(
'label' => '<img src="static/novius-os/admin/novius-os/img/icons/status-green.png" />',
'side_label' => __('Published'),
),
),
'class' => 'flat',
),
);
Any options for the jQuery UI Tag-it widget. See the documentation for all available options.
Adding a tags editor in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Tag',
'renderer_options' => array(
'model' => 'Model_Tag',
'label_column' => 'tag_label',
'relation_name' => 'tags'
),
);
This renderer will show the value of the field as plain-text.
Adding a text in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Text',
);
All the jQuery UI Time Picker options can be used.
Parameters: |
|
---|---|
Returns: | The <input> tag with JavaScript to initialise it |
Displays a time picker in a standalone manner.
Adding a time picker in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Time_Picker',
'renderer_options' => array(
// jQuery UI Time Picker options
),
);
Displaying a time picker:
<?php
echo Nos\Renderer_Time_Picker::renderer(array(
'name' => 'my_time',
'class' => 'some_class',
'value' => '17:48',
'renderer_options' => array(
// jQuery UI Time Picker options
),
));
See also
NosOrm_Behaviour_Virtualname
Adding a Virtual name in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Virtualname',
);
Any options for the TinyMCE WYSIWYG editor. See the TinyMCE documentation for all available options.
Parameters: |
|
---|---|
Returns: | The <textarea> tag with JavaScript to initialise it |
Displays a TinyMCE WYSIWYG editor in a standalone manner.
Adding a WYSIWYG in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Wysiwyg',
'renderer_options' => array(
// TinyMCE options
),
);
Displaying a WYSIWYG editor:
<?php
echo Nos\Renderer_Wysiwyg::renderer(array(
'name' => 'my_wysiwyg',
'value' => '<p>My contents</p>',
'renderer_options' => array(
// TinyMCE options
),
));
View path: nos::form/layout_standard.
Params:
title: | Main fields at the top of the form. |
---|---|
medias: | Medias are shown at the left of the title. |
large: | Default layout has spaces on the sides. If true, the form will use 100% of the width. |
save: | Which field is the save button. |
subtitle: | Fields under title. |
content: | It has the same syntax as the full version of the crud layout. |
menu: | Shown on the right. Data for the accordion view (see below). Optionally comes with an simplified syntax. |
Standard syntax for the accordion:
array(
'first_accordion' => array(
'title' => __('My first accordion'),
'fields' => array('field_1', 'field_2'),
),
'second_accordion' => array(
'title' => __('My second accordion'),
'fields' => array('field_3', 'field_4'),
),
),
(so you can’t omit the fields if you set a title).
Simplified syntax for the accordion:
array(
__('My first accordion') => array(
'field_1',
'field_2',
),
__('My second accordion') => array(
'field_3',
'field_4',
),
),
// OR
array(
__('My first accordion') => array(
'fields' => array('field_1', 'field_2'),
),
__('My second accordion') => array(
'fields' => array('field_4', 'field_4'),
),
),
View path: nos::form/expander
See also
Params:
title: | Expander’s title. |
---|---|
options: | Options for the wijexpander. |
content: | Either a plain string, a callable, or a view + params pair (array). |
show_when_empty: | |
Optional. Default false. Should the expander be displayed if there is no content inside of it? |
View path: nos::form/accordion
See also
For each accordion, you can either set:
Params:
accordions: | A list of accordions
|
---|
View path: nos::form/fields
Params:
begin: | String to display at the beginning. |
---|---|
end: | String to display at the end. |
fields: | A list of field names. |
callback: | Optional. Callback function used to render the field. By default, a field will be rendered by calling it’s build() method. |
show_when_empty: | |
Optional. Default false. Should the begin and end variables be displayed if there is no content inside of it? |
View path: nos::admin/permissions/standalone
Params:
list: | A list of permissions
|
---|
A configuration file is loaded.
Parameters: |
|
---|
<?php
// Listening to the event
Event::register_function('config|nos::controller/admin/page/page', function(&$config)
{
// ...
}
// Triggering the event
$config = Config::load('nos::controller/admin/page/page', true);
Also works with absolute paths :
<?php
// Listening to the event
Event::register_function('config|/data/www/novius-os/local/config/test.php', function(&$config)
{
// ...
}
// Triggering the event (file must exists)
$config = Config::load('/data/www/novius-os/local/config/test.php', true);
A configuration array is loaded.
Parameters: |
|
---|
<?php
// Listening to the event
Event::register_function('config|group', function(&$config)
{
// ...
}
// Triggering the event
Config::load(array(), 'group');
An .html page is requested.
Parameters: |
|
---|
<?php
Event::register_function('front.start', function($params)
{
$url =& $params['url'];
$cache_path =& $params['cache_path'];
// ...
});
Additional processing on a WYSIWYG (HTML content).
Parameters: |
|
---|
<?php
Event::register_function('front.parse_wysiwyg', function(&$content)
{
// ...
});
Additional processing on the page (HTML content).
Parameters: |
|
---|
<?php
Event::register_function('front.display', function(&$html)
{
// ...
});
Page to display have been found.
Parameters: |
|
---|
<?php
Event::register('front.pageFound', function($params)
{
$page = $params['page'];
// ...
});
Before that the response be sended.
Parameters: |
|
---|
<?php
Event::register_function('front.response', function($params)
{
$content =& $params['content'];
$status =& $params['status'];
$headers =& $params['headers'];
// ...
});
An .html page was requested, but not found.
Parameters: |
|
---|
<?php
Event::register('front.404NotFound', function($params)
{
$url = $params['url'];
// ...
});
New in version 0.2.0.2.
A inexistant file is requested. Can be media or attachment file.
Parameters: |
|
---|
<?php
Event::register_function('404.start', function($params)
{
$url =& $params['url'];
// ...
});
Media to send have been found.
Parameters: |
|
---|
<?php
Event::register_function('404.mediaFound', function($params)
{
$url = $params['url'];
$media = $params['media'];
$send_file =& $params['send_file'];
// ...
});
A inexistant media file is requested.
Parameters: |
|
---|
<?php
Event::register('404.mediaNotFound', function($url)
{
// ...
});
Attachment file to send have been found.
Parameters: |
|
---|
<?php
Event::register_function('404.attachmentFound', function($params)
{
$url = $params['url'];
$attachement = $params['attachement'];
$send_file =& $params['send_file'];
// ...
});
A inexistant attachment file is requested.
Parameters: |
|
---|
<?php
Event::register('404.attachmentNotFound', function($url)
{
// ...
});
A inexistant file is requested. No attachment or media file matched the URL.
Parameters: |
|
---|
<?php
Event::register('404.end', function($url)
{
// ...
});
Triggered after recuperation and before parsing of installed launchers.
Parameters: |
|
---|
<?php
Event::register_function('admin.launchers', function(&$launchers)
{
// ...
});
New in version 4.2.
A user just successfully connected to the back-office.
<?php
Event::register('admin.loginSuccess', function()
{
// ...
});
A user is trying to connect to the back-office with an email or an invalid password.
<?php
Event::register('admin.loginFail', function()
{
// ...
});
A user just successfully re-connected to the back-office using the cookie.
<?php
Event::register('admin.loginSuccessWithCookie', function()
{
// ...
});
A user has failed to connect to the back-office using the cookie.
<?php
Event::register('admin.loginFailWithCookie', function()
{
// ...
});
Before sending an email.
Parameters: |
|
---|
<?php
Event::register('email.before_send', function($email)
{
// ...
}
After a mail was sent.
Parameters: |
|
---|
<?php
Event::register('email.after_send', function($email)
{
// ...
}
On email send error.
Parameters: |
|
---|
A deprecated message will be write in log.
Parameters: |
|
---|
<?php
Event::register('nos.deprecated', function($params)
{
$message = $params['message'];
$since = $params['since'];
$debug_backtrace = $params['debug_backtrace'];
// ...
});
A migration throw an exception. Exception propagation can be stopped.
Parameters: |
|
---|
<?php
Event::register_function('migrate.exception', function($params)
{
$e = $params['e'];
$ignore = $params['ignore'];
$migration =& $params['migration'];
// ...
$ignore = true; // The exception will not be propagated
});
We extended some classes from FuelPHP. The additions we made are listed in this page.
__construct() will try to create the specified cache directory when it doesn’t exists.
send(): we added two events email.before_send and email.after_send
Added two methods register_function() and trigger_function() to deal with by-reference arguments.
Added the static method shrink($max_width, $max_height = null, $keepar = true, $pad = false)
Added a cache for Model::$_properties
Added behaviours
Added somes relations
Added two options in build options:
before_where: An array, search_column => $replace, where $replace can be a string or a closure which takes the $condition array by parameterIf $replace return null, the $condition will be remove from the where optionsbefore_order_by: An array, search_column => $replace, where $replace can be a string or a closure which takes the entry column by parameterIf $replace return null, the column will be remove from the order_by options
In this documentation, $ means the jQuery object itself.
$.nosNotify('message');
Replaces placeholder defined by the {{placeholder}} pattern in a string or JSON.
Arguments: |
|
---|---|
Returns: | Initial object with placeholders replaced. |
$.nosDataReplace(obj, data);
$.nosDataReplace('exemple {{foo}}', {foo : 'bar'});
// returns 'exemple bar'
$.nosDataReplace({
astring: 'example {{foo}}',
json: {
string: 'sample {{bar}}',
}
},
{
foo : 'bar',
bar : 'foo'
});
//returns {
// astring: 'example bar',
// json: {
// string: 'sample foo',
//}
Displays notification(s) to the user. This is a wrapper of the jQuery plugin Pines Notify.
Arguments: |
|
---|
$.nosNotify('message');
$.nosNotify('message', 'error');
$.nosNotify({
title: 'It\'s working',
type: 'success'
sticker: false, // Don't provide a button for the user to manually stick the notice.
hide: false, // Don't remove the notification after a delay.
});
Arguments: |
|
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: | A DOM element detach from DOM. |
$.nosUIElement({
type: 'button',
label: 'A button'
},
{
id: 5
foo: 'bar'
});
Note
content and label are exclusive. You don’t need both. Same goes for the icon (either use a name, CSS classes or an URL).
In this documentation, $container means a jQuery collection of DOM elements.
$('#id').nosTabs('open', {
url: 'url',
iframe: false,
label: 'Title',
labelDisplay: true,
iconUrl: 'icon.png',
iconSize: 16
});
Many functions of the Novius OS Javascript API have sub-functions. The first parameter is the name of a sub-function. If this parameter is omitted, the default sub-function is called.
$('#id').nosTabs('open', { url: 'url', iframe: false, label: 'Title', labelDisplay: true, iconUrl: 'icon.png', iconSize: 16 }); // This call do the same thing that the previous $('#id').nosTabs({ url: 'url', iframe: false, label: 'Title', labelDisplay: true, iconUrl: 'icon.png', iconSize: 16 });
Executes an action
Arguments: |
|
---|
Action: | nosTabs |
---|---|
Method: | Any sub-function name of $container.nosTabs(). |
Tab: | First parameter passed to sub-function of $container.nosTabs(). |
Dialog: | Second parameter passed to sub-function of $container.nosTabs(). |
$(domContext).nosAction({
action: 'nosTabs',
method: 'add',
tab: {
url: 'path/url',
label: 'A title',
iconUrl: 'url/of/icon.png'
},
dialog: {
width: 800,
height: 400
}
});
Action: | nosDialog |
---|---|
Dialog: | Second parameter passed to nosDialog.open(). |
$(domContext).nosAction({
action: 'nosDialog',
dialog: {
ajax: true,
contentUrl: 'path/url/,
title: 'A title',
width: 500,
height: 200
}
});
A special form of nosAction.nosDialog for confirmation.
Action: | confirmationDialog |
---|---|
Dialog: | Second parameter passed to nosDialog.open(). |
$(domContext).nosAction({
action: 'confirmationDialog',
dialog: {
contentUrl: 'path/url/,
title: 'A title'
}
});
Action: | nosAjax |
---|---|
Params: | Settings of $container.nosAjax(). |
$(domContext).nosAction({
action: 'nosAjax',
params: {
url: 'path/url',
method: 'POST',
data: {
id: '{{_id}}'
)
}
}, {
_id: 5
});
Open a new browser window.
Action: | window.open |
---|---|
Url: | URL of the new window. |
$(domContext).nosAction({
action: 'window.open',
url: 'path/url'
});
Redirects the browser window to a new URL.
Action: | document.location |
---|---|
Url: | The new URL. |
$(domContext).nosAction({
action: 'document.location',
url: 'path/url'
});
This action has no parameters. It only depends on the data passed with action. See $.nosMediaVisualise().
Action: | nosMediaVisualise |
---|
$(domContext).nosAction({
action: 'nosMediaVisualise'
}, {
path: 'url/of/media/',
image: true
});
Action: | dialogPick |
---|---|
Event: | Name of the event to trigger. |
$(domContext).nosAction({
action: 'dialogPick',
'event' => 'event_name'
});
Performs an asynchronous HTTP (AJAX) request. This is a wrapper of jQuery.ajax().
Arguments: |
|
---|
$(domContext).nosAjax({
dataType: 'json', // datatype is default 'json'.
type: 'POST', // The request is made in POST by default.
data: {}
});
Process JSON of a succeeded AJAX request.
Arguments: |
|
---|
Process a failed AJAX request.
Arguments: |
|
---|
Manages back-office’s popup. This is a function with sub-functions.
Arguments: |
|
---|
Opens a popup. This is a wrapper of Wijmo widget Dialog.
A popup can be created in three ways:
Catch events dispatched by $.nosDispatchEvent().
Arguments: |
|
---|
// Popup containing the HTML result of the AJAX request on contentUrl
$(domContext).nosDialog('open', {
contentUrl: 'path/url',
ajaxData: {
foo: 'bar'
},
title: 'title of the popup',
height: 400,
width: 700
});
// Same as previous, without first parameter, open is the default sub-function
$(domContext).nosDialog({
contentUrl: 'path/url',
ajaxData: {
foo: 'bar'
},
title: 'title of the popup',
height: 400,
width: 700
});
// Popup containing an iframe width contentUrl href
$(domContext).nosDialog({
iframe: true
contentUrl: 'path/url',
title: 'title of the popup',
height: 400,
width: 700
});
// Popup containing <div> with the id 'id_de_div'
$('#id_de_div').nosDialog({
title: 'title of the popup',
height: 400,
width: 700
});
Will perform UI enhancements on DOM elements on all the children of js:data::$container using Wijmo and jQuery UI widgets.
Element with a .notransform CSS class will be left unchanged.
Input text: | Using the wijtextbox widget. |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Select: | Using the wijdropdown widget. |
||||||||||
Checkbox: | Using the wijcheckbox widget. |
||||||||||
Radio: | Using the wijradio widget. |
||||||||||
Expander: | Elements with the .expander CSS class using wijexpander widget.
You can set options with the data-wijexpander-options HTML attribute (JSON for additional settings).
|
||||||||||
Accordion: | Elements with CSS class .accordion using wijaccordion widget. |
||||||||||
Submit: | Using the button widget.
| You can set options with the data- HTML attributes (additional settings).
|
$(domContext).nosFormUI();
Will use the jquery-form plugin to submit any form inside js:data::$container using Ajax rather than the native browser action.
The default response data type is json, and the success and error callbacks functions will call $container.nosAjaxSuccess() and $container.nosAjaxError().
$(domContext).nosFormAjax();
Will use the jquery-validation plugin to perform inline validation on any form inside js:data::$container.
It’s already configured to display error messages nicely, and take into account some specificity from the UI enhancements (like the accordion).
Most forms are using it, since it’s part of the form’s standard layout.
$(domContext).nosFormValidate({});
Transforms an <input type="hidden"> element into a media selector UI in Media Center using plugin inputFileThumb.
Arguments: |
|
---|
$(:input).nosMedia();
$(:input).nosMedia({
mode: 'image',
inputFileThumb: {
title: 'a title'
}
});
See also
Displays a media, in a popup for images or in a new browser window for other documents (like PDF).
Arguments: |
|
---|
$.nosMediaVisualise({
path: 'url/of/media/',
image: true
});
Special API which delays the rendering of UI elements when they become visible. A lot of UI elements don’t initialise correctly when they are hidden (they can’t calculate sizes properly).
This is a function with sub-functions.
Arguments: |
|
---|
Triggers all functions bounded with nosOnShow.bind() for any children of $container.
Warning
You have to actually show the element before calling this function.
$(domContext).show().nosOnShow();
// Or
$(domContext).show().nosOnShow('show');
Binds a callback function which will be called only the one time (at the first display).
Arguments: |
|
---|
$(element).nosOnShow('one', function() {
$(this).widget();
});
Binds a callback function which will be called each time that the element becomes visible.
Arguments: |
|
---|
$(element).nosOnShow('bind', function() {
$(this).widgetRefresh(); // widgetRefresh don't exist, it's an example.
});
Manages back-office’s tabs. This is a function with sub-functions.
Arguments: |
|
---|
Open a new tab or re-open an existing tab if it has the same URL.
Arguments: |
|
---|
$(domContext).nosTabs('open', {
url: 'path/url',
iframe: false,
label: 'title',
labelDisplay: true,
iconUrl: 'path/icon.png',
iconSize: 16
});
// Call simplified
$(domContext).nosTabs({
url: 'path/url',
iframe: false,
label: 'title',
labelDisplay: true,
iconUrl: 'path/icon.png',
iconSize: 16
});
Adds a new tab, even if an existing has the same URL.
Arguments: |
|
---|
$(domContext).nosTabs(
'add',
{
url: 'path/url',
iframe: false,
label: 'title',
labelDisplay: true,
iconUrl: 'path/icon.png',
iconSize: 16
},
'end'
);
Close current tab (compared to the tab where is the DOM element in jQuery container).
$(domContext).nosTabs('close');
Update current js:data::$container tab. Can load a new URL.
Arguments: |
|
---|
$(domContext).nosTabs('update', {
url: 'path/url',
label: 'Title',
labelDisplay: true,
iconUrl: 'path/icon.png',
iconSize: 16
reload: true
});
Manage back-office’s toolbars. This is a function with sub-functions.
Arguments: |
|
---|
Adds an element to the toolbar of the current js:data::$container. If no toolbar exists, creates a new one on-the-fly.
Arguments: |
|
---|
$(domContext).nosToolbar('add', element, right_side);
\\ or
$(domContext).nosToolbar(element, right_side);
\\ Add a button, right side of toolbar
$(domContext).nosToolbar('<button>Exemple</button>', true);
\\ Add a link, left side of toolbar
var $a = $('<a href="#">Exemple</a>');
$(domContext).nosToolbar($a);
The back-office of Novius OS is one “big HTML page”. Actions performed in one tab can affect other tabs (ex: adding, modifying or deleting an item).
An event system has been established to enable the various interface elements to communicate with each other.
Dispatched events are executed immediately on the current active tab or popup (the one which has focus). For other tabs (or popups), they are executed only when the tab or popup becomes active / focused.
For the callback function to be triggered, listened and triggered events should not match exactly. The listened event can just match one property of the triggered event.
Arguments: |
|
---|
// Listen all events with name 'Nos\Model_Page'
$(domContext).nosListenEvent({
name: 'Nos\Model_Page'
}, function(event) {
// ...
}, 'caller');
// Listen all events with the 'Nos\Model_Page' name and 'insert' or 'delete' actions
$(domContext).nosListenEvent({
name: 'Nos\Model_Page',
action: ['insert', 'delete']
},
function(event) {
// ...
});
// Listen all events with the 'Nos\Model_Page' name and 'insert' or 'delete' actions,
// or events with the 'Nos\Model_Page' name and the 'main::en_GB' context
$(domContext).nosListenEvent([
{
name: 'Nos\Model_Page',
action: ['insert', 'delete']
},
{
name; 'Nos\Model_Page',
context; 'main::en_GB'
}
], function(event) {
// ...
});
Stop listening events for a specific caller. See caller param of nosListenEvent.
Arguments: |
|
---|
$(domContext).nosUnlistenEvent('caller');
Dispatches an event to all available dispatchers.
Arguments: |
|
---|
// Dispatch event, page with ID 4 has been create with 'main::en_GB' context
$.nosDispatchEvent({
name: 'Nos\Model_Page',
action: 'insert',
id: 4,
context: 'main::en_GB',
});
Triggered by the enhancer before displaying the form to the user.
Allows to modify the $fields and the $layout. The $item (Model_Form instance) and $enhancer_args (label_position, etc.) variables are read-only.
Parameters: |
|
---|
<?php
Event::register_function('noviusos_form::rendering', function(array &$args)
{
$fields =& $args['fields'];
$layout =& $args['layout'];
$form = $args['item']; // Instance of Nos\Form\Model_Form
$enhancer_args = $args['enhancer_args'];
// This is an exemple of what $layout contains
$layout = 'noviusos_form::foundation';
foreach ($fields as &$field) {
// This is an example of what $field contains
$field = array(
'label' => array(
'callback' => array('Form', 'label'),
'args' => array('Label:', 'technical_id', array(
'for' => 'field_technical_id',
)),
),
'field' => array(
'callback' => array('Form', 'input'),
'args' => array('field_name', 'field_value', array(
'id' => 'field_technical_id',
'class' => 'field_technical_css',
'title' => 'Label:',
'placeholder' => 'Label:',
'required' => 'required',
)),
),
'instructions' => array(
'callback' => 'html_tag',
'args' => array('p', array('class' => 'instructions'), 'Instructions for the user'),
),
'new_row' => true,
'new_page' => true,
'width' => 4,
'item' => $item, // Instance of Nos\Form\Model_Field
);
}
// ...
}
Same as noviusos_form::rendering, but only triggered for a form with the specified <virtual_name>.
Warning
This function must return an array containing the detected validation errors.
Additional data validation after submitting a form from the Form application.
Parameters: |
|
---|---|
Return array: | List of validation errors |
<?php
Event::register_function('noviusos_form::data_validation', function(&$data, $fields, $form) {
$errors = array();
// This will mark all fields as error
foreach ($data as $name => $value) {
$errors[$name] = '{{label}}: ‘{{value}}’ non valid.';
}
return $errors;
});
The messages can contain the {{label}} and {{value}} placeholders (they will be replaced appropriately).
Same as noviusos_form::data_validation, but only triggered for a form with the specified <virtual_name>.
Before saving the answer in the database
Parameters: |
|
---|---|
Return bool: | false to prevent saving the answer in the database |
<?php
Event::register_function('noviusos_form::before_submission', function(&$data, $form, $enhancer_args) {
// You can alter $data before saving them into the database
// Or you can return 'false' if you don't want the answer to be saved in the database
return false;
});
Same as noviusos_form::before_submission, but only triggered for a form with the specified <virtual_name>.
After the answer has been created (not saved in the DB yet)
Parameters: |
|
---|
<?php
Event::register('noviusos_form::after_submission', function($params) {
$answer = $params['answer'];
$enhancer_args = $params['enhancer_args'];
// ...
});
Same as noviusos_form::after_submission, but only triggered for a form with the specified <virtual_name>.
To modify configuration of slideshow, extend configuration file noviusos_slideshow::slideshow.
default_format: | The default format. flexslider-big by default. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
formats: |
|
You can add your own formats. Keys view and label are required in your format. If defined, the key config is passed to the displaying view.
You can configure Flexslider formats by extend configuration file noviusos_slideshow::formats/flexslider.
animation: | Select your animation type, fade or slide. Default fade. |
---|---|
slideDirection: | Select the sliding direction, horizontal or vertical. |
slideshow: | Boolean, animate slider automatically. Default true. |
slideshowSpeed: | Integer, set the speed of the slideshow cycling, in milliseconds. |
animationDuration: | |
Integer, set the speed of animations, in milliseconds. | |
directionNav: | Boolean, create navigation for previous/next navigation. |
controlNav: | Boolean, create navigation for paging control of each slide. Note: Leave true for manualControls usage. |
keyboardNav: | Boolean, allow slider navigating via keyboard left/right keys. |
mousewheel: | Boolean, allow slider navigating via mousewheel. |
prevText: | Set the text for the previous directionNav item. |
nextText: | Set the text for the next directionNav item. |
pausePlay: | Boolean, create pause/play dynamic element. |
pauseText: | Set the text for the pause pausePlay item. |
playText: | Set the text for the play pausePlay item. |
randomize: | Boolean, randomize slide order. |
slideToStart: | Integer, the slide that the slider should start on. Array notation (0 = first slide). |
animationLoop: | Boolean, should the animation loop? If false, directionNav will received “disable” classes at either end. |
pauseOnAction: | Boolean, pause the slideshow when interacting with control elements, highly recommended. |
pauseOnHover: | Boolean, pause the slideshow when hovering over slider, then resume when no longer hovering. |
controlsContainer: | |
Selector, declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken. | |
manualControls: | Selector, declare custom control navigation. Example would be ".flex-control-nav li" or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs. |
To modify configuration of Blog or News, extend respectively configuration files noviusos_blog::config or noviusos_news::config.
categories: |
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tags: |
|
||||||||||||||||
authors: |
|
||||||||||||||||
summary: |
|
||||||||||||||||
comments: |
|
||||||||||||||||
publication_date: | |||||||||||||||||
|
|||||||||||||||||
thumbnail: |
|
Adds the ability to use the Comment API on an a Nos\Orm\Model.
Returns: | An instance of Nos\Comments\Api`, configured for this item. |
---|
Returns and caches the number of comments related to one item
Returns: | Number of comments |
---|
Allow to enter a custom cached number of comments related to the item. Can be useful when adding or removing a comment for instance.
Parameters: |
|
---|
From a items’ list, retrieve the number of comments in an optimal way.
Parameters: |
|
---|
This behaviour adds a comments relation to retrieve all the published comments of the Model.
<?php
class Model_Monkey extends \Nos\Orm\Model
{
protected static $_behaviours = array(
'Nos\Comments\Orm_Behaviour_Commentable' => array(
),
);
}
Parameters: |
|
---|
Parameters: |
|
||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: | True if comment is added, false if not passed recaptcha, ‘none’ if not passed anti spam. |
Parameters: |
|
---|
Parameters: |
|
---|
Returns: | the API configuration. |
---|
Parameters: |
|
---|---|
Returns: | An array (to be used with Nos\Tools_RSS) |
Parameters: |
|
||
---|---|---|---|
Returns: | A Nos\Tools_RSS instance. |
Parameters: |
|
---|
To modify the comments API configuration, you need to extend the configuration file noviusos_comments::api.
default: |
|
||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setups: | Array. The setup id in key, array like default for the value. |
You can modify the default configuration, or add a setup for a specific model or a specific context.
If you want to change configuration for all cases:
<?php
array(
'default' => array(
'use_recaptcha' => true,
),
);
If you want to change configuration only for a specific model:
<?php
array(
'setups' => array(
'My\Namespace\Model_Item' => array(
'use_recaptcha' => true,
),
),
);
If you want to change configuration only for a specific context:
<?php
array(
'setups' => array(
'main::en_GB' => array(
'use_recaptcha' => true,
),
),
);
Note
If you want to activate Recaptcha, you have to install this package in local/packages.
Extends Nos\Orm\Model.
Retrieves the instance of the related item model, if it exists.
Returns: | Returns the Model instance, if it exists |
---|
Changes the user subscription status to new comments on an item.
Parameters: |
|
---|
Parameters: |
|
---|
View helper that allows to keep a consistent indentation when generating code.
Parameters: |
|
---|
Generates folders from a list of folder paths
Parameters: |
|
---|
Generates applications files (models, controllers, view), from information on the configuration file and the form values.
Parameters: |
|
---|
The configuration is organized in a key => value structure to allow eventually multiple configuration management; for instance, one key’s purpose could be to generate a basic application, an other key’s purpose could be to generate a template.