id = $id;
}
function setConfigureIcon(){
if($this->isConfigurable)
$additionalTitle = '
| ';
return $additionalTitle;
}
// No longer needed, replaced with getHeader/getFooter
function getTitle($text = '') {
return '';
}
/**
* Called when Dashlet is displayed
*
* @param string $text text after the title
* @return string Header html
*/
function getHeader($text = '') {
global $app_strings, $sugar_config;
$title = '' . $text . ' | ';
$title .= $this->setConfigureIcon();
$title .= $this->setRefreshIcon();
$title .= $this->setDeleteIcon();
if(!function_exists('get_form_header')) {
global $theme;
}
$str = 'id . '" class="hd">
' . get_form_header($this->title, $title, false) . '
';
return $str;
}
/**
* Called when Dashlet is displayed
*
* @param string $text text after the title
* @return string footer html
*/
function getFooter($text = '') {
//$footer = '
';
$footer = '
';
return $footer;
}
/**
* Called when Dashlet is displayed, override this
*
* @param string $text text after the title
* @return string title html
*/
function display($text = '') {
return '';
}
/**
* Called when Dashlets configuration options are called
*
*/
function displayOptions() {
}
/**
* override if you need to do pre-processing before display is called
*
*/
function process() {
}
function save() {
}
/**
* Override this if your dashlet is configurable (this is called when the the configureDashlet form is shown)
* Filters the array for only the parameters it needs to save
*
* @param array $req the array to pull options from
*
* @return array options array
*/
function saveOptions($req) {
}
/**
* Sets the language strings
*
* @param string $dashletClassname classname of the dashlet
*
*/
function loadLanguage($dashletClassname, $dashletDirectory = 'modules/Home/Dashlets/') {
global $current_language, $dashletStrings;
if(!isset($dashletStrings[$dashletClassname])) {
// load current language strings for current language, else default to english
if(is_file($dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.' . $current_language . '.lang.php')
|| is_file('custom/' . $dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.' . $current_language . '.lang.php') ) {
if(is_file($dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.' . $current_language . '.lang.php')) {
require($dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.' . $current_language . '.lang.php');
}
if(is_file('custom/' . $dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.' . $current_language . '.lang.php')) {
require('custom/' . $dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.' . $current_language . '.lang.php');
}
}
else {
if(is_file($dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.en_us.lang.php')) {
require($dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.en_us.lang.php');
}
if(is_file('custom/' . $dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.en_us.lang.php')) {
require('custom/' . $dashletDirectory . $dashletClassname . '/' . $dashletClassname . '.en_us.lang.php');
}
}
}
$this->dashletStrings = $dashletStrings[$dashletClassname];
}
/**
* Generic way to store an options array into UserPreferences
*
* @param array $optionsArray the array to save
*/
function storeOptions($optionsArray) {
global $current_user;
$dashletDefs = $current_user->getPreference('dashlets', 'Home'); // load user's dashlets config
$dashletDefs[$this->id]['options'] = $optionsArray;
$current_user->setPreference('dashlets', $dashletDefs, 0, 'Home');
}
/**
* Generic way to retrieve options array from UserPreferences
*
* @return array options array stored in UserPreferences
*/
function loadOptions() {
global $current_user;
$dashletDefs = $current_user->getPreference('dashlets', 'Home'); // load user's dashlets config
if(isset($dashletDefs[$this->id]['options']))
return $dashletDefs[$this->id]['options'];
else
return array();
}
/**
* Override this in the subclass. It is used to determine whether the dashlet can be displayed.
*
* @return bool indicating whether or not the current user has access to display this Dashlet.
*/
function hasAccess(){
return true;
}
}
?>