Location: PHPKode > scripts > Impleo Music Collection Script > impleo/statistics.php
<?php
/* ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <hide@address.com> wrote this file. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return Christoffer Kjeldgaard Petersen
 * ----------------------------------------------------------------------------
 */

header("content-type:text/html;charset=utf-8");

require_once(dirname(__FILE__) . '/classes/Factory.class.php');
require_once(dirname(__FILE__) . '/classes/ImpleoTemplate.class.php');

$tpl = new ImpleoTemplate("statistics.tpl");
$factory = Factory::getInstance();

$arrDetails = $factory->getDetailInfo();

// Top artists:
$arrArtists = $factory->getAttributeListCount('artist', 5);
$tpl->assign('topArtists', $arrArtists);
$tpl->assign('numArtists', $factory->getAttributeCount('artist'));

// Top formats (if any):
$hasFormat = false;
foreach($arrDetails as $arrDetail)
{
    if (in_array('format', $arrDetail))
    {
        $arrFormats = $factory->getAttributeListCount('format', 5);
        $tpl->assign('topFormats', $arrFormats);
        $tpl->assign('numFormats', $factory->getAttributeCount('format'));
        if (count($arrFormats) > 0)
            $hasFormat = true;
    }
}
$tpl->assign('hasFormat', $hasFormat);

// Top labels (if any):
$hasLabel = false;
foreach($arrDetails as $arrDetail)
{
    if (in_array('label', $arrDetail))
    {
        $arrLabels = $factory->getAttributeListCount('label', 5);
        $tpl->assign('topLabels', $arrLabels);
        $tpl->assign('numLabels', $factory->getAttributeCount('label'));
        if (count($arrLabels) > 0)
            $hasLabel = true;
    }
}
$tpl->assign('hasLabel', $hasLabel);

// Get collection name:
$arrGeneralSettings = $factory->getGeneralSettings();
$tpl->assign('collectionName', $arrGeneralSettings['name']);

// Check if there's any records:
if ($factory->getNumberOfItems() > 0)
    $hasRecords = true;
else
    $hasRecords = false;
$tpl->assign('hasRecords', $hasRecords);

$tpl->displayTemplate();
?>
Return current item: Impleo Music Collection Script