Skip to content

Class: Addons

Saqib Razzaq edited this page Apr 20, 2019 · 10 revisions

Addons class enables developers to build or enhance chunks of features which can be enabled / disabled with a simple click.

idle

Scans Addons directory and returns list of addons available to be installed

Returns

An array with details of all found addons

Examples
$addons->idle();

count

Counts total installed addons

Parameters
[array] $parameters [optional]

An array of parameters to filter by. See details of these options in list section.

Returns

Total number of addons installed

Examples
// count all installed addons
$addons->count(); 
// counts addons by author tommy_shelby
$parameters = array('author' => 'tommy_shleby'); 
$addons->count($parameters));

list

List Addons matching several dynamic parameters.

Parameters
[array] $parameters [optional]

An array of parameters to match videos against. This array can contain any of columns from 'videos' table. You can select values using =, >, >=, < or <= to have more control.

Returns

An array consisting of videos that matched pattern after $limit was applied.

Examples
// list addons by specific author
$parameters['author'] = 'jon';
$addons->list($parameters);
// list addons with version higher than 1
$parameters['version'] = array('1', '>');
$addons->list($parameters);

exists

Check if an addon is installed

Parameters
[string] $name

Name of addon to check

Returns

Boolean

Examples
$addons->exists('developer_tools');

listActive

List active addons

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of addons matching parameters.

Examples
// get 10 active addons
$addons->listActive(10);

listInactive

List inactive addons

[array] $parameters [optional]

Additional parameters to apply

Returns

An array of addons matching parameters.

Examples
// get 10 installed but inactive addons
$addons->listInactive(10);

install

Installs an addon

Parameters
[string] $name

Name of addon to install

Returns

Integer ID of installed addon

Examples
$addons->install('tags_dip');

get

Get all details for an addon

Parameters
[string] $name

Name of addon to get details for

Returns

An array with all details

Examples
$addons->get('social_crow');

getField

Get a single field of an addon

Parameters
[string] $name

Name of addon

[string] $field

Field to get

Returns

An array with details

Examples
$addons->getField('tags_dip', 'version'); // get version
$addons->getField('tags_dip', 'description'); // get description

getFields

Get multiple fields of an addon

[string] $name

name to search for

[array] $fields

A list of fields to fetch

Returns

An array of data consisting of fields requested only.

Examples
// get author and version
$addons->getFields('tags_dip', array('author','version'));

displayName

Get an addon's display name

Parameters
[string] $name

Internal name of addon

Returns

Display name of addon

Examples
$addons->displayName('tags_dip'); // tagsDip

version

Get an addon's version

Parameters
[string] $name

Internal name of addon

Returns

Integer version

Examples
$addons->version('tags_dip'); // 1.0

description

Get an addon's description

Parameters
[string] $name

Internal name of addon

Returns

String description of addon

Examples
$addons->description('tags_dip'); // "This allows you to insert custom tags"

author

Get an addon's author name

Parameters
[string] $name

Internal name of addon

Returns

Author name of addon

Examples
$addons->author('tags_dip'); // BriskLimbs

status

Get an addon's status

Parameters
[string] $name

Internal name of addon

Returns

Status of addon

Examples
$addons->status('tags_dip');

directory

Get an addon's directory

Parameters
[string] $name

Internal name of addon

Returns

Full directory path of addon

Examples
$addons->directory('tags_dip'); // /var/www/html/addons/tagsDip

setField

Update a single field of single addon

Parameters
[string] $field

Field to be updated

[mixed] $value

New value to set

[mixed] $identiferValue

Value to search addon by

[string] $identifier [optional]

Column to search against. If false then function will consider it name.

Returns

Boolean depending on how update query went.

Examples
// update addon display_name using name 
$addons->setField('display_name', 'Black Crows', 'tags_dip', 'name');

setFieldBulk

update a single field of multiple addons

Parameters
[string] $field

Field to be updated

[mixed] $value

New value to set

[array] $identifierValueArray

Value list to search addon by

[string] $identifier [optional]

Column to search against. If false then function will consider it names.

Returns

Boolean depending on how update query went.

Examples
// activate multiple addons
$list= array('tags_dip', 'social_crow', 'developer_tools');
$addons->setFieldBulk('status', 'active', $list, 'name');

setFields

update multiple fields of single video

Parameters
[array] $fieldValueArray

An assoc. array of field => value to update

[mixed] $identiferValue

Value to search addon by

[string] $identifier [optional]

Column to search values against. If false then function will consider it name.

Returns

Boolean depending on status of update.

Examples
// update author, version and description
$details = array(
    'author' => 'Drogon',
    'version' => 2,
    'description' => 'Breath fire and eat goats'
);

$addons->setFields($details, 'tags_dip', 'name');

setFieldsBulk

update multiple columns of multiple addons

Parameters
[array] $fieldValueArray

An assoc. array of field => value to update

[mixed] $identiferValueArray

List of values to search addons by

[string] $identifier [optional]

Column to search values against. If false then function will consider it names.

Returns

Boolean depending on status of update.

Examples
// activate multiple addons, set their version and change their author
$fields = array(
    'status' => 'active',
    'version' => '10',
    'author' => 'luca'
);
$list = array('tags_dip', 'social_crow', 'developer_tools');
$addons->setFieldsBulk($fields, $list);

activate

Set addon state to active

Parameters
[mixed] $video

Name or id of addon to activate

Returns

Boolean depending on how request went

Examples
$addons->activate('tags_dip');

bulkActivate

Set addon state to active for multiple addons

Parameters
[array] $addonsArray

A list of addons to be activated

[string] $identifier [optional]

Column to match list against. If nothing is specified then it is considered 'name'.

Returns

Boolean depending on how request went

Examples
$list = array('tags_dip', 'social_crow', 'developer_tools');
$addons->bulkActivate($list);

deactivate

Set addon state to inactive

Parameters
[mixed] $video

ID or name of addon to deactivate

Returns

Boolean depending on how request went

Examples
$addons->deactivate('tags_dip');

bulkDeactivate

Set addon state to inactive for multiple addons

Parameters
[array] $addonsArray

A list of addons to be deactivated

[string] $identifier [optional]

Column to match list against. If nothing is specified then it is considered 'name'.

Returns

Boolean depending on how request went

Examples
$list = array(141532, 12411, 14245);
$addons->bulkDeactivate($list, 'id');

uninstall

Uninstall an addon

Parameters
[string] $name

Name of addon to uninstall

Returns

Boolean depending on result

Examples
$addons->uninstall('facebook_comments');

bulkUninstall

Uninstall multiple addons

Parameters
[array] $names

A list of names of addons to be uninstalled

Returns

Boolean depending on result

Examples
$list = array('tags_dip', 'facebook_commets');
$addons->bulkUninstall($list);

load

Loads all active functions by requiring their main files during BriskLimbs init phase

addHook

Adds an addon hook to inject functionality

Parameters
[string] $name

Name of hook to be used in Twig templates

[string] $function

Function to be called when hooked

Returns

Boolean

Examples
// create function 
function sayHello() {
  echo "Hello world";
}

// register hook
$addons->addHook('hello', 'sayHello');

// use hook in templates like
{{hello()}}

addMenu

Adds a new menu in admin area

Parameters
[array] $menu

An array containing details of menu

Examples
$menu = array(
  'developer_tools' => array(
    'display_name' => 'Developer Tools',
    'sub' => array( // this is needed only when you want a sub menu
      'PHP Info' => $pages . '|info.php',
      'Requirements' => $pages . '|requirements.php',
      'Server Configs' => $pages . '|configs.php'
    )
  )
);

$addons->addMenu($menu);

display

Display template file in admin area from addon

Parameters
[string] $addonCoreDirectoryName

Base name of addon's main directory

[string] $file

html file relative to $addonCoreDirectoryName

[array] $parameters [optional]

An array of parameters to assign to template

Examples
$addons->display('tagsDip', 'pages/requirements.html', $parameters)

url

Returns URL for an addon

Parameters
[string] $name

Name of addon

Returns

String URL for addon

Examples
$addons->url('tags_dip'); // /var/www/html/addons/tagsDip

addTrigger

Register a new trigger

Parameters
[string] $function

Name of function to be called

[string] $location

Where this function should be called

[string] $return [optional]

Fields to be returned by trigger

Returns

Boolean

Examples
$addons->addTrigger('facebookScript', 'body_before');
Clone this wiki locally