3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 class CRM_Contact_Page_DashBoard
extends CRM_Core_Page
{
26 public function run() {
27 CRM_Utils_System
::setTitle(ts('CiviCRM Home'));
28 $contactID = CRM_Core_Session
::getLoggedInContactID();
30 // call hook to get html from other modules
31 // ignored but needed to prevent warnings
32 $contentPlacement = CRM_Utils_Hook
::DASHBOARD_BELOW
;
33 $html = CRM_Utils_Hook
::dashboard($contactID, $contentPlacement);
34 if (is_array($html)) {
35 $this->assign_by_ref('hookContent', $html);
36 $this->assign('hookContentPlacement', $contentPlacement);
39 $communityMessages = CRM_Core_CommunityMessages
::create();
40 if ($communityMessages->isEnabled()) {
41 $message = $communityMessages->pick();
43 $this->assign('communityMessages', $communityMessages->evalMarkup($message['markup']));
47 $loader = Civi
::service('angularjs.loader');
48 $loader->addModules('crmDashboard');
49 $loader->setPageName('civicrm/dashboard');
51 // For each dashlet that requires an angular directive, load the angular module which provides that directive
52 foreach (CRM_Core_BAO_Dashboard
::getContactDashlets() as $dashlet) {
53 if (!empty($dashlet['directive'])) {
54 foreach ($loader->getAngular()->getModules() as $name => $module) {
55 if (!empty($module['exports'][$dashlet['directive']])) {
56 $loader->addModules($name);
67 * partialsCallback from crmDashboard.ang.php
69 * Generates an html template for each angular-based dashlet.
75 public static function angularPartials($moduleName, $module) {
77 foreach (CRM_Core_BAO_Dashboard
::getContactDashlets() as $dashlet) {
78 if (!empty($dashlet['directive'])) {
79 // FIXME: Wrapping each directive in <div id='bootstrap-theme'> produces invalid html (duplicate ids in the dom)
80 // but it's the only practical way to selectively apply boostrap3 theming to specific dashlets
81 $partials["~/$moduleName/directives/{$dashlet['directive']}.html"] = "<div id='bootstrap-theme'><{$dashlet['directive']}></{$dashlet['directive']}></div>";
88 * settingsFactory from crmDashboard.ang.php
92 public static function angularSettings() {
94 'dashlets' => CRM_Core_BAO_Dashboard
::getContactDashlets(),