Location: PHPKode > scripts > Impleo Music Collection Script > impleo/admin/edit-records-list.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
 * ----------------------------------------------------------------------------
 */

session_start();

// Login control:
if (!$_SESSION['login'] == 1)
{
	header("Location: ./");
	exit;
}

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

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

$tpl = new ImpleoTemplate("edit-records-list.tpl");
$factory = Factory::getInstance();

if (is_numeric($_POST['delete_id']))
{
    $factory->deleteRecord($_POST['delete_id']);
}

$LIMIT = 25;
if (isset($_GET['perpage']) && is_numeric($_GET['perpage']))
	$LIMIT = $_GET['perpage'];

$arrRecords = $factory->getMusicItems();
$intNumRecords =  $factory->getNumberOfItems();

$limitOptions = array(15, 25, 50, 100, 250);
if ($intNumRecords > 250)
	$limitOptions[] = $intNumRecords;

/* Page-control */
if (is_numeric($_GET['page']))
{
	$display = $_GET['page'];
	$start = $display*$LIMIT-$LIMIT;
}
else
{
	$display = 1;
	$start = 0;
}

if ($intNumRecords > $LIMIT)
{
	$arrPaging = Paging::createPagingList($intNumRecords, $LIMIT, $display, $_SERVER['QUERY_STRING']);
	$showPaging = true;
}
else
	$showPaging = false;

$arrMusic = array();
for($i = $start; $i < $start+$LIMIT; $i++)
{
	if (array_key_exists($i, $arrRecords))
	{
		$arrMusic[] = $arrRecords[$i];
	}
}

$tpl->assign('numRecords', $factory->getNumberOfItems());
$tpl->assign('musiclist', $arrMusic);
$tpl->assign('selectedLimit', $LIMIT);
$tpl->assign('limitOptions', $limitOptions);

$tpl->assign('uri', $_SERVER['REQUEST_URI']);
$tpl->assign('showPaging', $showPaging);
$tpl->assign('paging', $arrPaging);

$tpl->displayTemplate();

?>
Return current item: Impleo Music Collection Script