Location: PHPKode > projects > Philosopher'Stone Personal > pssp/dvdedt.php
<?php

// Copyright (c) 2010 by Paul M. Foster <hide@address.com>
// Licensed under PostgreSQL License (see LICENSE file)

include('setup.php');

allowed(127, 5);


/* ***** FIELDS TO BE VALIDATED ***** */

$fields = array(
	'id' => array('label' => 'Title', 'rules' => 'required|integer'),
	'newtitle' => array('label' => 'New Title', 'rules' => 'required|text|maxlength[50]')
);


/* ***** CLASS REGISTRATION ***** */

$sc->register('dvd', array('class' => 'dvd', 'shared' => true, 'depends' => 'db', 'arguments' => '%db%'));
$sc->register('validation', array('class' => 'validation', 'shared' => true, 'arguments' => '%fields%'));


/* ***** INSTANTIATE CLASSES HERE ***** */

$app_navs = $sc->appnavs;
$dvd = $sc->dvd;
$v = $sc->validation;

/* ***** VALIDATE USER DATA ***** */

if (count($_POST) == 0) {
	$items = $dvd->get_select_list();
}
elseif ($_POST['save'] === 'Save') {
	$errors = $v->validate();
	if (!$errors) {
		$dvd->alter($_POST['id'], $_POST['newtitle']);
		smsg('Your title has been changed.');
		$items = $dvd->get_select_list();
	}
}


/* ***** PAGE SETUP ***** */

$meta['app_navs'] = $app_navs->get();
$meta['file_mtime'] = date('d F Y H:i:s', getlastmod());
$meta['mod_navs'] = array(
	array('url' => 'dvdadd.php', 'txt' => 'Add Title'),
	array('url' => 'dvddel.php', 'txt' => 'Delete Title'),
	array('url' => 'dvd.php', 'txt' => 'List Titles')
);
$meta['return_url'] = 'dvdedt.php';
$meta['app_title'] = 'DVD';
$meta['page_title'] = 'Edit DVD';
$meta['view_file'] = fullpath('view', 'dvdedt');

include('generic.php');
Return current item: Philosopher'Stone Personal