::main_controller()¶
-
static
Nos\Nos::
main_controller
¶ Returns: Instance of the main controller.
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.
cache
¶Boolean
for use of cache on front. By default is true
, except in DEVELOPMENT environment.
New in version 0.2.0.2.
cache_duration_page
¶Int
, number of seconds of cache validity. By default is 60
.
cache_model_properties
¶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
upload
¶Array
:
Parameters: |
|
---|
assets_minified
¶Boolean
for use of assets minified in back-office. By default is true
, except in DEVELOPMENT environment.
temp_dir
¶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:
default
setup. All characters ?
, :
, \
, /
, #
, [
, ]
, @
, &
and space are replaced by -
.
Transform to lower case. Remove trailing -
. Replace multiple -
by one.no_accent
setup. All accent characters are replaced by the equivalent character without accent.no_special
setup. All characters that are not a word character, a -
or a _
are replaced by -
.no_accent_and_special
setup. Combination of no_accent
and no_special
setups.A setup value is an array. This array can contains :
key => value
, in this case, all occurrence of key
in the slug are replaced by value
.replacement
and a key flags
for the regular expression.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.
cellFormatter
is an associative array.cellFormatter
, just use arrays.cellFormatter
. This way, someone else can delete or modify it by overloading configuration.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
.
app_a
application extends app_b
application, especially config/common.config.php
, lang/common.lang.php
and views/common.view.php
.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:
layout
array (see below) ;left
and top
in CSS) ;width
and height
in CSS.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 :
|
screenshot: | Optional. URL of the image representing the template. |
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',
),
),
),
);
Templates are not used directly in Novius OS. Template variations by context is used.
See also
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: |
|||||
sorting_callback: | |||||
A closure function taking two parameters: the |
|||||
multiContextHide: | |||||
Hide grid column when items are filtered on more than one contexts. |
|||||
isSafeHtml: | If |
||||
value: | A closure function taking current item |
||||
cellFormatters: | Associative array of cellFormatters for formatting column display. |
||||
preview_url: | allow to custom url of the current item (used through “visualise” action).
|
<?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 |
||||||||
red: | Is it a red action? (especially used for ‘Delete’) |
||||||||
align: | Alignment of the button. Can be a string ( |
||||||||
targets: | Where is the action displayed? This has no effect if the action is not
|
||||||||
disabled: | Callback function or array of callback functions (the one taken into account is the first which doesn’t
return |
||||||||
visible: | Callback function or array of callback functions (the one taken into account is the first which doesn’t
return
|
<?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:
controller_base_url
: URL of the crud controllermodel_label
: generated from model class name_id
: ID of the item_title
: Title of the item_context
: if the item has the Contextable
behaviourAdditionally, 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_by: | |
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: |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
input_end: | Name of the input for the end date. Default value: |
||||||||||
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 |
insert
and update
must contain plain string
value ;update
can either contain a plain string
value, or a callable
taking one argument: the $item
;labels.update
is the item’s title.<?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:
$item
: the instance of the model currently edited (or added / translated).$fieldset
: the form instance which holds all fields definition.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'),
),
);
type = submit
generates <input type="submit">
type = button
generates <input type="button">
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:
$role
: Current role
for which the permissions are applicable to.We (kindly) provide a native view to cover basic usage: Permissions standalone.
The configuration of a template variation is assumed to be application_name::variation/template_name
.
init: | Optional. A callback function. Call to initialize a |
||||
---|---|---|---|---|---|
admin: | Array
See also |
||||
layout: | Optional. A callback function. If exist, the return value overload the template configuration. Take the |
||||
cols: | Optional. A callback function. If exist, the return value overload the template configuration. Take the |
||||
rows: | Optional. A callback function. If exist, the return value overload the template configuration. Take the |
||||
file: | Optional. A callback function. If exist, the return value overload the template configuration. Take the |
||||
screenshot: | Optional. A callback function. If exist, the return value overload the template configuration. Take the |
See also
<?php
return array(
'cols' => function($tpvar) {
return int_val($tpvar->tpvar_data['cols']);
},
'admin' => array(
'layout' => array(
'content' => array(
'expander' => array(
'view' => 'nos::form/expander',
'params' => array(
'title' => __('Configuration'),
'options' => array(
'allowExpand' => false,
),
'content' => array(
'view' => 'nos::form/fields',
'params' => array(
'fields' => array(
'menus->principal->menu_id',
'cols',
),
),
),
),
),
),
),
'fields' => array(
'menus->principal->menu_id' => array(
'label' => __('Menu'),
'renderer' => 'Nos\Renderer_Item_Picker',
'renderer_options' => array(
'model' => 'Nos\Menu\Model_Menu',
'appdesk' => 'admin/noviusos_menu/menu/appdesk',
'defaultThumbnail' => 'static/apps/noviusos_menu/img/64/menu.png',
'texts' => array(
'empty' => __('No menu selected'),
'add' => __('Pick a menu'),
'edit' => __('Pick another menu'),
'delete' => __('Un-select this menu'),
),
),
),
'cols' => array(
'label' => __('Column number'),
'form' => array(
'type' => 'number',
),
),
),
),
);
All native constants of FuelPHP are available but links to specific Novius OS directories.
See also
NOSROOT
¶Path where Novius OS is installed.
PUBLIC_DIR
¶Contains the name of the public directory. Initialized to public
if not set.
New in version 4.2.
NOSPATH
¶Path of Novius OS core: NOSROOT/novius-os/framework/
.
APPPATH
¶Overload of the native FuelPHP’s constant. Path to the application directory: NOSROOT/local/
.
COREPATH
¶Overload of the native FuelPHP’s constant. Path to the FuelPHP core directory: NOSROOT/novius-os/fuel-core/
.
DOCROOT
¶Overload of the native FuelPHP’s constant. Path to the location where the startup script is: NOSROOT/public/
.
PKGPATH
¶Overload of the native FuelPHP’s constant. Path to the packages directory: NOSROOT/novius-os/packages/
.
__
($message, $default = null)¶Retrieves a translation from the last loaded dictionary.
Parameters: |
|
---|---|
Returns: | The translation or |
n__
($singular, $plural, $n = false)¶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 |
___
($group, $message, $default = null)¶Retrieves a translation from a specific dictionary.
Parameters: |
|
---|---|
Returns: | The translation or |
Nos\Orm\
Model
¶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 totrue
if you want that this property stores a null value when it receives empty string.
Nos\Orm\Model::$
title_property
¶$iitem
as parameter).title
, label
or name
in its name, or (as last resort) the first varchar
.Nos\Orm\Model::$
attachment
¶Defines the attachments of a model. Attachment is a special type of relations created for Novius OS. See Nos\Attachment
.
Nos\Orm\Model::$
providers
¶Defines the behaviours of model.
Relation: | Required. Wherein the relation is based on the provider. Must be a multiple relation and have cascade_save activate. |
---|---|
Value_property: | Optional. Set to value if empty. The fields containing the provider value. |
Key_property: | Optional. Set to key if empty. The fields containing the provider key. |
Value_relation: | Optional. If set, must contains a single relation name and then the provider value become the model. |
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
, providers
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;
},
);
Nos\Orm\Model::$
linked_wysiwygs
¶Nos\Model_Wysiwyg
Nos\Orm\Model::$
linked_medias
¶Nos\Media\Model_Link
Warning
Don’t use these relations directly, we created providers for them.
Nos\Orm\Model::$
medias
¶Provider 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);
Nos\Orm\Model::$
wysiwygs
¶Provider 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->wysiwygs->summary = null; // Remove a wysiwyg from an item
// or
unset($item->wysiwygs->summary);
Nos\Orm\Model::
title_property
¶Returns: | Title property of model. See Model::$title_property . |
---|
Nos\Orm\Model::
table
¶Returns: | The DB table name of model. |
---|
Nos\Orm\Model::
behaviours
($specific = null, $default = null)¶Nos\Orm\Model::
add_properties
($properties)¶Parameters: |
|
---|
Nos\Orm\Model::
addRelation
($type, $name, array $options = array())¶Add a relation to model
Parameters: |
|
---|---|
Throws: |
|
Nos\Orm\Model::
providers
($specific = null, $default = null)¶Get the class’s providers and what they provide
Parameters: |
|
---|---|
Throws: |
|
Returns: | The specific provider if it exist and is requested or the defaut value. Else, array of all providers. |
Nos\Orm\Model::
addProvider
($name, array $properties)¶Add a provider to model
Parameters: |
|
---|---|
Throws: |
|
Nos\Orm\Model::
configModel
¶Returns: | Array configurations of the model. |
---|
Nos\Orm\Model::
getApplication
¶Returns: | Application name of the model. |
---|
Nos\Orm\Model::
event
($method, $args = array())¶Trigger an event (caught by behaviours) on the item.
Parameters: |
|
---|
Nos\Orm\Model::
eventStatic
($method, $args = array())¶Trigger an event (caught by behaviours) on the model class.
Parameters: |
|
---|
Nos\Orm\Model::
prefix
¶Returns: | Prefix of column name. Computed from the primary key name (everything before the first _ character). |
---|
Nos\Orm\Model::
title_item
()¶Returns: | Returns the item’s title, calculated from Model::$title_property . |
---|
Nos\Orm\Model::
pick
($column[, $column[, $column[, ...]]])¶Parameters: |
|
---|---|
Returns: | Returns the first non empty column. Will add column prefix (see |
Nos\Page\
Model_Page
¶Extends Nos\Orm\Model
.
Nos\Page\Model_Page::
TYPE_CLASSIC
¶Nos\Page\Model_Page::
TYPE_EXTERNAL_LINK
¶Possible values of the page_type
column.
Nos\Page\Model_Page::$
children
¶Model_Page
Nos\Page\Model_Page::$
parent
¶Model_Page
Nos\Page\Model_Page::
htmlAnchor
($attributes = array())¶Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, page URL in href and page title in text. |
Nos\Page\Model_Page::
url
($params = array())¶Parameters: |
|
||
---|---|---|---|
Returns: | The absolute URL of the page |
Nos\Media\
Model_Media
¶Extends Nos\Orm\Model
.
Nos\Media\Model_Media::$
folder
¶Model_Folder
Nos\Media\Model_Media::
deleteFromDisk
()¶Delete the original media file from the disk.
Nos\Media\Model_Media::
deleteCache
()¶Delete all the cached versions (thumbnails) of the media files from the disk.
Nos\Media\Model_Media::
path
()¶Returns: | Private absolute media file path. |
---|
Nos\Media\Model_Media::
htmlImg
($params = array())¶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.
Nos\Media\Model_Media::
htmlImgResized
($max_width = null, $max_height = null, $params = array())¶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.
Nos\Media\Model_Media::
htmlAnchor
($attributes = array())¶Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, media URL in href and media title in text. |
Nos\Media\Model_Media::
url
($absolute = true)¶Parameters: |
|
---|
Nos\Media\Model_Media::
urlResized
($max_width = 0, $max_height = 0, $absolute = true)¶Parameters: |
|
---|---|
Returns: | If the media file is an image, media URL for specify size parameters. |
Nos\Media\Model_Media::
isImage
()¶Returns: | True or false , depend if media is an image. |
---|
Nos\Media\Model_Media::
getToolkitImage
()¶Returns: | Returns a Nos\Toolkit_Image based on the media if is an image, False otherwise. |
---|
Nos\Media\
Model_Link
¶Model_Media
and a Nos\Orm\Model
.Nos\Orm\Model
.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.
Nos\Media\Model_Link::$
media
¶Model_Media
Nos\Media\
Model_Folder
¶Extends Nos\Orm\Model
.
Nos\Media\Model_Folder::$
children
¶Model_Folder
Nos\Media\Model_Folder::$
media
¶Model_Media
Nos\Media\Model_Folder::$
parent
¶Model_Folder
Nos\Media\Model_Folder::
deleteFromDisk
()¶Delete the folder and all its content (recursively).
Nos\Media\Model_Folder::
deleteCache
()¶Delete all the public and cached entries (image thumbnails) of this folder
Nos\Media\Model_Folder::
path
($file = '')¶Parameters: |
|
---|---|
Returns: | Absolute folder path. |
Nos\Media\Model_Folder::
count_media
()¶Returns: | Number of media contained in the folder and all its sub-folders. |
---|
Nos\Media\Model_Folder::
count_media_usage
()¶Returns: | Number of media in use (by the applications) contained in this folder and all its sub-folders. |
---|
Nos\User\
Model_User
¶Extend Nos\Orm\Model
.
Nos\User\Model_User::$
roles
¶Model_Role
Nos\User\Model_User::
check_permission
($permission_name, $category_key = null)¶Parameters: |
|
---|---|
Returns: |
|
Nos\User\
Model_Role
¶Extend Nos\Orm\Model
.
Nos\User\Model_Role::$
users
¶Model_User
Nos\User\Model_Role::
checkPermission
($permission_name, $category_key = null, $allow_empty = false)¶Check whether a permissions exists with the given category.
Parameters: |
|
---|---|
Returns bool: |
|
Nos\User\Model_Role::
listPermissionCategories
($permission_name)¶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: |
|
Nos\User\Model_Role::
checkPermissionOrEmpty
($permission_name, $category_key = null)¶Alias to Nos\User\Model_Role::checkPermission
with $allow_empty = true
.
Nos\User\Model_Role::
checkPermissionExists
($permission_name, $category_key = null, $allow_empty = false)¶Alias to Nos\User\Model_Role::checkPermission
.
Nos\User\Model_Role::
checkPermissionExistsOrEmpty
($permission_name, $category_key = null, $allow_empty = false)¶Alias to Nos\User\Model_Role::checkPermission
with $allow_empty = true
.
Nos\User\Model_Role::
checkPermissionIsAllowed
($permission_name, $allow_empty = false)¶Check against a binary permission (without categories).
Parameters: |
|
---|---|
Returns bool: |
|
Nos\User\Model_Role::
checkPermissionAtLeast
($permission_name, $threshold, $value_when_empty = 0)¶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: |
|
Nos\User\Model_Role::
checkPermissionAtMost
($permission_name, $threshold, $value_when_empty = 0)¶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: |
|
Nos\User\Model_Role::
getPermissionValue
($permission_name, $default = 0)¶Retrieve the value of a given permission.
Parameters: |
|
---|---|
Returns string: |
Nos\Template\Variation\
Model_Template_Variation
¶Extends Nos\Orm\Model
.
Nos\Template\Variation\Model_Template_Variation::$
pages
¶Nos\Page\Model_Page
Nos\Menu\Model_Menu
Nos\Template\Variation\Model_Template_Variation::
configCompiled
($reload = false)¶Parameters: |
|
---|---|
Returns: | Returns the configuration array of the template variation. |
Nos\Template\Variation\Model_Template_Variation::
templateConfig
()¶Returns: | Returns the configuration array of the template use by the variation. |
---|
Nos\Template\Variation\Model_Template_Variation::
getTemplateVariationDefault
($context)¶Parameters: |
|
---|---|
Returns: | The default |
Nos\
Model_Wysiwyg
¶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.
Nos\
Model_Content_Nuggets
¶Extends Nos\Orm\Model
.
Nos\Model_Content_Nuggets::
DEFAULT_CATCHER
¶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. |
Nos\
Orm_Behaviour_Author
¶Keeps track of who created an item and who updated it. Great to use in combination of Observer_CreatedAt and Observer_UpdatedAt.
Nos\Orm_Behaviour_Author::$
created_by_property
¶Column used to store the user ID when the item is created. Its data type must be unsigned int
.
Nos\Orm_Behaviour_Author::$
updated_by_property
¶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',
),
);
}
Nos\
Orm_Behaviour_Contextable
¶Allows aNos\Orm\Model
to be bound to a context.
See also
Nos\Orm_Behaviour_Contextable::$
context_property
¶Required.
Column used to store the item’s context. Its data type must be varchar(25)
.
Nos\Orm_Behaviour_Contextable::$
default_context
¶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',
),
);
}
Nos\
Orm_Behaviour_Publishable
¶Adds a publication status on a Nos\Orm\Model
. 2 modes are available:
Nos\Orm_Behaviour_Publishable::$
publication_state_property
¶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
:
Nos\Orm_Behaviour_Publishable::$
publication_start_property
¶Required for date range mode.
Column used to store the publication start date. Its data type must be datetime
.
Nos\Orm_Behaviour_Publishable::$
publication_end_property
¶Required for date range mode.
Column used to store the publication end date. Its data type must be datetime
.
Nos\Orm_Behaviour_Publishable::$
options
¶allow_publish: | Callback function or array of callback functions. If any returns false then the item will be
restricted from publication. |
---|
Nos\Orm_Behaviour_Publishable::
published
()¶Returns: | true or false depending on whether the item is currently published or not. |
---|
Nos\Orm_Behaviour_Publishable::
planificationStatus
()¶Returns: | 0 (not published), 1 (published) or 2 (scheduled). |
---|
Nos\Orm_Behaviour_Publishable::
publicationStart
()¶Returns: | the publication start date, MySQL format. |
---|
Nos\Orm_Behaviour_Publishable::
publicationEnd
()¶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',
),
);
}
Nos\
Orm_Behaviour_Sharable
¶Adds the sharable behaviour on a Nos\Orm\Model
.
Nos\Orm_Behaviour_Sharable::$
data
¶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
.
Nos\Orm_Behaviour_Sharable::
get_default_nuggets
()¶Returns: | Array containing the default content nuggets of an item. |
---|
Nos\Orm_Behaviour_Sharable::
get_catcher_nuggets
($catcher = Model_Content_Nuggets::DEFAULT_CATCHER)¶Parameters: |
|
---|---|
Returns: | The |
Nos\Orm_Behaviour_Sharable::
get_sharable_property
($property = null, $default = null)¶Parameters: |
|
---|---|
Returns: |
|
Nos\Orm_Behaviour_Sharable::
data_catchers
()¶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 thedata catcher
names).
Nos\Orm_Behaviour_Sharable::
possible_medias
()¶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.
Nos\Orm_Behaviour_Sharable::
get_nugget_content
($catcher)¶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
Acontent 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();
},
),
),
),
),
);
Nos\
Orm_Behaviour_Sortable
¶Makes a Nos\Orm\Model
sortable.
Nos\Orm_Behaviour_Sortable::$
sort_property
¶Required.
Column name use for save sort index. Column must have type double
.
Nos\Orm_Behaviour_Sortable::$
sort_order
¶ASC
(default) ou DESC
Nos\Orm_Behaviour_Sortable::$
sort_twins
¶True
by default. If false
and the model is twinnable, the sorting won’t be common to all contexts.
Nos\Orm_Behaviour_Sortable::
move_before
($item)¶Parameters: |
|
---|
Nos\Orm_Behaviour_Sortable::
move_after
($item)¶Parameters: |
|
---|
Nos\Orm_Behaviour_Sortable::
move_to_last_position
()¶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);
Nos\
Orm_Behaviour_Tree
¶Nos\Orm\Model
behaves like a Tree.Nos\Orm_Behaviour_Tree::$
level_property
¶Column used to store the item’s depth inside the tree. Data type must be int
.
Nos\Orm_Behaviour_Tree::
get_parent
()¶Returns: | Model parent item, if it exists, null otherwise. |
---|
Nos\Orm_Behaviour_Tree::
set_parent
($new_parent)¶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: |
|
Nos\Orm_Behaviour_Tree::
find_children
($where = array(), $order_by = array(), $options = array())¶Returns: | All direct children of item. |
---|
Children can be filter and / or sort by parameters.
$options
parameter are passed to ->find()
like that:<?php
$options = \Arr::merge($options, array(
'where' => $where,
'order_by' => $order_by,
));
Nos\Orm_Behaviour_Tree::
find_children_recursive
($include_self = true)¶Parameters: |
|
---|---|
Returns: | All children of item and their descendants. |
Nos\Orm_Behaviour_Tree::
find_root
()¶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,
),
);
}
Nos\
Orm_Behaviour_Twinnable
¶Nos\Orm_Behaviour_Contextable
.Nos\Orm_Behaviour_Contextable
for configuration and methods.Nos\Orm_Behaviour_Twinnable::$
common_id_property
¶Required.
Column used to store the common ID between twinned items. Data type must be int
.
Nos\Orm_Behaviour_Twinnable::$
is_main_property
¶Required.
Column used to store if the item is the main item among twin items. Data type must be boolean
.
Nos\Orm_Behaviour_Twinnable::$
common_fields
¶Array of fields which are common to all context twins.
This behaviour adds 2 providers to link WYSIWYGs and medias to context twins.
Provider for Nos\Media\Model_Link
linked to context twins.
<?php
$item->shared_medias_context->avatar; // Get a Model_Link named 'avatar'
$item->shared_medias_context->avatar->media; // Get Model_Media named 'avatar'
$item->shared_medias_context->cv = $Model_Media; // Attach a Model_Media named 'cv'
$item->shared_medias_context->cv = null; // Detach a media from items context twins
// or
unset($item->shared_medias_context->cv);
Provider for Nos\Model_Wysiwyg
linked to context twins.
<?php
$item->shared_wysiwygs_context->content; // Get a Model_Wysiwyg named 'content'
$item->shared_wysiwygs_context->content->wysiwyg_text; // Get content of Model_Wysiwyg named 'content'
$item->shared_wysiwygs_context->summary = 'foo'; // Set a Model_Wysiwyg named 'content', with content 'foo'.
$item->shared_wysiwygs_context->summary = null; // Remove a wysiwyg from items context twins
// or
unset($item->shared_wysiwygs_context->summary);
Nos\Orm_Behaviour_Twinnable::
hasCommonFields
¶Returns: | True if model has common fields, medias or WYSIWYGs. |
---|
Nos\Orm_Behaviour_Twinnable::
isCommonField
($name)¶Parameters: |
|
---|---|
Returns: |
|
Nos\Orm_Behaviour_Twinnable::
delete_all_context
()¶Removes all items twinned to the current item, including the current item itself.
Nos\Orm_Behaviour_Twinnable::
is_main_context
()¶Returns: | True if item is the main among twin items. |
---|
Nos\Orm_Behaviour_Twinnable::
find_context
($context)¶Parameters: |
|
---|---|
Returns: | A twinned item, or an array of twinned items, |
Nos\Orm_Behaviour_Twinnable::
find_main_context
()¶Returns: | The main item among the twins. |
---|
Alias for ->find_context('main')
.
Nos\Orm_Behaviour_Twinnable::
find_other_context
($filter = array())¶Parameters: |
|
---|---|
Returns: | Array of twin items, current item exclude. |
Nos\Orm_Behaviour_Twinnable::
get_all_context
()¶Returns: | Array of all twinned contexts, including the one of the current item. |
---|
Nos\Orm_Behaviour_Twinnable::
get_other_context
($filter = array())¶Parameters: |
|
---|---|
Returns: | Array of all twinned contexts ID, excluding the one of the current item. |
Nos\Orm_Behaviour_Twinnable::
get_possible_context
()¶Returns: | Array of possible contexts ID for current item. |
---|
Nos\Orm_Behaviour_Twinnable::
findMainOrContext
($context, array $options = array())¶Parameters: |
|
---|---|
Returns: | Array of items, like |
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(),
),
);
}
Nos\
Orm_Behaviour_Urlenhancer
¶Nos\Orm\Model
displayed in the front-office by an URL Enhancer.Nos\Orm_Behaviour_Urlenhancer::
urls
($params = array())¶Parameters: | |
---|---|
Returns: | Associative array of all possibles URLs for this item
|
Nos\Orm_Behaviour_Urlenhancer::
url
($params = array())¶Parameters: |
|
||||
---|---|---|---|---|---|
Returns: | Absolute URL of item or |
Nos\Orm_Behaviour_Urlenhancer::
url_canonical
($params = array())¶Parameters: |
|
---|---|
Returns: | Absolute canonical URL of item or |
Alias for ->url(array('canonical' => true))
.
If the item is sharable
, returns the URL set in the shared data (content nugget)
.
Nos\Orm_Behaviour_Urlenhancer::
preview_url
()¶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))
.
Nos\Orm_Behaviour_Urlenhancer::
deleteCacheItem
()¶Delete the cache of the pages containing this item only (this will not delete the cache for the whole enhancer).
Nos\Orm_Behaviour_Urlenhancer::
deleteCacheEnhancer
()¶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.
Nos\Orm_Behaviour_Urlenhancer::
htmlAnchor
($attributes = array())¶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'),
),
);
}
Nos\
Orm_Behaviour_Virtualname
¶title_property
of the model if it is not specified.IfOrm_Behaviour_Virtualname::$unique
is set,->save()
method can throw anException
if slug already in use.
Nos\Orm_Behaviour_Virtualname::$
virtual_name_property
¶Required. Column used to store the slug.
Nos\Orm_Behaviour_Virtualname::$
unique
¶true
, false
or 'context'
if uniqueness must be checked by context.
Nos\Orm_Behaviour_Virtualname::
virtual_name
($virtual_name = null)¶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. |
Nos\Orm_Behaviour_Virtualname::
friendly_slug
($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',
),
);
}
Nos\
Orm_Behaviour_Virtualpath
¶Nos\Orm_Behaviour_Virtualname
.See also
Nos\Orm_Behaviour_Virtualname
for configuration and methods.
Nos\Orm_Behaviour_Virtualpath::$
virtual_path_property
¶Required. Column name use for save virtual path.
Nos\Orm_Behaviour_Virtualpath::$
extension_property
¶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.
Nos\Orm_Behaviour_Virtualpath::$
extension_property
Required. Name of the parent relation use to generate the first part of the virtual path.
Nos\Orm_Behaviour_Virtualpath::
virtual_path
($dir = false)¶Parameters: |
|
---|---|
Returns: | Virtual path of the item. |
Nos\Orm_Behaviour_Virtualpath::
extension
()¶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
.
dataset
(&$dataset)¶Trigger when fill dataset
of an item.
Parameters: |
|
---|
form_fieldset_fields
(&$config)¶Trigger when build a fieldset
from an item.
Parameters: |
|
---|
form_processing
($data, &$json_response)¶Trigger when receive a form
response.
Parameters: |
|
---|
wysiwygOptions
(&$options)¶Trigger when construct WYSIWYG options for an item.
Parameters: |
|
---|
gridQueryConfig
(&$config)¶Trigger when building a query configuration for a grid of model’s items.
Parameters: |
|
---|
New in version 4.3.
gridQuery
($config, &$query)¶Trigger when building a query for a grid of model’s items.
Parameters: |
|
---|
gridItem
($object, &$item)¶Trigger when building a grid’s item.
Parameters: |
|
---|
gridAfter
($config, $objects, &$items)¶Trigger after execute query for a grid of model’s items.
Parameters: |
|
---|
commonConfig
(&$config)¶Trigger when building a common configuration of a model.
Parameters: |
|
---|
crudConfig
(&$config, $controller)¶Trigger when building the configuration of the CRUD controller of the model.
Parameters: |
|
---|
crudFields
(&$fields, $controller)¶Trigger when building the fields for the CRUD controller of the model.
Parameters: |
|
---|
buildRelations
()¶Trigger when building relations of the model.
buildProviders
()¶Trigger when building providers of the model.
before_query
(&$options)¶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. 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(),
);
Nos\
Attachment
¶Binds a file to an object.
Nos\Attachment::$
attached
¶Required. The attached ID.
Nos\Attachment::$
dir
¶Required.
Directory path, where the attachment is stored. Relative to local/data/files
.
Nos\Attachment::$
alias
¶An URL alias to access the directory path.
Nos\Attachment::$
extensions
¶Array of valid files extensions.
Nos\Attachment::$
image
¶If true
, accepts only files with an image extension. Same that extensions
set to array('jpg', 'gif', 'png', 'jpeg')
.
Nos\Attachment::$
check
¶Used it to make the attachment private. A callback function to check permissions against. It takes a single parameter: Attachement instance.
Nos\Attachment::
forge
($attached, $config)¶Parameters: |
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns: | A new |
Nos\Attachment::
newFile
()¶Returns: | Get the new attachment file path if one, false if no file exists. |
---|
Nos\Attachment::
path
()¶Returns: | Get the attachment file path or false if no file exists. |
---|
Nos\Attachment::
filename
()¶Returns: | Get the attachment filename or false if no file exists. |
---|
Nos\Attachment::
extension
()¶Returns: | Get the attachment extension or false if no file exists. |
---|
Nos\Attachment::
isImage
()¶Returns: | True if the Attachment is an image, false otherwise. |
---|
Nos\Attachment::
url
($absolute = true)¶Parameters: |
|
---|---|
Returns: | Get the attachment url or |
Nos\Attachment::
urlResized
($max_width = 0, $max_height = 0, $absolute = true)¶Parameters: |
|
---|---|
Returns: | Get the resized url for the Attachment or |
Nos\Attachment::
htmlAnchor
($attributes = array())¶Parameters: |
|
---|---|
Returns: | Returns an HTML anchor tag with, by default, attachment URL in href and attachment filename in text. |
Nos\Attachment::
getToolkitImage
()¶Returns: | Returns a Nos\Toolkit_Image based on the attachment if is an image, False otherwise. |
---|
Nos\Attachment::
set
($file, $filename = null)¶Parameters: |
|
---|---|
Returns: | Set a new Attachment file. |
Throws: | FuelCoreFileAccessException if new file have a not allowed extension. |
Nos\Attachment::
save
()¶Save a new Attachment file
Returns: | True if the Attachment have been saved, false otherwise. |
---|
Nos\Attachment::
delete
()¶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();
Config
¶Extends FuelPHP config class and provides new functionalities.
Config::
mergeWithUser
($key, $config)¶Parameters: |
|
---|---|
Returns: | The configuration merged. |
Merge configuration with the one saved in user in the key $key.
Config::
getDbName
($key)¶Parameters: |
|
---|---|
Returns: | Valid user configuration key. |
Config::
configFile
($class)¶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. |
Config::
metadata
($application_name)¶Parameters: |
|
---|---|
Returns: | The metadata configuration. |
Config::
application
($application_name)¶Parameters: |
|
---|---|
Returns: | The global configuration. |
Config::
actions
($params = array())¶Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | The filtered actions. |
Config::
getActionDisabledState
($disabled, $item)¶Parameters: |
|
---|---|
Returns: | The processed disabled value. |
Config::
getActionDisabledState
($value, $positive_value, $argument_1, $argument_2, ...)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
Config::
placeholderReplace
($to_be_replaced, $placeholders, $remove_unset = true)¶Parameters: |
|
---|---|
Returns: | The replaced value. |
Nos\
Controller_Front
¶Novius OS front-office controller
Use Nos::main_controller
to retrieve its instance and call the methods.
Nos\Controller_Front::
getPage
()¶Returns: | Current Model_Page displayed. |
---|
Nos\Controller_Front::
getUrl
()¶Returns: | Current absolute URL. |
---|
Nos\Controller_Front::
getPageUrl
()¶Returns: | Relative (to Controller_Front::getContextUrl ) URL of the current page. |
---|
Nos\Controller_Front::
getEnhancedUrlPath
()¶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
.
Nos\Controller_Front::
getEnhancerUrl
()¶Returns: | Part of the URL processed by the URL enhancer.
False if no current URL enhancer. |
---|
Nos\Controller_Front::
getItemDisplayed
()¶Returns: | The current item displayed. |
---|
New in version 4.1.
Nos\Controller_Front::
setItemDisplayed
(OrmModel $item, array $properties = array(), array $templates = array())¶
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.
Nos\Controller_Front::
setBaseHref
($base_href)¶Parameters: |
|
---|
Nos\Controller_Front::
setTitle
($title, $template = null)¶Parameters: |
|
---|
Nos\Controller_Front::
setH1
($title, $template = null)¶
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.
Nos\Controller_Front::
setMetaDescription
($meta_description, $template = null)¶Parameters: |
|
---|
Nos\Controller_Front::
setMetaKeywords
($meta_keywords, $template = null)¶Parameters: |
|
---|
Nos\Controller_Front::
setMetaRobots
($meta_robots, $template = null)¶Parameters: |
|
---|
Nos\Controller_Front::
addMeta
($meta)¶Parameters: |
|
---|
Nos\Controller_Front::
addJavascript
($url, $footer = true)¶Parameters: |
|
---|
Nos\Controller_Front::
addJavascriptInline
($js, $footer = true)¶Parameters: |
|
---|
Nos\Controller_Front::
addCss
($url)¶Parameters: |
|
---|
Nos\Controller_Front::
addCssInline
($css)¶Parameters: |
|
---|
Nos\Controller_Front::
isPreview
()¶Returns: | Boolean, true if current page is requested in the preview mode. |
---|
Nos\Controller_Front::
disableCaching
()¶Disable caching and cache retrieve of the current page.
Nos\Controller_Front::
setCacheDuration
($cache_duration)¶Parameters: |
|
---|
Nos\Controller_Front::
setStatus
($status)¶Parameters: |
|
---|
Nos\Controller_Front::
setHeader
($name, $value, $replace = true)¶Add or replace a header to current response. Headers will be saved in cache.
Parameters: |
|
---|
Nos\Controller_Front::
getCustomData
($item, $default = null)¶Returns a (dot notated) custom data of the current process.
Parameters: |
|
---|---|
Returns: | The custom data or default if not found. |
Nos\Controller_Front::
setCustomData
($item, $value, $cached = false)¶Sets a (dot notated) custom data to the current process.
Parameters: |
|
---|
Nos\Controller_Front::
sendContent
($content)¶Replace the template by a specific content and stop treatments
Parameters: |
|
---|
Nos\Controller_Front::
addCacheSuffixHandler
($handler)¶Add a cache suffix handler for the current page
Parameters: |
|
---|---|
Returns: | The cache instance if the cache path have changed, null otherwise. |
Nos\
DataCatcher
¶Nos\DataCatcher::
TYPE_TITLE
¶Nos\DataCatcher::
TYPE_URL
¶Nos\DataCatcher::
TYPE_TEXT
¶Nos\DataCatcher::
TYPE_IMAGE
¶Nos\
FrontCache
¶Manage front cache
Nos\FrontCache::
callHmvcUncached
($uri, $args = array())¶Write a HMVC call in cache for after cache execution.
Parameters: |
|
---|
See also
Nos\FrontCache::
viewForgeUncached
($file = null, $data = null, $auto_filter = null)¶Write a View forge in cache for after cache execution.
Parameters: |
|
---|
Nos\
I18n
¶Provides the translation related functions.
Nos\I18n::
setLocale
($locale)¶Configure the locale to use for translations.
Parameters: |
|
---|
Nos\I18n::
load
($file)¶Loads a dictionary for the current locale.
Parameters: |
|
---|
Nos\I18n::
get
($message, $default = null)¶Retrieves a translation from the last loaded dictionary.
Parameters: |
|
---|---|
Returns: | The translation or |
Nos\I18n::
gget
($file, $message, $default = null)¶Retrieves a translation from a specific dictionary.
Parameters: |
|
---|---|
Returns: | The translation or |
Warning
The dictionary must have been loaded manually before.
Nos\I18n::
nget
($singular, $plural, $n)¶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 |
Nos\I18n::
gget
($group, $singular, $plural, $n)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.
Nos\I18n::
current_dictionary
($list)¶Set the current dictionary
Parameters: |
|
---|
Nos\I18n::
dictionary
($files)¶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');
Nos\Menu\
Menu_Item
¶This class is use to build Nos\Menu\Menu_Item_Driver
.
Nos\Menu\Menu_Item::
forge
($item)¶Parameters: |
|
---|---|
Returns: | A |
Nos\Menu\Menu_Item::
drivers
¶Returns: | An array of all available Nos\Menu\Menu_Item_Driver . Driver name in key, driver configuration in value. |
---|
Nos\Menu\
Menu_Item_Driver
¶This is an abstract class that must be extend by all declared drivers of Nos\Menu\Model_Menu_Item
.
To declare a driver of Nos\Menu\Model_Menu_Item
, you have to extend the noviusos_menu::config
configuration file.
Nos\Menu\Menu_Item_Driver::
title
()¶Returns: | The title of the Nos\Menu\Model_Menu_Item |
---|
Nos\Menu\Menu_Item_Driver::
html
(array $params = array())¶view
in his config, this view is forged with 2 parameters params
and item_driver
div
tag with html_tag
function with $params
and the driver title in parametersParameters: |
|
---|---|
Returns: | A HTML representation of the |
Nos\Menu\Menu_Item_Driver::
config
($reload = false)¶The config file is assumed to be application_name::driver_path
.
Parameters: |
|
---|---|
Returns array: | The configuration of the driver |
See also
Nos\
Migration
¶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.
Nos\Migration::
up
()¶Tries to execute a sql file with same path (if migration filename is 001_install.php, it will try to execute 001_install.sql).
Nos\
Nos
¶Provides static methods useful in Novius OS.
Nos\Nos::$
entry_point
¶The Novius OS entry point. Equal to one of the following constants.
Nos\Nos::
ENTRY_POINT_ADMIN
¶Nos\Nos::
ENTRY_POINT_FRONT
¶Nos\Nos::
ENTRY_POINT_404
¶Nos\Nos::
ENTRY_POINT_INSTALL
¶Nos\Nos::
ENTRY_POINT_OIL
¶New in version 0.2.0.1.
Nos\Nos::
main_controller
¶Returns: | Instance of the main controller. |
---|
Nos\User\
Permission
¶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.
Nos\User\Permission::
check
($permission_name, $category_key = null, $allow_empty = false)¶Alias to Nos\User\Permission::exists
Nos\User\Permission::
exists
($permission_name, $category_key = null, $allow_empty = false)¶Check whether a permissions exists (against all the roles of the current logged in user).
Parameters: |
|
---|---|
Returns bool: |
|
Nos\User\Permission::
existsOrEmpty
($permission_name, $category_key = null, $allow_empty = false)¶Alias to Nos\User\Permission::exists
with the optional parameter $alowEmpty = true
.
Parameters: |
|
---|---|
Returns bool: |
|
Nos\User\Permission::
isAllowed
($permission_name, $allow_empty = false)¶Check against a binary permission (without categories) against all the roles of the current logged in user.
Parameters: |
|
---|---|
Returns bool: |
|
Nos\User\Permission::
atLeast
($permission_name, $threshold, $value_when_empty = 0)¶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: |
|
Nos\User\Permission::
atMost
($permission_name, $threshold, $value_when_empty = 0)¶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: |
|
Nos\User\Permission::
listPermissionCategories
($permission_name)¶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 |
Nos\User\Permission::
isApplicationAuthorised
($application_name)¶Check whether a user can access a particular application
Parameters: |
|
---|
Nos\User\Permission::
contexts
¶See also
Returns an array of all the contexts the user can access.
Nos\User\Permission::
locales
¶See also
Returns an array of all the locales the user can access.
Nos\User\Permission::
sites
¶See also
Returns an array of all the sites the user can access.
Nos\
Renderer
¶Extends the class Fieldset_Field
of FuelPHP.
Nos\
Toolkit_Image
¶Toolkit for image manipulation.
To get a Toolkit_Image, use method getToolkitImage on classes supporting it.
Nos\Toolkit_Image::
transformations
($transformations)¶Add multiple transformations to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
crop
($x1, $y1, $x2, $y2)¶Add a crop transformation to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
resize
($width, $height, $keepar = true, $pad = false)¶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. |
Nos\Toolkit_Image::
shrink
($max_width, $max_height)¶Resizes the image only if too big
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
crop_resize
($width, $height)¶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. |
Nos\Toolkit_Image::
rotate
($degrees)¶Rotates the image
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
flip
($direction)¶Creates a vertical / horizontal or both mirror image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
watermark
($filename, $position, $padding = 5)¶Adds a watermark to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
border
($size, $color = null)¶Adds a border to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
mask
($maskimage)¶Masks the image using the alpha channel of the image input.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
rounded
($radius, $sides = null, $antialias = null)¶Adds rounded corners to the image.
Parameters: |
|
---|---|
Returns: | The current Toolkit_Image for chaining. |
Nos\Toolkit_Image::
grayscale
()¶Turns the image into a grayscale version
Returns: | The current Toolkit_Image for chaining. |
---|
Nos\Toolkit_Image::
url
($absolute = true)¶Build and return the URL of the modify image
Parameters: |
|
---|---|
Returns: | The URL of the modify image. |
Nos\Toolkit_Image::
sizes
()¶Returns: | The dimensions of the modify image (an object containing width and height variables). |
---|
Nos\Toolkit_Image::
html
($params = array())¶Creates an html image tag of the modify image
Sets width, height, alt attributes if not supplied.
Parameters: |
|
---|---|
Returns: | The image tag |
Nos\Toolkit_Image::
save
()¶Apply transformations of the Image_URL instance on a file and save it
Returns: | The save file path |
---|
Nos\Toolkit_Image::
parse
($image_url)¶Parse an existing modify URL and set transformations in queue. Check if the hash part of the URL match.
Parameters: |
|
---|---|
Returns: |
|
<?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',
));
}
Nos\
Tools_Context
¶Provides static methods to work with yours contexts, sites and languages.
See also
Nos\Tools_Context::
contexts
¶Returns: | An array of all your valid contexts. |
---|
<?php
$contexts = \Nos\Tools_Context::contexts();
foreach ($contexts as $context_code => $context_urls) {
// ....
}
Nos\Tools_Context::
sites
¶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'];
}
Nos\Tools_Context::
locales
¶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'];
}
Nos\Tools_Context::
defaultContext
¶Returns: | The code of default context of your Novius OS instance. |
---|
<?php
$default_context_code = \Nos\Tools_Context::defaultContext();
Nos\
Tools_RSS
¶Used to build a RSS feed.
Nos\Tools_RSS::
forge
($channel = array(), array $items = array())¶Parameters: |
|
---|---|
Encoding: | Default |
Version: | Default You can define any other key, which will be transformed into XML tag in the |
Returns: | A instance of |
Nos\Tools_RSS::
set
($property, $value = null)¶Parameters: |
|
---|
Set one or multiple channel properties.
Nos\Tools_RSS::
set_items
(array $items)¶Parameters: |
|
---|
Set a new array of items.
Nos\Tools_RSS::
add_item
(array $item)¶Parameters: |
|
---|
Add a new item to the $items
array.
Nos\Tools_RSS::
build
(array $channel = array(), array $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()
Nos\
Tools_Url
¶Provides static methods for URL.
Nos\Tools_Url::
page
($page_id)¶Parameters: |
|
---|---|
Returns: | URL of the specified page. |
Nos\Tools_Url::
context
($context)¶Parameters: |
|
---|---|
Returns: | Home URL of the specified context. |
Nos\
Tools_Wysiwyg
¶Provides static methods to work with WYSIWYG.
Nos\Tools_Wysiwyg::
parse
($content)¶Parameters: |
|
---|---|
Returns: | Prepare wysiwyg content for display. |
Model_Page
and Model_Media
IDs by theirs URLs
- If it begins with only one # then the href will be prefixed by the page url.
- If if begins with two ## then it is transformed to only one #.
View
¶Extends FuelPHP view class and provides new functionalities.
View::
__construct
($file = null, $data = null, $filter = null)¶Same specifications as in FuelPHP view class, except when you prefix the view name by !, view redirections are ignored.
View::
redirect
($from, $to, $callback = true)¶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`
Nos\
Renderer_Date_Picker
¶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.
Nos\
Renderer_Datetime_Picker
¶Nos\Renderer
.Nos\Renderer_Datetime_Picker::$
wrapper
¶HTML string to wrap the <input>
+ the generated image to open the datetimepicker
Nos\Renderer_Datetime_Picker::$
format
¶(Default: datetime
). Format saved and displayed : date
or datetime
New in version chiba.2.2.
Nos\Renderer_Datetime_Picker::$
null_allowed
¶(Default: false
). Set to true
if the date can be null.
New in version chiba.2.3.
Nos\Renderer_Datetime_Picker::$
datetimepicker
¶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
Nos\Renderer_Datetime_Picker::$
mysql_input_format
¶(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.
Nos\Renderer_Datetime_Picker::$
mysql_store_format
¶(Datetime default: mysql, Date default: mysql_date). Defines how to store value in the database
New in version chiba.2.2.
Nos\Renderer_Datetime_Picker::$
plugin
¶(Datetime default: datetimepicker, Date default: datepicker). Defines which jquery ui plugin to call on the form input
New in version chiba.2.2.
Nos\Renderer_Datetime_Picker::
renderer
($renderer)¶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>',
),
));
Nos\
Renderer_Item_Picker
¶Nos\Renderer
.Nos\Renderer_Item_Picker::$
model
¶The model name
Nos\Renderer_Item_Picker::$
appdesk
¶URL of the model appdesk.
Nos\Renderer_Item_Picker::$
size
¶Size of the thumbnail. Default 64
Nos\Renderer_Item_Picker::$
texts
¶Labels use for UI
empty: Label when no item selected. Default No item selected
.add: Label of button to pick an item. Default Pick an item
.edit: Label of button to pick another item. Default Pick another item
.delete: Label of button to un-select item. Default Un-select this item
.
Nos\Renderer_Item_Picker::$
defaultThumbnail
¶URL of the default thumbnail
Nos\Renderer_Item_Picker::
renderer
($renderer)¶Parameters: |
|
---|---|
Returns: | The <input> tag with JavaScript to initialise it |
Displays a item picker renderer in a standalone manner.
Adding a page item picker in a CRUD form configuration:
<?php
return array(
'label' => __('Page:'),
'renderer' => 'Nos\Renderer_Item_Picker',
'renderer_options' => array(
'model' => 'Nos\Page\Model_Page',
'appdesk' => 'admin/noviusos_page/appdesk',
'defaultThumbnail' => 'static/apps/noviusos_page/img/64/page.png',
'texts' => array(
'empty' => __('No page selected'),
'add' => __('Pick a page'),
'edit' => __('Pick another page'),
'delete' => __('Un-select this page'),
),
),
);
Nos\Media\
Renderer_Media
¶Nos\Renderer
.Default UI: | ![]() |
---|---|
Hover state UI: | ![]() |
Hover state with a selected media UI: | |
![]() |
Nos\Media\Renderer_Media::$
mode
¶Possible values are image
(default) or all
.
Nos\Media\Renderer_Media::$
inputFileThumb
¶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.
Nos\Media\Renderer_Media::
renderer
($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',
),
),
));
Nos\Page\
Renderer_Selector
¶Nos\Renderer
.Nos\Page\Renderer_Selector::$
input_name
¶Name for the radio input.
Nos\Page\Renderer_Selector::$
multiple
¶Set to true
if you want to select multiple pages. Default false
.
Nos\Page\Renderer_Selector::$
selected
¶An array
, or an array
of array
iff multiple
is true
, containning:
id: Pre-selected page id (value). model: Nos\Page\Model_Page
Nos\Page\Renderer_Selector::$
treeOptions
¶Array
Context: | Context of the pages displayed in the page selector. |
---|
Nos\Page\Renderer_Selector::$
height
¶Height of the renderer. Default is 150px.
Nos\Page\Renderer_Selector::$
width
¶Width of the renderer. Default is none.
Nos\Page\Renderer_Selector::
renderer
($renderer)¶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',
));
Nos\
Renderer_Radioset
¶Nos\Renderer
.Nos\Renderer_Radioset::$
name
¶Name for the radio input.
Nos\Renderer_Radioset::$
choices
¶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
Nos\Renderer_Radioset::$
value
¶Value of the selected input.
Nos\Renderer_Radioset::$
class
¶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',
),
);
Nos\
Renderer_Select_Model
¶Nos\Renderer
.select
tag fill with items from a model.Nos\Renderer_Select_Model::$
model
¶The name of the model
Nos\Renderer_Select_Model::$
multiple
¶Set to true
if you want to select multiple items. Default false
.
Nos\Renderer_Select_Model::$
empty_option
¶Set to true
if you want an empty option in select. Default true
.
Nos\Renderer_Select_Model::$
choose_label
¶The label of the empty option. Default empty.
Adding a select model on page in a CRUD form configuration:
<?php
return array(
'label' => __('Location:'),
'renderer' => 'Nos\Renderer_Select_Model',
'renderer_options' => array(
'model' => 'Nos\Page\Model_Page',
),
);
Nos\
Renderer_Tag
¶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'
),
);
Nos\
Renderer_Text
¶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',
);
Nos\
Renderer_Time_Picker
¶All the jQuery UI Time Picker options can be used.
Nos\Renderer_Time_Picker::
renderer
($renderer)¶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
),
));
Nos\
Renderer_Virtualname
¶Nos\Renderer
.See also
NosOrm_Behaviour_Virtualname
Adding a Virtual name in a CRUD form configuration:
<?php
return array(
'label' => '',
'renderer' => 'Nos\Renderer_Virtualname',
);
Nos\
Renderer_Wysiwyg
¶Any options for the TinyMCE WYSIWYG editor. See the TinyMCE documentation for all available options.
Nos\Renderer_Wysiwyg::
renderer
($renderer)¶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'),
),
),
title
is omitted, it will use the key as default value ;fields
is omitted, it will use the whole array as the list of fields.(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
|
---|
config|<path>($config)
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);
config|<group>($config)
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');
front.start($params)
An .html page is requested.
Parameters: |
|
---|
<?php
Event::register_function('front.start', function($params)
{
$url =& $params['url'];
$cache_path =& $params['cache_path'];
// ...
});
front.parse_wysiwyg($html)
Additional processing on a WYSIWYG (HTML content).
Parameters: |
|
---|
<?php
Event::register_function('front.parse_wysiwyg', function(&$content)
{
// ...
});
front.display($html)
Additional processing on the page (HTML content).
Parameters: |
|
---|
<?php
Event::register_function('front.display', function(&$html)
{
// ...
});
front.pageFound($params)
Page to display have been found.
Parameters: |
|
---|
<?php
Event::register('front.pageFound', function($params)
{
$page = $params['page'];
// ...
});
front.response($params)
Before that the response be sended.
Parameters: |
|
---|
<?php
Event::register_function('front.response', function($params)
{
$content =& $params['content'];
$status =& $params['status'];
$headers =& $params['headers'];
// ...
});
front.404NotFound($params)
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.
404.start($params)
A inexistant file is requested. Can be media or attachment file.
Parameters: |
|
---|
<?php
Event::register_function('404.start', function($params)
{
$url =& $params['url'];
// ...
});
404.mediaFound($params)
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'];
// ...
});
404.mediaNotFound($url)
A inexistant media file is requested.
Parameters: |
|
---|
<?php
Event::register('404.mediaNotFound', function($url)
{
// ...
});
404.attachmentFound($params)
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'];
// ...
});
404.attachmentNotFound($url)
A inexistant attachment file is requested.
Parameters: |
|
---|
<?php
Event::register('404.attachmentNotFound', function($url)
{
// ...
});
404.end($url)
A inexistant file is requested. No attachment or media file matched the URL.
Parameters: |
|
---|
<?php
Event::register('404.end', function($url)
{
// ...
});
admin.launchers()
Triggered after recuperation and before parsing of installed launchers.
Parameters: |
|
---|
<?php
Event::register_function('admin.launchers', function(&$launchers)
{
// ...
});
New in version 4.2.
admin.loginSuccess()
A user just successfully connected to the back-office.
<?php
Event::register('admin.loginSuccess', function()
{
// ...
});
admin.loginFail()
A user is trying to connect to the back-office with an email or an invalid password.
<?php
Event::register('admin.loginFail', function()
{
// ...
});
admin.loginSuccessWithCookie()
A user just successfully re-connected to the back-office using the cookie.
<?php
Event::register('admin.loginSuccessWithCookie', function()
{
// ...
});
admin.loginFailWithCookie()
A user has failed to connect to the back-office using the cookie.
<?php
Event::register('admin.loginFailWithCookie', function()
{
// ...
});
email.before_send($email)
Before sending an email.
Parameters: |
|
---|
<?php
Event::register('email.before_send', function($email)
{
// ...
}
email.after_send($email)
After a mail was sent.
Parameters: |
|
---|
<?php
Event::register('email.after_send', function($email)
{
// ...
}
email.error($params)
On email send error.
Parameters: |
|
---|
nos.deprecated($params)
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'];
// ...
});
migrate.exception($params)
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.
Controller_Admin_Page
controller, its filename can either be
classes/controller/admin/page.php
or classes/controller/admin/page.ctrl.php
.__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.
Autoloader
, see above)Added a cache for Model::$_properties
Added behaviours
Added somes relations
Added two options in build options:
before_where: Anarray
,search_column
=>$replace
, where$replace
can be a string or aclosure
which takes the$condition
array by parameterIf$replace
return null, the$condition
will be remove from thewhere
optionsbefore_order_by: Anarray
,search_column
=>$replace
, where$replace
can be a string or aclosure
which takes the entry column by parameterIf$replace
return null, the column will be remove from theorder_by
options
$
¶In this documentation, $
means the jQuery object itself.
$.nosNotify('message');
$.
nosDataReplace
(object, data)¶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',
//}
$.
nosNotify
(message[, type])¶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.
});
$.
nosUIElement
(element[, data])¶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).
$container
¶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 });
$container.
nosAction
(action[, data])¶Executes an action
Arguments: |
|
---|
nosAction.
nosTabs
¶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
}
});
nosAction.
nosDialog
¶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
}
});
nosAction.
confirmationDialog
¶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'
}
});
nosAction.
nosAjax
¶Action: | nosAjax |
---|---|
Params: | Settings of $container.nosAjax() . |
$(domContext).nosAction({
action: 'nosAjax',
params: {
url: 'path/url',
method: 'POST',
data: {
id: '{{_id}}'
)
}
}, {
_id: 5
});
nosAction.
windowOpen
¶Open a new browser window.
Action: | window.open |
---|---|
Url: | URL of the new window. |
$(domContext).nosAction({
action: 'window.open',
url: 'path/url'
});
nosAction.
documentLocation
¶Redirects the browser window to a new URL.
Action: | document.location |
---|---|
Url: | The new URL. |
$(domContext).nosAction({
action: 'document.location',
url: 'path/url'
});
nosAction.
nosMediaVisualise
¶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
});
nosAction.
dialogPick
¶Action: | dialogPick |
---|---|
Event: | Name of the event to trigger. |
$(domContext).nosAction({
action: 'dialogPick',
'event' => 'event_name'
});
$container.
nosAjax
(options)¶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: {}
});
$container.
nosAjaxSuccess
(options)¶Process JSON of a succeeded AJAX request.
Arguments: |
|
---|
$container.
nosAjaxError
(jqXHR, textStatus)¶Process a failed AJAX request.
Arguments: |
|
---|
$container.
nosDialog
([method[, options[, ...]]])¶Manages back-office’s popup. This is a function with sub-functions.
Arguments: |
|
---|
nosDialog.
open
(dialog)¶Opens a popup. This is a wrapper of Wijmo widget Dialog.
A popup can be created in three ways:
iframe
.<div>
from an AJAX request.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
});
$container.
nosFormUI
()¶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 |
||||||||||
Submit: | Using the button widget.
| You can set options with the
data- HTML attributes (additional settings).
|
$(domContext).nosFormUI();
$container.
nosFormAjax
()¶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();
$container.
nosFormValidate
()¶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({});
$container.
nosMedia
([options])¶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
$.
nosMediaVisualise
(media)¶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
});
$container.
nosOnShow
([method[, options[, ...]]])¶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: |
|
---|
nosOnShow.
show
()¶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');
nosOnShow.
one
(callback)¶Binds a callback function which will be called only the one time (at the first display).
Arguments: |
|
---|
$(element).nosOnShow('one', function() {
$(this).widget();
});
nosOnShow.
bind
(callback)¶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.
});
$container.
nosTabs
([method[, options[, ...]]])¶Manages back-office’s tabs. This is a function with sub-functions.
Arguments: |
|
---|
nosTabs.
open
(tab[, dialogOptions])¶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
});
nosTabs.
add
(tab[, dialogOptions, position])¶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'
);
nosTabs.
close
()¶Close current tab (compared to the tab where is the DOM element in jQuery container).
$(domContext).nosTabs('close');
nosTabs.
update
(tab)¶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
});
$container.
nosToolbar
([method[, options[, ...]]])¶Manage back-office’s toolbars. This is a function with sub-functions.
Arguments: |
|
---|
nosToolbar.
add
(element[, right_side])¶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.
$container.nosAjax()
),
which are then dispatched to all interface elements via dispatchers.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.
Event
¶Event.
name
¶string
Model
, the name is the Model name, including its PHP namespace.Event.
id
¶int
or [int]
Model
, ID(s) of the item to which they relate.Event.
action
¶string
insert
, update
or delete
.Event.
context
¶string
or [string]
$container.
nosListenEvent
(event, callback[, caller])¶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) {
// ...
});
$container.
nosUnlistenEvent
(caller)¶Stop listening events for a specific caller. See caller param of nosListenEvent
.
Arguments: |
|
---|
$(domContext).nosUnlistenEvent('caller');
$.
nosDispatchEvent
(event)¶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',
});
noviusos_form::
rendering
($params)¶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.
noviusos_form::
data_validation
(&$data, $fields, $form)¶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>
.
noviusos_form::
before_submission
(&$data, $form, $enhancer_args)¶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>
.
noviusos_form::
after_submission
($params)¶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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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: |
|
Nos\Comments\
Orm_Behaviour_Commentable
¶Adds the ability to use the Comment API on an a Nos\Orm\Model
.
Nos\Comments\Orm_Behaviour_Commentable::
commentApi
¶Returns: | An instance of Nos\Comments\Api` , configured for this item. |
---|
Nos\Comments\Orm_Behaviour_Commentable::
count_comments
()¶Returns and caches the number of comments related to one item
Returns: | Number of comments |
---|
Nos\Comments\Orm_Behaviour_Commentable::
setNbComments
($nb)¶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: |
|
---|
Nos\Comments\Orm_Behaviour_Commentable::
count_multiple_comments
($items)¶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(
),
);
}
Nos\Comments\
Api
¶Nos\Comments\Api::
__construct
($config)¶Parameters: |
|
---|
Nos\Comments\Api::
addComment
($data)¶Parameters: |
|
||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
|
Nos\Comments\Api::
sendNewCommentToAuthor
(Model_Comment $comment)¶Parameters: |
|
---|
Nos\Comments\Api::
sendNewCommentToCommenters
(Model_Comment $comment)¶Parameters: |
|
---|
Nos\Comments\Api::
getConfig
()¶Returns: | the API configuration. |
---|
Nos\Comments\Api::
getRssComment
($comment)¶Parameters: |
|
---|---|
Returns: | An array (to be used with |
Nos\Comments\Api::
getRss
($options = array())¶Parameters: |
|
||
---|---|---|---|
Returns: | A |
Nos\Comments\Api::
changeSubscriptionStatus
($from, $email, $subscribe)¶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 |
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
.
Nos\Comments\
Model_Comment
¶Extends Nos\Orm\Model
.
Nos\Comments\Model_Comment::
getRelatedItem
()¶Retrieves the instance of the related item model, if it exists.
Returns: | Returns the Model instance, if it exists |
---|
Nos\Comments\Model_Comment::
changeSubscriptionStatus
($from, $email, $subscribe)¶Changes the user subscription status to new comments on an item.
Parameters: |
|
---|
Nos\AppWizard\
Application_Generator
¶Nos\AppWizard\Application_Generator::
generate
($config, $input)¶Parameters: |
|
---|
Nos\AppWizard\Application_Generator::
indent
($pre, $str)¶View helper that allows to keep a consistent indentation when generating code.
Parameters: |
|
---|
Nos\AppWizard\Application_Generator::
generateFolders
($root_dir, $folders)¶Generates folders from a list of folder paths
Parameters: |
|
---|
Nos\AppWizard\Application_Generator::
generateFiles
($root_dir, $config, $input)¶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.