Ejemplo n.º 1
0
	function contact () {
		
		if ($_GET['sent']) {
			return $this->page('contact', array('sent' => True));
		}
		
		$f = new Form();
		$f->add_fields(array(
			'name' => new CharField('Name', array('length' => 100)),
			'email' => new CharField('E-mail', array('length' => 100)),
			'message' => new TextField('Message'),
		));
		
		$context = array(
			'contact_form' => $f,
		);
		
		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
			
			$f->input($_POST);
			
			if ( !($_POST['name'] && $_POST['email'] && $_POST['message']) ) {
				$context['error'] = 'All fields are required. Please complete the form.';
			}
			elseif (!validate_email($_POST['email'])) {
				$context['error'] = 'Invalid e-mail address.';
			}
			else {
				
				// Get e-mail address from the Settings app
				$to = Frix::app('settings')->get('contact_email');
				
				// Send the e-mail
				$ok = send_mail('Contact', $f->get_message(), $f->get_email(), $to);
				
				// Error sending the message?
				if (!$ok) {
					$context['error'] = 'Couldn\'t send message, please try again later.';
				}
				else {
					redir('./?sent=1');
				}
				
			}
			
		}
		
		return $this->page('contact', $context);
		
	}
Ejemplo n.º 2
0
	function run_view () {
		
		// Get an instance of an app and load the views
		$this->app = Frix::app($this->app_name);
		
		// Check if the class is valid and the method exists
		if (method_exists($this->app->views, $this->view_name)) {
			
			// Call the view method passing params found by check_route
			call_user_func_array(array(&$this->app->views, $this->view_name), $this->params);
			
			// Return success
			return true;
			
		}
		
		// No view found, throw an error!
		throw new RouterNoViewException(sprintf('View "%s" not found on app "%s".', $this->view_name, $this->app_name));
		
	}
Ejemplo n.º 3
0
Archivo: Frix.php Proyecto: ricobl/frix
	static function model ($app_name, $name) {
		Frix::app($app_name)->load_model($name);
	}
Ejemplo n.º 4
0
<?
// Get models
Frix::model('cms', 'CmsPage');
Frix::model('cms', 'CmsFile');
Frix::model('cms', 'CmsImage');
Frix::model('cms', 'CmsVideo');

Frix::model('cms', 'CmsMenu');
Frix::model('cms', 'CmsMenuItem');

class CmsPageOptions extends AdminOptions {
	
	public $inlines = array('CmsFile', 'CmsImage', 'CmsVideo');
	public $list_display = array('title', 'slug', 'visible');
	
	public $custom_position = 'pos';
	
}

class CmsMenuOptions extends AdminOptions {
	
	public $inlines = array('CmsMenuItem');
	
}

// Register
Frix::app('admin')->register('CmsPage', 'CmsPageOptions');
Frix::app('admin')->register('CmsMenu', 'CmsMenuOptions');
?>
Ejemplo n.º 5
0
				redir('../?msg=changed');
			}
			
		}
		
		// Get form and password field
		$f = $this->get_form();
		$password = $f->fields['password'];
		
		// Enable and clear password field
		$password->editable = true;
		$password->value = '';
		
		// Move password field to the end
		unset($f->fields['password']);
		$f->fields['password'] = $password;
		
		// Add password confirmation field
		$f->add_field('password_conf', new PasswordField('Confirm'));
		
		$context['form'] = $f;
		$context['inlines'] = $this->get_inlines();
		
	}
	
}

// Register
Frix::app('admin')->register('AuthUser', 'AuthUserOptions');
?>
Ejemplo n.º 6
0
<?
// Get models
Frix::model('settings', 'SettingsProperty');

class SettingsPropertyOptions extends AdminOptions {
	
	public $list_display = array('name', 'value');
	
	public $can_add = false;
	public $can_delete = false;
	public $can_change = true;
	
}

// Register
Frix::app('admin')->register('SettingsProperty', 'SettingsPropertyOptions');
?>
Ejemplo n.º 7
0
	function app ($app_name) {
		
		// Get the app
		$this->context_app($app_name);
		
		$registry = Frix::app('admin')->registry[$app_name];
		
		// If there's only one model, redirect to the model page
		if (count($registry) == 1) {
			$first = reset($registry);
			redir(self::$root . $first->meta->admin_url);
		}
		
		// Get the meta models
		// $models = array();
		// foreach ($registry as $k => $options) {
			// $models[$k] = $options->meta;
		// }
			
		// Save model-list into the context
		self::$context['models_options'] = $registry;
		
		$t = new Template(
			sprintf('frix/admin/%s/app', $app_name),
			'frix/admin/app'
		);
		echo $t->render(self::$context);
		
	}
Ejemplo n.º 8
0
Archivo: base.php Proyecto: ricobl/frix
				<? endforeach; ?>
			</ul>
		</div>
	</div>
	
	<div id="main">
		<div id="contents">
			<? block('contents') ?><? end_block() ?>
		</div>

		<div id="sidebar">
			<? block('sidebar') ?>
				<div class="box">
					<h3>Pages</h3>
					<ul>
						<? foreach (Frix::app('cms')->get_root_pages() as $item): ?>
							<li><a href="<?php 
echo $item->slug;
?>
/"><?php 
echo $item->title;
?>
</a></li>
						<? endforeach; ?>
					</ul>
				</div>
			<? end_block() ?>
		</div>
	</div>
</div>