summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/g2_import/controllers/admin_g2_import.php18
-rw-r--r--modules/g2_import/helpers/g2_import.php47
-rw-r--r--modules/gallery/css/upgrader.css117
-rw-r--r--modules/gallery/helpers/gallery_installer.php65
-rw-r--r--modules/gallery/views/upgrader.html.php108
5 files changed, 194 insertions, 161 deletions
diff --git a/modules/g2_import/controllers/admin_g2_import.php b/modules/g2_import/controllers/admin_g2_import.php
index 968d97cd..f2969f49 100644
--- a/modules/g2_import/controllers/admin_g2_import.php
+++ b/modules/g2_import/controllers/admin_g2_import.php
@@ -44,20 +44,13 @@ class Admin_g2_import_Controller extends Admin_Controller {
$form = $this->_get_import_form();
if ($form->validate()) {
$embed_path = $form->configure_g2_import->embed_path->value;
- $multi_path = $form->configure_g2_import->multi_path->value;
-
if (!is_file($embed_path) && file_exists("$embed_path/embed.php")) {
$embed_path = "$embed_path/embed.php";
}
-
- if (!empty($multi_path) && !is_file($multi_path) && file_exists("$multi_path/config.php")) {
- $multi_path = "$multi_path/embed.php";
- }
- if (g2_import::is_valid_embed_path($embed_path, $multi_path)) {
+ if (g2_import::is_valid_embed_path($embed_path)) {
message::success("Gallery 2 path saved.");
module::set_var("g2_import", "embed_path", $embed_path);
- module::set_var("g2_import", "multi_path", $multi_path);
url::redirect("admin/g2_import");
} else {
$form->configure_g2_import->embed_path->add_error("invalid", 1);
@@ -74,16 +67,11 @@ class Admin_g2_import_Controller extends Admin_Controller {
$form = new Forge(
"admin/g2_import/save", "", "post", array("id" => "gAdminConfigureG2ImportForm"));
$group = $form->group("configure_g2_import")->label(t("Configure Gallery 2 Import"));
- $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file (in case of multisite config, use the path to the 'master')"))
+ $group->input("embed_path")->label(t("Filesystem path to your Gallery 2 embed.php file"))
->value(module::get_var("g2_import", "embed_path", ""));
-
- $group->input("multi_path")->label(t("Filesystem path to your Gallery 2 multisite instance config (leave empty if not applicable)"))
- ->value(module::get_var("g2_import", "multi_path", ""));
-
$group->embed_path->error_messages(
"invalid", t("The path you entered is not a Gallery 2 installation."));
-
$group->submit("")->value(t("Save"));
return $form;
}
-}
+} \ No newline at end of file
diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php
index 00e3d31a..2eee564a 100644
--- a/modules/g2_import/helpers/g2_import.php
+++ b/modules/g2_import/helpers/g2_import.php
@@ -38,24 +38,22 @@ class g2_import_Core {
}
$embed_path = module::get_var("g2_import", "embed_path");
- $multi_path = module::get_var("g2_import", "multi_path");
-
if (empty($embed_path)) {
throw new Exception("@todo G2_IMPORT_NOT_CONFIGURED");
}
- g2_import::$init = g2_import::init_embed($embed_path, $multi_path);
+ g2_import::$init = g2_import::init_embed($embed_path);
}
- static function is_valid_embed_path($embed_path, $multi_path) {
- return file_exists($embed_path) && (empty($multi_path) || file_exists($multi_path)) && g2_import::init_embed($embed_path, $multi_path);
+ static function is_valid_embed_path($embed_path) {
+ return file_exists($embed_path) && g2_import::init_embed($embed_path);
}
/**
* Initialize the embedded Gallery2 instance. Call this before any other Gallery2 calls.
*/
- static function init_embed($embed_path, $multi_path) {
- if (!is_file($embed_path) && (empty($multi_path) || is_dir($multi_path))) {
+ static function init_embed($embed_path) {
+ if (!is_file($embed_path)) {
return false;
}
@@ -72,11 +70,17 @@ class g2_import_Core {
@dir::unlink($mod_path);
mkdir($mod_path);
- $base_dir = dirname($embed_path);
- if (!empty($multi_path))
- $config_dir = dirname($multi_path);
- else
- $config_dir = $base_dir;
+ $config_dir = dirname($embed_path);
+ if (filesize($embed_path) > 200) {
+ // Regular install
+ $base_dir = $config_dir;
+ } else {
+ // Multisite install. Line 2 of embed.php will be something like:
+ // require('/usr/home/bharat/public_html/gallery2/embed.php');
+ $lines = file($embed_path);
+ preg_match("#require\('(.*)/embed.php'\);#", $lines[2], $matches);
+ $base_dir = $matches[1];
+ }
file_put_contents(
"$mod_path/embed.php",
@@ -108,11 +112,13 @@ class g2_import_Core {
array("require_once(dirname(__FILE__) . '/modules/core/classes/Gallery.class');",
"require_once(dirname(__FILE__) . '/modules/core/classes/GalleryDataCache.class');",
"define('GALLERY_CONFIG_DIR', dirname(__FILE__));",
- "\$gallery =& new Gallery();"),
+ "\$gallery =& new Gallery();",
+ "\$gallery = new Gallery();"),
array("require_once(dirname(__FILE__) . '/Gallery.class');",
"require_once('$base_dir/modules/core/classes/GalleryDataCache.class');",
"define('GALLERY_CONFIG_DIR', '$config_dir');",
- "\$gallery =& new G2_Gallery();"),
+ "\$gallery =& new G2_Gallery();",
+ "\$gallery = new G2_Gallery();"),
array_merge(array("<?php defined(\"SYSPATH\") or die(\"No direct script access.\") ?>\n"),
file("$base_dir/bootstrap.inc"))));
@@ -576,7 +582,18 @@ class g2_import_Core {
return;
}
- foreach (preg_split("/[,;]/", $keywords) as $keyword) {
+ // Keywords in G2 are free form. So we don't know what our user used as a separator. Try to
+ // be smart about it. If we see a comma or a semicolon, expect the keywords to be separated
+ // by that delimeter. Otherwise, use space as the delimiter.
+ if (strpos($keywords, ";")) {
+ $delim = ";";
+ } else if (strpos($keywords, ",")) {
+ $delim = ",";
+ } else {
+ $delim = " ";
+ }
+
+ foreach (preg_split("/$delim/", $keywords) as $keyword) {
$keyword = trim($keyword);
if ($keyword) {
tag::add($item, $keyword);
diff --git a/modules/gallery/css/upgrader.css b/modules/gallery/css/upgrader.css
new file mode 100644
index 00000000..6bd16064
--- /dev/null
+++ b/modules/gallery/css/upgrader.css
@@ -0,0 +1,117 @@
+body {
+ background: #eee;
+ font-family: Trebuchet MS;
+ font-size: 1.1em;
+}
+
+h1 {
+ font-size: 1.4em;
+}
+
+div#outer {
+ width: 650px;
+ background: white;
+ border: 1px solid #999;
+ margin: 0 auto;
+ padding: -10px;
+}
+
+div#inner {
+ padding: 0 1em 0 1em;
+ margin: 0px;
+}
+
+div#footer {
+ border-top: 1px solid #ccc;
+ margin: 1em;
+}
+
+td.name {
+ text-align: left;
+ padding-left: 30px;
+}
+
+td {
+ text-align: center;
+ border-bottom: 1px solid #eee;
+}
+
+tr.current td {
+ color: #999;
+ font-style: italic;
+}
+
+tr.current td.gallery {
+ color: #00d;
+}
+
+tr.upgradeable td {
+ font-weight: bold;
+}
+
+tr.upgradeable td.gallery {
+ color: #00d;
+}
+
+table {
+ width: 600px;
+ margin-bottom: 10px;
+}
+
+p {
+ font-size: .9em;
+}
+
+ul {
+ font-size: .9em;
+ list-style: none;
+}
+
+li {
+ display: inline;
+}
+
+li:before {
+ content: "\00BB \0020";
+}
+
+div.button {
+ margin: 0 auto;
+ width: 120px;
+ text-align: center;
+ border: 1px solid #999;
+ background: #eee;
+}
+
+div.button a {
+ text-decoration: none;
+}
+
+div.button:hover {
+ background: #ccc;
+}
+
+div#confirmation {
+ position: absolute;
+ background: blue;
+ z-index: 1000;
+ margin: 10px;
+ text-align: center;
+}
+
+div#confirmation div {
+ margin: 2px;
+ padding: 20px;
+ border: 2px solid #999;
+ background: #eee;
+}
+
+.gray_on_done {
+ opacity: <?= $done ? "0.5" : "1" ?>;
+}
+
+pre {
+ display: inline;
+ margin: 0px;
+ padding: 0px;
+}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index b2be63be..cd871c17 100644
--- a/modules/gallery/helpers/gallery_installer.php
+++ b/modules/gallery/helpers/gallery_installer.php
@@ -50,6 +50,18 @@ class gallery_installer {
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {incoming_translations} (
+ `id` int(9) NOT NULL auto_increment,
+ `key` char(32) NOT NULL,
+ `locale` char(10) NOT NULL,
+ `message` text NOT NULL,
+ `revision` int(9) DEFAULT NULL,
+ `translation` text,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`key`, `locale`),
+ KEY `locale_key` (`locale`, `key`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+
$db->query("CREATE TABLE {items} (
`id` int(9) NOT NULL auto_increment,
`album_cover_item_id` int(9) default NULL,
@@ -117,44 +129,24 @@ class gallery_installer {
UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {themes} (
- `id` int(9) NOT NULL auto_increment,
- `name` varchar(64) default NULL,
- `version` int(9) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-
- $db->query("CREATE TABLE {permissions} (
- `id` int(9) NOT NULL auto_increment,
- `display_name` varchar(64) default NULL,
- `name` varchar(64) default NULL,
- PRIMARY KEY (`id`),
- UNIQUE KEY(`name`))
- ENGINE=InnoDB DEFAULT CHARSET=utf8;");
-
- $db->query("CREATE TABLE {incoming_translations} (
+ $db->query("CREATE TABLE {outgoing_translations} (
`id` int(9) NOT NULL auto_increment,
+ `base_revision` int(9) DEFAULT NULL,
`key` char(32) NOT NULL,
`locale` char(10) NOT NULL,
`message` text NOT NULL,
- `revision` int(9) DEFAULT NULL,
`translation` text,
PRIMARY KEY (`id`),
UNIQUE KEY(`key`, `locale`),
KEY `locale_key` (`locale`, `key`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
- $db->query("CREATE TABLE {outgoing_translations} (
+ $db->query("CREATE TABLE {permissions} (
`id` int(9) NOT NULL auto_increment,
- `base_revision` int(9) DEFAULT NULL,
- `key` char(32) NOT NULL,
- `locale` char(10) NOT NULL,
- `message` text NOT NULL,
- `translation` text,
+ `display_name` varchar(64) default NULL,
+ `name` varchar(64) default NULL,
PRIMARY KEY (`id`),
- UNIQUE KEY(`key`, `locale`),
- KEY `locale_key` (`locale`, `key`))
+ UNIQUE KEY(`name`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE {sessions} (
@@ -179,6 +171,14 @@ class gallery_installer {
KEY (`owner_id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+ $db->query("CREATE TABLE {themes} (
+ `id` int(9) NOT NULL auto_increment,
+ `name` varchar(64) default NULL,
+ `version` int(9) default NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY(`name`))
+ ENGINE=InnoDB DEFAULT CHARSET=utf8;");
+
$db->query("CREATE TABLE {vars} (
`id` int(9) NOT NULL auto_increment,
`module_name` varchar(64) NOT NULL,
@@ -248,18 +248,20 @@ class gallery_installer {
block_manager::add("dashboard_center", "gallery", "photo_stream");
block_manager::add("dashboard_center", "gallery", "log_entries");
- module::set_version("gallery", 1);
+ module::set_version("gallery", $version = 1);
module::set_var("gallery", "version", "3.0 beta 1");
module::set_var("gallery", "choose_default_tookit", 1);
// @todo this string needs to be picked up by l10n_scanner
module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>");
- } else if ($version == 1) {
+ }
+
+ if ($version == 1) {
module::set_var("gallery", "date_format", "Y-M-d");
module::set_var("gallery", "date_time_format", "Y-M-d H:i:s");
module::set_var("gallery", "time_format", "H:i:s");
module::set_var("gallery", "version", "3.0 pre beta 2 (git)");
- module::set_version("gallery", 2);
+ module::set_version("gallery", $version = 2);
}
}
@@ -268,16 +270,15 @@ class gallery_installer {
$db->query("DROP TABLE IF EXISTS {access_caches}");
$db->query("DROP TABLE IF EXISTS {access_intents}");
$db->query("DROP TABLE IF EXISTS {graphics_rules}");
+ $db->query("DROP TABLE IF EXISTS {incoming_translations}");
$db->query("DROP TABLE IF EXISTS {items}");
$db->query("DROP TABLE IF EXISTS {logs}");
- $db->query("DROP TABLE IF EXISTS {messages}");
$db->query("DROP TABLE IF EXISTS {modules}");
- $db->query("DROP TABLE IF EXISTS {themes}");
- $db->query("DROP TABLE IF EXISTS {incoming_translations}");
$db->query("DROP TABLE IF EXISTS {outgoing_translations}");
$db->query("DROP TABLE IF EXISTS {permissions}");
$db->query("DROP TABLE IF EXISTS {sessions}");
$db->query("DROP TABLE IF EXISTS {tasks}");
+ $db->query("DROP TABLE IF EXISTS {themes}");
$db->query("DROP TABLE IF EXISTS {vars}");
foreach (array("albums", "resizes", "thumbs", "uploads",
"modules", "logs", "database.php") as $entry) {
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index fa21e196..07792322 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -2,106 +2,10 @@
<html>
<head>
<title><?= t("Gallery3 Upgrader") ?></title>
+ <link rel="stylesheet" type="text/css" href="<?= url::file("modules/gallery/css/upgrader.css") ?>"
+ media="screen,print,projection" />
+ <script src="<?= url::file("lib/jquery.js") ?>" type="text/javascript"></script>
</head>
- <style>
- body {
- background: #eee;
- font-family: Trebuchet MS;
- font-size: 1.1em;
- }
- h1 {
- font-size: 1.4em;
- }
- div#outer {
- width: 650px;
- background: white;
- border: 1px solid #999;
- margin: 0 auto;
- padding: -10px;
- }
- div#inner {
- padding: 0 1em 0 1em;
- margin: 0px;
- }
- div#footer {
- border-top: 1px solid #ccc;
- margin: 1em;
- }
- td.name {
- text-align: left;
- padding-left: 30px;
- }
- td {
- text-align: center;
- border-bottom: 1px solid #eee;
- }
- tr.current td {
- color: #999;
- font-style: italic;
- }
- tr.current td.gallery {
- color: #00d;
- }
- tr.upgradeable td {
- font-weight: bold;
- }
- tr.upgradeable td.gallery {
- color: #00d;
- }
- table {
- width: 600px;
- margin-bottom: 10px;
- }
- p {
- font-size: .9em;
- }
- ul {
- font-size: .9em;
- list-style: none;
- }
- li {
- display: inline;
- }
- li:before {
- content: "\00BB \0020";
- }
- div.button {
- margin: 0 auto;
- width: 120px;
- text-align: center;
- border: 1px solid #999;
- background: #eee;
- }
- div.button a {
- text-decoration: none;
- }
- div.button:hover {
- background: #ccc;
- }
- div#confirmation {
- position: fixed;
- top: 400px;
- left: 325px;
- background: blue;
- z-index: 1000;
- margin: 10px;
- text-align: center;
- }
- div#confirmation div {
- margin: 2px;
- padding: 20px;
- border: 2px solid #999;
- background: white;
- }
- .gray_on_done {
- opacity: <?= $done ? "0.5" : "1" ?>;
- }
- pre {
- display: inline;
- margin: 0px;
- padding: 0px;
- }
- </style>
<body>
<div id="outer">
<img src="<?= url::file("modules/gallery/images/gallery.png") ?>" />
@@ -117,6 +21,12 @@
</p>
</div>
</div>
+ <script type="text/javascript">
+ $(document).ready(function() {
+ $("#confirmation").css("left", Math.round(($(window).width() - $("#confirmation").width()) / 2));
+ $("#confirmation").css("top", Math.round(($(window).height() - $("#confirmation").height()) / 2));
+ });
+ </script>
<? endif ?>
<p class="gray_on_done">
<?= t("Welcome to the Gallery upgrader. One click and you're done!") ?>