Add a Main subclass to customise the templating directory structure
This commit is contained in:
@@ -1,32 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
define('ML_File', 'index');
|
||||||
|
|
||||||
require_once('../private/config.php');
|
require_once('../private/config.php');
|
||||||
require_once(SihnonFramework_Lib . 'SihnonFramework/Main.class.php');
|
require_once(SihnonFramework_Lib . 'SihnonFramework/Main.class.php');
|
||||||
|
|
||||||
require 'smarty/Smarty.class.php';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Sihnon_Main::registerAutoloadClasses('SihnonFramework', SihnonFramework_Lib, 'MediaListing', Sihnon_Main::makeAbsolutePath('../source/lib/'));
|
Sihnon_Main::registerAutoloadClasses('SihnonFramework', SihnonFramework_Lib, 'MediaListing', Sihnon_Main::makeAbsolutePath('../source/lib/'));
|
||||||
$main = MediaListing_Main::instance();
|
$main = MediaListing_Main::instance();
|
||||||
|
$smarty = $main->smarty();
|
||||||
|
|
||||||
$smarty = new Smarty();
|
$page = new MediaListing_Page($smarty, $main->request());
|
||||||
$smarty->template_dir = '../source/templates';
|
if ($page->evaluate()) {
|
||||||
$smarty->compile_dir = '../private/tmp/templates';
|
|
||||||
$smarty->cache_dir = '../private/tmp/cache';
|
|
||||||
$smarty->config_dir = '../private/config';
|
|
||||||
$smarty->register_modifier('formatDuration', array('MediaListing_Main', 'formatDuration'));
|
|
||||||
$smarty->register_modifier('formatFilesize', array('MediaListing_Main', 'formatFilesize'));
|
|
||||||
$smarty->assign('version', '0.1');
|
|
||||||
$smarty->assign('base_uri', $main->baseUri());
|
|
||||||
|
|
||||||
$request = new MediaListing_RequestParser(isset($_GET['l']) ? $_GET['l'] : '');
|
|
||||||
$page = new MediaListing_Page($smarty, $request);
|
|
||||||
if ($page->evaluate(
|
|
||||||
array(
|
|
||||||
'smarty' => $smarty,
|
|
||||||
'request' => $request,
|
|
||||||
)
|
|
||||||
)) {
|
|
||||||
$smarty->display('index.tpl');
|
$smarty->display('index.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
67
source/lib/MediaListing/Main.class.php
Normal file
67
source/lib/MediaListing/Main.class.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'smarty/Smarty.class.php';
|
||||||
|
|
||||||
|
class MediaListing_Main extends SihnonFramework_Main {
|
||||||
|
|
||||||
|
protected static $instance;
|
||||||
|
|
||||||
|
protected $template_dir = '../source/templates';
|
||||||
|
protected $template_code_dir = '../source/pages';
|
||||||
|
|
||||||
|
protected $smarty;
|
||||||
|
protected $request;
|
||||||
|
|
||||||
|
protected function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$request_string = isset($_GET['l']) ? $_GET['l'] : '';
|
||||||
|
|
||||||
|
$this->request = new MediaListing_RequestParser($request_string, $this->template_dir, $this->template_code_dir);
|
||||||
|
|
||||||
|
if (ML_File == 'index') {
|
||||||
|
$this->smarty = new Smarty();
|
||||||
|
$this->smarty->template_dir = $this->template_dir;
|
||||||
|
$this->smarty->compile_dir = '../private/tmp/templates';
|
||||||
|
$this->smarty->cache_dir = '../private/tmp/cache';
|
||||||
|
$this->smarty->config_dir = '../private/tmp/config';
|
||||||
|
|
||||||
|
$this->smarty->registerPlugin('modifier', 'formatDuration', array('MediaListing_Main', 'formatDuration'));
|
||||||
|
$this->smarty->registerPlugin('modifier', 'formatFilesize', array('MediaListing_Main', 'formatFilesize'));
|
||||||
|
|
||||||
|
$this->smarty->assign('version', '0.1');
|
||||||
|
$this->smarty->assign('messages', array());
|
||||||
|
|
||||||
|
$this->smarty->assign('base_uri', $this->base_uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the directory where page templates can be found
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function templateDir() {
|
||||||
|
return $this->template_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Smarty
|
||||||
|
*/
|
||||||
|
public function smarty() {
|
||||||
|
return $this->smarty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return MediaListing_RequestParser
|
||||||
|
*/
|
||||||
|
public function request() {
|
||||||
|
return $this->request;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = MediaListing_Main::instance()->config();
|
$main = MediaListing_Main::instance();
|
||||||
|
$config = $main->config();
|
||||||
|
$request = $main->request();
|
||||||
|
$smarty = $main->smarty();
|
||||||
|
|
||||||
$source_paths = $config->get('sources');
|
$source_paths = $config->get('sources');
|
||||||
$sources = array();
|
$sources = array();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user