Skip to content

Quickstart

Step 1: Download and extract

  • After purchasing a license, and downloading the ZIP-file from the official download site, ...
  • extract the contents into your project directory
    After extraction, ensure that the file resources/lib/AppGiniHelperIndicators.php exists.

Step 2: Initialize

  • Open hooks/header-extras.php in your favourite code editor
  • Initialize the library with the following line of code:
    1
    2
    3
    4
    <!-- file: hooks/header-extras.php -->
    <?php
    
    AppGiniHelperIndicators::init();
    

Step 3: Create indicators

  • Open hooks/__global.php in your favourite code editor
  • Tell the library which indicators you want and what values they shall return by pasting the following code somewhere after the <?php tag:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php 
// file: hooks/__global.php

// ...more functions here

function indicator_loader($context)
{
  return [
    $context->create("num_tasks")->updateEvery(30)->whenActive(),
    $context->create("num_messages")->updateEvery(30)->whenActive(),
    $context->create("date")->updateEvery(60),
    $context->create("time")->updateEvery(5),
  ];
}

function indicator_handler($context, &$indicator) 
{
  switch ($indicator->name) {
    case 'date':
      $indicator->value = date("d.m.Y");
      $indicator->tooltip = date("l, d.m.Y");
      $indicator->icon = "calendar";
      break;
    case 'time':
      $indicator->value = date("H:i");
      $indicator->icon = "time";
      break;
    case 'num_tasks':
      $indicator->value = $context->getRecordCount("tasks", true, "id NOT IN (1, 5)");
      $indicator->href = "tasks_view.php";      
      $indicator->icon = "copy";
      $indicator->tooltip = "Number of all open tasks";
      break;
    case 'num_messages':
      $indicator->value =  sqlValue("SELECT count(*) FROM messages");
      $indicator->icon = "envelope";
      $indicator->visible = $indicator->value > 0;
      $indicator->bullet = AppGiniHelperIndicatorBullets::Blue;
      $indicator->tooltip = "Number of messages";
     break;
  }
  return TRUE;
}
  • save and test in you browser by reloading.

Description

This example creates 4 different indicators.

  • The function indicator_loader returns the (unique) names (=keys) of the required indicators and controls beaviour for example the refresh-interval.

  • The function indicator_handler gets called repeatedly and returns the value to be shown per indicator, identified by name, plus additional settings like icon, visibility or tooltip.