Skip to content
Browse files

Merging changes from revisions [337] [338] [339] [340] [341]

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@342 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
1 parent 7791b8d commit 6460f6e83fd0aee4719f796bd82db140cf405daa @phpnut phpnut committed
Sorry, we could not display the entire diff because it was too big.
View
4 .htaccess
@@ -1,5 +1,5 @@
<IfModule mod_rewrite.c>
RewriteEngine on
- RewriteRule ^$ public/ [L]
- RewriteRule (.*) public/$1 [L]
+ RewriteRule ^$ public/ [L]
+ RewriteRule (.*) public/$1 [L]
</IfModule>
View
38 app/controllers/pages_controller.php
@@ -36,32 +36,32 @@ class PagesController extends PagesHelper{
*
* @var unknown_type
*/
- var $helpers = array('html', 'ajax');
-
+ var $helpers = array('html', 'ajax');
+
/**
* Displays a view
*
*/
- function display()
- {
- if (!func_num_args())
- {
- $this->redirect('/');
- }
+ function display()
+ {
+ if (!func_num_args())
+ {
+ $this->redirect('/');
+ }
- $path = func_get_args();
-
- if (!count($path))
- {
- $this->redirect('/');
- }
+ $path = func_get_args();
+
+ if (!count($path))
+ {
+ $this->redirect('/');
+ }
- $this->set('page', $path[0]);
- $this->set('subpage', empty($path[1])? null: $path[1]);
- $this->set('title', ucfirst($path[count($path)-1]));
- $this->render(join('/', $path));
- }
+ $this->set('page', $path[0]);
+ $this->set('subpage', empty($path[1])? null: $path[1]);
+ $this->set('title', ucfirst($path[count($path)-1]));
+ $this->render(join('/', $path));
+ }
}
View
10 app/controllers/tests_controller.php
@@ -29,11 +29,11 @@ class TestsController extends TestsHelper {
* Runs all library and application tests
*
*/
- function test_all ()
- {
- $this->layout = null;
- require_once SCRIPTS.'test.php';
- }
+ function test_all ()
+ {
+ $this->layout = null;
+ require_once SCRIPTS.'test.php';
+ }
}
?>
View
6 app/views/layouts/default.thtml
@@ -1,9 +1,9 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="pl" xml:lang="pl">
<head>
- <title><?=$title_for_layout?></title>
- <?=$html->charsetTag('UTF-8')?>
- <?=$html->cssTag('default')?>
+ <title><?=$title_for_layout?></title>
+ <?=$html->charsetTag('UTF-8')?>
+ <?=$html->cssTag('default')?>
</head>
<body>
View
8 app/views/layouts/test.thtml
@@ -34,14 +34,14 @@ background-color:#F8F8F8;
padding:.5em 1em .5em 2em;
}
TR.info .ok {
- color:Green;
+ color:Green;
}
TR.info .not {
- color:Red;
+ color:Red;
}
TR.info EM {
- color:Gray;
- font-style:normal;
+ color:Gray;
+ font-style:normal;
}
TR.unkn TD {
background-color:#FF0;
View
20 app/views/pages/home.thtml
@@ -11,12 +11,12 @@
<h2>Features</h2>
<ul>
- <li>Compatibile with PHP4 and PHP5.</li>
- <li>Supplies integrated <acronym title="Create, Read, Update, Delete">CRUD</acronym> for databases.</li>
- <li>Pretty URL's that work with and without mod_rewrite.</li>
- <li>Fast, flexible templating (PHP syntax with helper methods).</li>
- <li>Suported database-types: MySQL, PostgreSQL and SQLIte</li>
- <li>Suported webservers: Apache (others will most likely also work)</li>
+ <li>Compatibile with PHP4 and PHP5.</li>
+ <li>Supplies integrated <acronym title="Create, Read, Update, Delete">CRUD</acronym> for databases.</li>
+ <li>Pretty URL's that work with and without mod_rewrite.</li>
+ <li>Fast, flexible templating (PHP syntax with helper methods).</li>
+ <li>Suported database-types: MySQL, PostgreSQL and SQLIte</li>
+ <li>Suported webservers: Apache (others will most likely also work)</li>
</ul>
<p>Cake is still in its early infancy, but we are proceeding in good direction &ndash; table joins will most probably get added in 0.9.3 release, and better support for user-defined settings is also underway.</p>
@@ -26,10 +26,10 @@
<p>Cake PHP needs you! We have already quiet active user base, but we are allways open to new bug reports or feature ideas!</p>
<ul>
- <li><?=$html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> &ndash; for public discussions about everything Cake.</li>
- <li><?=$html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> &ndash; fastest way of getting newest information on Cake PHP.</li>
- <li><?=$html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.</li>
- <li><?=$html->linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> &ndash; check our plans for the bright future.</li>
+ <li><?=$html->linkOut('Google Group','http://groups-beta.google.com/group/cake-php')?> &ndash; for public discussions about everything Cake.</li>
+ <li><?=$html->linkOut('Wiki','https://trac.cakephp.org/wiki')?> &ndash; fastest way of getting newest information on Cake PHP.</li>
+ <li><?=$html->linkOut('Report a bug or feature request','https://trac.cakephp.org/newticket')?>.</li>
+ <li><?=$html->linkOut('Roadmap','https://trac.cakephp.org/roadmap')?> &ndash; check our plans for the bright future.</li>
</ul>
<p>Soon there will be oficial <?=$html->linkOut('Cake PHP website','http://www.cakephp.org/')?>, so stay tuned.</p>
View
28 config/database.php.default
@@ -21,21 +21,21 @@
*/
class DATABASE_CONFIG
{
- var $default = array(
- 'driver' => 'mysql',
- 'host' => 'localhost',
- 'login' => 'www',
- 'password' => '',
- 'database' => 'project_name'
- );
+ var $default = array(
+ 'driver' => 'mysql',
+ 'host' => 'localhost',
+ 'login' => 'www',
+ 'password' => '',
+ 'database' => 'project_name'
+ );
- var $test = array(
- 'driver' => 'mysql',
- 'host' => 'localhost',
- 'login' => 'www-test',
- 'password' => '',
- 'database' => 'project_name-test'
- );
+ var $test = array(
+ 'driver' => 'mysql',
+ 'host' => 'localhost',
+ 'login' => 'www-test',
+ 'password' => '',
+ 'database' => 'project_name-test'
+ );
}
?>
View
2 config/paths.php
@@ -23,7 +23,7 @@
*/
if(!defined('ROOT'))
{
- define ('ROOT', '../');
+ define ('ROOT', '../');
}
/**
View
28 config/tags.php
@@ -34,32 +34,32 @@
/**
* Tag template for an input type='text' tag.
*/
-define('TAG_INPUT', '<input name="data[%s]" %s/>');
+define('TAG_INPUT', '<input name="data[%s][%s]" %s/>');
/**
* Tag template for an input type='hidden' tag.
*/
-define('TAG_HIDDEN', '<input type="hidden" name="data[%s]" %s/>');
+define('TAG_HIDDEN', '<input type="hidden" name="data[%s][%s]" %s/>');
/**
* Tag template for a textarea tag.
*/
-define('TAG_AREA', '<textarea name="data[%s]"%s>%s</textarea>');
+define('TAG_AREA', '<textarea name="data[%s][%s]"%s>%s</textarea>');
/**
* Tag template for a input type='checkbox ' tag.
*/
-define('TAG_CHECKBOX', '<label for="tag_%s"><input type="checkbox" name="data[%s]" id="tag_%s" %s/>%s</label>');
+define('TAG_CHECKBOX', '<label for="tag_%s"><input type="checkbox" name="data[%s][%s]" id="tag_%s" %s/>%s</label>');
/**
* Tag template for a input type='radio' tag.
*/
-define('TAG_RADIOS', '<label for="tag_%s"><input type="radio" name="data[%s]" id="tag_%s" %s/>%s</label>');
+define('TAG_RADIOS', '<label for="tag_%s"><input type="radio" name="data[%s][%s]" id="tag_%s" %s/>%s</label>');
/**
* Tag template for a select opening tag.
*/
-define('TAG_SELECT_START', '<select name="data[%s]"%s>');
+define('TAG_SELECT_START', '<select name="data[%s][%s]"%s>');
/**
* Tag template for an empty select option tag.
@@ -74,32 +74,32 @@
/**
* Tag template for a closing select tag.
*/
-define('TAG_SELECT_END', '</select>');
+define('TAG_SELECT_END', '</select>');
/**
* Tag template for a password tag.
*/
-define('TAG_PASSWORD', '<input type="password" name="data[%s]" %s/>');
+define('TAG_PASSWORD', '<input type="password" name="data[%s][%s]" %s/>');
/**
* Tag template for a file input tag.
*/
-define('TAG_FILE', '<input type="file" name="%s" %s/>');
+define('TAG_FILE', '<input type="file" name="%s" %s/>');
/**
* Tag template for a submit button tag.
*/
-define('TAG_SUBMIT', '<input type="submit" %s/>');
+define('TAG_SUBMIT', '<input type="submit" %s/>');
/**
* Tag template for an image tag.
*/
-define('TAG_IMAGE', '<img src="%s" alt="%s" %s/>');
+define('TAG_IMAGE', '<img src="%s" alt="%s" %s/>');
/**
* Tag template for a table header tag.
*/
-define('TAG_TABLE_HEADER', '<th%s>%s</th>');
+define('TAG_TABLE_HEADER', '<th%s>%s</th>');
/**
* Tag template for table headers row tag.
@@ -109,12 +109,12 @@
/**
* Tag template for a table cell tag.
*/
-define('TAG_TABLE_CELL', '<td%s>%s</td>');
+define('TAG_TABLE_CELL', '<td%s>%s</td>');
/**
* Tag template for a table row tag.
*/
-define('TAG_TABLE_ROW', '<tr%s>%s</tr>');
+define('TAG_TABLE_ROW', '<tr%s>%s</tr>');
/**
* Tag template for a CSS link tag.
View
74 index.php
@@ -46,43 +46,41 @@
* As mod_rewrite (or .htaccess files) is not working, we need to take care
* of what would normally be rewrited, i.e. the static files in /public
*/
-if (empty($_GET['url']) || ($_GET['url'] == '/'))
-{
- require (ROOT.'public/index.php');
-}
-else
-{
- $elements = explode('/index.php?url=', $_SERVER['REQUEST_URI']);
- $base = $elements[0].'/public';
- $path = $elements[1];
-
- $filename = ROOT.'public'.str_replace('/', DS, $path);
- $url = $base.$path;
-
- if (file_exists($filename))
- {
- if (preg_match('/^.*\.([a-z]+)$/i', $filename, $ext))
- {
- switch ($ext[1])
- {
- case 'jpg':
- case 'jpeg':
- header('Content-type: image/jpeg');
- break;
-
- case 'css':
- header('Content-type: text/css');
- }
- }
-
- print (file_get_contents($filename));
- die();
- }
- else
- {
- require (ROOT.'public/index.php');
- }
-}
-
+ if (empty($_GET['url']) || ($_GET['url'] == '/'))
+ {
+ require (ROOT.'public/index.php');
+ }
+ else
+ {
+ $elements = explode('/index.php?url=', $_SERVER['REQUEST_URI']);
+ $base = $elements[0].'/public';
+ $path = $elements[1];
+
+ $filename = ROOT.'public'.str_replace('/', DS, $path);
+ $url = $base.$path;
+ if (file_exists($filename))
+ {
+ if (preg_match('/^.*\.([a-z]+)$/i', $filename, $ext))
+ {
+ switch ($ext[1])
+ {
+ case 'jpg':
+ case 'jpeg':
+ header('Content-type: image/jpeg');
+ break;
+
+ case 'css':
+ header('Content-type: text/css');
+ }
+ }
+
+ print (file_get_contents($filename));
+ die();
+ }
+ else
+ {
+ require (ROOT.'public/index.php');
+ }
+ }
?>
View
934 libs/bake.php
@@ -45,480 +45,480 @@
*/
class Bake extends Object {
- /**
- * Standard input stream (php://stdin).
- *
- * @var resource
- * @access private
- */
- var $stdin = null;
-
- /**
- * Standard output stream (php://stdout).
- *
- * @var resource
- * @access private
- */
- var $stdout = null;
-
- /**
- * Standard error stream (php://stderr).
- *
- * @var resource
- * @access private
- */
- var $stderr = null;
-
- /**
- * Counts actions taken.
- *
- * @var integer
- * @access private
- */
- var $actions = null;
-
- /**
- * Decides whether to overwrite existing files without asking.
- *
- * @var boolean
- * @access private
- */
- var $dontAsk = false;
-
- /**
- * Returns code template for PHP file generator.
- *
- * @param string $type
- * @return string
- * @access private
- */
- function template ($type) {
- switch ($type) {
- case 'view': return "%s";
- case 'model': return "<?php\n\nclass %s extends AppModel {\n}\n\n?>";
- case 'action': return "\n\tfunction %s () {\n\t}\n";
- case 'ctrl': return "<?php\n\nclass %s extends %s {\n%s\n}\n\n?>";
- case 'helper': return "<?php\n\nclass %s extends AppController {\n}\n\n?>";
- case 'test': return '<?php
+/**
+ * Standard input stream (php://stdin).
+ *
+ * @var resource
+ * @access private
+ */
+ var $stdin = null;
+
+/**
+ * Standard output stream (php://stdout).
+ *
+ * @var resource
+ * @access private
+ */
+ var $stdout = null;
+
+/**
+ * Standard error stream (php://stderr).
+ *
+ * @var resource
+ * @access private
+ */
+ var $stderr = null;
+
+/**
+ * Counts actions taken.
+ *
+ * @var integer
+ * @access private
+ */
+ var $actions = null;
+
+/**
+ * Decides whether to overwrite existing files without asking.
+ *
+ * @var boolean
+ * @access private
+ */
+ var $dontAsk = false;
+
+/**
+ * Returns code template for PHP file generator.
+ *
+ * @param string $type
+ * @return string
+ * @access private
+ */
+ function template ($type) {
+ switch ($type) {
+ case 'view': return "%s";
+ case 'model': return "<?php\n\nclass %s extends AppModel {\n}\n\n?>";
+ case 'action': return "\n\tfunction %s () {\n\t}\n";
+ case 'ctrl': return "<?php\n\nclass %s extends %s {\n%s\n}\n\n?>";
+ case 'helper': return "<?php\n\nclass %s extends AppController {\n}\n\n?>";
+ case 'test': return '<?php
class %sTest extends TestCase {
- var $abc;
-
- // called before the tests
- function setUp() {
- $this->abc = new %s ();
- }
-
- // called after the tests
- function tearDown() {
- unset($this->abc);
- }
-
+ var $abc;
+
+ // called before the tests
+ function setUp() {
+ $this->abc = new %s ();
+ }
+
+ // called after the tests
+ function tearDown() {
+ unset($this->abc);
+ }
+
/*
- function testFoo () {
- $result = $this->abc->Foo();
- $expected = \'\';
- $this->assertEquals($result, $expected);
- }
+ function testFoo () {
+ $result = $this->abc->Foo();
+ $expected = \'\';
+ $this->assertEquals($result, $expected);
+ }
*/
}
?>';
- default:
- return false;
- }
- }
-
-
- /**
- * Baker's constructor method. Initialises bakery, and starts production.
- *
- * @param string $type
- * @param array $names
- * @access public
- * @uses Bake::stdin Opens stream for reading.
- * @uses Bake::stdout Opens stream for writing.
- * @uses Bake::stderr Opens stream for writing.
- * @uses Bake::newModel() Depending on the case, can create a new model.
- * @uses Bake::newView() Depending on the case, can create a new view.
- * @uses Bake::newController() Depending on the case, can create a new controller.
- */
- function __construct ($type, $names) {
-
- $this->stdin = fopen('php://stdin', 'r');
- $this->stdout = fopen('php://stdout', 'w');
- $this->stderr = fopen('php://stderr', 'w');
-
- // Output directory name
- fwrite($this->stderr, "\n".substr(ROOT,0,strlen(ROOT)-1).":\n".str_repeat('-',strlen(ROOT)+1)."\n");
-
- switch ($type) {
-
- case 'model':
- case 'models':
- foreach ($names as $model_name)
- $this->newModel($model_name);
- break;
-
- case 'controller':
- case 'ctrl':
- $controller = array_shift($names);
-
- $add_actions = array();
- foreach ($names as $action) {
- $add_actions[] = $action;
- $this->newView($controller, $action);
- }
-
- $this->newController($controller, $add_actions);
- break;
-
- case 'view':
- case 'views':
- $r = null;
- foreach ($names as $model_name) {
- if (preg_match('/^([a-z0-9_]+(?:\/[a-z0-9_]+)*)\/([a-z0-9_]+)$/i', $model_name, $r)) {
- $this->newView($r[1], $r[2]);
- }
- }
- break;
- }
-
- if (!$this->actions)
- fwrite($this->stderr, "Nothing to do, quitting.\n");
-
- }
-
- /**
- * Creates new view in VIEWS/$controller/ directory.
- *
- * @param string $controller
- * @param string $name
- * @access private
- * @uses Inflector::underscore() Underscores directory's name.
- * @uses Bake::createDir() Creates new directory in views dir, named after the controller.
- * @uses VIEWS
- * @uses Bake::createFile() Creates view file.
- * @uses Bake::template() Collects view template.
- * @uses Bake::actions Adds one action for each run.
- */
- function newView ($controller, $name) {
-// $controller = Inflector::pluralize($controller);
- $dir = Inflector::underscore($controller);
- $path = $dir.DS.strtolower($name).".thtml";
- $this->createDir(VIEWS.$dir);
- $fn = VIEWS.$path;
- $this->createFile($fn, sprintf($this->template('view'), "<p>Edit <b>app".DS."views".DS."{$path}</b> to change this message.</p>"));
- $this->actions++;
- }
-
- /**
- * Creates new controller with defined actions, controller's test and helper
- * with helper's test.
- *
- * @param string $name
- * @param array $actions
- * @access private
- * @uses Inflector::pluralize()
- * @uses Bake::makeController()
- * @uses Bake::makeControllerTest()
- * @uses Bake::makeHelper()
- * @uses Bake::makeHelperTest()
- * @uses Bake::actions Adds one action for each run.
- */
- function newController ($name, $actions=array()) {
-// $name = Inflector::pluralize($name);
- $this->makeController($name, $actions);
- $this->makeControllerTest($name);
- $this->makeHelper($name);
- $this->makeHelperTest($name);
- $this->actions++;
- }
-
- /**
- * Creates new controller file with defined actions.
- *
- * @param string $name
- * @param array $actions
- * @return boolean
- * @access private
- * @uses Bake::makeControllerName() CamelCase for controller's name.
- * @uses Bake::makeHelperName() CamelCase for helper's name.
- * @uses Bake::template() Controller's template.
- * @uses Bake::getActions() Actions' templates to be included in the controller.
- * @uses Bake::createFile() Creates controller's file.
- * @uses Bake::makeControllerFn() Underscored name for controller's filename.
- */
- function makeController ($name, $actions) {
- $ctrl = $this->makeControllerName($name);
- $helper = $this->makeHelperName($name);
- $body = sprintf($this->template('ctrl'), $ctrl, $helper, join('', $this->getActions($actions)));
- return $this->createFile($this->makeControllerFn($name), $body);
- }
-
- /**
- * Returns controller's name in CamelCase.
- *
- * @param string $name
- * @return string
- * @access private
- * @uses Inflector::camelize CamelCase for controller name.
- */
- function makeControllerName ($name) {
- return Inflector::camelize($name).'Controller';
- }
-
- /**
- * Returns a name for controller's file, underscored.
- *
- * @param string $name
- * @return string
- * @access private
- * @uses Inflector::underscore() Underscore for controller's file name.
- */
- function makeControllerFn ($name) {
- return CONTROLLERS.Inflector::underscore($name).'_controller.php';
- }
-
- /**
- * Creates new test for a controller.
- *
- * @param string $name
- * @return boolean
- * @access private
- * @uses CONTROLLER_TESTS
- * @uses Inflector::underscore()
- * @uses Bake::getTestBody()
- * @uses Bake::makeControllerName()
- * @uses Bake::createFile()
- */
- function makeControllerTest ($name) {
- $fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
- $body = $this->getTestBody($this->makeControllerName($name));
- return $this->createFile($fn, $body);
- }
-
- /**
- * Creates new helper.
- *
- * @param string $name
- * @return boolean
- * @access private
- * @uses Bake::template()
- * @uses Bake::makeHelperName()
- * @uses Bake::createFile()
- * @uses Bake::makeHelperFn()
- */
- function makeHelper ($name) {
- $body = sprintf($this->template('helper'), $this->makeHelperName($name));
- return $this->createFile($this->makeHelperFn($name), $body);
- }
-
- /**
- * Returns CamelCase name for a helper.
- *
- * @param string $name
- * @return string
- * @access private
- * @uses Inflector::camelize()
- */
- function makeHelperName ($name) {
- return Inflector::camelize($name).'Helper';
- }
-
- /**
- * Underscores file name for a helper.
- *
- * @param string $name
- * @return string
- * @access private
- * @uses HELPERS
- * @uses Inflector::underscore()
- */
- function makeHelperFn ($name) {
- return HELPERS.Inflector::underscore($name).'_helper.php';
- }
-
- /**
- * Creates new test for a helper.
- *
- * @param string $name
- * @return boolean
- * @access private
- * @uses HELPER_TESTS
- * @uses Inflector::underscore()
- * @uses Bake::getTestBody()
- * @uses Bake::makeHelperName()
- * @uses Bake::createFile()
- */
- function makeHelperTest ($name) {
- $fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
- $body = $this->getTestBody($this->makeHelperName($name));
- return $this->createFile($fn, $body);
- }
-
- /**
- * Returns an array of actions' templates.
- *
- * @param array $as
- * @return array
- * @access private
- * @uses Bake::template()
- */
- function getActions ($as) {
- $out = array();
- foreach ($as as $a)
- $out[] = sprintf($this->template('action'), $a);
- return $out;
- }
-
- /**
- * Returns a test template for given class.
- *
- * @param string $class
- * @return string
- * @access private
- * @uses Bake::template()
- */
- function getTestBody ($class) {
- return sprintf($this->template('test'), $class, $class);
- }
-
- /**
- * Creates new model.
- *
- * @param string $name
- * @access private
- * @uses Bake::createFile()
- * @uses Bake::getModelFn()
- * @uses Bake::template()
- * @uses Bake::getModelName()
- * @uses Bake::makeModelTest()
- * @uses Bake::actions
- */
- function newModel ($name) {
- $this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
- $this->makeModelTest ($name);
- $this->actions++;
- }
-
- /**
- * Returns an underscored filename for a model.
- *
- * @param string $name
- * @return string
- * @access private
- * @uses MODELS
- * @uses Inflector::underscore()
- */
- function getModelFn ($name) {
- return MODELS.Inflector::underscore($name).'.php';
- }
-
- /**
- * Creates a test for a given model.
- *
- * @param string $name
- * @return boolean
- * @access private
- * @uses MODEL_TESTS
- * @uses Inflector::underscore()
- * @uses Bake::getTestBody()
- * @uses Bake::getModelName()
- * @uses Bake::createFile()
- */
- function makeModelTest ($name) {
- $fn = MODEL_TESTS.Inflector::underscore($name).'_test.php';
- $body = $this->getTestBody($this->getModelName($name));
- return $this->createFile($fn, $body);
- }
-
- /**
- * Returns CamelCased name of a model.
- *
- * @param string $name
- * @return string
- * @access private
- * @uses Inflector::camelize()
- */
- function getModelName ($name) {
- return Inflector::camelize($name);
- }
-
- /**
- * Creates a file with given path and contents.
- *
- * @param string $path
- * @param string $contents
- * @return boolean
- * @access private
- * @uses Bake::dontAsk
- * @uses Bake::stdin
- * @uses Bake::stdout
- * @uses Bake::stderr
- */
- function createFile ($path, $contents) {
- $shortPath = str_replace(ROOT,null,$path);
-
- if (is_file($path) && !$this->dontAsk) {
- fwrite($this->stdout, "File {$shortPath} exists, overwrite? (yNaq) ");
- $key = trim(fgets($this->stdin));
-
- if ($key=='q') {
- fwrite($this->stdout, "Quitting.\n");
- exit;
- }
- elseif ($key=='a') {
- $this->dont_ask = true;
- }
- elseif ($key=='y') {
- }
- else {
- fwrite($this->stdout, "Skip {$shortPath}\n");
- return false;
- }
- }
-
- if ($f = fopen($path, 'w')) {
- fwrite($f, $contents);
- fclose($f);
- fwrite($this->stdout, "Wrote {$shortPath}\n");
-// debug ("Wrote {$path}");
- return true;
- }
- else {
- fwrite($this->stderr, "Error! Couldn't open {$shortPath} for writing.\n");
-// debug ("Error! Couldn't open {$path} for writing.");
- return false;
- }
- }
-
- /**
- * Creates a directory with given path.
- *
- * @param string $path
- * @return boolean
- * @access private
- * @uses Bake::stdin
- * @uses Bake::stdout
- */
- function createDir ($path) {
- if (is_dir($path))
- return true;
-
- $shortPath = str_replace(ROOT, null, $path);
-
- if (mkdir($path)) {
- fwrite($this->stdout, "Created {$shortPath}\n");
-// debug ("Created {$path}");
- return true;
- }
- else {
- fwrite($this->stderr, "Error! Couldn't create dir {$shortPath}\n");
-// debug ("Error! Couldn't create dir {$path}");
- return false;
- }
- }
+ default:
+ return false;
+ }
+ }
+
+
+/**
+ * Baker's constructor method. Initialises bakery, and starts production.
+ *
+ * @param string $type
+ * @param array $names
+ * @access public
+ * @uses Bake::stdin Opens stream for reading.
+ * @uses Bake::stdout Opens stream for writing.
+ * @uses Bake::stderr Opens stream for writing.
+ * @uses Bake::newModel() Depending on the case, can create a new model.
+ * @uses Bake::newView() Depending on the case, can create a new view.
+ * @uses Bake::newController() Depending on the case, can create a new controller.
+ */
+ function __construct ($type, $names) {
+
+ $this->stdin = fopen('php://stdin', 'r');
+ $this->stdout = fopen('php://stdout', 'w');
+ $this->stderr = fopen('php://stderr', 'w');
+
+ // Output directory name
+ fwrite($this->stderr, "\n".substr(ROOT,0,strlen(ROOT)-1).":\n".str_repeat('-',strlen(ROOT)+1)."\n");
+
+ switch ($type) {
+
+ case 'model':
+ case 'models':
+ foreach ($names as $model_name)
+ $this->newModel($model_name);
+ break;
+
+ case 'controller':
+ case 'ctrl':
+ $controller = array_shift($names);
+
+ $add_actions = array();
+ foreach ($names as $action) {
+ $add_actions[] = $action;
+ $this->newView($controller, $action);
+ }
+
+ $this->newController($controller, $add_actions);
+ break;
+
+ case 'view':
+ case 'views':
+ $r = null;
+ foreach ($names as $model_name) {
+ if (preg_match('/^([a-z0-9_]+(?:\/[a-z0-9_]+)*)\/([a-z0-9_]+)$/i', $model_name, $r)) {
+ $this->newView($r[1], $r[2]);
+ }
+ }
+ break;
+ }
+
+ if (!$this->actions)
+ fwrite($this->stderr, "Nothing to do, quitting.\n");
+
+ }
+
+/**
+ * Creates new view in VIEWS/$controller/ directory.
+ *
+ * @param string $controller
+ * @param string $name
+ * @access private
+ * @uses Inflector::underscore() Underscores directory's name.
+ * @uses Bake::createDir() Creates new directory in views dir, named after the controller.
+ * @uses VIEWS
+ * @uses Bake::createFile() Creates view file.
+ * @uses Bake::template() Collects view template.
+ * @uses Bake::actions Adds one action for each run.
+ */
+ function newView ($controller, $name) {
+// $controller = Inflector::pluralize($controller);
+ $dir = Inflector::underscore($controller);
+ $path = $dir.DS.strtolower($name).".thtml";
+ $this->createDir(VIEWS.$dir);
+ $fn = VIEWS.$path;
+ $this->createFile($fn, sprintf($this->template('view'), "<p>Edit <b>app".DS."views".DS."{$path}</b> to change this message.</p>"));
+ $this->actions++;
+ }
+
+/**
+ * Creates new controller with defined actions, controller's test and helper
+ * with helper's test.
+ *
+ * @param string $name
+ * @param array $actions
+ * @access private
+ * @uses Inflector::pluralize()
+ * @uses Bake::makeController()
+ * @uses Bake::makeControllerTest()
+ * @uses Bake::makeHelper()
+ * @uses Bake::makeHelperTest()
+ * @uses Bake::actions Adds one action for each run.
+ */
+ function newController ($name, $actions=array()) {
+// $name = Inflector::pluralize($name);
+ $this->makeController($name, $actions);
+ $this->makeControllerTest($name);
+ $this->makeHelper($name);
+ $this->makeHelperTest($name);
+ $this->actions++;
+ }
+
+/**
+ * Creates new controller file with defined actions.
+ *
+ * @param string $name
+ * @param array $actions
+ * @return boolean
+ * @access private
+ * @uses Bake::makeControllerName() CamelCase for controller's name.
+ * @uses Bake::makeHelperName() CamelCase for helper's name.
+ * @uses Bake::template() Controller's template.
+ * @uses Bake::getActions() Actions' templates to be included in the controller.
+ * @uses Bake::createFile() Creates controller's file.
+ * @uses Bake::makeControllerFn() Underscored name for controller's filename.
+ */
+ function makeController ($name, $actions) {
+ $ctrl = $this->makeControllerName($name);
+ $helper = $this->makeHelperName($name);
+ $body = sprintf($this->template('ctrl'), $ctrl, $helper, join('', $this->getActions($actions)));
+ return $this->createFile($this->makeControllerFn($name), $body);
+ }
+
+/**
+ * Returns controller's name in CamelCase.
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ * @uses Inflector::camelize CamelCase for controller name.
+ */
+ function makeControllerName ($name) {
+ return Inflector::camelize($name).'Controller';
+ }
+
+/**
+ * Returns a name for controller's file, underscored.
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ * @uses Inflector::underscore() Underscore for controller's file name.
+ */
+ function makeControllerFn ($name) {
+ return CONTROLLERS.Inflector::underscore($name).'_controller.php';
+ }
+
+/**
+ * Creates new test for a controller.
+ *
+ * @param string $name
+ * @return boolean
+ * @access private
+ * @uses CONTROLLER_TESTS
+ * @uses Inflector::underscore()
+ * @uses Bake::getTestBody()
+ * @uses Bake::makeControllerName()
+ * @uses Bake::createFile()
+ */
+ function makeControllerTest ($name) {
+ $fn = CONTROLLER_TESTS.Inflector::underscore($name).'_controller_test.php';
+ $body = $this->getTestBody($this->makeControllerName($name));
+ return $this->createFile($fn, $body);
+ }
+
+/**
+ * Creates new helper.
+ *
+ * @param string $name
+ * @return boolean
+ * @access private
+ * @uses Bake::template()
+ * @uses Bake::makeHelperName()
+ * @uses Bake::createFile()
+ * @uses Bake::makeHelperFn()
+ */
+ function makeHelper ($name) {
+ $body = sprintf($this->template('helper'), $this->makeHelperName($name));
+ return $this->createFile($this->makeHelperFn($name), $body);
+ }
+
+/**
+ * Returns CamelCase name for a helper.
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ * @uses Inflector::camelize()
+ */
+ function makeHelperName ($name) {
+ return Inflector::camelize($name).'Helper';
+ }
+
+/**
+ * Underscores file name for a helper.
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ * @uses HELPERS
+ * @uses Inflector::underscore()
+ */
+ function makeHelperFn ($name) {
+ return HELPERS.Inflector::underscore($name).'_helper.php';
+ }
+
+/**
+ * Creates new test for a helper.
+ *
+ * @param string $name
+ * @return boolean
+ * @access private
+ * @uses HELPER_TESTS
+ * @uses Inflector::underscore()
+ * @uses Bake::getTestBody()
+ * @uses Bake::makeHelperName()
+ * @uses Bake::createFile()
+ */
+ function makeHelperTest ($name) {
+ $fn = HELPER_TESTS.Inflector::underscore($name).'_helper_test.php';
+ $body = $this->getTestBody($this->makeHelperName($name));
+ return $this->createFile($fn, $body);
+ }
+
+/**
+ * Returns an array of actions' templates.
+ *
+ * @param array $as
+ * @return array
+ * @access private
+ * @uses Bake::template()
+ */
+ function getActions ($as) {
+ $out = array();
+ foreach ($as as $a)
+ $out[] = sprintf($this->template('action'), $a);
+ return $out;
+ }
+
+/**
+ * Returns a test template for given class.
+ *
+ * @param string $class
+ * @return string
+ * @access private
+ * @uses Bake::template()
+ */
+ function getTestBody ($class) {
+ return sprintf($this->template('test'), $class, $class);
+ }
+
+/**
+ * Creates new model.
+ *
+ * @param string $name
+ * @access private
+ * @uses Bake::createFile()
+ * @uses Bake::getModelFn()
+ * @uses Bake::template()
+ * @uses Bake::getModelName()
+ * @uses Bake::makeModelTest()
+ * @uses Bake::actions
+ */
+ function newModel ($name) {
+ $this->createFile($this->getModelFn($name), sprintf($this->template('model'), $this->getModelName($name)));
+ $this->makeModelTest ($name);
+ $this->actions++;
+ }
+
+/**
+ * Returns an underscored filename for a model.
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ * @uses MODELS
+ * @uses Inflector::underscore()
+ */
+ function getModelFn ($name) {
+ return MODELS.Inflector::underscore($name).'.php';
+ }
+
+/**
+ * Creates a test for a given model.
+ *
+ * @param string $name
+ * @return boolean
+ * @access private
+ * @uses MODEL_TESTS
+ * @uses Inflector::underscore()
+ * @uses Bake::getTestBody()
+ * @uses Bake::getModelName()
+ * @uses Bake::createFile()
+ */
+ function makeModelTest ($name) {
+ $fn = MODEL_TESTS.Inflector::underscore($name).'_test.php';
+ $body = $this->getTestBody($this->getModelName($name));
+ return $this->createFile($fn, $body);
+ }
+
+/**
+ * Returns CamelCased name of a model.
+ *
+ * @param string $name
+ * @return string
+ * @access private
+ * @uses Inflector::camelize()
+ */
+ function getModelName ($name) {
+ return Inflector::camelize($name);
+ }
+
+/**
+ * Creates a file with given path and contents.
+ *
+ * @param string $path
+ * @param string $contents
+ * @return boolean
+ * @access private
+ * @uses Bake::dontAsk
+ * @uses Bake::stdin
+ * @uses Bake::stdout
+ * @uses Bake::stderr
+ */
+ function createFile ($path, $contents) {
+ $shortPath = str_replace(ROOT,null,$path);
+
+ if (is_file($path) && !$this->dontAsk) {
+ fwrite($this->stdout, "File {$shortPath} exists, overwrite? (yNaq) ");
+ $key = trim(fgets($this->stdin));
+
+ if ($key=='q') {
+ fwrite($this->stdout, "Quitting.\n");
+ exit;
+ }
+ elseif ($key=='a') {
+ $this->dont_ask = true;
+ }
+ elseif ($key=='y') {
+ }
+ else {
+ fwrite($this->stdout, "Skip {$shortPath}\n");
+ return false;
+ }
+ }
+
+ if ($f = fopen($path, 'w')) {
+ fwrite($f, $contents);
+ fclose($f);
+ fwrite($this->stdout, "Wrote {$shortPath}\n");
+// debug ("Wrote {$path}");
+ return true;
+ }
+ else {
+ fwrite($this->stderr, "Error! Couldn't open {$shortPath} for writing.\n");
+// debug ("Error! Couldn't open {$path} for writing.");
+ return false;
+ }
+ }
+
+/**
+ * Creates a directory with given path.
+ *
+ * @param string $path
+ * @return boolean
+ * @access private
+ * @uses Bake::stdin
+ * @uses Bake::stdout
+ */
+ function createDir ($path) {
+ if (is_dir($path))
+ return true;
+
+ $shortPath = str_replace(ROOT, null, $path);
+
+ if (mkdir($path)) {
+ fwrite($this->stdout, "Created {$shortPath}\n");
+// debug ("Created {$path}");
+ return true;
+ }
+ else {
+ fwrite($this->stderr, "Error! Couldn't create dir {$shortPath}\n");
+// debug ("Error! Couldn't create dir {$path}");
+ return false;
+ }
+ }
}
View
196 libs/basics.php
@@ -50,11 +50,11 @@
*/
function loadModels ()
{
- require (APP.'app_model.php');
- foreach (listClasses(MODELS) as $model_fn)
- {
- require (MODELS.$model_fn);
- }
+ require (APP.'app_model.php');
+ foreach (listClasses(MODELS) as $model_fn)
+ {
+ require (MODELS.$model_fn);
+ }
}
/**
@@ -67,17 +67,17 @@ function loadModels ()
*/
function loadControllers ()
{
- require (APP.'app_controller.php');
+ require (APP.'app_controller.php');
- foreach (listClasses(HELPERS) as $helper)
- {
- require (HELPERS.$helper.'.php');
- }
+ foreach (listClasses(HELPERS) as $helper)
+ {
+ require (HELPERS.$helper.'.php');
+ }
- foreach (listClasses(CONTROLLERS) as $controller)
- {
- require (CONTROLLERS.$controller.'.php');
- }
+ foreach (listClasses(CONTROLLERS) as $controller)
+ {
+ require (CONTROLLERS.$controller.'.php');
+ }
}
/**
@@ -88,15 +88,15 @@ function loadControllers ()
*/
function loadController ($name)
{
- $controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
- $helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
+ $controller_fn = CONTROLLERS.Inflector::underscore($name).'_controller.php';
+ $helper_fn = HELPERS.Inflector::underscore($name).'_helper.php';
- require(APP.'app_controller.php');
+ require(APP.'app_controller.php');
- if (file_exists($helper_fn))
- require($helper_fn);
+ if (file_exists($helper_fn))
+ require($helper_fn);
- return file_exists($controller_fn)? require($controller_fn): false;
+ return file_exists($controller_fn)? require($controller_fn): false;
}
/**
@@ -107,8 +107,8 @@ function loadController ($name)
*/
function listClasses($path)
{
- $modules = new Folder($path);
- return $modules->find('(.+)\.php');
+ $modules = new Folder($path);
+ return $modules->find('(.+)\.php');
}
/**
@@ -116,25 +116,25 @@ function listClasses($path)
*/
function config ()
{
- $args = func_get_args();
- foreach ($args as $arg)
- {
- if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php'))
- {
- include_once(CONFIGS.$arg.'.php');
- }
- elseif (file_exists(CONFIGS.$arg.'.php'))
- {
- include (CONFIGS.$arg.'.php');
- if (count($args) == 1) return true;
- }
- else
- {
- if (count($args) == 1) return false;
- }
- }
-
- return true;
+ $args = func_get_args();
+ foreach ($args as $arg)
+ {
+ if (('database' == $arg) && file_exists(CONFIGS.$arg.'.php'))
+ {
+ include_once(CONFIGS.$arg.'.php');
+ }
+ elseif (file_exists(CONFIGS.$arg.'.php'))
+ {
+ include (CONFIGS.$arg.'.php');
+ if (count($args) == 1) return true;
+ }
+ else
+ {
+ if (count($args) == 1) return false;
+ }
+ }
+
+ return true;
}
/**
@@ -149,20 +149,20 @@ function config ()
*/
function uses ()
{
- $args = func_get_args();
- foreach ($args as $arg)
- {
- require_once(LIBS.strtolower($arg).'.php');
- }
+ $args = func_get_args();
+ foreach ($args as $arg)
+ {
+ require_once(LIBS.strtolower($arg).'.php');
+ }
}
function vendor($name)
{
- $args = func_get_args();
- foreach ($args as $arg)
- {
- require_once(VENDORS.$arg.'.php');
- }
+ $args = func_get_args();
+ foreach ($args as $arg)
+ {
+ require_once(VENDORS.$arg.'.php');
+ }
}
/**
@@ -173,13 +173,13 @@ function vendor($name)
*/
function debug($var = false, $show_html = false)
{
- if (DEBUG)
- {
- print "\n<pre>\n";
- if ($show_html) $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
- print_r($var);
- print "\n</pre>\n";
- }
+ if (DEBUG)
+ {
+ print "\n<pre>\n";
+ if ($show_html) $var = str_replace('<', '&lt;', str_replace('>', '&gt;', $var));
+ print_r($var);
+ print "\n</pre>\n";
+ }
}
@@ -190,11 +190,11 @@ function debug($var = false, $show_html = false)
*
* @return integer
*/
- function getMicrotime()
- {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
- }
+ function getMicrotime()
+ {
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+ }
}
if (!function_exists('sortByKey'))
@@ -208,27 +208,27 @@ function getMicrotime()
* @param integer $type
* @return mixed
*/
- function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
- {
- if (!is_array($array))
- return null;
+ function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
+ {
+ if (!is_array($array))
+ return null;
- foreach ($array as $key => $val)
- {
- $sa[$key] = $val[$sortby];
- }
+ foreach ($array as $key => $val)
+ {
+ $sa[$key] = $val[$sortby];
+ }
- $order == 'asc'
- ? asort($sa, $type)
- : arsort($sa, $type);
+ $order == 'asc'
+ ? asort($sa, $type)
+ : arsort($sa, $type);
- foreach ($sa as $key=>$val)
- {
- $out[] = $array[$key];
- }
+ foreach ($sa as $key=>$val)
+ {
+ $out[] = $array[$key];
+ }
- return $out;
- }
+ return $out;
+ }
}
if (!function_exists('array_combine'))
@@ -241,25 +241,25 @@ function sortByKey(&$array, $sortby, $order='asc', $type=SORT_NUMERIC)
* @param array $a2
* @return mixed Outputs either combined array or false.
*/
- function array_combine($a1, $a2)
- {
- $a1 = array_values($a1);
- $a2 = array_values($a2);
- $c1 = count($a1);
- $c2 = count($a2);
+ function array_combine($a1, $a2)
+ {
+ $a1 = array_values($a1);
+ $a2 = array_values($a2);
+ $c1 = count($a1);
+ $c2 = count($a2);
- if ($c1 != $c2) return false; // different lenghts
- if ($c1 <= 0) return false; // arrays are the same and both are empty
-
- $output = array();
-
- for ($i = 0; $i < $c1; $i++)
- {
- $output[$a1[$i]] = $a2[$i];
- }
-
- return $output;
- }
+ if ($c1 != $c2) return false; // different lenghts
+ if ($c1 <= 0) return false; // arrays are the same and both are empty
+
+ $output = array();
+
+ for ($i = 0; $i < $c1; $i++)
+ {
+ $output[$a1[$i]] = $a2[$i];
+ }
+
+ return $output;
+ }
}
?>
View
64 libs/cache.php
@@ -50,38 +50,38 @@ class Cache extends Model {
*
* @var unknown_type
*/
- var $id = null;
+ var $id = null;
/**
* Content container for cache data.
*
* @var unknown_type
*/
- var $data = null;
+ var $data = null;
/**
* Content to be cached.
*
* @var unknown_type
*/
- var $for_caching = null;
+ var $for_caching = null;
/**
* Name of the database table used for caching.
*
* @var unknown_type
*/
- var $use_table = 'cache';
+ var $use_table = 'cache';
/**
* Constructor. Generates an md5'ed id for internal use. Calls the constructor on Model as well.
*
* @param unknown_type $id
*/
- function __construct ($id) {
- $this->id = (md5($id));
- parent::__construct($this->id);
- }
+ function __construct ($id) {
+ $this->id = (md5($id));
+ parent::__construct($this->id);
+ }
/**
* Returns this object's id after setting it. If no $id is given then $this->id is returned.
@@ -89,10 +89,10 @@ function __construct ($id) {
* @param unknown_type $id
* @return unknown
*/
- function id ($id=null) {
- if (!$id) return $this->id;
- return ($this->id = $id);
- }
+ function id ($id=null) {
+ if (!$id) return $this->id;
+ return ($this->id = $id);
+ }
/**
* Save $content in cache for $keep_for seconds.
@@ -101,50 +101,50 @@ function id ($id=null) {
* @param int $keep_for Number of seconds to keep data in cache.
* @return unknown
*/
- function remember ($content, $keep_for=CACHE_PAGES_FOR) {
- $data = addslashes($this->for_caching.$content);
- $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999));
- return $this->query("REPLACE {$this->use_table} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
- }
+ function remember ($content, $keep_for=CACHE_PAGES_FOR) {
+ $data = addslashes($this->for_caching.$content);
+ $expire = date("Y-m-d H:i:s",time()+($keep_for>0? $keep_for: 999999999));
+ return $this->query("REPLACE {$this->use_table} (id,data,expire) VALUES ('{$this->id}', '{$data}', '{$expire}')");
+ }
/**
* Returns content from the Cache object itself, if the Cache object has a non-empty data property. Else from the database cache.
*
* @return unknown
*/
- function restore() {
- if (empty($this->data['data']))
- return $this->find("id='{$this->id}' AND expire>NOW()");
-
- return $this->data['data'];
- }
+ function restore() {
+ if (empty($this->data['data']))
+ return $this->find("id='{$this->id}' AND expire>NOW()");
+
+ return $this->data['data'];
+ }
/**
* Returns true if the cache data property has current (non-stale) content for given id.
*
* @return boolean
*/
- function has() {
- return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
- }
+ function has() {
+ return is_array($this->data = $this->find("id='{$this->id}' AND expire>NOW()"));
+ }
/**
* Appends $string to the for_caching property of the Cache object.
*
* @param string $string
*/
- function append($string) {
- $this->for_caching .= $string;
- }
+ function append($string) {
+ $this->for_caching .= $string;
+ }
/**
* Clears the cache database table.
*
* @return unknown
*/
- function clear() {
- return $this->query("DELETE FROM {$this->use_table}");
- }
+ function clear() {
+ return $this->query("DELETE FROM {$this->use_table}");
+ }
}
?>
View
648 libs/controller.php
@@ -49,337 +49,349 @@
*/
class Controller extends Object
{
- /**
- * Name of the controller.
- *
- * @var unknown_type
- * @access public
- */
- var $name = null;
-
- /**
- * Stores the current URL (for links etc.)
- *
- * @var string Current URL
- */
- var $here = null;
-
- /**
- * Enter description here...
- *
- * @var unknown_type
- * @access public
- */
- var $parent = null;
-
- /**
- * Action to be performed.
- *
- * @var string
- * @access public
- */
- var $action = null;
-
- /**
- * An array of names of models the particular controller wants to use.
- *
- * @var mixed A single name as a string or a list of names as an array.
- * @access protected
- */
- var $uses = false;
-
- /**
- * An array of names of built-in helpers to include.
- *
- * @var mixed A single name as a string or a list of names as an array.
- * @access protected
- */
- var $helpers = array('html');
-
- var $viewPath;
-
- /**
- * Variables for the view
- *
- * @var array
- * @access private
- */
- var $_viewVars = array();
-
- /**
- * Enter description here...
- *
- * @var boolean
- * @access private
- */
- var $pageTitle = false;
-
- /**
- * An array of model objects.
- *
- * @var array Array of model objects.
- * @access public
- */
- var $models = array();
-
-
- /**
- * Enter description here...
- *
- * @var unknown_type
- * @access public
- */
- var $base = null;
-
- /**
- * Enter description here...
- *
- * @var string
- * @access public
- */
- var $layout = 'default';
-
- /**
- * Enter description here...
- *
- * @var boolean
- * @access public
- */
- var $autoRender = true;
-
- /**
- * Enter description here...
- *
- * @var boolean
- * @access public
- */
- var $autoLayout = true;
-
-
- /**
- * Constructor.
- *
- */
- function __construct ($params=null)
- {
- parent::__construct();
+/**
+ * Name of the controller.
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $name = null;
- $this->params = $params;
+/**
+ * Stores the current URL (for links etc.)
+ *
+ * @var string Current URL
+ */
+ var $here = null;
- $r = null;
- if (!preg_match('/(.*)Controller/i', get_class($this), $r))
- {
- die("Controller::__construct() : Can't get or parse my own class name, exiting.");
- }
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $parent = null;
- $this->name = strtolower($r[1]);
- $this->viewPath = Inflector::underscore($r[1]);
+/**
+ * Action to be performed.
+ *
+ * @var string
+ * @access public
+ */
+ var $action = null;
- $model_class = Inflector::singularize($this->name);
+/**
+ * An array of names of models the particular controller wants to use.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access protected
+ */
+ var $uses = false;
- //Is this needed?
- $this->db = DboFactory::getInstance();
+/**
+ * An array of names of built-in helpers to include.
+ *
+ * @var mixed A single name as a string or a list of names as an array.
+ * @access protected
+ */
+ var $helpers = array('html');
- if (class_exists($model_class) && ($this->uses === false))
- {
- $this->models[$model_class] = new $model_class();
- }
- elseif ($this->uses)
- {
- if (!$this->db)
- {
- die("Controller::__construct() : ".$this->name." controller needs database access, exiting.");
- }
+ var $viewPath;
- $uses = is_array($this->uses)? $this->uses: array($this->uses);
+/**
+ * Variables for the view
+ *
+ * @var array
+ * @access private
+ */
+ var $_viewVars = array();
- foreach ($uses as $model_name)
- {
- $model_class = ucfirst(strtolower($model_name));
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ * @access private
+ */
+ var $pageTitle = false;
+
+/**
+ * An array of model objects.
+ *
+ * @var array Array of model objects.
+ * @access public
+ */
+ var $models = array();
+
+
+/**
+ * Enter description here...
+ *
+ * @var unknown_type
+ * @access public
+ */
+ var $base = null;
+
+/**
+ * Enter description here...
+ *
+ * @var string
+ * @access public
+ */
+ var $layout = 'default';
+
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ * @access public
+ */
+ var $autoRender = true;
- if (class_exists($model_class))
+/**
+ * Enter description here...
+ *
+ * @var boolean
+ * @access public
+ */
+ var $autoLayout = true;
+
+
+/**
+ * Constructor.
+ *
+ */
+ function __construct ($params=null)
+ {
+ // parent::__construct();
+ $r = null;
+ if (!preg_match('/(.*)Controller/i', get_class($this), $r))
+ {
+ die("Controller::__construct() : Can't get or parse my own class name, exiting.");
+ }
+
+ $this->name = strtolower($r[1]);
+ $this->viewPath = Inflector::underscore($r[1]);
+
+ parent::__construct();
+ }
+
+ function contructClasses(){
+
+ if(empty($this->params['pass']))
{