Exemplo n.º 1
0
	/**
	 * quickbox::__construct()
	 *
	 * @param array $init Initialization configuration
	 *
	 * Constructor which basically creates quickbox
	 * and readies it for doing things.
	 */
	public function __construct ($init)
	{
		# We need to include initialize the config class because it allows us to get and
		# set configuration variables without using a global
		require $init['quickbox/path'] . '/classes/core/config.class.php';
		config::init($init);
		define(DEBUG, config::get('debug'));
		# Start a database connection
		$this->db = new database();
		try
		{
			$this->db->init();
		} catch (Exception $e)
		{
			trigger_error(text::get('system/fatalError',$e->getMessage()), E_USER_ERROR);
		}
		require $init['quickbox/path'] . '/classes/core/metaclass.class.php';
		metaclass::init($this->db);
		# Put the post and get variables into a private for later use.
		$_POST = $_POST;
		$this->qbGet = $_GET;
		# Start the session, giving it the database connection.
		$this->qbSession = new session($this->db);
		if ($this->qbGet['page'] == 'logout')
		{
			$this->qbSession->logout();
		}
		$this->qbSession->checkCookie();
		if (strlen($_POST['user']) > 0 && $_POST['login'] == 1)
		{
			$this->qbErrors['login'] = $this->qbSession->login($_POST['user'], $_POST['password']);
		}
		$this->qbPage = ($_GET['page'] ? janitor::cleanData($_GET['page']) : 'home');
	}
Exemplo n.º 2
0
	function addField ($name, $type, $value = null, $title = null, $linkfield = false, $properties = false)
	{
		$dataType = metaclass::create($type, 'datatypes');
		if ($dataType == null)
		{
			$dataType = metaclass::create('string', 'datatypes');
		}
		if (is_array($dataType->scripts))
		{
			foreach ($dataType->scripts as $k => $v)
			{
				$this->scripts[$k] = $v;
			}
		}
		$this->rows[] = $dataType->formField($name, $title, $value, $linkfield, $properties);
		$dataType = null;
	}
Exemplo n.º 3
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.º 4
0
	public function makeTable ($fields = false)
	{
		if (! $fields)
		{
			$fields[] = 'id';
			foreach ($this->definitions as $k => $v)
			{
				if ($v['ontable'])
				{
					$fields[] = $k;
				}
				if ($v['linkfield'])
				{
					$linkfield = $k;
				}
			}
		}
		$fields2['id'] = "ID";
		foreach ($fields as $v)
		{
			$fields2[$v] = $this->definitions[$v]['title'];
		}
		$fields2['delete'] = "";
		$table = new table($fields2, array (
			'class' => 'span-16'
		));
		$fieldsList = metaclass::getItems($this->table, $fields, $this->keyField);
		foreach ($fieldsList as $k => $v)
		{
			$v['delete'] = text::get('form/delete');
			$table->addRow($v, 
					array (
						$linkfield => array (
							'type' => 'link' , 
							'href' => $this->urlbase . '?id=' . $v['id']
						) , 
						'delete' => array (
							'type' => 'link' , 
							'href' => 'javascript:deleteitem(\'' . $v['id'] . '\',\'' . janitor::cleanData(
									$v['title']) . '\',\'' . $this->urlbase . '\')'
						)
					));
		}
		return $table->output();
	}
Exemplo n.º 5
0
	/**
	 * Creates a table in the image of the property definitions supplied to it.
	 *
	 * @param string $tableName What the table will be called.
	 * @param array $propertyDefinitions The structure of the table.
	 * 
	 * @todo Need to make this use the query class.
	 */
	private static function createTable ($tableName, $propertyDefinitions)
	{
		$query .= " CREATE TABLE `" . metaclass::$db->getProperty('database') . "`.`$tableName` (\n";
		$query .= " `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n";
		foreach ($propertyDefinitions as $k => $v)
		{
			$vars = metaclass::getClassVars($v['type'], 'datatypes');
			$querylines[] .= "`$k` " . (janitor::notNull($vars['fieldtype']) ? $vars['fieldtype'] : 'VARCHAR( 255 )') .
					 " NOT NULL ";
		}
		$query .= implode(",\n", $querylines);
		$query .= ")";
		metaclass::$db->query($query);
		metaclass::$tablesLoaded[] = $tableName;
	}
Exemplo n.º 6
-1
	function formField ($name, $title, $value = null, $linkfield, $properties)
	{
		$cvs = metaclass::getClassVars($properties['requirements']['real']);
		if (metaclass::$db->tableExists($cvs['table']))
		{
			$query = new query();
			$query->select(array (
				'id' , 
				'title'
			))->from($cvs['table']);
			$result = metaclass::$db->query($query);
			$return .= '<label for="' . $name . '">
							' . $title . '
						</label><br/>
						<select  id="' . $name . '" name="' . $name . '">';
			while ($row = metaclass::$db->assoc($result))
			{
				$return .= '<option value="' . $row['id'] . '"' . ($row['id'] == $value ? ' selected' : null) . '>' .
						 $row['title'] . '</option>';
			}
			$return .= '</select>
						<br/>';
		} else
		{
			$return .= '<label for="' . $name . '">
							' . $title . '
						</label><br/>';
			$return .= '<p class="error">' . text::get('form/foreignTableNotExist', $cvs['title']) . '</p>';
		}
		return $return;
	}
Exemplo n.º 7
-1
	function exec ($object)
	{
		$this->object = $object;
		$this->db = $db;
		$classVars = metaclass::getClassVars(get_class($object));
		foreach ($classVars['propertyDefinitions'] as $k => $v)
		{
			$dataType = metaclass::create($v['type'], 'datatypes');
			if ($dataType == null)
			{
				$dataType = metaclass::create('string', 'datatypes');
			}
			$this->check($dataType, $object->properties[$k], $v['title'], $object->id, $k, $classVars['table'], 
					$v['requirements']);
			$dataType = null;
		}
		if ($this->invalid)
		{
			$this->valid = false;
		} else
		{
			$this->valid = true;
		}
	}