summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/controllers/scaffold.php11
-rw-r--r--core/helpers/MY_url.php8
-rw-r--r--core/helpers/core_installer.php1
-rw-r--r--core/models/item.php14
4 files changed, 25 insertions, 9 deletions
diff --git a/core/controllers/scaffold.php b/core/controllers/scaffold.php
index 8266ba8f..395e032d 100644
--- a/core/controllers/scaffold.php
+++ b/core/controllers/scaffold.php
@@ -112,8 +112,11 @@ class Scaffold_Controller extends Template_Controller {
// Since we're in a state of flux, it's possible that other stuff went wrong with the
// uninstall, so back off and nuke it from orbit. It's the only way to be sure.
$db = Database::instance();
- foreach ($db->list_tables() as $table) {
- $db->query("DROP TABLE `$table`");
+ $tables = $db->list_tables();
+ if (!empty($tables)) {
+ foreach ($db->list_tables() as $table) {
+ $db->query("DROP TABLE `$table`");
+ }
}
set_error_handler($old_handler);
} else {
@@ -423,7 +426,9 @@ class Scaffold_Controller extends Template_Controller {
function _create_directories() {
foreach (array("logs", "uploads") as $dir) {
- @mkdir(VARPATH . "$dir");
+ if (!file_exists(VARPATH . "$dir")) {
+ @mkdir(VARPATH . "$dir");
+ }
}
}
diff --git a/core/helpers/MY_url.php b/core/helpers/MY_url.php
index dd3682df..c5f2d16c 100644
--- a/core/helpers/MY_url.php
+++ b/core/helpers/MY_url.php
@@ -19,9 +19,9 @@
*/
class url extends url_Core {
static function site($uri, $protocol=false) {
- list($controller, $arg1, $args) = explode("/", $uri, 3);
- if ($controller == "albums" || $controller == "photos") {
- $uri = ORM::factory("item", $arg1)->relative_path();
+ $parts = explode("/", $uri, 3);
+ if ($parts[0] == "albums" || $parts[0] == "photos") {
+ $uri = ORM::factory("item", empty($parts[1]) ? 1 : $parts[1])->relative_path();
}
return parent::site($uri, $protocol);
}
@@ -33,7 +33,7 @@ class url extends url_Core {
$count = count(Router::$segments);
foreach (ORM::factory("item")
- ->where("name", Router::$segments[$count - 1])
+ ->where("path", Router::$segments[$count - 1])
->where("level", $count + 1)
->find_all() as $match) {
if ($match->relative_path() == Router::$current_uri) {
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 24b9e993..eacb08eb 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -63,6 +63,7 @@ class core_installer {
`level` int(9) NOT NULL,
`mime_type` varchar(64) default NULL,
`name` varchar(255) default NULL,
+ `path` varchar(255) default NULL,
`owner_id` int(9) default NULL,
`parent_id` int(9) NOT NULL,
`resize_height` int(9) default NULL,
diff --git a/core/models/item.php b/core/models/item.php
index e29f3245..e188e0a3 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -215,10 +215,10 @@ class Item_Model extends ORM_MPTT {
if (empty($this->relative_path)) {
foreach ($this->parents() as $parent) {
if ($parent->id > 1) {
- $paths[] = $parent->name;
+ $paths[] = $parent->path;
}
}
- $paths[] = $this->name;
+ $paths[] = $this->path;
$this->relative_path = implode($paths, "/");
}
return $this->relative_path;
@@ -242,6 +242,16 @@ class Item_Model extends ORM_MPTT {
}
/**
+ * @see ORM::__get()
+ */
+ public function __set($column, $value) {
+ if ($column == "name") {
+ parent::__set("path", preg_replace("/[^A-Za-z0-9\.\-_]/", "_", $value));
+ }
+ parent::__set($column, $value);
+ }
+
+ /**
* @see ORM::save()
*/
public function save() {