function viewAll($f3) { $db = $f3->get('db'); // Get Channels $channels = new Db\SQL\Mapper($f3->get('db'), 'channels'); $channels = $channels->find(); $f3->set('channels', $channels); // Get Videos $videos = new Db\SQL\Mapper($f3->get('db'), 'videos'); foreach ($channels as $channel) { $videoArray[$channel->id] = $videos->find(array('channel=?', $channel->id)); } $f3->set('videos', $videoArray); echo Template::instance()->render('templates/header.html'); echo Template::instance()->render('templates/channels.html'); }
$f3->config('config.cfg'); require 'video.php'; require 'channel.php'; require 'user.php'; $f3->set('DEBUG', 1); $f3->set('db', new DB\SQL('sqlite:' . $f3->get('DATABASE_FILE'))); $f3->set('CACHE', true); // Required For Sessions new Session(); if ($f3->get('ALLOW_EMBED')) { $f3->set('XFRAME', 0); } $f3->route('GET /', function ($f3) { // Get Channels $channels = new Db\SQL\Mapper($f3->get('db'), 'channels'); $f3->set('channels', $channels->find()); echo Template::instance()->render('templates/index.html'); }); $f3->route('GET /channel/@channelID/status', 'Channel->status'); if (!$f3->get('READ_ONLY')) { if (!$f3->get('LOGIN') || $f3->get('SESSION')) { $f3->route('GET @channelList: /channels', 'Channel->viewAll'); $f3->route('GET /channel/new', 'Channel->addForm'); $f3->route('POST /channel/new', 'Channel->add'); $f3->route('GET @channelEdit: /channel/@channelID/edit', 'Channel->editForm'); $f3->route('POST /channel/@channelID/edit', 'Channel->edit'); $f3->route('GET /channel/@channelID/new', 'Video->addForm'); $f3->route('POST /channel/@channelID/new', 'Video->add'); $f3->route('GET /channel/@channelID/@videoID', 'Video->editForm'); $f3->route('POST /channel/@channelID/@videoID', 'Video->edit'); } else {