heartbeat_plugin.inc in Heartbeat 7
File
modules/heartbeat_plugins/includes/heartbeat_plugin.inc
View source
<?php
interface iHeartbeatPluginWrapper {
public function getPlugin();
}
class HeartbeatPluginWrapper extends HeartbeatCtoolsObject implements iHeartbeatPluginWrapper {
public $plugin_name = '';
public $label = '';
public $settings = array();
public $error = array();
public function getPlugin() {
$class = 'Heartbeat' . $this->plugin_name . 'Plugin';
module_load_include('inc', $this->module, 'plugins/' . $this->plugin_name);
if (class_exists($class)) {
$plugin = new $class($this->label, $this->settings);
$plugin
->addSettings(array(
'plugin_name' => $this->plugin_name,
));
}
else {
$plugin = NULL;
$this->error = array(
'critical' => t('No class found for @class', array(
'@class' => $class,
)),
);
}
return $plugin;
}
}
interface iHeartbeatPlugin {
public function loadAttachments(HeartbeatActivity &$heartbeatActivity, $name = NULL);
public function hasContent();
public function hasAttachmentsContent();
public function renderAttachmentsContent(HeartbeatActivity $heartbeatActivity);
public function hasButtons();
public function hasAttachmentsButtons();
public function renderButtons(HeartbeatActivity $heartbeatActivity);
public function isStreamAdaptor();
public function adaptsStream();
public function streamLoaded(HeartbeatStream $heartbeatStream);
}
class HeartbeatBasePlugin {
protected $label = '';
protected $settings = array();
protected $stream = NULL;
public function __construct($label, $settings) {
$this
->setLabel($label);
$this
->addSettings($settings);
}
public function setLabel($label) {
$this->label = $label;
}
public function getLabel() {
return $this->label;
}
public final function setStream(HeartbeatStream $heartbeatStream) {
$this->stream = $heartbeatStream;
}
public function addSettings($settings) {
$this->settings += $settings;
}
public function getSettings() {
return $this->settings;
}
public function getAttachments($template, $component_type) {
return array(
array(
'name' => $this->settings['plugin_name'],
'title' => $this->settings['plugin_name'],
'enabled' => isset($template->attachments[$component_type]['enabled'][$this->settings['plugin_name']]) ? $template->attachments[$component_type]['enabled'][$this->settings['plugin_name']] : 0,
'weight' => 5,
),
);
}
public function activityRemoved($uaids, $all) {
}
public function getMenuItems() {
return array();
}
public function pluginUIForm(&$form, &$form_state) {
}
public function pluginAttachmentForm(&$form, $form_values, $component_type) {
}
public function pluginStreamForm(&$form, &$form_state) {
}
}