Implemented some core changes to the Layout system
This commit is contained in:
parent
a9212d9709
commit
0910b30d93
|
@ -50,9 +50,9 @@ class Layout {
|
|||
|
||||
/**
|
||||
* The directory of the file to be loaded by the layout manager
|
||||
* @var null|string
|
||||
* @var string
|
||||
*/
|
||||
public static $directory = null;
|
||||
public static $directory = 'Application/Views';
|
||||
|
||||
/**
|
||||
* All assigned currently assigned to the template
|
||||
|
@ -96,7 +96,8 @@ class Layout {
|
|||
* @return void
|
||||
* @throws LayoutException On error
|
||||
*/
|
||||
public static function view($file, $directory = 'Application/Views') {
|
||||
public static function view($file, $directory = null) {
|
||||
$directory = (is_null($directory) ? self::$directory : $directory);
|
||||
echo self::get($file, $directory);
|
||||
return;
|
||||
}
|
||||
|
@ -114,7 +115,8 @@ class Layout {
|
|||
* @return String The output of the template
|
||||
* @throws LayoutException On error
|
||||
*/
|
||||
public static function get($file, $directory = 'Application/Views') {
|
||||
public static function get($file, $directory = null) {
|
||||
$directory = (is_null($directory) ? self::$directory : $directory);
|
||||
Logger::newLevel("Loading template file '".$file."' in '".$directory."'");
|
||||
|
||||
// First load the template engines
|
||||
|
@ -198,7 +200,7 @@ class Layout {
|
|||
* @throws LayoutException On error
|
||||
*/
|
||||
public static function getFileFromString($string, $directory, $extensions = array()) {
|
||||
$directory = preg_replace('#/+#','/',(!is_null($directory) ? $directory : "Application/Views") . "/");
|
||||
$directory = preg_replace('#/+#','/',(!is_null($directory) ? $directory : self::$directory) . "/");
|
||||
|
||||
if (!file_exists($directory)) {
|
||||
throw new LayoutException("Could not get file. Directory does not exist", 1);
|
||||
|
@ -260,7 +262,7 @@ class Layout {
|
|||
*/
|
||||
public static function setFileFromString($string, $directory, $extensions = array()) {
|
||||
self::$file = self::getFileFromString($string, $directory, $extensions);
|
||||
self::$directory = preg_replace('#/+#','/',(!is_null($directory) ? $directory : "Application/Views") . "/");
|
||||
self::$directory = preg_replace('#/+#','/',(!is_null($directory) ? $directory : self::$directory) . "/");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,7 @@ class LayoutTest extends CoreTestAbstract
|
|||
|
||||
/**
|
||||
* @depends testGetFileExtensions
|
||||
* @todo Add malformed paths
|
||||
*/
|
||||
public function testGetFilePath(){
|
||||
|
||||
|
|
|
@ -359,14 +359,14 @@ class QueryTests extends \CoreTestAbstract {
|
|||
|
||||
public function testUpdateSimple(){
|
||||
|
||||
$this->query->update('table')->set(array('field' => 'value'));
|
||||
$this->query->setTable('table')->update()->set(array('field' => 'value'));
|
||||
$this->assertEquals('UPDATE table SET field=?', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
}
|
||||
|
||||
public function testUpdateMultiple(){
|
||||
|
||||
$this->query->update('table')->set(array('field1' => 'value1', "field2" => 'value2'));
|
||||
$this->query->setTable('table')->update()->set(array('field1' => 'value1', "field2" => 'value2'));
|
||||
$this->assertEquals('UPDATE table SET field1=?, field2=?', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ class QueryTests extends \CoreTestAbstract {
|
|||
|
||||
public function testDeleteSimple(){
|
||||
|
||||
$this->query->delete()->from('table');
|
||||
$this->query->setTable('table')->delete();
|
||||
$this->assertEquals('DELETE FROM table', $this->query->getSql());
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ class QueryTests extends \CoreTestAbstract {
|
|||
|
||||
public function testReplaceSimple(){
|
||||
|
||||
$this->query->replace(array('field' => 'value'), 'table');
|
||||
$this->query->setTable('table')->replace(array('field' => 'value'));
|
||||
$this->assertEquals('REPLACE INTO table (field) VALUES (?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value'), $this->query->getBinds());
|
||||
|
||||
|
@ -415,7 +415,7 @@ class QueryTests extends \CoreTestAbstract {
|
|||
|
||||
public function testReplaceMultiple(){
|
||||
|
||||
$this->query->replace(array('field1' => 'value1', 'field2' => 'value2'), 'table');
|
||||
$this->query->setTable('table')->replace(array('field1' => 'value1', 'field2' => 'value2'));
|
||||
$this->assertEquals('REPLACE INTO table (field1,field2) VALUES (?,?)', $this->query->getSql());
|
||||
$this->assertEquals(array('value1', 'value2'), $this->query->getBinds());
|
||||
|
||||
|
|
Loading…
Reference in New Issue