-
Notifications
You must be signed in to change notification settings - Fork 19
Class: Addons
Addons class enables developers to build or enhance chunks of features which can be enabled / disabled with a simple click.
- idle
- count
- list
- exists
- active
- inactive
- install
- get
- getField
- getFields
- displayName
- version
- description
- author
- status
- directory
- setField
- setFields
- activate
- bulkActivate
- deactivate
- bulkDeactivate
- uninstall
- bulkUninstall
- load
- addHook
- addMenu
- display
- url
- addTrigger
Scans Addons directory and returns list of addons available to be installed
An array with details of all found addons
$addons->idle();
Counts total installed addons
An array of parameters to filter by. See details of these options in list section.
Total number of addons installed
// count all installed addons
$addons->count();
// counts addons by author tommy_shelby
$parameters = array('author' => 'tommy_shleby');
$addons->count($parameters));
List Addons matching several dynamic parameters.
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.
An array consisting of videos that matched pattern after $limit was applied.
// 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);
Check if an addon is installed
Name of addon to check
Boolean
$addons->exists('developer_tools');
List active addons
Additional parameters to apply
An array of addons matching parameters.
// get 10 active addons
$addons->listActive(10);
List inactive addons
Additional parameters to apply
An array of addons matching parameters.
// get 10 installed but inactive addons
$addons->listInactive(10);
Installs an addon
Name of addon to install
Integer ID of installed addon
$addons->install('tags_dip');
Get all details for an addon
Name of addon to get details for
An array with all details
$addons->get('social_crow');
Get a single field of an addon
Name of addon
Field to get
An array with details
$addons->getField('tags_dip', 'version'); // get version
$addons->getField('tags_dip', 'description'); // get description
Get multiple fields of an addon
name to search for
A list of fields to fetch
An array of data consisting of fields requested only.
// get author and version
$addons->getFields('tags_dip', array('author','version'));
Get an addon's display name
Internal name of addon
Display name of addon
$addons->displayName('tags_dip'); // tagsDip
Get an addon's version
Internal name of addon
Integer version
$addons->version('tags_dip'); // 1.0
Get an addon's description
Internal name of addon
String description of addon
$addons->description('tags_dip'); // "This allows you to insert custom tags"
Get an addon's author name
Internal name of addon
Author name of addon
$addons->author('tags_dip'); // BriskLimbs
Get an addon's status
Internal name of addon
Status of addon
$addons->status('tags_dip');
Get an addon's directory
Internal name of addon
Full directory path of addon
$addons->directory('tags_dip'); // /var/www/html/addons/tagsDip
Update a single field of single addon
Field to be updated
New value to set
Value to search addon by
Column to search against. If false then function will consider it name.
Boolean depending on how update query went.
// update addon display_name using name
$addons->setField('display_name', 'Black Crows', 'tags_dip', 'name');
update a single field of multiple addons
Field to be updated
New value to set
Value list to search addon by
Column to search against. If false then function will consider it names.
Boolean depending on how update query went.
// activate multiple addons
$list= array('tags_dip', 'social_crow', 'developer_tools');
$addons->setFieldBulk('status', 'active', $list, 'name');
update multiple fields of single video
An assoc. array of field => value to update
Value to search addon by
Column to search values against. If false then function will consider it name.
Boolean depending on status of update.
// update author, version and description
$details = array(
'author' => 'Drogon',
'version' => 2,
'description' => 'Breath fire and eat goats'
);
$addons->setFields($details, 'tags_dip', 'name');
update multiple columns of multiple addons
An assoc. array of field => value to update
List of values to search addons by
Column to search values against. If false then function will consider it names.
Boolean depending on status of update.
// 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);
Set addon state to active
Name or id of addon to activate
Boolean depending on how request went
$addons->activate('tags_dip');
Set addon state to active for multiple addons
A list of addons to be activated
Column to match list against. If nothing is specified then it is considered 'name'.
Boolean depending on how request went
$list = array('tags_dip', 'social_crow', 'developer_tools');
$addons->bulkActivate($list);
Set addon state to inactive
ID or name of addon to deactivate
Boolean depending on how request went
$addons->deactivate('tags_dip');
Set addon state to inactive for multiple addons
A list of addons to be deactivated
Column to match list against. If nothing is specified then it is considered 'name'.
Boolean depending on how request went
$list = array(141532, 12411, 14245);
$addons->bulkDeactivate($list, 'id');
Uninstall an addon
Name of addon to uninstall
Boolean depending on result
$addons->uninstall('facebook_comments');
Uninstall multiple addons
A list of names of addons to be uninstalled
Boolean depending on result
$list = array('tags_dip', 'facebook_commets');
$addons->bulkUninstall($list);
Loads all active functions by requiring their main files during BriskLimbs init phase
Adds an addon hook to inject functionality
Name of hook to be used in Twig templates
Function to be called when hooked
Boolean
// create function
function sayHello() {
echo "Hello world";
}
// register hook
$addons->addHook('hello', 'sayHello');
// use hook in templates like
{{hello()}}
Adds a new menu in admin area
An array containing details of menu
$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 template file in admin area from addon
Base name of addon's main directory
html file relative to $addonCoreDirectoryName
An array of parameters to assign to template
$addons->display('tagsDip', 'pages/requirements.html', $parameters)
Returns URL for an addon
Name of addon
String URL for addon
$addons->url('tags_dip'); // /var/www/html/addons/tagsDip
Register a new trigger
Name of function to be called
Where this function should be called
Fields to be returned by trigger
Boolean
$addons->addTrigger('facebookScript', 'body_before');