Exemplo n.º 1
0
/**
 * news.disp.php
 *
 * @version $Id$
 * @copyright 2008
 */
if (isset($safeGet['name']))
{
	# This code will break in the year 2100 (due to their choice of date format) but we will probably have been
	# eaten by robots by then anyway so it doesn't matter.
	$name = $safeGet['name'];
	$query = new query();
	$query->select('id')->from('newsArticles')->where('name', $name)->limit('1');
	$result = $this->db->query($query);
	$row = $this->db->assoc($result);
	$article = metaclass::load('newsArticle', $row['id']);
	$this->dOutput['news']['header'] = $article->getProperty('title');
	$this->dOutput['news']['content'] = $article->getProperty('text');
} else
{
	$query = new query();
	$query->select(array (
		'id' , 
		'name' , 
		'date' , 
		'title' , 
		'textshort'
	))->from('newsArticles')->order('date', 'desc');
	$result = $this->db->query($query);
	$i = 0;
	while ($row = $this->db->assoc($result))
Exemplo n.º 2
-1
	public function process ($input)
	{
		$this->populate(janitor::unCleanData($input));
		switch ($this->action)
		{
			case 'creating':
				$object = metaclass::create($this->type);
				break;
			case 'updating':
				$object = metaclass::load($this->type, $this->id);
				break;
		}
		foreach ($this->definitions as $k => $v)
		{
			$object->setProperty($k, $input[$k]);
		}
		if ($object->save())
		{
			return true;
		} else
		{
			foreach ($object->invalid as $k => $v)
			{
				foreach ($v as $y => $z)
				{
					$obVars = metaclass::getClassVars($this->type);
					$this->invalid[] = text::get('validation/error_' . $y, 
							array (
								$obVars['propertyDefinitions'][$k]['title']
							));
				}
			}
			return false;
		}
	}