<?php
require_once(MODULE_PATH . "/gallery/gallery.php");

$m = new Gallery();

// Transfer page fields to module settings.
foreach($page->fields as $f)
{
	$m->set($f->key, $f->value);
}

// This goes AFTER we transfer the settings so that the theme will be included properly.
$m->load(0); // Causes some important code to run. Nothing will be loaded.
$m->set("title", "");
$m->set("title_heading_level", "");

$CI = get_instance();

if($m->enable_jquery())
{
	$CI->enable_jquery = true;
}
if($m->enable_jquery_ui())
{
	$CI->enable_jquery_ui = true;
}

foreach($m->scripts() as $script)
{
	$CI->scripts[] = $script;
}

if(file_exists(MODULE_PATH . "/gallery/gallery.less"))
{
	$CI->less[] = MODULE_PATH . "/gallery/gallery.less";
}

$m->render();
