Pepper Properties

This article is part of a series on developing Pepper for Mint introduced here.

Let’s start by taking a look at the default properties of all Pepper in /mint/app/lib/pepper.php:

  • $Mint
  • $pepperId
  • $version
  • $info
  • $panes
  • $prefs
  • $data
  • $manifest
  • $moderate

Each of these properties (with the exception of $Mint and $pepperId) may be overridden in your Pepper’s class.php file. All properties will be accessible within your Pepper as $this->propertyName. It is very important that you understand you are extending this file in your Pepper’s class.php file and that pepper.php should NEVER be modified.

var $Mint;

The $Mint property will contain a reference to the current Mint object allowing you to access its properties like the $db and $cfg arrays as well as other installed Pepper.

var $pepperId;

The $pepperId property holds the unique integer id given to this Pepper when loaded by Mint. With the exception of the Default Pepper which is always installed first this value will vary from Mint install to Mint install depending on Pepper installation order. The $Mint->getPepperByClassName() method is the only reliable way to access another Pepper.

The following properties with sample values are taken from the Default Pepper class file.

var $version    = 120;

The $version property should be an integer under 100 for Pepper still in beta. When formatted a $version of 120 will display as 1.2. A $version of 121 will display as 1.21. This property is used by Mint to determine if a user has updated this Pepper and if so call the Pepper’s onUpdate() event handler.

var $info       = array
(
    'pepperName'    => 'Default',
    'pepperUrl'     => 'http://www.haveamint.com/',
    'pepperDesc'    => 'The Default Pepper covers the basics...',
    'developerName' => 'Shaun Inman',
    'developerUrl'  => 'http://www.shauninman.com/'
);

The $info property holds an associative array containing information about this Pepper, its developer, including a description and urls. The pepperName index should contain the display name of your Pepper without the word “Pepper”. The pepperUrl index is a link to more info about the Pepper. The pepperDesc index is a casual description of what the Pepper actually does. The developerName index should contain you or your company’s name. The developerUrl index should contain a link to you or your company’s site.

var $panes      = array
(
    'Visits'    => array
    (
        'Refresh'
    ),
    'Referrers' => array
    (
        'Newest Unique',
        'Most Recent',
        'Repeat'
    ),
    ...
);

The $panes property contains an associative array of arrays. Each string index represents a pane that appears when displaying Mint. The array to which each index points contains the names of the tabs in the given pane. When a pane only displays one view of information I strongly recommend you include a tab named “Refresh” which will allow users to refresh your Pepper’s pane without having to reload the entire Mint interface.

As of Mint 1.2 you may now create utility Pepper that do not display any data in Mint. The Backup/Restore Pepper is one example of this. If you are developing a pane-less Pepper you may omit the $panes property from your Pepper class.

var $prefs      = array
(
    'condensedVisits'           => 0,
    'trimPrefixIndex'           => 1,
    'referrerTimespan'          => 24,
    'ignoreReferringDomains'    => ''
);

The $prefs property contains an array indexed by preference name with default values for each preference. You may omit this property if your Pepper does not require preferences. Each Pepper is responsible for validating and assigning user input to this array in the onSavePreferences() event handler. Mint automatically retrieves and saves this property to the database.

var $data       = array
(
    ...,
    'watched'   => array()
);

Like the $prefs property, the $data property is optional. Data stored in this property is retrieved and saved to the database by Mint. This is useful for storing small lookup arrays or fixed-size data sets that aren’t directly associated to a specific visit row or better suited as a preference. Use as an alternative to creating a separate database table.

var $manifest   = array
(
    'visit' => array
    (
        'ip_long'           => "INT(10) NOT NULL",
        'referer'           => "VARCHAR(255) NOT NULL",
        'referer_checksum'  => "INT(10) NOT NULL",
        ...
    )
);

The $manifest property is used to register column and table additions to the Mint database. This property contains an associative array of arrays, indexed by table name (without the Mint table prefix). Column additions are indexed by column name and should only contain the SQL code for column type and default values. Any integer columns (INT, TINYINT, etc) will be indexed automatically. When creating a new table the first index will always be the PRIMARY KEY of the new table.

With the introduction of the $manifest property Mint is now aware of all information stored in the database at all times, largely eliminating the need for onInstall() and onUninstall() event handlers and allowing Mint to independently uninstall missing, malfunctioning, or incompatible Pepper.

var $moderate   = array('outbound');

The $moderate property is used to register Pepper-specific database tables for automatic expiration. Mint remains a snappy, fresh look at your site because older, arguably irrelevant data is deleted. By default, data in a moderated table that is older than 5 weeks or in excess of 25 MB (per table) is expired. If your Pepper requires it’s own Pepper-specific table (and not just additional columns in the default visit table) that table must be moderated—either by adding it’s name to this single-dimensional array $moderate property or with custom code. Moderated tables must have their own id (an unsigned, auto-incrementing integer) and dt (a Unix timestamp) columns.

With the properties covered, let’s continue to the default Pepper methods and event handlers. Questions? Visit the Mint Forum.

Previous
Intro to Pepper Development
Next
Pepper Event Handlers and Methods
Author
Shaun Inman
Posted
October 21st, 2005 at 2:00 pm
Categories
PHP
Mint
Web