Code Search for Developers
 
 
  

DashboardController.php from Brim at Krugle


Show DashboardController.php syntax highlighted

<?php

require_once ('framework/Controller.php');
require_once ('framework/model/PluginServices.php');

/**
 * The Dashboard controller: shows info per activated plugin
 * on the index page
 *
 * This file is part of the Brim project.
 * The brim-project is located at the following
 * location: {@link http://www.brim-project.org/ http://www.brim-project.org/}
 *
 * <pre> Enjoy :-) </pre>
 *
 * @author Barry Nauta - July 2004
 * @package org.brim-project.framework
 *
 *
 * @copyright [brim-project.org] - Copyright (c) 2003 - 2007 Barry Nauta
 *
 * @license http://opensource.org/licenses/gpl-license.php
 * The GNU Public License
 */
class DashboardController extends Controller
{
	/**
	 * Theplugin services, used to ask for the activated
	 * plugins for the current user
	 *
	 * @var object the services that provide plugin information
	 */
	var $pluginServices;

	/**
	 * Default constructor
	 */
	function DashboardController ()
	{
		parent::Controller ();
		$this->title = 'Brim';
		$this->itemName = 'Dashboard';
		$this->pluginServices = new PluginServices ();
	}

	/**
	 * Activates the controller
	 */
	function activate ()
	{
		$languages = array ();
		$dictionary = $this->getDictionary ();
		$this->renderer = 'index';
		$this->renderObjects = sprintf ($dictionary['welcome_page'],
			$this->getUserName());
		if ($_SESSION['brimUserIsAdmin'] == 'true' && $this->installerExists ())
		{
			$this->renderEngine->assign	('about',
				$dictionary['installer_exists'].$dictionary['about_page']);
		}
		else
		{
			$this->renderEngine->assign	('about', $dictionary['about_page']);
		}
		$this->renderEngine->assign ('dashboard', $this->getDashboard());
		if (!isset ($_SESSION['brimShowTips'])
			|| (isset ($_SESSION['brimShowTips'])
				&& ($_SESSION['brimShowTips']=='1')))
		{
			$this->renderEngine->assign ('tip',	$this->getTip());
		}
		include ('framework/configuration/languages.php');
		$this->renderEngine->assign('languages', $languages);
	}

	/**
	 * Loop over all activated plugins and retrieve dashboard
	 * (overview) information for the specific plugin
	 *
	 * @return array an array with dashboard information per plugin
	 */
	function getDashboard ()
	{
		$plugins = array ();
		//
		// This function heavily uses the
		// framework/configuration/plugins.php file
		//
		include ('framework/configuration/plugins.php');
		$result = array ();
		$configuredPlugins = $this->pluginServices->getPluginSettingsAsArray
				($this->getUserName());
		//
		// Loop over all plusgins
		//
		foreach ($plugins as $plugin)
		{
				$name = $plugin['name'];
				//
				// Check if the current plugin is activated for this
				// user
				//
				if (isset ($configuredPlugins[$name]) &&
					$configuredPlugins[$name] == 'true')
				{
					include('plugins/'.$name.'/'.$plugin['controller']);
					$controller = new $plugin['controllerName'];
					//
					// reinitialize the contents
					//
					$contents = array ();
					if (isset ($plugin['dashboardCallback']))
					{
						$contents = $controller->$plugin['dashboardCallback']();
					}
					else 
						if (isset ($plugin['dashboardContent'])
						&& isset ($plugin['dashboardSort'])
						&& isset ($plugin['dashboardAction'])
					)
					{
						$contents = $controller->getDashboard
							($plugin['dashboardContent'], 5,
								$plugin['dashboardSort']);
					}
					//
					// If this plugin has dashboard fuctionality (the
					// action is set), add the plugin's parameters to
					// the result
					//
					if (isset ($plugin['dashboardAction'])
						&& isset ($plugin['dashboardSort'])
					)
					{
						$result[$name]= array (
							'name'=>$name,
							'content'=>(isset($plugin['dashboardContent']))
								? $plugin['dashboardContent']: NULL,
							'contents'=>$contents,
							'action'=>$plugin['dashboardAction'],
							'title'=>$plugin['dashboardTitle'],
							'controller'=>'index.php?plugin='.$plugin['name']
						);
						if (isset ($plugin['dashboardAdditionalLinkParameters']))
						{
							$result[$name]['dashboardAdditionalLinkParameters']=
								$plugin['dashboardAdditionalLinkParameters'];
						}
					}
				}
		}
		return $result;
	}

	/**
	 * Returns the filename that will be given to the template for
	 * display
	 *
	 * @return string the filename of the template file to show.
	 */
	function getTemplateFile ()
	{
		//
		// Allow the template to override a specific file.
		// If this file exist (the file in the template directory),
		// it will be loaded, otherwise the default (in the plugin
		// directory) will be loaded
		//
		$renderer = 'templates/'.$this->getTemplate ().'/'.
			$this->getRenderer ();
		if (!(file_exists ($renderer)))
		{
			$renderer = 'framework/view/'.$this->getRenderer ();
		}
		return $renderer;
	}

	/**
	 * Retrieves the dictionary file by first tryin the language
	 * specific dictionary file, defaulting to the english version if
	 * the language specific file for the item does not exist and
	 * returns the contents as an array
	 *
	 * @return array the dictionary
	 */
	function getDictionary ()
	{
		include ('framework/i18n/dictionary_en.php');
		if (file_exists ('framework/i18n/dictionary_'.
			$_SESSION['brimLanguage'] . '.php'))
		{
			include ('framework/i18n/dictionary_'.
				$_SESSION['brimLanguage'].'.php');
		}
		//
		// Overrule the title for this page
		//
		$dictionary['title']='Brim';
		$dictionary['item_title']='Brim';
		return $dictionary;
	}

	/**
	 * Reads the tip directory and selects one tip
	 *
	 * @return string a random tip
	 */
	function getTip ()
	{
		include ('framework/i18n/tips_en.php');
		if (file_exists ('framework/i18n/tips_'.
			$_SESSION['brimLanguage'] . '.php'))
		{
			include ('framework/i18n/tips_'.
				$_SESSION['brimLanguage'].'.php');
		}
		$random = rand (1, count($dictionary));
		if ($random < 10)
		{
			$random = '0'.$random;
		}
		return $dictionary['tip'.$random];
	}

	/**
	 * Checks if the installation file still exists. This is used
	 * to display a message to the admin user in case it is still there
	 *
	 * @return boolean <code>true</code>, if the installation
	 * file still exists, <code>false</code> otherwise
	 */
	function installerExists ()
	{
		return file_exists ('install.php');
	}
}
?>




See more files for this project here

Brim

BRIM is a MVC framework, written in PHP and based on items with a hierarchical relationship. The list of plugins make BRIM a Information Manager with plugins like bookmarks, a calendar, contacts tasks, notes, RSS etc. The application is multilingual.

Project homepage: http://sourceforge.net/projects/brim
Programming language(s): JavaScript,PHP,SQL
License: other

  configuration/
    databaseConfiguration.example.php
    index.php
    languages.php
    ldapConfiguration.example.php
    menuItems.php
    plugins.php
    preferenceConfiguration.php
    realmConfiguration.php
    templates.php
  i18n/
    common.php
    dictionary_cs.php
    dictionary_da.php
    dictionary_de.php
    dictionary_en.php
    dictionary_eo.php
    dictionary_es.php
    dictionary_es_CO.php
    dictionary_fr.php
    dictionary_gr_GR.php
    dictionary_he.php
    dictionary_hu.php
    dictionary_it.php
    dictionary_it_IT.php
    dictionary_nl.php
    dictionary_no.php
    dictionary_pl.php
    dictionary_pt.php
    dictionary_pt_BR.php
    dictionary_ro.php
    dictionary_ru.php
    dictionary_sv.php
    dictionary_zh_TW.php
    index.php
    messages_da.php
    messages_de.php
    messages_en.php
    messages_es_CO.php
    messages_fr.php
    messages_it.php
    messages_nl.php
    messages_pt_BR.php
    tips_da.php
    tips_en.php
    tips_fr.php
    tips_it.php
    tips_nl.php
  model/
    AdminServices.php
    Information.php
    InformationFactory.php
    InformationServices.php
    Item.php
    ItemFactory.php
    ItemParticipation.php
    ItemParticipationFactory.php
    ItemParticipationServices.php
    PluginServices.php
    PluginSetting.php
    PluginSettingFactory.php
    Preference.php
    PreferenceFactory.php
    PreferenceServices.php
    Services.php
    User.php
    UserFactory.php
    UserServices.php
    index.php
  realm/
    DatabaseRealm.php
    LdapRealm.php
    Realm.php
    RealmFactory.php
  sql/
    adminQueries.php
    authQueries.php
    create.mysql.brim_admin.sql
    create.mysql.brim_item_participation.sql
    create.mysql.brim_plugin_settings.sql
    create.mysql.brim_temp_users.sql
  test/
  util/
  view/
  AboutController.php
  AdminController.php
  AdminInstaller.php
  AjaxController.php
  Controller.php
  DashboardController.php
  HelpController.php
  Installer.php
  ItemController.php
  ItemParticipationInstaller.php
  PluginController.php
  PluginInstaller.php
  PreferenceController.php
  PreferenceInstaller.php
  RightsManager.php
  RightsManagerImpl.php
  TempUserInstaller.php
  UserController.php
  UserInstaller.php
  checkLogin.php
  index.php