diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/controllers/welcome.php | 22 | ||||
-rw-r--r-- | core/helpers/core_installer.php | 42 | ||||
-rw-r--r-- | core/tests/File_Structure_Test.php | 77 | ||||
-rw-r--r-- | core/views/welcome.html.php | 84 | ||||
-rw-r--r-- | core/views/welcome_syscheck.html.php | 4 |
5 files changed, 121 insertions, 108 deletions
diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index 93670cfe..f1201cff 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -74,18 +74,18 @@ class Welcome_Controller extends Template_Controller { } else { $old_handler = set_error_handler(array("Welcome_Controller", "_error_handler")); try { - Database::instance()->connect(); + Database::instance()->connect(); } catch (Exception $e) { - $error = new stdClass(); - $error->message = "Database error: {$e->getMessage()}"; - $db_name = Kohana::config("database.default.connection.database"); - if (strchr($error->message, "Unknown database")) { - $error->instructions[] = "mysqladmin -uroot create $db_name"; - } else { - $error->instructions = array(); - $error->message2 = "Check " . VARPATH . "database.php"; - } - $errors[] = $error; + $error = new stdClass(); + $error->message = "Database error: {$e->getMessage()}"; + $db_name = Kohana::config("database.default.connection.database"); + if (strchr($error->message, "Unknown database")) { + $error->instructions[] = "mysqladmin -uroot create $db_name"; + } else { + $error->instructions = array(); + $error->message2 = "Check " . VARPATH . "database.php"; + } + $errors[] = $error; } set_error_handler($old_handler); } diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index ea01a0c0..5720976b 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -24,38 +24,38 @@ class core_installer { $base_version = ORM::factory("module")->where("name", "core")->find()->version; } catch (Exception $e) { if ($e->getMessage() == "Table modules does not exist in your database.") { - $base_version = 0; + $base_version = 0; } else { - throw $e; + throw $e; } } if ($base_version == 0) { $db->query("CREATE TABLE `modules` ( - `id` int(9) NOT NULL auto_increment, - `name` char(255) default NULL, - `version` int(9) default NULL, - PRIMARY KEY (`id`), + `id` int(9) NOT NULL auto_increment, + `name` char(255) default NULL, + `version` int(9) default NULL, + PRIMARY KEY (`id`), UNIQUE KEY(`name`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE `items` ( - `id` int(9) NOT NULL auto_increment, - `type` char(32) default NULL, - `title` char(255) default NULL, - `description` char(255) default NULL, - `path` char(255) default NULL, - `left` int(9) default NULL, - `right` int(9) default NULL, - `parent_id` int(9) default NULL, - `scope` int(9) default NULL, - PRIMARY KEY (`id`), - KEY `parent_id` (`parent_id`), - KEY `type` (`type`)) - ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + `id` int(9) NOT NULL auto_increment, + `type` char(32) default NULL, + `title` char(255) default NULL, + `description` char(255) default NULL, + `path` char(255) default NULL, + `left` int(9) default NULL, + `right` int(9) default NULL, + `parent_id` int(9) default NULL, + `scope` int(9) default NULL, + PRIMARY KEY (`id`), + KEY `parent_id` (`parent_id`), + KEY `type` (`type`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); foreach (array("albums", "thumbnails") as $dir) { - @mkdir(VARPATH . $dir); + @mkdir(VARPATH . $dir); } $core = ORM::factory("module")->where("name", "core")->find(); diff --git a/core/tests/File_Structure_Test.php b/core/tests/File_Structure_Test.php index a34c61b2..00663bc6 100644 --- a/core/tests/File_Structure_Test.php +++ b/core/tests/File_Structure_Test.php @@ -24,9 +24,9 @@ class File_Structure_Test extends Unit_Test_Case { $incorrect = array(); foreach ($dir as $file) { if (!preg_match("|\.html\.php$|", $file->getPathname())) { - $this->assert_false( - preg_match('/\?\>\s*$/', file_get_contents($file)), - "{$file->getPathname()} ends in ?>"); + $this->assert_false( + preg_match('/\?\>\s*$/', file_get_contents($file)), + "{$file->getPathname()} ends in ?>"); } } } @@ -36,12 +36,12 @@ class File_Structure_Test extends Unit_Test_Case { new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); foreach ($dir as $file) { if ($file->getFilename() == 'kohana_unit_test.php') { - // Exception: this file must be named accordingly for the test framework - continue; + // Exception: this file must be named accordingly for the test framework + continue; } $this->assert_false( - preg_match("|/views/.*?(?<!\.html)\.php$|", $file->getPathname()), - "{$file->getPathname()} should end in .html.php"); + preg_match("|/views/.*?(?<!\.html)\.php$|", $file->getPathname()), + "{$file->getPathname()} should end in .html.php"); } } @@ -52,24 +52,37 @@ class File_Structure_Test extends Unit_Test_Case { $expected = $this->_get_preamble(__FILE__); foreach ($dir as $file) { if (preg_match("/views/", $file->getPathname())) { - // The preamble for views is a single line that prevents direct script access - $lines = file($file->getPathname()); - $this->assert_equal( - "<? defined(\"SYSPATH\") or die(\"No direct script access.\"); ?>\n", - $lines[0], - "in file: {$file->getPathname()}"); + // The preamble for views is a single line that prevents direct script access + $lines = file($file->getPathname()); + $this->assert_equal( + "<? defined(\"SYSPATH\") or die(\"No direct script access.\"); ?>\n", + $lines[0], + "in file: {$file->getPathname()}"); } else if (preg_match("|\.php$|", $file->getPathname())) { - $actual = $this->_get_preamble($file->getPathname()); - if ($file->getPathName() == DOCROOT . "index.php") { - // index.php allows direct access, so modify our expectations for the first line - $index_expected = $expected; - $index_expected[0] = "<?php"; - $this->assert_equal($index_expected, $actual, "in file: {$file->getPathname()}"); - } else { - // We expect the full preamble in regular PHP files - $actual = $this->_get_preamble($file->getPathname()); - $this->assert_equal($expected, $actual, "in file: {$file->getPathname()}"); - } + $actual = $this->_get_preamble($file->getPathname()); + if ($file->getPathName() == DOCROOT . "index.php") { + // index.php allows direct access, so modify our expectations for the first line + $index_expected = $expected; + $index_expected[0] = "<?php"; + $this->assert_equal($index_expected, $actual, "in file: {$file->getPathname()}"); + } else { + // We expect the full preamble in regular PHP files + $actual = $this->_get_preamble($file->getPathname()); + $this->assert_equal($expected, $actual, "in file: {$file->getPathname()}"); + } + } + } + } + + public function no_tabs_in_our_code_test() { + $dir = new GalleryCodeFilterIterator( + new RecursiveIteratorIterator(new RecursiveDirectoryIterator(DOCROOT))); + $incorrect = array(); + foreach ($dir as $file) { + if (substr($file->getFilename(), -4) == ".php") { + $this->assert_false( + preg_match('/\t/', file_get_contents($file)), + "{$file->getPathname()} has tabs in it"); } } } @@ -80,7 +93,7 @@ class File_Structure_Test extends Unit_Test_Case { for ($i = 0; $i < count($lines); $i++) { $copy[] = rtrim($lines[$i]); if (!strncmp($lines[$i], ' */', 3)) { - return $copy; + return $copy; } } return $copy; @@ -92,12 +105,12 @@ class GalleryCodeFilterIterator extends FilterIterator { // Skip anything that we didn't write $path_name = $this->getInnerIterator()->getPathName(); return !(strstr($path_name, ".svn") || - substr($path_name, -1, 1) == "~" || - strstr($path_name, SYSPATH) !== false || - strstr($path_name, MODPATH . 'forge') !== false || - strstr($path_name, MODPATH . 'unit_test') !== false || - strstr($path_name, MODPATH . 'mptt') !== false || - strstr($path_name, DOCROOT . 'var') !== false || - strstr($path_name, DOCROOT . 'test') !== false); + substr($path_name, -1, 1) == "~" || + strstr($path_name, SYSPATH) !== false || + strstr($path_name, MODPATH . 'forge') !== false || + strstr($path_name, MODPATH . 'unit_test') !== false || + strstr($path_name, MODPATH . 'mptt') !== false || + strstr($path_name, DOCROOT . 'var') !== false || + strstr($path_name, DOCROOT . 'test') !== false); } } diff --git a/core/views/welcome.html.php b/core/views/welcome.html.php index adea7543..b7a290a0 100644 --- a/core/views/welcome.html.php +++ b/core/views/welcome.html.php @@ -64,54 +64,54 @@ <body> <div class="outer"> <center> - <img src="http://www.gallery2.org/gallery2.png"/> + <img src="http://www.gallery2.org/gallery2.png"/> </center> <div class="inner"> - <h1>Gallery3 Scaffold</h1> - <p> - This is - a <b><a href="http://www.google.com/images?q=scaffold">scaffold</a></b>: - a <i>temporary structure built to support the developers as - they create the real product</i>. - </p> + <h1>Gallery3 Scaffold</h1> + <p> + This is + a <b><a href="http://www.google.com/images?q=scaffold">scaffold</a></b>: + a <i>temporary structure built to support the developers as + they create the real product</i>. + </p> - <p> - As we flesh out Gallery 3, we'll make it possible for you to - peer inside and see the application taking shape. - Eventually, this page will go away and you'll start in the - application itself. In the meantime, here are some useful - links to get you started. - </p> + <p> + As we flesh out Gallery 3, we'll make it possible for you to + peer inside and see the application taking shape. + Eventually, this page will go away and you'll start in the + application itself. In the meantime, here are some useful + links to get you started. + </p> - <h2>System Configuration</h2> - <?= $syscheck ?> + <h2>System Configuration</h2> + <?= $syscheck ?> - <h2>Activities</h2> - <p> - <?= html::anchor("album/1", "Browse Gallery") ?> - </p> + <h2>Activities</h2> + <p> + <?= html::anchor("album/1", "Browse Gallery") ?> + </p> - <h2>Documentation</h2> - <ul> - <li> - <a href="http://docs.google.com/Doc?id=dfjxt593_184ff9jhmd8&hl=en">Gallery3: Prioritized Feature List</a> - </li> - <li> - <a href="http://docs.google.com/Doc?id=dfjxt593_185czczpm4f&hl=en">Gallery3: Secondary Features</a> - </li> - <li> - <a href="http://gallery.svn.sourceforge.net/viewvc/gallery/trunk/eval/gx/ui/HTML/index.html">Mockups</a> - </li> - <li> - <a href="http://www.nabble.com/Rough-Gallery-3-time-line-td20240153.html">Rough Timeline</a> (as of Oct 29, 2008) - </li> - <li> - <a href="http://codex.gallery2.org/Gallery3:About">Gallery3: About Page</a> - </li> - <li> - <a href="http://codex.gallery2.org/Gallery3:Coding_Standards">Gallery3: Coding Standards</a> - </li> - </ul> + <h2>Documentation</h2> + <ul> + <li> + <a href="http://docs.google.com/Doc?id=dfjxt593_184ff9jhmd8&hl=en">Gallery3: Prioritized Feature List</a> + </li> + <li> + <a href="http://docs.google.com/Doc?id=dfjxt593_185czczpm4f&hl=en">Gallery3: Secondary Features</a> + </li> + <li> + <a href="http://gallery.svn.sourceforge.net/viewvc/gallery/trunk/eval/gx/ui/HTML/index.html">Mockups</a> + </li> + <li> + <a href="http://www.nabble.com/Rough-Gallery-3-time-line-td20240153.html">Rough Timeline</a> (as of Oct 29, 2008) + </li> + <li> + <a href="http://codex.gallery2.org/Gallery3:About">Gallery3: About Page</a> + </li> + <li> + <a href="http://codex.gallery2.org/Gallery3:Coding_Standards">Gallery3: Coding Standards</a> + </li> + </ul> </div> </div> </body> diff --git a/core/views/welcome_syscheck.html.php b/core/views/welcome_syscheck.html.php index 7355e431..5f1a1945 100644 --- a/core/views/welcome_syscheck.html.php +++ b/core/views/welcome_syscheck.html.php @@ -40,8 +40,8 @@ <td><?= $module->name ?></td> <td><?= $module->version ?></td> <td> - <?= html::anchor("welcome/install/{$module->name}", "install") ?>, - <?= html::anchor("welcome/uninstall/{$module->name}", "uninstall") ?> + <?= html::anchor("welcome/install/{$module->name}", "install") ?>, + <?= html::anchor("welcome/uninstall/{$module->name}", "uninstall") ?> </td> </tr> <? endforeach; ?> |