Exemple #1
0
	function find_template ($template) {
		
		// Template param may be a string or an array
		// If it's not an array, put the string in a new array
		if (!is_array($template)) {
			$template = array($template);
		}
		
		// Loop through template paths config
		foreach (Frix::config('TEMPLATE_PATHS') as $path) {
			
			foreach ($template as $template_file) {
				
				$template_path = join_path(array($path, $template_file . '.php'));
				
				if (file_exists($template_path)) {
					return $template_path;
				}
				
			}
			
		}
		
		// No template found? Throw an exception.
		// debug($template);
		throw new TemplateException(sprintf('Template(s) "%s" not found!', implode('", "', $template)));
		
	}
Exemple #2
0
	function __construct ($name) {
		
		$apps = Frix::config('APPS');
		
		// Check if app is installed or throw an exception
		if (!array_key_exists($name, $apps)) {
			throw new AppException(sprintf('Application "%s" not installed!', $name));
		}
		
		// Set name
		$this->name = $name;
		
		// Use the class-name to create verbose_name if it's not set
		$v_name = preg_replace('/App$/', '', get_class($this));
		def($this->verbose_name, $v_name);
		
		// Configure the application path
		// $this->path = join_path(array(Frix::config('ROOT'), $apps[$name]));
		$this->path = $apps[$name];
		
		// Setup models and views path
		def($this->views_path, join_path(array($this->path, 'views.php')));
		def($this->models_path, join_path(array($this->path, 'models')));
		
	}
Exemple #3
0
	static function flash ($src, $width, $height, $get = '', $params = array()) {
		
		$src = url(Frix::config('MEDIA_URL'), $src);
		
		$get = ($get ? '?' : '') . $get;
		
		$context = array(
			'src' => $src . $get,
			'src_no_ext' => dirname($src) . '/' . basename($src, '.swf') . $get,
			'width' => $width,
			'height' => $height,
		);
		
		// Load template and render
		$t = new Template('frix/html/flash');
		return $t->render($context);
		
	}
Exemple #4
0
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<title><?php 
echo Frix::config('PROJECT_TITLE');
?>
 -- Error <?php 
echo $error_code;
?>
</title>
</head>

<body>

<h1>Error: <?php 
echo $error_code;
?>
</h1>

<p><?php 
echo $error_msg;
?>
</p>

</body>
</html>
Exemple #5
0
	function get_absolute_url () {
		return url(Frix::config('WEB_ROOT'), $this->slug);
	}
Exemple #6
0
	static function app ($app_name) {
		
		if (!array_key_exists($app_name, Frix::$app_cache)) {
			
			// Import app definition file
			import(join_path(array(Frix::config('APPS', $app_name), 'app.php')));
			
			// Convert app-name to app-classname: news -> NewsApp
			// $app_class = ucfirst(strtolower($app_name)) . 'App';
			$app_class = camel($app_name) . 'App';
			
			// Create a new instance of the app in the cache
			Frix::$app_cache[$app_name] = new $app_class($app_name);
			
		}
		
		// Return the app from the cache
		return Frix::$app_cache[$app_name];
		
	}
Exemple #7
0
<? $this->extend('frix/admin/base') ?>

<? block('scripts') ?>
<script type="text/javascript" src="<?php 
echo url(Frix::config('FRIX_MEDIA'), 'gz.php?file=admin/js/j.js');
?>
"></script>
<script type="text/javascript" src="<?php 
echo url(Frix::config('FRIX_MEDIA'), 'gz.php?file=admin/js/add_change.js');
?>
"></script>
<? end_block() ?>

<? $this->block('contents') ?>
	<form <?php 
echo Template::attrs($form->attrs);
?>
 enctype="multipart/form-data">
		
		<?php 
echo $form->render_fields();
?>
			
		<? foreach ($inlines as $inline): ?>
			<fieldset class="inline">
				<h3><?php 
echo $inline->meta->verbose_name_plural;
?>
</h3>
				<table>
					<?
Exemple #8
0
	function get_thumb ($width = null, $height = null) {
		
		load('Image');
		
		$path = $this->get_real_path();
		
		// Value to append to the thumbnail filename
		$extra = '_t';
		
		// Append width and/or height if size changed
		if ($width) {
			$extra .= '_w' . $width;
		}
		if ($height) {
			$extra .= '_h' . $height;
		}
		
		// Split file path and change file name
		$path_info = pathinfo($path);
		$path_info['filename'] .= $extra;
		
		// Join path together
		$new_path = sprintf('%s/%s.%s', $path_info['dirname'], $path_info['filename'], $path_info['extension']);
		
		// If the thumbnail doesn't exists or the original has been modified
		if (!file_exists($new_path) || (filemtime($path) > filemtime($new_path))) {
			// Create image object
			$i = Image::open($path);
			// Adjust size
			$i->fit($width, $height);
			
			$i->save_as($new_path);
		}
		
		return url(Frix::config('MEDIA_URL'), $this->path, sprintf('%s.%s', $path_info['filename'], $path_info['extension']));
		
	}
Exemple #9
0
	function files_list ($root, $path = '') {
		
		$fb_root = url(self::$root, $root);
		
		self::$context['filebrowser'] = true;
		
		$this->context_breadcrumbs('Filebrowser', $fb_root);
		
		$files = array();
		
		// Fix empty path
		$path = preg_replace('#(^/)|(/$)#', '', $path);
		
		$real_path = join_path(Frix::config('MEDIA_ROOT'), $this->file_manager_path, $path);
		
		if ($path) {
			
			$current_path = $fb_root;
			$parts = explode('/', $path);
			
			foreach ($parts as $part) {
				$current_path = url($current_path, $part);
				$this->context_breadcrumbs($part, $current_path);
			}
			
			// Remove current dir
			array_pop($parts);
			
			$files[] = array(
				'name' => '.. (' . end($parts) . ')',
				'class' => 'up',
				'size' => '&nbsp;',
				'is_dir' => true,
				'is_empty' => false,
				'link' => url($fb_root, dirname($path)),
			);
		}
		
		if (!is_dir($real_path)) {
			throw new Http404Exception;
		}
		
		if ($_POST['new_dir']) {
			return $this->files_new_dir($real_path);
		}
		elseif ($_POST['new_file']) {
			return $this->files_new($real_path);
		}
		elseif ($_GET['del']) {
			return $this->files_delete($real_path);
		}
		
		if ($_GET['err']) {
			
			self::$context['msg_type'] = 'err';
			
			if ($_GET['err'] == 'bad_upload') {
				load('Upload');
				self::$context['msg'] = Upload::$errors[$_GET['code']];
			}
			else {
				$msg = array(
					'err_upload' => 'Couldn\'t save file, check your permissions.',
					'bad_dir' => 'Invalid or forbidden folder name!',
					'file_exists' => 'File or folder already exists, try a different name.',
					'del_dir' => 'Couldn\'t remove folder, check if it is empty.',
					'del_file' => 'Couldn\'t remove folder, check your permissions.',
					'not_found' => 'Object not found!',
				);
				
				self::$context['msg'] = $msg[$_GET['err']];
			}
			
			
		}
		elseif ($_GET['msg']) {
			$msg = array(
				'new_dir' => 'Folder created sucessfully!',
				'del_dir' => 'Folder removed sucessfully!',
				'del_file' => 'File removed sucessfully!',
				'new_file' => 'File uploaded sucessfully!',
			);
			
			self::$context['msg'] = $msg[$_GET['msg']];
			self::$context['msg_type'] = 'ok';
		}
		
		// Load a list of files not starting with a dot
		$file_list = Fs::dir($real_path, '^[^.].*');
		
		$base_link = url(Frix::config('MEDIA_URL'), $this->file_manager_path, $path);
		
		foreach ($file_list as $file) {
			
			$full_path = join_path($real_path, $file);
			
			$file_obj = array(
				'name' => $file,
			);
			
			if (is_dir($full_path)) {
				$file_obj['size'] = '&nbsp;';
				$file_obj['link'] = url($fb_root, $path, $file);
				$file_obj['is_dir'] = true;
				$file_obj['is_empty'] = Fs::is_empty_dir($full_path);
				$file_obj['class'] = 'dir';
			}
			else {
				$file_obj['size'] = Fs::format_size(Fs::file_size($full_path), 1);
				$file_obj['link'] = url($base_link, $file);
				$file_obj['target'] = '_blank';
				$file_obj['class'] = Fs::extension($file);
			}
			
			$files[] = $file_obj;
			
		}
		
		self::$context['files'] = $files;
		
		$t = new Template('frix/admin/filebrowser/list');
		echo $t->render(self::$context);
		
	}
Exemple #10
0
>

<div id="container">
	
	<div id="header">
		<h1><a href="<?php 
echo url(Frix::config('WEB_ROOT'));
?>
"><?php 
echo Frix::config('PROJECT_TITLE');
?>
</a></h1>
		<div id="menu">
			<ul>
				<li><a href="<?php 
echo url(Frix::config('WEB_ROOT'));
?>
">Home</a></li>
				<? foreach (Frix::app('cms')->get_root_pages() as $item): ?>
					<li><a href="<?php 
echo $item->get_absolute_url();
?>
"><?php 
echo $item->title;
?>
</a></li>
				<? endforeach; ?>
			</ul>
		</div>
	</div>
	
Exemple #11
0
<? extend('frix/admin/base') ?>

<? if ($popup): ?>
	<? block('body_attr') ?> id="filebrowser" class="popup"<? end_block() ?>
	<? block('scripts') ?>
	<script type="text/javascript" src="<?php 
echo url(Frix::config('FRIX_MEDIA'), 'gz.php?file=admin/js/j.js');
?>
"></script>
	<? end_block() ?>
<? else: ?>
	<? block('body_attr') ?> id="filebrowser"<? end_block() ?>
<? endif; ?>

<? block('contents') ?>
	
	<div id="quick_forms">
		<form action="./" method="post">
			<p>
				<label>
					<input type="text" name="dir_name" />
				</label>
				<span class="button"><input type="submit" name="new_dir" value="Create Folder" /></span>
			</p>
		</form>
		<form action="./" method="post" enctype="multipart/form-data">
			<p>
				<label>
					<input type="file" name="file" />
				</label>
				<span class="button"><input type="submit" name="new_file" value="Upload File" /></span>