summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkiz_09872006-03-24 14:04:52 (GMT)
committerkiz_09872006-03-24 14:04:52 (GMT)
commitc15e9178ae63dd88afa36bf26b8e019d0d9bcd58 (patch)
tree14d537645f7f31d0b354fe54faf5d144f4de438d
parent9e95ee77658a5a6bd4fa7853f0e2fd9b7146cd84 (diff)
Initial Gallery2.1 compatible module for Drupal 4.7
-rw-r--r--[-rwxr-xr-x]CREDITS.txt (renamed from contrib/g2_filter/CREDITS.txt)11
-rwxr-xr-xG2EmbedDiscoveryUtilities.class467
-rwxr-xr-xG2EmbedTestUtilities.class368
-rw-r--r--INSTALL.txt86
-rw-r--r--README.txt16
-rwxr-xr-xcontrib/g2_filter/INSTALL.txt4
-rwxr-xr-xcontrib/g2_filter/README.txt28
-rwxr-xr-xcontrib/g2_filter/TODO.txt32
-rwxr-xr-xcontrib/g2_filter/changelog.txt7
-rwxr-xr-xcontrib/g2_filter/g2_filter.css14
-rwxr-xr-xcontrib/g2_filter/g2_filter.module440
-rwxr-xr-xdrupal_g2.css103
-rw-r--r--g2image.js19
-rw-r--r--gallery.module560
-rw-r--r--gallery_base.inc178
-rwxr-xr-xgallery_filter.css20
-rw-r--r--gallery_filter.inc202
-rw-r--r--gallery_g2image.inc62
-rw-r--r--gallery_help.inc157
-rw-r--r--gallery_roles.inc208
-rw-r--r--gallery_search.inc226
-rw-r--r--gallery_settings.inc971
-rw-r--r--gallery_user.inc308
-rw-r--r--po/fr.po105
-rw-r--r--po/gallery-module.pot109
25 files changed, 3590 insertions, 1111 deletions
diff --git a/contrib/g2_filter/CREDITS.txt b/CREDITS.txt
index 766e90f..0e9d206 100755..100644
--- a/contrib/g2_filter/CREDITS.txt
+++ b/CREDITS.txt
@@ -1,4 +1,11 @@
-This module would not exist without image_filter by Eric Scouten (http://drupal.org/node/9707). I started with that module and transformed it bit by bit into this module. While there's not a lot of original code left, I wouldn't have been able
-to do this without using image_filter as a template.
+// $Id$
+
+kiz_0987:
+This gallery.module was based on original code by walkah. The gallery_filter part is almost
+entirely based on work by MichelleC and Waldemar. The g2image application is by capt_kirk.
+Thanks for all your efforts.
+
+MichelleC (g2_filter):
+This module would not exist without image_filter by Eric Scouten (http://drupal.org/node/9707). I started with that module and transformed it bit by bit into this module. While there's not a lot of original code left, I wouldn't have been able to do this without using image_filter as a template.
This module is dependent on Drupal (of course), Gallery 2, and the gallery.module (http://drupal.org/project/gallery) so thanks to everyone for all the work on those. Without them, this module would be useless. :) \ No newline at end of file
diff --git a/G2EmbedDiscoveryUtilities.class b/G2EmbedDiscoveryUtilities.class
new file mode 100755
index 0000000..ab5fcdc
--- /dev/null
+++ b/G2EmbedDiscoveryUtilities.class
@@ -0,0 +1,467 @@
+<?php
+/*
+ * $RCSfile$
+ *
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2006 Bharat Mediratta
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+/**
+ * @version $Revision$ $Date$
+ * @package GalleryCore
+ * @author Andy Staudacher <ast@gmx.ch>
+ */
+
+/**
+ * A collection of useful G2Embed related utilities to find the correct GalleryEmbed::init
+ * parameters
+ *
+ * @package GalleryCore
+ * @subpackage GalleryEmbed
+ * @static
+ */
+class G2EmbedDiscoveryUtilities {
+ /**
+ * Documentation:
+ * To use GalleryEmbed and its GalleryEmbed::init method to initialize G2, you need:
+ * a) the absolute filesystem path to embed.php
+ * b) embedUri, the URL of the entry point to your embedding application / embedded G2
+ * e.g. http://example.com/ or just / , or http://example.com/index.php?mod=gallery
+ * c) g2Uri, the URL path to G2, e.g. http://example.com/gallery2/ or just /gallery2/
+ *
+ * Methods to finding out the path to embed.php:
+ * ============================================
+ *
+ * - It's a good assumption that you can find out or define embedUri easily
+ * - g2Uri must be entered by the admin that configures the integration, just copy and paste
+ * the URL of G2
+ * - finding out embed.php is a little tricky.
+ *
+ * We offer two methods to get embed.php. Do NOT call them for each request. Call them once
+ * when configuring / installing your integration. Else you get a performance penalty.
+ *
+ * 1. If you ask the user to enter the g2Uri, you can call:
+ * list ($success, $embedPhpPath, $errorString) =
+ * G2EmbedDiscoveryUtilities::getG2EmbedPathByG2Uri($g2Uri);
+ * if (!$success) {
+ * print $errorString;
+ * /* Tell the admin to enter the correct input
+ * } else {
+ * /* embedPhpPath is correct and you can store it in your config for later use
+ * }
+ *
+ * 2. If you ask only for the g2Uri, you also need to provide the filesystem path to the
+ * entry point (the filesystem path to the file that embedUri points to)
+ * list ($success, $embedPhpPath, $errorString) =
+ * G2EmbedDiscoveryUtilities::getG2EmbedPathByG2UriEmbedUriAndLocation(
+ * $g2Uri, $embedUri, dirname(dirname(__FILE__)));
+ * if (!$success) {
+ * print $errorString;
+ * /* Tell the admin to enter the correct input
+ * } else {
+ * /* embedPhpPath is correct and you can store it in your config for later use
+ * }
+ * Disadvantage of this method: it's less reliable. It won't work with Apache Alias,
+ * or with subdomains, ...
+ *
+ *
+ * Method to normalize the g2Uri and embedUri before using them in GalleryEmbed::init:
+ * ==================================================================================
+ *
+ * Do NOT call them on each request. Call them once to verify / sanitize user input
+ * and then store them in your configuration.
+ * - These methods try their best to be tolerant to common user mistakes and return a
+ * string that GalleryEmbd::init accepts
+ * - You don't have to call these methods before calling the above methods to get
+ * embed.php, since it does that already internally
+ *
+ * 1. $g2Uri = G2EmbedDiscoveryUtilities::normalizeG2Uri($g2Uri);
+ * 2. $embedUri = G2EmbedDiscoveryUtilities::normalizeEmbedUri($embedUri);
+ */
+
+ /**
+ * The format for g2Uri accepted by GalleryEmbed::init is quite strict and well defined
+ * missing traling / leading slashes have a meaning.
+ * This function is more tolerant for incorrect user input and tries to normalize the
+ * given g2Uri to a value that is probably what the user meant to provide
+ *
+ * The returned URI is either a server-relative URI (e.g. /gallery2/) or an absolute URI
+ * including the schema (e.g. http://example.com/gallery/)
+ *
+ * The file / query string part is always removed)
+ *
+ * @param string g2Uri
+ * @return string normalized g2Uri
+ */
+ function normalizeG2Uri($g2Uri) {
+ list ($schemaAndHost, $path, $file, $queryString, $fragment) =
+ G2EmbedDiscoveryUtilities::_normalizeUri($g2Uri);
+
+ return $schemaAndHost . $path;
+ }
+
+ /**
+ * @see normalizeG2Uri
+ *
+ * Very similar, but file / query string is kept in the result
+ */
+ function normalizeEmbedUri($embedUri) {
+ list ($schemaAndHost, $path, $file, $queryString, $fragment) =
+ G2EmbedDiscoveryUtilities::_normalizeUri($embedUri);
+
+ return $schemaAndHost . $path . $file . $queryString . $fragment;
+ }
+
+ /**
+ * Find the absolute filesystem path to G2's embed.php when given the g2Uri
+ *
+ * Returns false if the g2Uri is wrong. Can also fail if G2 and emApp are
+ * on different (sub)domains / IPs
+ *
+ * @param string the g2Uri, a full URL or a server-relative URI
+ * @return array boolean success,
+ * string filesystem path of embed.php
+ * string error string
+ */
+ function getG2EmbedPathByG2Uri($g2Uri) {
+ $g2Uri = trim($g2Uri);
+ if (empty($g2Uri)) {
+ return array (false, null, "Bad parameter: the provided g2Uri is empty");
+ }
+
+ $g2Uri = G2EmbedDiscoveryUtilities::normalizeG2Uri($g2Uri);
+
+ /* Add a schema / host part to the g2Uri if necessary */
+ if (strpos($g2Uri, 'http') !== 0) {
+ $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
+ $host = !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1';
+ $g2Uri = sprintf('%s://%s%s', $protocol, $host, $g2Uri);
+ }
+
+ $components = @parse_url($g2Uri);
+ if (!$components) {
+ return array(false, null, "Unable to parse normalized URL $g2Uri. Please enter the " .
+ "full address of your Gallery 2 installation.");
+ }
+ $port = empty($components['port']) ? 80 : $components['port'];
+ if (empty($components['path'])) {
+ $components['path'] = '/';
+ }
+
+ $fd = @fsockopen($components['host'], $port, $errno, $errstr, 1);
+ if (empty($fd)) {
+ return array(false, null, "Error $errno: '$errstr' retrieving $url");
+ }
+
+ $get = $components['path'] . 'embed.php?getEmbedPath=1';
+
+ /* Read the web page into a buffer */
+ $ok = fwrite($fd, sprintf("GET %s HTTP/1.0\r\n" .
+ "Host: %s\r\n" .
+ "\r\n",
+ $get,
+ $components['host']));
+ if (!$ok) {
+ /* Zero bytes written or false was returned */
+ $errorStr = "Verification of Gallery 2 location failed. fwrite call failed for $g2Uri";
+ if ($ok === false) {
+ $errorStr .= "\nreturn value was false";
+ }
+ return array(false, null, $errorStr);
+ }
+ $ok = fflush($fd);
+ if (!$ok) {
+ if (version_compare(phpversion(), '4.2.0', '>=')) {
+ /* Ignore false returned from fflush on PHP 4.1 */
+ return array(false, null, "Verification of Gallery 2 location failed. " .
+ "fflush call failed for $g2Uri");
+ }
+ }
+
+ /*
+ * Read the response code. fgets stops after newlines.
+ * The first line contains only the status code (200, 404, etc.).
+ */
+ $headers = array();
+ $response = trim(fgets($fd, 4096));
+
+ /* if the HTTP response code did not begin with a 2 this request was not successful */
+ if (!preg_match("/^HTTP\/\d+\.\d+\s2\d{2}/", $response)) {
+ return array(false, null, "URL derived from $g2Uri is invalid");
+ }
+
+ /* Read the headers. */
+ while (!feof($fd)) {
+ $line = trim(fgets($fd, 4096));
+ if (empty($line)) {
+ break;
+ }
+ /* Normalize the line endings */
+ $line = str_replace("\r", '', $line);
+
+ list ($key, $value) = explode(':', $line, 2);
+ $headers[$key] = trim($value);
+ }
+
+ $embedPhpPath = '';
+ if (isset($headers['X-G2-EMBED-PATH'])) {
+ $embedPhpPath = $headers['X-G2-EMBED-PATH'];
+ } else {
+ return array(false, null, "Either your server does not support the automated " .
+ "verification of the Gallery 2 location or the supplied g2Uri " .
+ "points to a incompatible Gallery 2 version (older than 2.1)");
+ }
+
+ if (empty($embedPhpPath)) {
+ return array(false, null, "Correct URL, but the returned " .
+ "embed.php path is empty (server error?!)");
+ }
+
+ /* Verify path */
+ list ($ok, $errorString) = @G2EmbedDiscoveryUtilities::isFileReadable($embedPhpPath);
+ if (!$ok) {
+ return array(false, null, $errorString);
+ } else {
+ return array(true, $embedPhpPath, null);
+ }
+ }
+
+ /**
+ * Get the absolute filesystem path to embed.php from the given g2Uri, embedUri and the
+ * absolute filesystem path of the entry point file of your embedding application
+ *
+ * Can be unreliable if short URLs are entered or if apache alias / symlinks are used
+ *
+ * @param string g2Uri
+ * @param string embedUri
+ * @param string the dirname of the location of the entry point of your embedding application
+ * e.g. dirname(__FILE__) if your embedUri points right to your wrapper file or if your
+ * wrapper file is in the same directory as the entry point to your emApp
+ * e.g. dirname(dirname(dirname(__FILE__))) if your wrapper is in a
+ * modules/g2integration/wrapper.inc.php file, which is 2 subdirectories deeper than
+ * the actual entry point that embedUri is pointing to
+ * @return array boolean success,
+ * string absolute filesystem path to embed.php,
+ * string errorString
+ */
+
+ function getG2EmbedPathByG2UriEmbedUriAndLocation($g2Uri, $embedUri, $dirnameOfEmApp) {
+ if (empty($dirnameOfEmApp)) {
+ return array(false, null, 'dirname of embedding application is empty');
+ }
+ /* Normalize g2Uri, embedUri */
+ list ($schemaAndHost, $path, $file, $queryString, $fragment) =
+ G2EmbedDiscoveryUtilities::_normalizeUri($g2Uri);
+ $g2Path = $path;
+ list ($schemaAndHost, $path, $file, $queryString, $fragment) =
+ G2EmbedDiscoveryUtilities::_normalizeUri($embedUri);
+ $embedPath = $path;
+
+ /* Normalize path separators */
+ $dirnameOfEmApp = str_replace(DIRECTORY_SEPARATOR, '/', $dirnameOfEmApp);
+ /* Remove trailing slash */
+ if (substr($dirnameOfEmApp, -1) == '/') {
+ $dirnameOfEmApp = substr($dirnameOfEmApp, 0, strlen($dirnameOfEmApp) - 1);
+ }
+
+ /*
+ * Do some directory traversal to translate g2Path + embedPath + dirnameOfEmApp
+ * to path to embed.php
+ * path
+ * Example: g2Path = /baz/bar/gallery2/ , embedPath = /baz/cms/foo/ ,
+ * dirnameOfEmApp = /home/john/www/cms/foo/
+ * 1. Remove as many dirs from the end of dirnameOfEmApp as embedPath has
+ * 2. append g2Path to dirnameOfEmApp
+ */
+ $numberOfSubDirs = count(explode('/', $embedPath));
+ /* Don't count the one before the leading and after the traling slash */
+ $numberOfSubDirs -= 2;
+
+ $pathElements = explode('/', $dirnameOfEmApp);
+ $max = 30; /* prevent infinite loop */
+ while ($numberOfSubDirs-- > 0 && $max-- > 0) {
+ array_pop($pathElements);
+ }
+
+ $embedPhpPath = join('/', $pathElements) . $g2Path . 'embed.php';
+
+ /* Convert / back to platform specific directory separator */
+ $embedPhpPath = str_replace('/', DIRECTORY_SEPARATOR, $embedPhpPath);
+
+ /* Verify path */
+ list ($ok, $errorString) = @G2EmbedDiscoveryUtilities::isFileReadable($embedPhpPath);
+ if (!$ok) {
+ return array(false, null, $errorString);
+ } else {
+ return array(true, $embedPhpPath, null);
+ }
+ }
+
+ /**
+ * Helper function for normalizeG2Uri and normalizeEmbedUri
+ *
+ * @access private
+ */
+ function _normalizeUri($uri) {
+ $uri = trim($uri);
+ if (empty($uri)) {
+ return array('', '/', '', '', '');
+ }
+ $schema = $host = $schemaAndHost = $path = $file = '';
+ $fragment = $queryString = '';
+
+ /* Normalize path separators */
+ $uri = str_replace("\\", '/', $uri);
+
+ /*
+ * With schema (http://) -> easy to identify host
+ * A single slash:
+ * www.example.com/
+ * www.example.com/gallery2
+ * www.example.com/index.php
+ * gallery2/
+ * /
+ * /gallery2
+ * /index.php
+ * gallery2/index.php
+ * Multiple slashes:
+ * www.example.com/gallery2/
+ * /gallery2/
+ * ....
+ * Problem: Differentiate between host, path and file
+ * @files: .php|.html? is recognized as file
+ * @host: (?:\w+:\w+@)[\w\.]*\w+\.\w{2-4}(?::\d+) is most likely a host string
+ * localhost or other host strings without a dot are impossible to
+ * differentiate from path names ->only http://localhost accepted
+ * @path: everything that is not a file or a host
+ */
+
+ /* Remove fragment / query string */
+ if (($pos = strpos($uri, '#')) !== false) {
+ $fragment = substr($uri, $pos);
+ $uri = substr($uri, 0, $pos);
+ }
+ if (($pos = strpos($uri, '?')) !== false) {
+ $queryString = substr($uri, $pos);
+ $uri = substr($uri, 0, $pos);
+ }
+
+ /* Handle and remove file part */
+ if (preg_match('{(.*/)?([\w\.]+\.(?:php|html?))$}i', $uri, $matches)) {
+ $uri = empty($matches[1]) ? '/' : $matches[1];
+ $file = $matches[2];
+ }
+
+ /* Get the schema and host for absolute URLs */
+ if (preg_match('{^(https?://)([^/]+)(.*)$}i', $uri, $matches)) {
+ $schema = strtolower($matches[1]);
+ $host = $matches[2];
+ $schemaAndHost = $schema . $host;
+ $uri = empty($matches[3]) ? '/' : $matches[3];
+ $uri = $uri{0} != '/' ? '/' . $uri : $uri;
+ } else {
+ /* Get the host string, e.g. from www.example.com/foo or www.example.com */
+ if (preg_match('{^((?:\w+:\w+@)?[\w\.]*\w+\.\w+(?::\d+)?)(.*)$}', $uri, $matches)) {
+ $host = $matches[1];
+ $schema = 'http://';
+ if ( !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
+ $schema = 'https://';
+ }
+ $schemaAndHost = $schema . $host;;
+ $uri = empty($matches[2]) ? '/' : $matches[2];
+ $uri = $uri{0} != '/' ? '/' . $uri : $uri;
+ }
+ }
+
+ /* Add leading / trailing slash to path */
+ $path = $uri{0} != '/' ? '/' . $uri : $uri;
+ $path .= substr($path, -1) != '/' ? '/' : '';
+
+ return array($schemaAndHost, $path, $file, $queryString, $fragment);
+ }
+
+ function isFileReadable($path) {
+ if (@file_exists($path) && @is_readable($path)) {
+ return array(true, null);
+ } else if (@G2EmbedDiscoveryUtilities::_isRestrictedByOpenBaseDir($path)) {
+ return array(false, "file $path is restricted by PHP open_basedir");
+ } else if (@file_exists($path) && !@is_readable($path)) {
+ return array(false, "file $path exists but is not readable");
+ } else {
+ return array(false, "file $path does not exist");
+ }
+ }
+
+ /**
+ * Return true if the path provided is not allowed by the current open_basedir configuration.
+ *
+ * Copied from GalleryPlatform and adjusted to be independent of the G2 framework
+ *
+ * @return true if the path is restricted
+ */
+ function _isRestrictedByOpenBaseDir($path) {
+ $slash = DIRECTORY_SEPARATOR;
+ if (!strncasecmp(PHP_OS, 'win', 3)) {
+ $separator = ';';
+ $caseSensitive = false;
+ } else {
+ $separator = ':';
+ $caseSensitive = true;
+ }
+
+ $openBasedir = @ini_get('open_basedir');
+ if (empty($openBasedir)) {
+ return false;
+ }
+
+ if (($realpath = realpath($path)) === false) {
+ /*
+ * PHP's open_basedir will actually take an invalid path, resolve relative
+ * paths, parse out .. and . and then check against the dir list..
+ * Here we do an ok job of doing the same, though it isn't perfect.
+ */
+ $s = '\\\/'; /* do this by hand because preg_quote() isn't reliable */
+ if (!preg_match("{^([a-z]+:)?[$s]}i", $path)) {
+ $path = getcwd() . $slash . $path;
+ }
+ for ($realpath = $path, $lastpath = ''; $realpath != $lastpath;) {
+ $realpath = preg_replace("#[$s]\.([$s]|\$)#", $slash, $lastpath = $realpath);
+ }
+
+ for ($lastpath = ''; $realpath != $lastpath;) {
+ $realpath = preg_replace("#[$s][^$s]+[$s]\.\.([$s]|\$)#",
+ $slash, $lastpath = $realpath);
+ }
+ }
+
+ $function = $caseSensitive ? 'strncmp' : 'strncasecmp';
+ foreach (explode($separator, $openBasedir) as $baseDir) {
+ if (($baseDirMatch = realpath($baseDir)) === false) {
+ $baseDirMatch = $baseDir;
+ } else if ($baseDir{strlen($baseDir)-1} == $slash) {
+ /* Realpath will remove a trailing slash.. add it back to avoid prefix match */
+ $baseDirMatch .= $slash;
+ }
+ /* Add slash on path so /dir is accepted if /dir/ is a valid basedir */
+ if (!$function($baseDirMatch, $realpath . $slash, strlen($baseDirMatch))) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
+?> \ No newline at end of file
diff --git a/G2EmbedTestUtilities.class b/G2EmbedTestUtilities.class
new file mode 100755
index 0000000..22c8e9e
--- /dev/null
+++ b/G2EmbedTestUtilities.class
@@ -0,0 +1,368 @@
+<?php
+// $Id$
+
+/**
+ * @version
+ * @package GalleryCore
+ * @author Kieran Parsons
+ */
+
+/**
+ * A collection of useful G2Embed related utilities to test that all the required
+ * parameters and modules are correctly configures
+ *
+ * @package GalleryCore
+ * @subpackage GalleryEmbed
+ * @static
+ */
+class G2EmbedTestUtilities {
+
+ /**
+ * Validate the Gallery2 Embed variables
+ *
+ * Returns false if any test failed
+ * @param $orig, $autodetect
+ * @return array($gallery_valid, $new, $results)
+ */
+ function checkLocations($orig, $autodetect=true) {
+ $gallery_valid = 1;
+ // Normalise the G2 URI
+ $g2Uri = G2EmbedDiscoveryUtilities::normalizeG2Uri($orig['g2Uri']);
+ $new['g2Uri'] = $g2Uri;
+ if ($g2Uri != $orig['g2Uri']) {
+ $results['g2Uri']['title'] = G2EmbedTestUtilities::_trans('\'URI of Gallery2\' variable:');
+ $results['g2Uri']['advise'] = true;
+ $results['g2Uri']['notice'] = G2EmbedTestUtilities::_trans('%origG2Uri automatically updated to %g2Uri to adhere to Gallery2 requirements.',
+ array('%origG2Uri' => $orig['g2Uri'], '%g2Uri' => $g2Uri));
+ }
+
+ // Find the Gallery Directory and Embed URI
+ if ($autodetect) {
+ // Auto-Detect the G2 embed path
+ list ($success, $embedPhpPath, $errorString) =
+ G2EmbedDiscoveryUtilities::getG2EmbedPathByG2Uri($g2Uri);
+ if (!$success) {
+ // Something is wrong with the G2 URI given as the G2 embed path is not found
+ $results['g2Uri2']['title'] = G2EmbedTestUtilities::_trans('\'URI of Gallery2\' variable:');
+ $results['g2Uri2']['error'] = true;
+ $results['g2Uri2']['notice'] = $errorString;
+ $new['g2EmbedPath'] = rtrim($embedPhpPath, 'embed.php');
+ $gallery_valid = 0;
+ } else {
+ // G2 Embed Path is found OK
+ $results['g2Uri2']['title'] = G2EmbedTestUtilities::_trans('\'URI of Gallery2\' variable:');
+ $results['g2Uri2']['success'] = true;
+ $new['g2EmbedPath'] = rtrim($embedPhpPath, 'embed.php');
+ }
+
+ // Auto-Detect the Embed Application URI
+ $embedUri = G2EmbedTestUtilities::_autodetectEmbedUri();
+ // Normalise the Embed Application URI
+ $embedUri = G2EmbedDiscoveryUtilities::normalizeEmbedUri($embedUri);
+ $new['embedUri'] = $embedUri;
+
+ } else {
+ // Do not autodetect the variables, but check the manually entered ones.
+ $results['g2Uri2']['title'] = G2EmbedTestUtilities::_trans('\'URI of Gallery2\' variable:');
+ $results['g2Uri2']['advise'] = true;
+ $results['g2Uri2']['notice'] =
+ G2EmbedTestUtilities::_trans('Cannot fully check this when not in auto-detect mode.');
+
+ $embedPhpPath = $orig['g2EmbedPath'];
+ // Check path can be read, adding embed.php if needed
+ if (substr($embedPhpPath, -1) != '/') {
+ $embedPhpPath = $embedPhpPath . '/';
+ $results['g2EmbedPath']['title'] =
+ G2EmbedTestUtilities::_trans('\'Location of Gallery2\' variable:');
+ $results['g2EmbedPath']['advise'] = true;
+ $results['g2EmbedPath']['notice'] =
+ G2EmbedTestUtilities::_trans('%g2EmbedPath automatically updated to %embedPhpPath to adhere to Gallery2 requirements.',
+ array('%g2EmbedPath' => $orig['g2EmbedPath'],
+ '%embedPhpPath' => $embedPhpPath));
+ }
+ list ($ok, $errorString) =
+ G2EmbedDiscoveryUtilities::isFileReadable($embedPhpPath.'embed.php');
+ $new['g2EmbedPath'] = $embedPhpPath;
+ if (!$ok) {
+ // Something is wrong with the G2 embed path
+ $results['g2EmbedPath2']['title'] =
+ G2EmbedTestUtilities::_trans('\'Location of Gallery2\' variable:');
+ $results['g2EmbedPath2']['error'] = true;
+ $results['g2EmbedPath2']['notice'] = $errorString;
+ $gallery_valid = 0;
+ } else {
+ // G2 Embed Path is found OK
+ $results['g2EmbedPath2']['title'] =
+ G2EmbedTestUtilities::_trans('\'Location of Gallery2\' variable:');
+ $results['g2EmbedPath2']['success'] = true;
+ }
+ $embedUri = $orig['embedUri'];
+ $embedUri = G2EmbedDiscoveryUtilities::normalizeEmbedUri($embedUri);
+ $new['embedUri'] = $embedUri;
+ if ($embedUri != $orig['embedUri']) {
+ $results['embedUri']['title'] =
+ G2EmbedTestUtilities::_trans('\'Embed URI\' variable:');
+ $results['embedUri']['advise'] = true;
+ $results['embedUri']['notice'] =
+ G2EmbedTestUtilities::_trans('%origEmbedUri automatically updated to %embedUri to adhere to Gallery2 requirements.',
+ array('%origEmbedUri' => $orig['embedUri'],
+ '%embedUri' => $embedUri));
+ }
+ $results['embedUri2']['title'] =
+ G2EmbedTestUtilities::_trans('\'Embed URI\' variable:');
+ $results['embedUri2']['advise'] = true;
+ $results['embedUri2']['notice'] =
+ G2EmbedTestUtilities::_trans('Cannot fully check this when not in auto-detect mode.');
+ }
+
+ list ($numErrors, $numWarnings) = G2EmbedTestUtilities::_getNumErrorsAndWarnings($results);
+ return array($numErrors, $numWarnings, $new, $results);
+ // return array($gallery_valid, $new, $results);
+ }
+
+ /**
+ * Check the status of Gallery2 Modules before Gallery Init
+ *
+ * @param $testsToRun
+ * @return array results
+ */
+ function preInitTests($testsToRun = null) {
+ if (!$testsToRun) {
+ $testsToRun['php_memory']['errorlevel'] = 'error';
+ $testsToRun['php_memory']['minimumMemoryLimit'] = 24;
+ }
+ /* Check for adequate PHP Memory Limit */
+ if (isset($testsToRun['php_memory'])) {
+ $results['php_memory'] = G2EmbedTestUtilities::phpMemoryCheck(
+ $testsToRun['php_memory']['minimumMemoryLimit']);
+ }
+ list ($numErrors, $numWarnings) = G2EmbedTestUtilities::_getNumErrorsAndWarnings($results);
+ return array($numErrors, $numWarnings, $results);
+ }
+
+ /**
+ * Check the status of Gallery2 Modules after Gallery Init
+ *
+ * @param $testsToRun
+ * @return array results
+ */
+ function postInitTests($testsToRun = null) {
+
+ if (!$testsToRun) {
+ $testsToRun['imageblock']['errorlevel'] = 'error';
+ $testsToRun['imageframe']['errorlevel'] = 'warning';
+ $testsToRun['urlrewrite']['errorlevel'] = 'advise';
+ }
+
+ list ($ret, $allModulesStatus) = GalleryCoreApi::fetchPluginStatus('module');
+ /* Check for ImageBlock Module */
+ if (isset($testsToRun['imageblock'])) {
+ $results['imageblock'] =
+ G2EmbedTestUtilities::moduleCheck('imageblock', 'Image Block',
+ $testsToRun['imageblock']['errorlevel'], $allModulesStatus);
+ }
+ /* Check for ImageFrame Module */
+ if (isset($testsToRun['imageframe'])) {
+ $results['imageframe'] =
+ G2EmbedTestUtilities::moduleCheck('imageframe', 'Image Frame',
+ $testsToRun['imageframe']['errorlevel'], $allModulesStatus);
+ }
+ if (isset($testsToRun['urlrewrite'])) {
+ $results['urlrewrite'] =
+ G2EmbedTestUtilities::urlRewriteCheck($testsToRun['urlrewrite']['errorlevel']);
+ }
+ list ($numErrors, $numWarnings) = G2EmbedTestUtilities::_getNumErrorsAndWarnings($results);
+ return array($numErrors, $numWarnings, $results);
+ }
+
+ /**
+ * Warn if memory_limit is set and is too low
+ * (from Gallery2 install code)
+ *
+ * @param minimumMemoryLimit
+ * @return array results
+ */
+ function phpMemoryCheck($minimumMemoryLimit = 24) {
+ $memoryLimit = ini_get('memory_limit');
+ $title = G2EmbedTestUtilities::_trans('PHP Memory Limit:');
+ if ($memoryLimit != '' && ($this->_getBytes($memoryLimit) / (1024 * 1024)) < $minimumMemoryLimit) {
+ $results = array(
+ 'title' => $title,
+ 'error' => true,
+ 'notice' => G2EmbedTestUtilities::_trans(
+ 'Your PHP is configured to limit the memory to %memLimit (<b>
+ memory_limit</b> parameter in php.ini). You should raise this limit
+ to at least <b>%minMemLimitMB</b> for proper Embedded Gallery2 operation',
+ array('%memLimit' => $memoryLimit, '%minMemLimit' => $minimumMemoryLimit)),
+ );
+ } else {
+ $results = array(
+ 'title' => $title,
+ 'success' => true,
+ );
+ }
+ return $results;
+ }
+
+ /**
+ * Check the status of Gallery2 URL Rewrite Module
+ *
+ * @param $errorLevel
+ * @return array results
+ */
+ function urlRewriteCheck($errorLevel) {
+ /* Check for URL Rewrite Module */
+ $title = 'Gallery2 URL Rewrite Module Status:';
+ list ($ret, $rewriteApi) = GalleryCoreApi::newFactoryInstance('RewriteApi');
+ if ($ret) {
+ /* G2 Error handling */
+ $results = array(
+ 'title' => $title,
+ 'installed' => false,
+ 'active' => false,
+ 'available' => false,
+ $errorLevel => true,
+ 'notice' => G2EmbedTestUtilities::_trans(
+ 'Gallery2 Error when trying to access URL Rewrite Module status. %ret',
+ array('%ret' => $ret->getAsHtml())),
+ );
+ }
+ if (empty($rewriteApi)) {
+ $results = array(
+ 'title' => $title,
+ 'installed' => false,
+ 'active' => false,
+ 'available' => false,
+ $errorLevel => true,
+ 'notice' => G2EmbedTestUtilities::_trans(
+ 'Either the URL rewrite module is not installed or the version is too old.'),
+ );
+ } else {
+ /* Check compatibility */
+ $required = array(1, 0);
+ list ($ret, $isCompatible) = $rewriteApi->isCompatibleWithApi($required);
+ if ($ret) {
+ /* Error handeling */
+ $results = array(
+ 'title' => $title,
+ 'installed' => false,
+ 'active' => false,
+ 'available' => false,
+ $errorLevel => true,
+ 'notice' => G2EmbedTestUtilities::_trans(
+ 'Gallery2 Error when trying to access URL Rewrite Module status. %ret',
+ array('%ret' => $ret->getAsHtml())),
+ );
+ } else {
+ if (!$isCompatible) {
+ $results = array(
+ 'title' => $title,
+ 'installed' => false,
+ 'active' => false,
+ 'available' => false,
+ $errorLevel => true,
+ 'notice' => G2EmbedTestUtilities::_trans(
+ 'The installed URL Rewrite module version is not compatible.'),
+ );
+ } else {
+ /* Add rules checking etc */
+ $results = array(
+ 'title' => $title,
+ 'success' => true,
+ );
+ }
+ }
+ }
+ return $results;
+ }
+
+ /**
+ * Check the status of a Gallery2 Module
+ *
+ * @param $moduleId, $moduleName, $errorLevel, $allModulesStatus
+ * @return array moduleStatus
+ */
+ function moduleCheck($moduleId, $moduleName, $errorLevel, $allModulesStatus) {
+ $moduleStatus = array();
+ if (isset($allModulesStatus[$moduleId])) {
+ $moduleStatus['installed'] = true;
+ $moduleStatus['active'] = $allModulesStatus[$moduleId]['active'];
+ $moduleStatus['available'] = $allModulesStatus[$moduleId]['available'];
+ } else {
+ $moduleStatus['installed'] = false;
+ $moduleStatus['active'] = false;
+ $moduleStatus['available'] = false;
+ }
+ $moduleStatus['title'] = 'Gallery2 ' . $moduleName .' Module Status:';
+ if (!$moduleStatus['installed']) {
+ $moduleStatus[$errorLevel] = true;
+ $moduleStatus['notice'] = G2EmbedTestUtilities::_trans(
+ 'The %moduleName Module is not installed.',
+ array('%moduleName' => $moduleName));
+ } else {
+ if ($moduleStatus['active'] && $moduleStatus['available']) {
+ $moduleStatus['success'] = true;
+ } else {
+ $moduleStatus[$errorLevel] = true;
+ $moduleStatus['notice'] = G2EmbedTestUtilities::_trans(
+ 'The %moduleName Module is installed but not active or configured correctly.',
+ array('%moduleName' => $moduleName));
+ }
+ }
+ return $moduleStatus;
+ }
+
+ /**
+ * Calculate the number of errors and warnings
+ *
+ * @param $results
+ * @return array($numErrors, $numWarnings)
+ */
+ function _getNumErrorsAndWarnings($results) {
+ $numErrors = 0;
+ $numWarnings = 0;
+ foreach ($results as $key=>$result) {
+ if ($result['error']) {
+ $numErrors++;
+ }
+ if ($result['warning']) {
+ $numWarnings++;
+ }
+ }
+ return array($numErrors, $numWarnings);
+ }
+
+ /**
+ * Translate the message string
+ * This needs to be implemented by each embed application individually.
+ *
+ * Returns the translated string.
+ * @param $string A string containing the English string to translate.
+ * $args An associative array of replacements to make after translation.
+ * Incidences of any key in this array are replaced with the corresponding value.
+ * @return string Translated String
+ */
+ function _trans($string, $args = 0) {
+ return t($string, $args);
+ }
+
+ /**
+ * Autodetect the Embed URI
+ * This needs to be implemented by each embed application individually.
+ *
+ * @param none
+ * @return string autodetected URI
+ */
+ function _autodetectEmbedUri() {
+ $uri = url('gallery', null, null, false);
+ if (substr($uri, -8) == '/gallery') {
+ $uri = substr($uri, 0, strlen($string)-7) . 'index.php?q=gallery';
+ }
+ // strip the end /gallery if present and replace with index.php?q=gallery to avoid any
+ // url rewrite issues. See http://gallery.menalto.com/node/46181
+ // Note the use of index.php in all cases. Not needed for Apache, but is for IIS
+ // see drupaldocs documentation for url.
+ return $uri;
+ }
+}
+?> \ No newline at end of file
diff --git a/INSTALL.txt b/INSTALL.txt
index f6d0c05..56e9d42 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -1,53 +1,69 @@
-Installation Instructions
--------------------------
+$Id$
-1. Install Gallery 2 and Drupal (see their respective installation
- documents). Gallery2 should be *inside* your Drupal installation
- so that it's accessible by the same website. If you accidentally
- install Gallery somewhere else, you can create a symlink to it
- from inside your drupal site, eg:
- cd /var/www/drupal.site
- ln -s /path/to/gallery2
+HELP
+----
+For more help, check out:
+http://codex.gallery2.org/index.php/Gallery2:How_to_Embed_Gallery2_in_Drupal
- Or you can move Gallery2. If you're going to do that, read this
- FAQ:
- http://codex.gallery2.org/index.php/Gallery2:FAQ#How_can_I_move_my_gallery_installation_from_one_folder_to_another.3F
+Requirements
+------------
+Gallery2.1 (CVS)
+Image Block module installed and activated in Gallery2
+Image Frame module installed and activated in Gallery2
+Drupal 4.7 (CVS)
+gallery.module
-2. Copy gallery.module to your drupal modules/ directory.
+Installation Instructions
+-------------------------
-3. Enable the gallery module in administer -> modules in your drupal
- installation.
+1. Install Gallery 2.1 and Drupal 4.7 (see their respective installation
+ documents).
+
+ ***Warning*** - Do not name your G2 directory "gallery", call it something else
+ (eg "gallery2"). Calling it "gallery" will cause a conflict with the Drupal gallery.module
+ as Drupal assumes that http://www.example.com/gallery refers to the Drupal module.
-4. Go to administer -> settings -> gallery and enter the path to your
- gallery2 installation. So if your Drupal is installed at:
- /var/www/www.drupal.site
+2. Ensure that "Image Block" and "Image Frame" modules are installed and activated in Gallery2.
+ Check them in the non-embedded Gallery. See Gallery2:Download for instructions to download it
+ if it was not included in your installation.
- And your gallery2 is at:
- /var/www/drupal.site/gallery2
+3. Log out of G2 (non-embedded) - people have reported errors relating to sessions if this is not
+ done.
- Then your Gallery2 path would be:
- gallery2/
+4. Copy the entire gallery module directory to your drupal modules/ directory.
- Your gallery should now be available at:
+5. Enable the gallery module in administer -> modules in your drupal
+ installation.
- http://your.site/gallery
+6. Go to administer -> settings -> gallery and enter the URI of Gallery2.
+ Leave "autodetect" selected and click "submit". A series of tests will run to check if
+ everything is OK. There is a HELP link.
-5. Enable the "Gallery Block" in administer -> blocks
+7. Enable the "Gallery Block" in administer -> blocks, and optionally the "Gallery Navigation"
+ block.
-Note: the default themes don't work so well with Drupal yet. You'll get best
-results if you edit the default theme and move all the blocks out of the sidebar
-and into the album and photo pages. There's a drupal specific theme on the way,
-stay tuned.
+Optional Steps
+--------------
+ 1. Tolerant base_url. To ensure http://www.example.com and http://example.com both work and avoid
+ potential session problems, use the tolerant base_url patch in your
+ drupal settings.php file. See http://drupal.org/node/6554
+
+ 2. Themeing. If you want to, you can add your own drupal_g2.css file in your *drupal* theme dir
+ and it will automatically be loaded after the one in the gallery.module dir.
+
+ 3. Sidebar. Go to your G2 site admin and include the blocks you want in the sidebar (under
+ Themes). I use "Item Actions" and "Album Quick Links (DHTML)". To use the latter
+ you need to have installed the Album Select module.
-Note: To get the rewrite module working, you need to first configure and
-use it with the standalone Gallery2 install. Once it's working there disable
-all the rules except for the 'Show Item' rule and set its URL pattern to:
- gallery/%path%
+ 4. URL Rewrite.
-Then when you browse to http://your.site/gallery you should see short urls
-inside drupal.
+Troubleshooting
+---------------
+See http://codex.gallery2.org/index.php/Gallery2:How_to_Embed_Gallery2_in_Drupal
NOTE: this is beta software, so it might not always work. If you have
questions or problems contact:
+Kieran Parsons <kiz_0987@yahoo.com>
James Walker <walkah@walkah.net>
+
diff --git a/README.txt b/README.txt
index bbe4f59..973084e 100644
--- a/README.txt
+++ b/README.txt
@@ -1,19 +1,23 @@
+$Id$
+
Overview
---------
-This is an integration module for gallery2
+This is an integration module for Gallery2.1 with Drupal 4.7
(http://gallery.menalto.com/).
-NOTE: Gallery 2 is still alpha software (use at your own risk)
-
Requirements
------------
-* Gallery 2 CVS HEAD (from 2004-01-24 or later)
-* Drupal 4.5.x or later
+* Gallery 2.1 CVS HEAD (with ImageBlock and ImageFrame modules installed and activated)
+* Drupal 4.7 CVS HEAD (preferably after 4.7beta5 was released)
For installation instructions please see INSTALL.txt
+Known issues:
+ 1. Deselecting all "Image Data" checkboxes will result in an error for Drupal 4.7 beta 5 and
+ below. Update to CVS HEAD version of Drupal to remove error.
+
Author
-------
-
James Walker <walkah@walkah.net>
+Kieran Parsons <kiz_0987@yahoo.com>
diff --git a/contrib/g2_filter/INSTALL.txt b/contrib/g2_filter/INSTALL.txt
deleted file mode 100755
index 7c694f3..0000000
--- a/contrib/g2_filter/INSTALL.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-1) Unpack the g2_filter module into your /modules directory.
-2) Enable the module under admin/modules.
-3) Add the filter to at least one of your input types at /admin/filters
-3) Configure the filter. This is important because there are some path settings it needs to know.
diff --git a/contrib/g2_filter/README.txt b/contrib/g2_filter/README.txt
deleted file mode 100755
index 2203a15..0000000
--- a/contrib/g2_filter/README.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-This module creates a filter that lets you embed items from your embedded Gallery 2 install.
-
-Requirements:
-
-* Gallery 2 - http://gallery.menalto.com/
-* gallery.module - http://drupal.org/project/gallery
-
-Syntax:
-
- [G2:item_id class=name size=number frame=name]
-
-
-* item_id (required) *
-This is the item ID from G2. If you look at the URL of the item, this is the last number.
-
-* class *
-The block that G2 returns is wrapped in a DIV so additional styling can be done. The classes for this DIV are located in g2_filter.css. Included with the module are "left", "right", and "nowrap". These position the image block to the left or right or on a line all its own with the text not wrapping. You can also add your own class(es) to the CSS file and they will automatically be available.
-
-* size *
-The length of the longest side for the thumbnail. The other side is determined automatically to keep the same aspect ratio.
-
-* frame *
-G2 comes with several item/album frames and allows you to add more. You can use any of these frames for the embedded thumbnail just by specifying a name. Frames included with the default install are: Bamboo, Book, Branded Wood, Dot Apple, Dots, Flicking, Gold, Gold 2, Polaroid, Polaroids, Shadow, Shells, Slide, Solid, Spiral Notebook, Wood.
-
-
-
-
-Send comments to mcox@charter.net
diff --git a/contrib/g2_filter/TODO.txt b/contrib/g2_filter/TODO.txt
deleted file mode 100755
index 20c6726..0000000
--- a/contrib/g2_filter/TODO.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-Left to do as of 2005/Oct/21:
-
-* Add arguments for the rest of the "show" items
-* Add arguments for the rest of the "block" items
-* Improve the CSS for the div class.
-* Investigate the float clearing brought up by kiz
-
-Keizo's notes:
-/******issues that remain
-*should we keep n as an option in the config settings? see comments in get_settings_form()
-*should n be required to solve that issue?
-
-*how should the 'show' param be implemented. I've put it in the settings, which works good for defaults.
-*How should the syntax be? it could be caption=yes/no title=yes/no date=yes/no etc.
-*is that optimal? how about about show=title,caption,date ..this one seems easier interms of usability, yes?
-
-*are the syntax standard enough? it would be a pain to change them later
-*since it would break all instances of the filters use.
-*Should we make the default tag [image:id] instead of G2? like the image filter? or may [img:id]? or just lower case [g2:id] for easyness?
-
-*what should we use as the default for 'type', right now it's viewedImage. recentImage might be more useful?
-*do we need to bother making different types per block? I don't think so, people could just make a second block
-
-*still need to implement link target
-
-*does the 'frame=' work? its not working for me in this version, i didn't look too closely as to why
-
-***features wish list
-*I would like it so there was an 'see all photos' link when an album is displayed. selecting an item_id of an album with n=1 does this.
-*any possible to make the block display horizontally?
-*and ofcourse an auto javescript thing to auto insert the [G2] tags
-*/
diff --git a/contrib/g2_filter/changelog.txt b/contrib/g2_filter/changelog.txt
deleted file mode 100755
index 6ae8786..0000000
--- a/contrib/g2_filter/changelog.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Oct 21, 2005
-* Changed class names internally to add "giImageBlock." to make them unique. Classes are still refered to as "left, right, nowrap" in the filter call.
-* Moved CSS file links to the HEAD via theme_add_style()
-
-Oct 7, 2005
-* Add ability to specify "none" for class and not have block wrapped in div (not added to docs)
-* Removed redundant / from frame CSS link
diff --git a/contrib/g2_filter/g2_filter.css b/contrib/g2_filter/g2_filter.css
deleted file mode 100755
index 5a3d504..0000000
--- a/contrib/g2_filter/g2_filter.css
+++ /dev/null
@@ -1,14 +0,0 @@
-div.giImageBlock.left{
- float: left;
- margin: 1em;
-}
-
-div.giImageBlock.right{
- float: right;
- margin: 1em;
-}
-
-div.giImageBlock.nowrap {
- float: none;
- margin: 1em
-} \ No newline at end of file
diff --git a/contrib/g2_filter/g2_filter.module b/contrib/g2_filter/g2_filter.module
deleted file mode 100755
index c6de406..0000000
--- a/contrib/g2_filter/g2_filter.module
+++ /dev/null
@@ -1,440 +0,0 @@
-<?php
-// $Id$
-
-/**
- * @file
- * Allows adding gallery blocks into nodes using a filter --> [G2:item_id]
- *
- */
-
-/******************************* Help sections ************************************/
-
-function g2_filter_short_tip_translated() {
- return t('You may link to G2 items on this site <a href="%explanation-url">using a special syntax</a>',
- array('%explanation-url' => url('filter/tips', NULL, 'filter-g2_filter-0')));
-}
-
-function g2_filter_long_tip_translated() {
- $prefix = variable_get("g2_filter_prefix", "G2");
-
-$output = "";
-$output .= '<strong>G2 Filter:</strong><p>You can link to items in your ';
-$output .= 'embedded Gallery 2 using a special code. ';
-$output .= 'This code will be replaced by a thumbnail image that is ';
-$output .= 'linked to the actual item in your Gallery. ';
-$output .= '<em>Syntax:</em><br />';
-$output .= '<blockquote><code>';
-$output .= '['.$prefix.':<em>item_id</em> n=<em>number</em> type=<em>type</em> size=<em>number</em> class=<em>name</em> frame=<em>name</em> album_frame=<em>name</em> item_frame=<em>name</em>]';
-$output .= '</code></blockquote>';
-
-$output .= '<ul><li>item_id (required): This is the item ID from G2. ';
-$output .= 'If you look at the URL of the item, this is the last number. '
- .'<em>Note that if the item_id is a single photo, n must be 1</em></li> ';
-
-$output .= '<li>n (suggested): This is the number of photos you want the block to show. ';
-$output .= 'It will override whatever is set in the defaults (initially 1). '
- .' Note: this will change past instances where you did not set n -- the reason for its suggested use.</li> ';
-
-$output .= '<li>type: The default type of gallery block. Any of the following may be used: ';
-$output .= '<em>randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, '
- .'weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem . </em> '
- .'Note that for n=1, selectedItem is automatically chosen regardless of this parameter.</li> ';
-
-$output .= '<li>class: The block that G2 returns is wrapped in a DIV so additional styling can be done. ';
-$output .= 'The classes for this DIV are located in g2_filter.css. Included with the module ';
-$output .= 'are "left", "right", and "nowrap". These position the image block to the left or ';
-$output .= 'right or on a line all its own with the text not wrapping. You can also add your ';
-$output .= 'own class(es) to the CSS file and they will automatically be available.</li> ';
-
-$output .= '<li>size: The length of the longest side for the thumbnail. ';
-$output .= 'The other side is determined automatically to keep the same aspect ratio.</li> ';
-
-$output .= '<li>frame/album_frame/item_frame: You can use just "frame" to assign a frame ';
-$output .= 'to the thumbnail regardless of whether it\'s for an album or a single item. ';
-$output .= 'Using aframe will only affect albums and iframe will only affect single items. ';
-$output .= 'Frames included with the default Gallery 2 install are: ';
-$output .= 'bamboo, book, brand , dots, flicking, gold, gold2, polaroid, polaroids, shadow, ';
-$output .= 'shells, slide, solid, notebook, wood.</li>';
-
-return t($output);
-
-}
-
-function g2_filter_help($section = 'admin/help#image_filter') {
- $output = '';
- switch ($section) {
- case 'admin/help#g2_filter':
- $output = t('<p>Used to add image blocks from your embedded Gallery 2 to a node
- like a blog entry or a story. To enable this feature and learn the proper syntax,
- visit the <a href="%filters">filters configuration screen</a>.</p>',
- array('%filters' => url('admin/filters')));
-
- break;
- case 'admin/modules#description':
- $output = t("Allow users to reference G2 items from nodes.");
- break;
- case 'filter#short-tip':
- return g2_filter_short_tip_translated();
- case 'filter#long-tip':
- return g2_filter_long_tip_translated();
- }
-
- return $output;
-}
-
-
-/******************************* Configuration ************************************/
-
-function g2_filter_get_settings_form() {
- $typeMap = array('randomImage' => t('Random image'),
- 'recentImage' => t('Recent image'),
- 'viewedImage' => t('Viewed image'),
- 'randomAlbum' => t('Random album'),
- 'recentAlbum' => t('Recent album'),
- 'viewedAlbum' => t('Viewed album'),
- 'dailyImage' => t('Daily image'),
- 'weeklyImage' => t('Weekly image'),
- 'monthlyImage' => t('Monthly image'),
- 'dailyAlbum' => t('Daily album'),
- 'weeklyAlbum' => t('Weekly album'),
- 'monthlyAlbum' => t('Monthly album'));
-//we don't include specificItem, since it can be selected automatically if n=1
-
- $output .= form_textfield(t("Filter prefix"), "g2_filter_prefix",
- variable_get("g2_filter_prefix", "G2"), 10, 10,
- t("Prefix to use with filter. Example: 'G2' means you use [G2: 999]."));
-
- $output .= form_select(t('Image Block Type'), 'g2_filter_default_block_type',
- variable_get('g2_filter_default_block_type', 'viewedImage'), $typeMap,
- t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'));
-
- $output .= form_textfield(t("Default Number of Images"), "g2_filter_n_images",
- variable_get("g2_filter_n_images", 1), 3, 3,
- t("How many images you want the default block to show. Best to keep at 1 and use the n parameter."));
-//////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
-//then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
-
- $output .= form_checkboxes(
- t('Default Image Block Settings'),
- 'g2_filter_default_show',
- variable_get('g2_filter_default_show', 'none'),
- array('title' => 'Title (the caption)',
- 'date' => 'Date',
- 'views' => 'View Count',
- 'owner' => 'Item owner',
- 'heading' => 'Heading',
- 'fullSize' => 'Full Size'),
- t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'));
-
-
- $output .= form_textfield(t("Default thumbnail size"), "g2_filter_default_size",
- variable_get("g2_filter_default_size", "150"), 3, 3,
- t('If no size is specified when calling the filter, this size will be used. '
- .'Note that the display size will be limited by the size of the item_id in Gallery.'));
-
- $output .= form_textfield(t("Default class"), "g2_filter_default_div_class",
- variable_get("g2_filter_default_div_class", "nowrap"), 20, 20,
- t("left, right, or nowrap. (See g2_filter.css to add more or modify these.)"));
-
- $output .= form_textfield(t("Default album frame"), "g2_filter_default_album_frame",
- variable_get("g2_filter_default_album_frame", "none"), 20, 20,
- t("Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use 'none' or blank for no frame. "));
-
- $output .= form_textfield(t("Default item frame"), "g2_filter_default_item_frame",
- variable_get("g2_filter_default_item_frame", "none"), 20, 20,
- t("Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use 'none' or blank for no frame. "));
-
- return $output;
-}
-
-// Hook which handles filtering.
-function g2_filter_filter($op, $delta = 0, $format = -1, $text = '') {
- switch ($op) {
- case 'list':
- return array(0 => t('G2 filter'));
- case 'description':
- return t('Allow users to easily reference G2 items from nodes.');
- case 'process':
- return g2_filter_process($text);
- case 'settings':
- $group = g2_filter_get_settings_form();
- return form_group(t("Gallery 2 Filter"), $group);
- default:
- return $text;
- }
-}
-
-function g2_filter_filter_tips($delta = 0, $format = -1, $long = false) {
- if ($long) {
- return g2_filter_long_tip_translated();
- }
- else {
- return g2_filter_short_tip_translated();
- }
-}
-
-// ***************** The Filter in Action ***********************
-
-define("G2_FILTER_WORD", 1);
-define("G2_FILTER_INTEGER", 2);
-define("G2_FILTER_STRING", 3);
-
-function g2_filter_attr_value($text, $value_type = G2_FILTER_WORD) {
- // Strip off initial and final quotes.
- $first = substr($text, 0, 1);
- if ($first == "\"" || $first == "\'") {
- if (substr($text, -1, 1) == $first) {
- $text = substr($text, 1, -1);
- }
- }
- switch ($value_type) {
- case G2_FILTER_WORD:
- return preg_replace("/\W/", '', $text);
- case G2_FILTER_INTEGER:
- return preg_replace("/\D/", '', $text);
- default:
- return check_plain($text);
- }
-}
-
-// Execute filter on given text.
-function g2_filter_process($text) {
-
- // Find all the image codes and loop over them, replacing each with the G2 image block
- $prefix = variable_get("g2_filter_prefix", "G2");
-
- $matchetxt = "/\[".trim($prefix).":(\d+)(\s*,)?\s*(.*?)\]/i";
- preg_match_all($matchetxt, $text, $matches, PREG_SET_ORDER);
-
- // If we have at least one match, set everything up
- if (count($matches) > 0) {
- // Set the default and path variables based on module settings
- $default_size = variable_get("g2_filter_default_size", 150);
- $default_div_class = variable_get("g2_filter_default_div_class", "nowrap");
- $default_album_frame = variable_get("g2_filter_default_album_frame", "");
- $default_item_frame = variable_get("g2_filter_default_item_frame", "");
- $default_block_type = variable_get('g2_filter_default_block_type', 'recentImage');
- $default_n_images = variable_get("g2_filter_n_images", 1);
- $default_show = variable_get('g2_filter_default_show', 'none');
-
- if ($default_album_frame == 'none') {
- $default_album_frame = '';
- }
- if ($default_item_frame == 'none') {
- $default_item_frame = '';
- }
-
- // This will hold the list of frames used for images so we can add the CSS link(s) at the end
- $frame_list = array() ;
-
-/* this is all done by _gallery_init(true) function
- // Set up the pathing
- $relative_G2_Path = variable_get("gallery_dir", "gallery2");
- $embed_uri = url('gallery');
- $embed_php_path = $relative_G2_Path . 'embed.php';
- //the above line needs work, when the user sets the relative G2 path without a trailing / this module breaks
-
- // The tolerant base_url patch in http://drupal.org/node/32389 seems to work well, but not all of it is needed.
- // The http or https part is not required.
- // BUT, does this work for all cases (Apache, IIS?)
- if ($dir = trim(dirname($_SERVER['SCRIPT_NAME']), '\,/')) {
- $embedPath = "/$dir";
- } else {
- $embedPath = '/';
- }
-
- // Link to the embedding code
- require_once($embed_php_path);
-
- // Grab the user information from Drupal
- global $user;
-*/
- // This sets up the embedding
- list ($success, $ret) = _gallery_init(true);
- //_gallery_init() is from gallery.module, any reason not to use it?
- //just remember if they change that function this module breaks
- if (!$success) {
- gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- return;
- } /* since i commented this out, and use galler_init, i can probably get rid of some of the init code above
- $ret = GalleryEmbed::init(array('embedUri' => $embed_uri,
- 'embedPath' => $embed_path,
- 'relativeG2Path' => $relative_G2_Path,
- 'loginRedirect' => '',
- 'fullInit' => true,
- 'activeUserId' => $user->uid)); */
- }
-
- foreach ($matches as $match) {
-
- // Pull out the arguments into the $args array
- $args = array();
- preg_match_all("/(\w+)\=(\"[^\"]*\"|\S*)/", $match[3], $a, PREG_SET_ORDER);
-
- foreach ($a as $arg) {
- $args[strtolower($arg[1])] = $arg[2];
- }
-
- // Set number of images to show
- $n_images = g2_filter_attr_value($args['n'], G2_FILTER_INTEGER);
- if ($n_images == 0) {
- // No size specified; use the default
- $n_images = $default_n_images;
- }
-
- // Set the block type
- $block_type = g2_filter_attr_value($args['type'], G2_FILTER_WORD);
- if (empty($block_type)) {
- // No size specified; use the default
- $block_type = $default_block_type;
- }
- if ($n_images <= 1) $block_type = 'specificItem'; //so it shows something if n=1 and an album is selected
-
- // Set the size of the thumbnail
- $size = g2_filter_attr_value($args['size'], G2_FILTER_INTEGER);
- if ($size == 0) {
- // No size specified; use the default
- $size = $default_size;
- }
-
- // Set the class of the div
- $div_class = g2_filter_attr_value($args['class'], G2_FILTER_WORD);
- if (empty($div_class)) {
- // No class specified; use the default
- $div_class = $default_div_class;
- }
-
- // Set the overriding, album, and item frames
- $frame = g2_filter_attr_value($args['frame'], G2_FILTER_WORD);
- $album_frame = g2_filter_attr_value($args['aframe'], G2_FILTER_WORD);
- $item_frame = g2_filter_attr_value($args['iframe'], G2_FILTER_WORD);
-
- if (empty($frame)) {
- // No overriding frame given; check for album_frame and item_frame
- if (empty($album_frame)) {
- // No album frame specified; use the default one
- $album_frame = $default_album_frame;
- }
-
- if (empty($item_frame)) {
- // No item frame specified; use the default one
- $item_frame = $default_item_frame;
- }
-
- } else {
- // Overriding frame given; use it
- $album_frame = $frame;
- $item_frame = $frame;
- }
-
- // Add the requested frames to the array so we can get the CSS later. Don't worry about
- // dupes at this point; they will be filtered out later.
- array_push($frame_list,$frame);
- array_push($frame_list,$album_frame);
- array_push($frame_list,$item_frame);
-
- // This part actually fetches the image block. It uses the same paramaters as the code
- // found under "Image Block" in site admin in G2. Copied and slightly modified here for reference.
-
- // blocks Pipe(|) separate list chosen from: randomImage, recentImage,
- // viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage,
- // weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum,
- // specificItem; default is randomImage
- // show Pipe(|) separated list chosen from: title, date, views, owner, heading,
- // fullSize; the value can also be: none
- // NOTE: If you want your size to be bigger than the thumbnail size for that image as
- // defined in your G2, you must use 'show' => 'fullSize'
- // itemId Limit the item selection to the subtree of the gallery under the
- // album with the given id; or the id of the item to display when used with
- // specificItem block type
- // maxSize Scale images to this maximum size
- // linkTarget Add a link target (for example, to open links in a new browser window)
- // itemFrame Image frame to use around images
- // albumFrame Image frame to use around albums
-
-
-//$blocks = 'specificItem'; //not used
-$show = $default_show;
-
-// Not customized yet:
-$link_target = '';
-
-
-///////keizo
- // Allow for multiple image types
- $param_blocks_array = array_fill(0,$n_images,$block_type);
- $params['itemId'] = $match[1];
- $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : "";
- $param_show_array = $show;
- $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : "";
- $params['maxSize'] = $size;
- // Add frames and link target using g2_filter code from MichelleC
- $params['albumFrame'] = $album_frame;
- $params['itemFrame'] = $item_frame;
- $params['linkTarget'] = $link_target;
-
- $block = array();
- list($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock($params);
- if ($ret->isError()) {
- gallery_error(t('Unable to get Gallery image block'), $ret);
- return;
- } else {
- //if ($imageBlockHtml) { this line is redundant isn't it?
- // Add a div around the table for styling
- if ($div_class != 'none') {
- $imageBlockHtml = '<div class ="giImageBlock ' . $div_class . '">' .
- $imageBlockHtml . '</div>';
- }
- // This puts the image block HTML back into the rest of the text
- $text = str_replace($match[0], $imageBlockHtml, $text);
- //}
- }
- //end keizo
-/* list ($ret, $imageBlockHtml) =
- GalleryEmbed::getImageBlock(array(
- 'blocks' => $blocks,
- 'show' => $show ,
- 'itemId' => $match[1],
- 'maxSize' => $size,
- 'linkTarget' => $link_target,
- 'albumFrame' => $album_frame,
- 'itemFrame' => $item_frame));
-
- // Add a div around the table for styling
- $imageBlockHtml = '<div class ="' . $div_class . '">' . $imageBlockHtml . '</div>';
-
- // This puts the image block HTML back into the rest of the text
- $text = str_replace($match[0], $imageBlockHtml, $text);
-*/
-
-
- } // end of for loop through matches
-
- // If we had at least one match, finish up
- if (count($matches) > 0) {
-
- GalleryEmbed::done();
-
- // Add the CSS link(s)
- $css_links = '';
-
- // In order to use the album/image frames, we need to link to the style sheet(s)
- $frame_list = array_unique($frame_list);
- foreach ($frame_list as $frame) {
- $css_links .= '<link rel="stylesheet" href="' . $relative_G2_Path .
- '/main.php?g2_controller=imageblock.ExternalCSS&amp;g2_frames=' .$frame.'"/> ' ;
- }
-
- // Link to the CSS that controls the styling of the wrapping div
- $div_css = drupal_get_path('module', 'g2_filter') . "/g2_filter.css";
- $css_links .= '<link rel="stylesheet" href="' . $div_css . '"/> ' ;
-
- $text = $css_links .= $text ;
-
- }
-
- return $text;
-}
-
-
-?>
diff --git a/drupal_g2.css b/drupal_g2.css
new file mode 100755
index 0000000..b9ba2be
--- /dev/null
+++ b/drupal_g2.css
@@ -0,0 +1,103 @@
+/* $Id$ */
+
+/**
+ * Drupal embeded Gallery2 css overrides.
+ * These do not make a perfect theme, but are not bad as a first step.
+ */
+ /* Increase font size */
+ #gallery {
+ font-size: 100%;
+ }
+
+ /* Remove the header */
+#gsHeader {
+ display: none;
+}
+
+/* Removes the Gallery Title (as Drupal displays it)*/
+#gallery .gbBlock h2 {
+ display: none;
+}
+
+/* Do not display the breadcrumb */
+#gsNavBar div.gbBreadCrumb {
+ display: none;
+}
+
+/* The system links ("Site Admin", "Your Album") should no longer float as the
+ breadcrumb has been removed. Just align right */
+#gsNavBar div.gbSystemLinks {
+ text-align: right;
+ float: none;
+}
+
+/* .block-gallery is in the sidebar */
+.block-gallery #gsSidebar {
+ border: none;
+ width: auto;
+ overflow: hidden;
+}
+
+.block-gallery div.block-core-ItemLinks {
+ margin: 0;
+ border-bottom: 1px solid #aaa;
+}
+
+.block-gallery .gbBlock {
+ padding: 0 5px 3px 5px;
+}
+
+/* Navigation Tree */
+.block-gallery .dtree {
+ font-size: 1em;
+}
+
+/* For g2ic_plugin */
+img.g2image_float_left, div.g2image_float_left
+{
+ float: left;
+ margin: 4px;
+}
+
+img.g2image_float_right, div.g2image_float_right {
+ float: right;
+ margin: 4px;
+}
+
+img.g2image_centered, div.g2image_centered {
+ display: block;
+ margin-left: auto;
+ margin-right: auto;
+ text-align: center;
+}
+
+.g2image_clear_images {
+ clear: both;
+ }
+
+.post-content img
+{
+float: left;
+clear: both;
+margin: 4px;
+}
+
+.page-content img
+{
+float: left;
+clear: both;
+margin: 4px;
+}
+
+/* Embed success, warning, error messages */
+.g2_embed_success {
+ color: green;
+}
+
+.g2_embed_warning {
+ color: #f63;
+}
+.g2_embed_error {
+ color: red;
+ font-weight: bold;
+}
diff --git a/g2image.js b/g2image.js
new file mode 100644
index 0000000..8fdaf65
--- /dev/null
+++ b/g2image.js
@@ -0,0 +1,19 @@
+// $Id$
+
+function g2ic_open(field) {
+ // Find the form id by going back through the hierarchy. Kludge until can get the form id
+ // directly from drupal.
+ var element = document.getElementById(field).parentNode;
+ while (element.tagName != 'FORM') {
+ element = element.parentNode;
+ }
+ var form = element.id;
+ var url = G2IMAGE_URI + 'g2image.php?g2ic_form='+form+'&g2ic_field='+field+'&g2ic_tinymce=0';
+ var name = 'g2image';
+ var w = 600;
+ var h = 600;
+ var valLeft = (screen.width) ? (screen.width-w)/2 : 0;
+ var valTop = (screen.height) ? (screen.height-h)/2 : 0;
+ var features = 'width='+w+',height='+h+',left='+valLeft+',top='+valTop+',resizable=1,scrollbars=1';
+ window.open(url, name, features);
+}
diff --git a/gallery.module b/gallery.module
index 1f67b45..cc098a9 100644
--- a/gallery.module
+++ b/gallery.module
@@ -1,64 +1,60 @@
<?php
// $Id$
+// For Drupal 4.7 with Gallery 2.1
-/**
- * Implementation of hook_help
- */
-function gallery_help($section) {
- switch($section) {
- case 'admin/modules#description':
- return t('Integration with Gallery2 (%gallery_url)', array('%gallery_url' => 'http://gallery.menalto.com/'));
- }
-}
+$path = drupal_get_path('module', 'gallery');
+require_once($path . '/gallery_base.inc');
/**
* Implementation of hook_menu
*/
function gallery_menu($may_cache) {
+ global $user;
$items = array();
-
+ $view_access = (user_access('access user profiles') || ($user->uid == arg(1)));
if ($may_cache) {
$items[] = array('path' => 'gallery',
'title' => t('gallery'),
'callback' => 'gallery_page',
'access' => user_access('access content'),
'type' => MENU_NORMAL_ITEM);
+ $items[] = array(
+ 'path' => 'admin/user/gallery', 'title' => t('gallery'),
+ 'callback' => 'gallery_users',
+ 'access' => user_access('administer users'),
+ 'type' => MENU_LOCAL_TASK);
+ } else {
+ // Add head info here so that it is included once only per page (almost)
+ gallery_set_html_head(gallery_css_include());
}
-
return $items;
+}
+
+/**
+ * Implementation of hook_help
+ */
+function gallery_help($section) {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_help.inc');
+ return _gallery_help($section);
}
/**
* Implementation of hook_settings
*/
function gallery_settings() {
- $form['gallery_dir'] = array(
- '#type' => 'textfield',
- '#title' => t('Location of Gallery2'),
- '#default_value' => variable_get('gallery_dir', 'gallery2/'),
- '#description' => t('Path to your gallery2 directory, relative to the root directory of your drupal installation. Please include a trailing slash ("/").'),
- );
- $form['gallery_drupal_dir'] = array(
- '#type' => 'textfield',
- '#title' => t('Location of Drupal'),
- '#default_value' => variable_get('gallery_drupal_dir', '/'),
- '#description' => t('Path to your drupal directory, relative to the root of your website. Please include a trailing slash ("/").'),
- );
- $form['gallery_error_mode'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Error logging'),
- '#default_value' => variable_get('gallery_error_mode', array(1)),
- '#options' => array(1 => t('Watchdog'), 2 => t('Output to the browser')),
- '#description' => t('Choose where errors are displayed'),
- );
-
- return $form;
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_settings.inc');
+ return _gallery_settings();
}
/**
* Implementation of hook_user
*/
function gallery_user($op, &$edit, &$user, $category = NULL) {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_user.inc');
+
switch ($op) {
case 'login':
/* _gallery_init() will try to create the user, if necessary */
@@ -68,80 +64,113 @@ function gallery_user($op, &$edit, &$user, $category = NULL) {
return;
}
break;
-
- case 'insert':
- list ($success, $ret) = _gallery_init();
- if (!$success) {
- gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- return;
+ case 'logout':
+ if (variable_get('gallery_valid', 0)) {
+ $embedPath = variable_get('gallery_dir', './gallery2/') . 'embed.php';
+ require_once($embedPath);
+ $ret = GalleryEmbed::logout();
+ break;
}
+ case 'view':
+ return gallery_view_user($user);
+ case 'insert':
+ return gallery_insert_user($edit, $user);
+ case 'update':
+ return gallery_update_user($edit, $user);
+ case 'delete':
+ return gallery_delete_user($user);
+ }
+}
- $ret = GalleryEmbed::createUser($user->uid,
- array('username' => $user->name,
- 'email' => $user->mail,
- 'fullname' => $user->name,
- 'language' => $user->language,
- 'hashedpassword' => $user->pass,
- 'hashmethod' => 'md5'
- ));
- if ($ret->isError()) {
- gallery_error(t('Error creating Gallery user'), $ret);
- return;
- }
- GalleryEmbed::done();
- break;
+/**
+ * Gallery Users Page - view a set of users
+ */
+function gallery_users() {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_user.inc');
+ return _gallery_users();
+}
- case 'update':
- list ($success, $ret) = _gallery_init();
- if (!$success) {
- gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- return;
- }
+/**
+ * implementation of hook_search
+ */
+function gallery_search($op = 'search', $keys = null) {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_search.inc');
+ return _gallery_search($op, $keys);
+}
- // on update we can't be sure how much info $edit will contain.
- $name = ($edit['name']) ? $edit['name'] : $user->name;
- $language = ($edit['language']) ? $edit['language'] : $user->language;
- $pass = ($edit['pass']) ? md5($edit['pass']) : $user->pass;
- $email = ($edit['email']) ? $edit['mail'] : $user->mail;
- $ret = GalleryEmbed::updateUser($user->uid,
- array('username' => $name,
- 'fullname' => $name,
- 'email' => $mail,
- 'language' => $language,
- 'hashedpassword' => $pass,
- 'hashmethod' => 'md5'));
- if ($ret->isError()) {
- // try to create user then.
- $ret = GalleryEmbed::createUser($user->uid,
- array('username' => $name,
- 'fullname' => $name,
- 'email' => $mail,
- 'language' => $language,
- 'hashedpassword' => $pass,
- 'hashmethod' => 'md5'
- ));
- if ($ret->isError()) {
- gallery_error(t('Error updating Gallery user'), $ret);
- return;
- }
- }
- GalleryEmbed::done();
- break;
+/**
+ * Implementation of hook_search_item to override how to display the item
+ */
+function gallery_search_page($results) {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_search.inc');
+ return _gallery_search_page($results);
+}
- case 'delete':
- list ($success, $ret) = _gallery_init();
- if (!$success) {
- gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- return;
- }
+/**
+ * Implementation of hook_filter
+ */
+function gallery_filter($op, $delta = 0, $format = -1, $text = '') {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_filter.inc');
+ switch ($op) {
+ case 'list' :
+ return array (0 => t('Gallery2 filter'));
+ case 'description' :
+ return t('Allow users to easily reference Gallery2 items from nodes.');
+ case 'process' :
+ return gallery_filter_process($text);
+ case 'no cache':
+ return !variable_get('gallery_filter_can_cache', 1);
+ default :
+ return $text;
+ }
+}
+
+/**
+ * Implementation of hook_filter_tips
+ */
+function gallery_filter_tips($delta = 0, $format = -1, $long = false) {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_help.inc');
+ if ($long) {
+ return gallery_filter_long_tip_translated();
+ } else {
+ return gallery_filter_short_tip_translated();
+ }
+}
- $ret = GalleryEmbed::deleteUser($user->uid);
- if ($ret->isError()) {
- gallery_error(t('Error deleting Gallery user'), $ret);
- }
- GalleryEmbed::done();
- break;
+/**
+ * Implementation of hook_perm().
+ */
+function gallery_perm() {
+ return array('access standalone g2image');
+}
+
+/**
+ * Implementation of hook_elements() - from img_assist
+ */
+function gallery_elements() {
+ $type['textarea'] = array('#process' => array('gallery_g2image_textarea' => array()));
+ return $type;
+}
+
+/*
+ * Add image link underneath textareas
+ */
+function gallery_g2image_textarea($element) {
+ $path = drupal_get_path('module', 'gallery');
+ require_once($path . '/gallery_g2image.inc');
+ if (_gallery_g2image_page_match() && !strstr($_GET['q'], 'gallery') &&
+ (variable_get('gallery_g2image_mode', 'disabled') == 'standalone') &&
+ (user_access('access standalone g2image'))) {
+ gallery_g2image_add_js();
+ $output = theme('gallery_g2image_textarea_link', $element, $link);
+ $element['#suffix'] .= $output;
}
+ return $element;
}
/**
@@ -151,134 +180,90 @@ function gallery_user($op, &$edit, &$user, $category = NULL) {
* - gallery imageblock (random, most viewed, etc)
*/
function gallery_block($op = 'list', $delta = 0, $edit = array()) {
- $typeMap = array('randomImage' => t('Random Image'),
- 'recentImage' => t('Newest Image'),
- 'viewedImage' => t('Most Viewed Image'),
- 'randomAlbum' => t('Random Album'),
- 'recentAlbum' => t('Newest Album'),
- 'viewedAlbum' => t('Most Viewed Album'),
- 'dailyImage' => t('Picture of the Day'),
- 'weeklyImage' => t('Picture of the Week'),
- 'monthlyImage' => t('Picture of the Month'),
- 'dailyAlbum' => t('Album of the Day'),
- 'weeklyAlbum' => t('Album of the Week'),
- 'monthlyAlbum' => t('Album of the Month'));
+// Modified typeMap to use current Gallery2 naming
+ $typeMap = array('none' => t('None'),
+ 'randomImage' => t('Random Image'),
+ 'recentImage' => t('Newest Image'),
+ 'viewedImage' => t('Most Viewed Image'),
+ 'randomAlbum' => t('Random Album'),
+ 'recentAlbum' => t('Newest Album'),
+ 'viewedAlbum' => t('Most Viewed Album'),
+ 'dailyImage' => t('Picture of the Day'),
+ 'weeklyImage' => t('Picture of the Week'),
+ 'monthlyImage' => t('Picture of the Month'),
+ 'dailyAlbum' => t('Album of the Day'),
+ 'weeklyAlbum' => t('Album of the Week'),
+ 'monthlyAlbum' => t('Album of the Month'));
switch ($op) {
- case 'list':
- $blocks[0]['info'] = t('Gallery Block');
- return $blocks;
-
- case 'configure':
- $form['gallery_block_block_'. $delta] = array(
- '#type' => 'checkboxes',
- '#title' => t('Image type'),
- '#default_value' => variable_get('gallery_block_block_' . $delta, array('randomImage')),
- '#options' => $typeMap,
- '#description' => t("Pick the type of image you'd like to see"),
- );
- $form['gallery_block_show_'. $delta] = array(
- '#type' => 'checkboxes',
- '#title' => t('Image data'),
- '#default_value' => variable_get('gallery_block_show_' . $delta, array('title', 'heading')),
- '#options' => array('title' => 'Title', 'date' => 'Date', 'views' => 'View Count', 'owner' => 'Item owner', 'heading' => 'Heading', 'fullSize' => 'Full Size'),
- '#description' => t("Choose the item metadata you'd like to display")
- );
- return $form;
- case 'save':
- // if no image types selected, assume randomImage
- if (count($edit['gallery_block_block_' . $delta])) {
- variable_set('gallery_block_block_' . $delta, array_keys($edit['gallery_block_block_' . $delta], 1));
- }
- else {
- variable_set('gallery_block_block_' . $delta, array('randomImage'));
- }
- variable_set('gallery_block_show_' . $delta, array_keys($edit['gallery_block_show_' . $delta], 1));
- break;
-
- case 'view':
- list ($success, $ret) = _gallery_init(true);
- if (!$success) {
- gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- return;
- }
-
- $params['blocks'] = implode('|', variable_get('gallery_block_block_' . $delta, array('randomImage')));
- $params['show'] = implode('|', variable_get('gallery_block_show_' . $delta, array()));
-
- // TODO: parameterize this
- $params['maxSize'] = 160;
+ case 'list':
+ $blocks[0]['info'] = t('Gallery Block');
+ $blocks[1]['info'] = t('Gallery Navigation');
+ return $blocks;
- $block = array();
- list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
- if ($ret->isError()) {
- gallery_error(t('Unable to get Gallery image block'), $ret);
- return;
- } else {
- if ($content) {
- if (count(variable_get('gallery_block_block_' . $delta, 'randomImage')) > 1) {
- $block['subject'] = t('Gallery');
- }
- else {
- $block['subject'] = $typeMap[$params['blocks']];
+ case 'view':
+ list ($success, $ret) = _gallery_init(true);
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+ switch ($delta) {
+ // 0 = Image Block
+ case 0:
+ // Allow for multiple image types
+ $param_blocks_array = variable_get('gallery_block_block', array('randomImage'));
+ $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : "";
+ $param_show_array = variable_get('gallery_block_show', array());
+ $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : "";
+ $params['maxSize'] = variable_get('gallery_maxsize', 160);
+ // Add frames and link target using g2_filter code from MichelleC
+ $params['albumFrame'] = variable_get('gallery_album_frame', 'none');;
+ $params['itemFrame'] = variable_get('gallery_item_frame', 'none');;
+ $params['linkTarget'] = variable_get('gallery_link_target', '');;
+
+ $block = array();
+ list($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
+ if ($ret) {
+ gallery_error(t('Unable to get Gallery image block'), $ret);
+ return;
+ } else {
+ if ($content) {
+ // If more than one image type selected then default the subject to 'Gallery'
+ // Also fixes typo in v1.9 -- block => blocks
+ if (count(variable_get('gallery_block_block', 'randomImage')) > 1) {
+ $block['subject'] = t('Gallery');
+ } else {
+ $block['subject'] = $typeMap[$params['blocks']];
+ }
+ // TODO: This should not be hardcoded, but included in the CSS.
+ $block['content'] = '<center>' . $content . '</center>';
}
- $block['content'] = '<center>'. $content . '</center>';
}
if ($head) {
- drupal_set_html_head($head);
+ gallery_set_html_head($head);
}
- }
-
- $ret = GalleryEmbed::done();
- if ($ret->isError()) {
- gallery_error(t('Unable to complete Gallery request'), $ret);
- return;
- }
- return $block;
- }
-}
-
-/**
- * implementation of hook_search
- */
-function gallery_search($op = 'search', $keys = null) {
- switch ($op) {
- case 'name':
- return t('gallery');
- case 'search':
- $find = array();
-
- list ($success, $ret) = _gallery_init(true);
- if (!$success) {
- gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- return;
- }
-
- list ($ret, $results) = GalleryEmbed::searchScan($keys, 20);
- if (!$ret->isError()) {
- $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
- foreach ($results as $name => $module) {
- if (count($module['results']) > 0) {
- foreach ($module['results'] as $result) {
- $excerpt = array();
- $words = search_index_split($keys);
- foreach ($result['fields'] as $field) {
- foreach ($words as $word) {
- if (preg_match("/$word/i", $field['value'])) {
- $excerpt[] = $field['key'] .': '.search_excerpt($words, $field['value']);
- }
- }
- }
- $link = str_replace('&amp;', '&', $urlGenerator->generateUrl(array('itemId' => $result['itemId'])));
- $find[] = array('title' => $result['fields'][0]['value'],
- 'link' => $link,
- 'type' => $module['name'],
- 'snippet' => implode('<br />', $excerpt));
- }
+ break;
+ // 1 = Navigation Block
+ case 1:
+ if (arg(0) == 'gallery') {
+ GalleryCapabilities::set('showSidebarBlocks', false);
+ $result = GalleryEmbed::handleRequest();
+ if (isset($result['sidebarBlocksHtml']) && !empty($result['sidebarBlocksHtml'])) {
+ $block['subject'] = t('Gallery Navigation');
+ $block['content'] = '<div id="gsSidebar" class="gcBorder1">' . join('', $result['sidebarBlocksHtml']) . '</div>';
}
}
+ break;
}
- return $find;
+ $ret = GalleryEmbed::done();
+ if ($ret) {
+ gallery_error(t('Unable to complete Gallery request'), $ret);
+ return;
+ }
+ return $block;
}
}
@@ -289,128 +274,45 @@ function gallery_page() {
list ($success, $ret) = _gallery_init(true);
if (!$success) {
gallery_error(t('Unable to initialize embedded Gallery'), $ret);
- print theme('page', 'You need to <a href="/admin/settings/gallery">configure your embedded Gallery</a>');
- return;
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ return $err_msg;
}
-
- /* Pass any excess path info to G2 */
- $path = substr($_GET['q'], 7 /* length of 'gallery/' */);
- if (!empty($path)) {
+ /* Pass any excess path info to G2 - NEEDED??? */
+// $path = substr($_GET['q'], 7 /* length of 'gallery/' */);
+ /* if (!empty($path)) {
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path'] = $path;
- }
-
+ }*/
+ // Turn off sidebar and pathbar
+ GalleryCapabilities::set('showSidebarBlocks', false);
$result = GalleryEmbed::handleRequest();
if (!$result['isDone']) {
list($title, $css, $javascript) = GalleryEmbed::parseHead($result['headHtml']);
if (!empty($javascript)) {
- drupal_set_html_head(implode("\n",$javascript));
+ gallery_set_html_head(implode("\n", $javascript));
}
- drupal_set_html_head(implode("\n",$css));
+ gallery_set_html_head(implode("\n", $css));
+ // Add Gallery head. FIX - this will be included twice on a gallery page. Has to be
+ // included here as it is after the G2 .css files and so can override them.
+ gallery_set_html_head(gallery_css_include(), false);
drupal_set_title($title);
- print theme('page', $result['bodyHtml']);
- }
-}
-
-/**
- * fetch a galleryEmbed object
- */
-function _gallery_init($full = false) {
- global $user;
-
- $galleryDir = variable_get('gallery_dir', 'gallery2/');
-
- $embedPath = $galleryDir . '/embed.php';
- if (!is_readable($embedPath)) {
- return array(false, null);
- }
-
- include_once($galleryDir . '/embed.php');
-
- // TODO: using the galleryDir as the relativeG2Path requires that
- // Gallery2 be installed as a subdir of Drupal, which is not necessarily
- // ideal. Make this a configuration option.
- $relativeG2Path = $galleryDir;
-
- $embedUri = url('gallery');
- $embedPath =variable_get('gallery_drupal_dir', '/');
- $params = array('embedUri' => $embedUri,
- 'embedPath' => $embedPath,
- 'relativeG2Path' => $relativeG2Path,
- 'loginRedirect' => url('user/login'),
- 'activeUserId' => $user->uid,
- 'activeLanguage' => $user->language,
- 'fullInit' => $full);
- $ret = GalleryEmbed::init($params);
- if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) {
- // Our user mapping is missing. Make a mapping, or create a new user.
- $g2_user = null;
-
- // Get the G2 user that matches the Drupal username
- list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($user->name);
- if ($ret->isError() && !($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {
- return array(false, $ret);
- }
-
- if (!isset($g2_user)) {
- // No G2 user with a matching username. If this is the admin user, we're going to
- // try a little harder and match it to the oldest admin in G2.
- if ($user->uid == 1) {
- list ($ret, $admin_group_id) =
- GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
- if ($ret->isError()) {
- return array(false, $ret);
- }
-
- list ($ret, $g2_users) = GalleryCoreApi::fetchUsersForGroup($admin_group_id);
- if ($ret->isError()) {
- return array(false, $ret);
- }
-
- $keys = array_keys($g2_users);
- $g2_user_name = $g2_users[$keys[0]];
- list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($g2_user_name);
- if ($ret->isError()) {
- return array(false, $ret);
- }
- }
- }
-
- if (isset($g2_user)) {
- $ret = GalleryEmbed::addExternalIdMapEntry($user->uid, $g2_user->getId(), 'GalleryUser');
- if ($ret->isError()) {
- return array(false, $ret);
- }
- } else {
- // No matching G2 user found -- create one.
- $ret = GalleryEmbed::createUser($user->uid, array('username' => $user->name,
- 'email' => $user->mail,
- 'fullname' => $user->name,
- 'language' => $user->language,
- 'hashedpassword' => $user->pass,
- 'hashmethod' => 'md5'));
- if ($ret->isError()) {
- return array(false, $ret);
+ // Add pathbar. See http://gallery.menalto.com/node/33447
+ if (isset($result['themeData'])) {
+ $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
+ $breadcrumb = array(l(t('Home'), ''));
+ foreach ($result['themeData']['parents'] as $parent) {
+ $parent_title = $parent['title'];
+ // Simple strip of bbcode (italics)
+ $parent_title = str_replace("[i]", "<i>", $parent_title);
+ $parent_title = str_replace("[/i]", "</i>", $parent_title);
+ $breadcrumb[] = '<a href="'.$urlGenerator->generateUrl(
+ array('itemId' => $parent['id'])) .'">'.$parent_title."</a>";
+ }
+ drupal_set_breadcrumb($breadcrumb);
}
- }
+ return $result['bodyHtml'];
}
-
- return array(true, GalleryStatus::success());
}
-function gallery_error($message, $ret) {
- $error_mode = variable_get('gallery_error_mode', array());
- if (in_array(2, $error_mode)) {
- drupal_set_message($message);
- }
-
- if (isset($ret)) {
- $full_message = $message . '<br/>' . $ret->getAsHtml();
- } else {
- $full_message = $message;
- }
-
- if (in_array(1, $error_mode)) {
- watchdog('gallery', $full_message, WATCHDOG_ERROR);
- }
-}
?>
diff --git a/gallery_base.inc b/gallery_base.inc
new file mode 100644
index 0000000..599dd73
--- /dev/null
+++ b/gallery_base.inc
@@ -0,0 +1,178 @@
+<?php
+// $Id$
+
+/**
+ * gallery.module : gallery_base.inc
+ * Base functions
+ */
+
+/* --------------------------------------------------------------------------
+ * Gallery init and misc functions
+ * --------------------------------------------------------------------------
+ */
+
+/**
+ * fetch a galleryEmbed object
+ */
+function _gallery_init($full = false, $vars = null) {
+ global $user;
+
+ if (!$vars) {
+ $embedPath = variable_get('gallery_dir', './gallery2/') . 'embed.php';
+ $g2Uri = variable_get('gallery_uri', '/gallery2/');
+ $embedUri = variable_get('gallery_embed_uri', '?q=gallery');
+ $gallery_valid = variable_get('gallery_valid', 0);
+ } else {
+ $embedPath = $vars['gallery_dir'] . 'embed.php';
+ $g2Uri = $vars['gallery_uri'];
+ $embedUri = $vars['gallery_embed_uri'];
+ $gallery_valid = $vars['gallery_valid'];
+ }
+
+ if (!$gallery_valid) {
+ // It's probably now bad practice to return a null here, given that $ret=null is a gallery2
+ // success response
+ return array(false, null);
+ }
+
+ include_once($embedPath);
+
+ $new_user_needed = false;
+ $active_id = ($user->uid>0) ? $user->uid : '';
+ $params = array('embedUri' => $embedUri,
+ 'g2Uri' => $g2Uri,
+ 'loginRedirect' => url('user/login', null, null, true),
+ 'activeUserId' => $active_id,
+ 'activeLanguage' => gallery_get_language($user),
+ 'fullInit' => $full);
+
+ $ret = GalleryEmbed::init($params);
+ if (!$ret) {
+ // No error returned, but it is still possible that the ExternalID mapping has not been done
+ $ret2 = GalleryEmbed::isExternalIdMapped($user->uid, 'GalleryUser');
+ if ($ret2 && ($ret2->getErrorCode() & ERROR_MISSING_OBJECT)) {
+ // Need to make a new user, but don't try to map anonymous user.
+ $new_user_needed = ($user->uid>0);
+ }
+ }
+ if (($new_user_needed) || ($ret && ($ret->getErrorCode() & ERROR_MISSING_OBJECT))) {
+ // Our user mapping is missing. Make a mapping, or create a new user.
+ $g2_user = null;
+ // Get the G2 user that matches the Drupal username
+ list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($user->name);
+ if ($ret && !($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {
+ return array(false, $ret);
+ }
+ if (!isset($g2_user)) {
+ // No G2 user with a matching username. If this is the admin user, we're going to
+ // try a little harder and match it to the oldest admin in G2.
+ if ($user->uid == 1) {
+ list ($ret, $admin_group_id) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.adminGroup');
+ if ($ret) {
+ return array(false, $ret);
+ }
+ list ($ret, $g2_users) = GalleryCoreApi::fetchUsersForGroup($admin_group_id);
+ if ($ret) {
+ return array(false, $ret);
+ }
+ $keys = array_keys($g2_users);
+ $g2_user_name = $g2_users[$keys[0]];
+ list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($g2_user_name);
+ if ($ret) {
+ return array(false, $ret);
+ }
+ }
+ }
+
+ if (isset($g2_user)) {
+ // The G2 user was found so add to the External ID Map
+ $ret = GalleryEmbed::addExternalIdMapEntry($user->uid, $g2_user->getId(), 'GalleryUser');
+ if ($ret) {
+ return array(false, $ret);
+ }
+ } else {
+ // No matching G2 user found -- create one.
+ return gallery_modify_user($user, 'create');
+ }
+ }
+ return array(true, null);
+}
+
+/**
+ * Include css files as needed
+ */
+function gallery_css_include($css_file = 'drupal_g2.css') {
+ /* The theme may not exist, so neither does path_to_theme(), so need to init */
+ global $theme;
+ if ($theme === NULL) {
+ $theme = init_theme();
+ }
+ $output = theme('stylesheet_import', base_path() . drupal_get_path('module', 'gallery') .
+ '/' . $css_file,'screen') ."\n";
+ $themecss = base_path() . path_to_theme() .'/' . $css_file;
+ if (file_exists($themecss)) {
+ $output .= theme('stylesheet_import', $themecss,'screen') . "\n";
+ }
+ return $output;
+}
+
+/**
+ * Include head information with check made for uniqueness (see drupal_add_js)
+ */
+function gallery_set_html_head($info, $unique=true) {
+ static $sent = array();
+ if ($unique) {
+ // Only set html head if this info has not been sent before.
+ $hash_info = md5($info);
+ if (!isset($sent[$hash_info])) {
+ drupal_set_html_head($info);
+ $sent[$hash_info] = true;
+ }
+ } else {
+ drupal_set_html_head($info);
+ }
+}
+
+/**
+ * Get the language for the user. If unknown, make a best guess.
+ */
+ function gallery_get_language($user) {
+ // Added depdev patch for language support (http://drupal.org/node/32374)
+ // without i18 part (I seem to remember a Rewrite issue with it
+ // Added test for no user language defined
+ if (($user->uid==0 || !($user->language)) && module_exist('locale')) {
+ // This is a visitor and locale module is enabled
+ // Get drupal's default language
+ $result = db_query('SELECT locale, name FROM {locales_meta} WHERE isdefault = 1');
+ $row = db_fetch_object($result);
+ return $row->locale;
+ } else {
+ return $user->language;
+ }
+}
+
+/*
+ * --------------------------------------------------------------------------
+ * Error Functions
+ * --------------------------------------------------------------------------
+ */
+function gallery_error($message, $ret) {
+// Changed default, just in case!
+ $error_mode = variable_get('gallery_error_mode', array(1));
+ if (in_array(2, $error_mode)) {
+ drupal_set_message($message);
+ }
+
+ if (isset($ret)) {
+ $full_message = $message . '<br/>' . $ret->getAsHtml();
+ } else {
+ $full_message = $message;
+ }
+
+ if (in_array(1, $error_mode)) {
+ watchdog('gallery', $full_message, WATCHDOG_ERROR);
+ }
+}
+
+
+?> \ No newline at end of file
diff --git a/gallery_filter.css b/gallery_filter.css
new file mode 100755
index 0000000..62bd88c
--- /dev/null
+++ b/gallery_filter.css
@@ -0,0 +1,20 @@
+/* $Id$ */
+
+div.giImageBlock.left {
+ float: left;
+ margin: 1em;
+}
+
+div.giImageBlock.right {
+ float: right;
+ margin: 1em;
+}
+
+div.giImageBlock.nowrap {
+ float: none;
+ margin: 1em
+}
+
+.giImageBlock-clear-both {
+ clear: both;
+}
diff --git a/gallery_filter.inc b/gallery_filter.inc
new file mode 100644
index 0000000..bf56f24
--- /dev/null
+++ b/gallery_filter.inc
@@ -0,0 +1,202 @@
+<?php
+// $Id$
+
+/**
+ * gallery.module : gallery_filter.inc
+ * Gallery Filter functions (originally by MichelleC and Waldemar)
+ */
+
+// ***************** The Filter in Action ***********************
+
+define('GALLERY__FILTER_WORD', 1);
+define('GALLERY_FILTER_INTEGER', 2);
+define('GALLERY_FILTER_STRING', 3);
+
+function gallery_filter_attr_value($text, $value_type = GALLERY_FILTER_WORD) {
+ // Strip off initial and final quotes.
+ $first = substr($text, 0, 1);
+ if ($first == "\"" || $first == "\'") {
+ if (substr($text, -1, 1) == $first) {
+ $text = substr($text, 1, -1);
+ }
+ }
+ switch ($value_type) {
+ case GALLERY_FILTER_WORD :
+ return preg_replace("/\W/", '', $text);
+ case GALLERY_FILTER_INTEGER :
+ return preg_replace("/\D/", '', $text);
+ default :
+ return check_plain($text);
+ }
+}
+
+// Execute filter on given text.
+function gallery_filter_process($text) {
+ // Find all the image codes and loop over them, replacing each with the Gallery2 image block
+ $prefix = variable_get('gallery_filter_prefix', 'G2');
+
+ $matchetxt = "/\[".trim($prefix).":(\d+)(\s*,)?\s*(.*?)\]/i";
+ preg_match_all($matchetxt, $text, $matches, PREG_SET_ORDER);
+ // If we have at least one match, set everything up
+ if (count($matches) > 0) {
+ // Set the default and path variables based on module settings
+ $default_size = variable_get('gallery_filter_default_size', 150);
+ $default_div_class = variable_get('gallery_filter_default_div_class', 'nowrap');
+ $default_album_frame = variable_get('gallery_filter_default_album_frame', '');
+ $default_item_frame = variable_get('gallery_filter_default_item_frame', '');
+ $default_block_type = variable_get('gallery_filter_default_block_type', 'recentImage');
+ $default_n_images = variable_get('gallery_filter_n_images', 1);
+ $default_show = variable_get('gallery_filter_default_show', 'none');
+ $default_link_target = variable_get('gallery_filter_default_link_target', '');
+
+ if ($default_album_frame == 'none') {
+ $default_album_frame = '';
+ }
+ if ($default_item_frame == 'none') {
+ $default_item_frame = '';
+ }
+
+ // This will hold the list of frames used for images so we can add the CSS link(s) at the end
+ $frame_list = array ();
+
+ // This sets up the embedding
+ list ($success, $ret) = _gallery_init(true);
+ if (!$success) {
+ gallery_error(t('Unable to initialize embedded Gallery'), $ret);
+ return;
+ }
+ }
+ foreach ($matches as $match) {
+ // Pull out the arguments into the $args array
+ $args = array ();
+ preg_match_all("/(\w+)\=(\"[^\"]*\"|\S*)/", $match[3], $a, PREG_SET_ORDER);
+
+ foreach ($a as $arg) {
+ $args[strtolower($arg[1])] = $arg[2];
+ }
+
+ // Set number of images to show
+ $n_images = gallery_filter_attr_value($args['n'], GALLERY_FILTER_INTEGER);
+ if ($n_images == 0) {
+ // No size specified; use the default
+ $n_images = $default_n_images;
+ }
+
+ // Set the block type
+ $block_type = gallery_filter_attr_value($args['type'], GALLERY_FILTER_WORD);
+ if (empty($block_type)) {
+ // No block type specified; use the default
+ $block_type = $default_block_type;
+ }
+ if ($n_images <= 1)
+ $block_type = 'specificItem'; //so it shows something if n=1 and an album is selected
+
+ // Set the size of the thumbnail
+ $size = gallery_filter_attr_value($args['size'], GALLERY_FILTER_INTEGER);
+ if ($size == 0) {
+ // No size specified; use the default
+ $size = $default_size;
+ }
+
+ // Set the class of the div
+ $div_class = gallery_filter_attr_value($args['class'], GALLERY_FILTER_WORD);
+ if (empty ($div_class)) {
+ // No class specified; use the default
+ $div_class = $default_div_class;
+ }
+ // Switch the class to g2image versions (adds consistency)
+ switch ($div_class) {
+ case 'left':
+ $div_class = "g2image_float_left";
+ break;
+ case 'right':
+ $div_class = "g2image_float_right";
+ break;
+ case 'center':
+ case 'centre':
+ $div_class = "g2image_centered";
+ break;
+ case 'normal':
+ $div_class = "g2image_normal";
+ break;
+ }
+ // Set the overriding, album, and item frames
+ $frame = gallery_filter_attr_value($args['frame'], GALLERY_FILTER_WORD);
+ $album_frame = gallery_filter_attr_value($args['aframe'], GALLERY_FILTER_WORD);
+ $item_frame = gallery_filter_attr_value($args['iframe'], GALLERY_FILTER_WORD);
+
+ if (empty ($frame)) {
+ // No overriding frame given; check for album_frame and item_frame
+ if (empty ($album_frame)) {
+ // No album frame specified; use the default one
+ $album_frame = $default_album_frame;
+ }
+
+ if (empty ($item_frame)) {
+ // No item frame specified; use the default one
+ $item_frame = $default_item_frame;
+ }
+
+ } else {
+ // Overriding frame given; use it
+ $album_frame = $frame;
+ $item_frame = $frame;
+ }
+
+ // Add the requested frames to the array so we can get the CSS later. Don't worry about
+ // dupes at this point; they will be filtered out later.
+ array_push($frame_list, $frame);
+ array_push($frame_list, $album_frame);
+ array_push($frame_list, $item_frame);
+
+ // This part actually fetches the image block. It uses the same paramaters as the code
+ // found under "Image Block" in site admin in Gallery2.
+
+ $show = $default_show;
+
+ // Not customized yet:
+ $link_target = $default_link_target;
+
+ $param_blocks_array = array_fill(0, $n_images, $block_type);
+ $params['itemId'] = $match[1];
+ $params['blocks'] = is_array($param_blocks_array) ? implode('|', $param_blocks_array) : "";
+ $param_show_array = $show;
+ $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : "";
+ $params['maxSize'] = $size;
+ // Add frames and link target using g2_filter code from MichelleC
+ $params['albumFrame'] = $album_frame;
+ $params['itemFrame'] = $item_frame;
+ $params['linkTarget'] = $link_target;
+
+ $g2_head = array();
+ $block = array ();
+ list ($ret, $content, $head) = GalleryEmbed::getImageBlock($params);
+ if ($ret) {
+ gallery_error(t('Unable to get Gallery image block'), $ret);
+ return;
+ } else {
+ if ($content) {
+ // Add a div around the table for styling
+ if ($div_class != 'none') {
+ $content = '<div class ="giImageBlock '.$div_class.'">'.$content.'</div>';
+ }
+ // This puts the image block HTML back into the rest of the text
+ $text = str_replace($match[0], $content, $text);
+ }
+ if ($head) {
+ $g2_head[] = $head;
+ }
+ }
+ } // end of for loop through matches
+ // If we had at least one match, finish up by adding the css. Unfotunately if there are multiple
+ // images on a page this will get added multiple times.
+ if (count($matches) > 0) {
+ GalleryEmbed :: done();
+ if ($g2_head) {
+ gallery_set_html_head(implode("\n", array_unique($g2_head)));
+ }
+ gallery_set_html_head(gallery_css_include('gallery_filter.css'));
+ }
+ return $text . "<br class=\"giImageBlock-clear-both\" />";;
+}
+?> \ No newline at end of file
diff --git a/gallery_g2image.inc b/gallery_g2image.inc
new file mode 100644
index 0000000..1920633
--- /dev/null
+++ b/gallery_g2image.inc
@@ -0,0 +1,62 @@
+<?php
+// $Id$
+
+/**
+ * gallery.module : gallery_g2image.inc
+ * Support functions for g2image by capt_kirk (from http://g2image.steffensenfamily.com)
+ */
+
+ /**
+ * Add js to page
+ */
+ function gallery_g2image_add_js() {
+ // Ensure only sent once
+ static $sent = false;
+ if (!$sent) {
+ $path = drupal_get_path('module', 'gallery');
+ $g2image_uri = base_path() . $path . '/g2image/';
+
+ $output .= '<script type="text/javascript">';
+ $output .= ' var G2IMAGE_URI = "' . $g2image_uri . '";';
+ $output .= '</script>';
+
+ drupal_set_html_head($output);
+ drupal_add_js($path . '/g2image.js');
+ $sent = true;
+ }
+}
+
+ /**
+ * Theme for adding an image link underneath textareas
+ */
+function theme_gallery_g2image_textarea_link($element, $link) {
+ $output = '<div class="g2image-button"><a class="g2image-link" id="g2image-link-'. $element['#id']
+ . '" title="'. t('Click here to add images from Gallery2 albums')
+ . '" href="#" onclick="g2ic_open(\''.$element['#id'].'\');">';
+ $output .= t('add Gallery2 images');
+ $output .= '</a></div>';
+
+ return $output;
+}
+
+/**
+ * Determine if g2image button should be attached to the page/textarea.
+ * (from img_assist and tinymce code)
+ *
+ * @return
+ * TRUE if can render, FALSE if not allowed.
+ */
+function _gallery_g2image_page_match() {
+ //if (variable_get('gallery_g2image_std_all', 1)) {
+ $page_match = FALSE;
+ $only_listed_pages = variable_get('gallery_g2image_only_listed_pages', 1);
+ $pages = variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages'));
+ if ($pages) {
+ $path = drupal_get_path_alias($_GET['q']);
+ $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. variable_get('site_frontpage', 'node') .'\2'), preg_quote($pages, '/')) .')$/';
+ $page_match = !($only_listed_pages xor preg_match($regexp, $path));
+ }
+ return $page_match;
+}
+
+ ?> \ No newline at end of file
diff --git a/gallery_help.inc b/gallery_help.inc
new file mode 100644
index 0000000..d81401c
--- /dev/null
+++ b/gallery_help.inc
@@ -0,0 +1,157 @@
+<?php
+// $Id$
+
+/**
+ * gallery.module : gallery_help.inc
+ * Help info
+ */
+
+/**
+ * Implementation of hook_help
+ */
+function _gallery_help($section) {
+
+ switch($section) {
+ case 'admin/modules#description':
+ return t('Integration with Gallery2.1 (%gallery_url)', array('%gallery_url' => 'http://gallery.menalto.com/'));
+ case 'filter#short-tip' :
+ return gallery_filter_short_tip_translated();
+ case 'filter#long-tip' :
+ return gallery_filter_long_tip_translated();
+ case 'admin/help#gallery_filter' :
+ return t('<p>Used to add image blocks from your embedded Gallery 2 to a node
+ like a blog entry or a story. To enable this feature and learn the proper syntax,
+ visit the <a href="%filters">filters configuration screen</a>.</p>',
+ array ('%filters' => url('admin/filters')));
+ case 'admin/help#gallery':
+ $output = t('
+ <p></p>
+ <h3>Settings</h3>
+ <h4>Directory Settings</h4>
+ <p>"URI of Gallery2" is the URI of the Gallery2 standalone location. Path from docroot to the directory main.php is located.
+ Protocol / host name are both optional. Examples: /gallery2/, /sub/gallery2/, http://photos.example.com/,
+ www.example.com/photos/main.php</p>
+ <p>"Location of Gallery2" is the path of your gallery2 installation,
+ either absolute (starts with "/") or
+ relative to your Drupal installation directory. Normally this is auto-detected, but in case
+ this fails you can turn off auto-detection and manually enter a value.</p>
+ <p>"Embed URI" is the URI needed to access Gallery2 through Drupal. This will end in
+ \'?q=gallery\' (non-clean URLs) or \'gallery\' (clean URLs). Normally this is auto-detected,
+ but in case this fails you can turn off auto-detection and manually enter a value.</p>
+ <p>Some examples:</p>
+ <p>Example 1: If your directory structure and website structure is
+ <ul>
+ <li>Drupal dir: /var/www/web/html/</li>
+ <li>Gallery dir: /var/www/web/html/gallery2/</li>
+ <li>Website URL: http://www.example.com</li>
+ <li>Standalone Gallery2 URL: http://www.example.com/gallery2/</li>
+ <li>Then<ul>
+ <li>"URI of Gallery2" = "/gallery2/" or "http://www.example.com/gallery2/"</li>
+ <li>"Location of Gallery2" = "gallery2/" or "/var/www/web/html/gallery2/"</li>
+ <li>"Embed URI" = "?q=gallery" or "http://www.example.com/?q=gallery"</li>
+ </ul>
+ </ul>
+ </p><p>Example 2: If your directory structure and website structure is
+ <ul>
+ <li>Drupal dir: /var/www/web/html/drupal/</li>
+ <li>Gallery dir: /var/www/web/html/gallery2/</li>
+ <li>Website URL: http://www.example.com/drupal</li>
+ <li>Standalone Gallery2 URL: http://www.example.com/gallery2/</li>
+ <li>Then<ul>
+ <li>"URI of Gallery2" = "/gallery2/" or "http://www.example.com/gallery2/"</li>
+ <li>"Location of Gallery2" = "../gallery2/" or "/var/www/web/html/gallery2/"</li>
+ <li>"Embed URI" = "/drupal/?q=gallery" or "http://www.example.com/drupal/?q=gallery"</li>
+ </ul>
+ </ul>
+ </p><p>Example 3: If your directory structure and website structure is
+ <ul>
+ <li>Drupal dir: /var/www/web/html/drupal/</li>
+ <li>Gallery dir: /var/www/web/html/someotherdir/gallery2/</li>
+ <li>Website URL: http://www.example.com/</li>
+ <li>Standalone Gallery2 URL: http://www.anotherexample.com/gallery2/</li>
+ <li>Then<ul>
+ <li>"URI of Gallery2" = "http://www.anotherexample.com/gallery2/"</li>
+ <li>"Location of Gallery2" = "/var/www/web/html/someotherdir/gallery2/"</li>
+ <li>"Embed URI" = "/drupal/?q=gallery" or "http://www.example.com/drupal/?q=gallery"</li>
+ </ul>
+ </ul>
+ </p>
+ <h4>Full Name settings</h4>
+ <p>Drupal does not have in-built support for full names but Gallery 2 does. If you would like
+ full names in both then you can install profile.module in Drupal and define a "full name" field.
+ Include the name of that field here. You can enable/disable this functionality at will, but it
+ may leave some users with different full names in their Drupal and Gallery users, so it is not
+ recommended.</p>
+ <h4>Search settings</h4>
+ <p>You can select how many items are returned per Gallery2 module. You can also specify
+ whether thumbnails should be returned, and if so, how they should be formatted.</p>
+ <h4>Error Logging settings</h4>
+ <p>You can choose whether errors occuring in this module are logged in the watchdog,
+ displayed in the browser, or both.</p>
+ ');
+ $output .= _gallery_g2image_help();
+ return $output;
+ case 'admin/settings/gallery':
+ return t('');
+ case 'admin/settings/gallery_g2image#pages':
+ return "node/*\ncomment/*";
+ }
+}
+
+function gallery_filter_short_tip_translated() {
+ return t('You may link to Gallery2 items on this site <a href="%explanation-url">using a special syntax</a>.', array ('%explanation-url' => url('filter/tips', NULL, 'filter-gallery-0')));
+}
+
+function gallery_filter_long_tip_translated() {
+ $prefix = variable_get("gallery_filter_prefix", "G2");
+
+ $output = "";
+ $output .= '<p><strong>Gallery2 Filter:</strong><p>You can link to items in your ';
+ $output .= 'embedded Gallery2 using a special code. ';
+ $output .= 'This code will be replaced by a thumbnail image that is ';
+ $output .= 'linked to the actual item in your Gallery. </p>';
+ $output .= '<p><em>Syntax:</em></p>';
+ $output .= '<blockquote><code>';
+ $output .= '['.$prefix.':<em>item_id</em> n=<em>number</em> type=<em>type</em> size=<em>number</em> class=<em>name</em> frame=<em>name</em> album_frame=<em>name</em> item_frame=<em>name</em>]';
+ $output .= '</code></blockquote>';
+
+ $output .= '<ul><li>item_id (required): This is the item ID from Gallery2. ';
+ $output .= 'If you look at the URL of the item, this is the last number. '.'<em>Note that if the item_id is a single photo, n must be 1.</em></li> ';
+
+ $output .= '<li>n (suggested): This is the number of photos you want the block to show. ';
+ $output .= 'It will override whatever is set in the defaults (initially 1). '.' Note: this will change past instances where you did not set n -- the reason for its suggested use.</li> ';
+
+ $output .= '<li>type: The default type of gallery block. Any of the following may be used: ';
+ $output .= '<em>randomImage, recentImage, viewedImage, randomAlbum, recentAlbum, viewedAlbum, dailyImage, '.'weeklyImage, monthlyImage, dailyAlbum, weeklyAlbum, monthlyAlbum, specificItem . </em> '.'Note that for n=1, selectedItem is automatically chosen regardless of this parameter.</li> ';
+
+ $output .= '<li>class: The block that Gallery2 returns is wrapped in a DIV so additional styling can be done. ';
+ $output .= 'The classes for this DIV are located in g2_filter.css. Included with the module ';
+ $output .= 'are "left", "right", and "nowrap". These position the image block to the left or ';
+ $output .= 'right or on a line all its own with the text not wrapping. You can also add your ';
+ $output .= 'own class(es) to the CSS file and they will automatically be available.</li> ';
+
+ $output .= '<li>size: The length of the longest side for the thumbnail. ';
+ $output .= 'The other side is determined automatically to keep the same aspect ratio.</li> ';
+
+ $output .= '<li>frame/album_frame/item_frame: You can use just "frame" to assign a frame ';
+ $output .= 'to the thumbnail regardless of whether it\'s for an album or a single item. ';
+ $output .= 'Using aframe will only affect albums and iframe will only affect single items. ';
+ $output .= 'Frames included with the default Gallery 2 install are: ';
+ $output .= 'bamboo, book, brand , dots, flicking, gold, gold2, polaroid, polaroids, shadow, ';
+ $output .= 'shells, slide, solid, notebook, wood.</li></p>';
+
+ return t($output);
+
+}
+
+function _gallery_g2image_help() {
+ $output = '<h3>Gallery Image Assist (g2image)</h3>';
+ $output .= '<p>Support for <a href=\'http://g2image.steffensenfamily.com\'>g2image</a> in either Standalone or TinyMCE is available to simplify ';
+ $output .= 'adding images already in your Gallery2 albums into your Drupal nodes.</p>';
+ $output .= '<p>Caution: By default, Drupal uses the \'Filtered HTML\' input format for adding
+content to the site and the default settings cause the &lt;img&gt; tags added by g2image to be removed. Check the TinyMCE documentation for instructions on how to avoid this.</p>';
+
+ return t($output);
+}
+
+?>
diff --git a/gallery_roles.inc b/gallery_roles.inc
new file mode 100644
index 0000000..9ebbbb1
--- /dev/null
+++ b/gallery_roles.inc
@@ -0,0 +1,208 @@
+<?php
+// $Id$
+/**
+ * gallery.module : gallery_roles.inc
+ * Group/Role Functions (sync groups, ...)
+ */
+
+/**
+ * Sync Drupal roles and Gallery groups for a specific user
+ */
+ // Check for remove user.
+function gallery_sync_groups_for_user($user) {
+ // Take this opportunity to sync the Drupal roles and Gallery groups
+ gallery_sync_groups();
+ // Find the Ids for the 2 special Drupal roles (from user.module code)
+ $authenticated_role = db_result(db_query("SELECT rid FROM {role} WHERE name = 'authenticated user'"));
+ $anonymous_role = db_result(db_query("SELECT rid FROM {role} WHERE name = 'anonymous user'"));
+
+ // Find the Ids for the special G2 groups
+ list ($ret, $g2_gid_everybodyGroup) = GalleryCoreApi::getPluginParameter('module', 'core',
+ 'id.everybodyGroup');
+ if ($ret) {
+ $msg = t('Error retrieving Gallery group Id for \'Everybody\' group');
+ gallery_error($msg, $ret);
+ }
+
+ // Get the Gallery groups for this user
+ // First get the G2 Id from the Drupal uid
+ list ($ret, $g2_user) = GalleryCoreApi::loadEntityByExternalId($user->uid, 'GalleryUser');
+ if ($ret) {
+ $msg = t('Error getting Gallery User info from Drupal Id');
+ $msg .= ' ' . t('Drupal User Id: ') . $user->uid;
+ gallery_error($msg, $ret);
+ }
+ // Then get the groups for this user currently set in G2
+ list ($ret, $g2_cur_groups) = GalleryCoreApi::fetchGroupsForUser($g2_user->getId());
+ if ($ret) {
+ $msg = t('Error getting Gallery group info for user');
+ $msg .= ' ' . t('Drupal User Id: ') . $user->uid;
+ gallery_error($msg, $ret);
+ }
+ // Now convert the new Drupal role Ids into Gallery Group Ids(for comparison)
+ foreach ($user->roles as $rid=>$role_name) {
+ list ($ret, $g2_group) = GalleryCoreApi::loadEntityByExternalId($rid, 'GalleryGroup');
+ if ($ret) {
+ $msg = t('Error getting Gallery Group Id from Drupal Role Id');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid;
+ gallery_error($msg, $ret);
+ }
+ $g2_rid[$rid] = $g2_group->getId();
+ }
+ // Find if the user needs to be deleted from any G2 groups (only mapped groups)
+ $g2_mapped_groups = gallery_get_mapped_groups();
+ foreach ($g2_cur_groups as $gid=>$gname) {
+ if (!in_array($gid, $g2_rid) && ($gid != $g2_gid_everybodyGroup) && in_array($gid, $g2_mapped_groups)) {
+ $delete_list[] = $gid;
+ $ret = GalleryCoreApi::removeUserFromGroup($g2_user->getId(), $gid);
+ if ($ret) {
+ $msg = t('Error removing user from Gallery group');
+ $msg .= ' ' . t('Gallery Group Id: ') . $gid . ' ' . t('Gallery Group Name: ') . $gname;
+ gallery_error($msg, $ret);
+ }
+ }
+ }
+ // Find if the user needs to be added to any G2 groups
+ foreach ($g2_rid as $rid=>$gid) {
+ if (!isset($g2_cur_groups[$gid])) {
+ $add_list[] = $gid;
+ $ret = GalleryCoreApi::addUserToGroup($g2_user->getId(), $gid);
+ if ($ret) {
+ $msg = t('Error adding user to Gallery group');
+ $msg .= ' ' . t('Gallery Group Id: ') . $gid;
+ gallery_error($msg, $ret);
+ }
+ }
+ }
+}
+
+/**
+ * Sync Drupal roles and Gallery groups. This will add any mappings that are required
+ * (eg on first install, or if a group is added). It will also delete groups in Gallery
+ * that have been deleted from Drupal.
+ */
+function gallery_sync_groups() {
+ // Check if the Drupal role <-> G2 group mapping exists
+ $roles = user_roles();
+ // Find the Ids for the 2 special Drupal groups (from user.module code)
+ $authenticated_role = db_result(db_query("SELECT rid FROM {role} WHERE name = 'authenticated user'"));
+ $anonymous_role = db_result(db_query("SELECT rid FROM {role} WHERE name = 'anonymous user'"));
+ // Go through each role and add or delete the gallery group if needed
+ foreach ($roles as $rid => $role_name) {
+ // Add Drupal<->G2 mapping if needed
+ $ret = GalleryEmbed::isExternalIdMapped($rid, 'GalleryGroup');
+ if ($ret && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {
+ // Need to add the mapping
+ switch ($rid) {
+ // Add mapping for Anonymous and get the G2 group Id
+ case $anonymous_role:
+ list ($ret, $g2_gid) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.everybodyGroup');
+ if ($ret) {
+ $msg = t('Error retrieving Gallery group Id for \'Everybody\' group');
+ gallery_error($msg, $ret);
+ }
+ $ret = GalleryEmbed::addExternalIdMapEntry($rid, $g2_gid, 'GalleryGroup');
+ if ($ret) {
+ $msg = t('Error creating new Drupal role <-> Gallery group mapping (for \'anonymous user\' role)');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
+ gallery_error($msg, $ret);
+ }
+ break;
+ // Add mapping for authenticated users role and get the G2 group Id
+ case $authenticated_role:
+ list ($ret, $g2_gid) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.allUserGroup');
+ if ($ret) {
+ $msg = t('Error retrieving Gallery group Id for \'Registered Users\' group');
+ gallery_error($msg, $ret);
+ }
+ $ret = GalleryEmbed::addExternalIdMapEntry($rid, $g2_gid, 'GalleryGroup');
+ if ($ret) {
+ $msg = t('Error creating new Drupal role <-> Gallery group mapping (for \'authenticated user\' role)');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
+ gallery_error($msg, $ret);
+ }
+ break;
+ default:
+ // Is there already a group by this name? If so, map to it.
+ list ($ret, $g2_group) = GalleryCoreApi::fetchGroupByGroupName($role_name);
+ if (!$ret) {
+ $g2_gid = $g2_group->getId();
+ $ret = GalleryEmbed::addExternalIdMapEntry($rid, $g2_gid, 'GalleryGroup');
+ if ($ret) {
+ $msg = t('Error creating new Drupal role <-> Gallery group mapping (by name)');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Gallery Group Id: ') . $g2_gid;
+ gallery_error($msg, $ret);
+ }
+ } else {
+ // If not, create a new group
+ $ret = GalleryEmbed::createGroup($rid, $role_name);
+ if ($ret) {
+ $msg = t('Error creating new Gallery group');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Drupal Role Name: ') . $role_name;
+ gallery_error($msg, $ret);
+ }
+ }
+ break;
+ }
+ } else {
+ // Update group name if needed (not for $authenticated_role or $anonymous_role)
+ list($ret, $g2_group) = GalleryCoreApi::loadEntityByExternalId($rid, 'GalleryGroup');
+ // In some cases the ExternalId may be present, but the user may have been deleted
+ if ($ret) {
+ $msg = t('Error retrieving Gallery Group Id from Drupal Role Id');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid;
+ gallery_error($msg, $ret);
+ }
+ if (($rid != $authenticated_role) && ($rid != $anonymous_role) && ($role_name != $g2_group->getGroupName())) {
+ $ret = GalleryEmbed::updateGroup($rid, array('groupname'=>$role_name));
+ if ($ret) {
+ $msg = t('Error updating Gallery group');
+ $msg .= ' ' . t('Drupal Role Id: ') . $rid . ' ' . t('Drupal Role Name: ') . $role_name;
+ gallery_error($msg, $ret);
+ }
+ }
+ }
+ }
+ // Now check for any deleted Drupal roles. Only delete those G2 groups that were mapped to Drupal roles
+ // (just in case other groups have been defined which are not meant to be sync'd with Drupal)
+ list ($ret, $g2_map) = GalleryEmbed::getExternalIdMap('entityId');
+ if ($ret) {
+ $msg = t('Error retrieving all Drupal<->Gallery Map Ids');
+ gallery_error($msg, $ret);
+ }
+ $g2_mapped_groups = gallery_get_mapped_groups();
+ foreach ($g2_mapped_groups as $rid=>$g2_gid) {
+ // Delete if needed
+ if (!isset($roles[$rid])) {
+ $msg = t('Deleting G2 group') . ' (' . t('Gallery Group Id: ') . $g2_gid .')';
+ $ret = GalleryEmbed::deleteGroup($rid);
+ if ($ret) {
+ $msg = t('Error deleting Gallery group');
+ $msg .= ' ' . t('Gallery Group Id: ') . $g2_gid;
+ gallery_error($msg, $ret);
+ }
+ }
+ }
+}
+
+/**
+ * Get G2 Groups that have been mapped to Drupal Roles
+ */
+function gallery_get_mapped_groups() {
+ list ($ret, $g2_map) = GalleryEmbed::getExternalIdMap('entityId');
+ if ($ret) {
+ $msg = t('Error retrieving all Drupal<->Gallery Map Ids');
+ gallery_error($msg, $ret);
+ }
+ /*
+ * getExternalIdMap returns groups and user mappings.
+ * Cannot use 'externalId' as key as is not unique between users & groups
+ */
+ foreach ($g2_map as $g2_gid => $g2_data) {
+ if ($g2_data['entityType'] == 'GalleryGroup') {
+ $g2_mapped_groups[$g2_data['externalId']] = $g2_gid;
+ }
+ }
+ return $g2_mapped_groups;
+}
+?> \ No newline at end of file
diff --git a/gallery_search.inc b/gallery_search.inc
new file mode 100644
index 0000000..7301dbe
--- /dev/null
+++ b/gallery_search.inc
@@ -0,0 +1,226 @@
+<?php
+// $Id$
+/**
+ * gallery.module search functions
+ */
+
+/**
+ * implementation of hook_search
+ */
+function _gallery_search($op = 'search', $keys = null) {
+ switch ($op) {
+ case 'name':
+ return t('gallery');
+ case 'search':
+ $find = array();
+ $g2_head = array();
+
+ list ($success, $ret) = _gallery_init(true);
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+
+ // Image block options for search
+ $params['blocks'] = "specificItem";
+ $param_show_array = variable_get('gallery_search_block_show', array());
+ $params['show'] = is_array($param_show_array) ? implode('|', $param_show_array) : "";
+ $params['maxSize'] = variable_get('gallery_search_maxsize', 160);
+ $params['albumFrame'] = variable_get('gallery_search_album_frame', 'none');
+ $params['itemFrame'] = variable_get('gallery_search_item_frame', 'none');
+ $params['linkTarget'] = variable_get('gallery_search_link_target', '');
+ $show_g2_thumbs = variable_get('gallery_search_show_thumbs', 1);
+ $max_items = variable_get('gallery_search_max_items', 50);
+
+ list ($ret, $results) = GalleryEmbed::searchScan($keys, $max_items);
+ if (!$ret) {
+ /**
+ * Format of $results is:
+ * [GalleryCoreSearch] => Array(
+ [start] => 1
+ [end] => 13
+ [count] => 13
+ [results] => Array(
+ [0] => Array(
+ [itemId] => 46
+ [fields] => Array(
+ [0] => Array([key] => Title, [value] => DSCN2884.JPG)
+ [1] => Array([key] => Summary, [value] => )
+ [2] => Array([key] => Keywords, [value] => )
+ [3] => Array([key] => Description, [value] => )
+ [4] => Array([key] => Owner, [value] => Me )
+ )
+ )
+ [1] => ...
+ [name] => Gallery Core
+ )
+ [comment] => ...
+ [CustomField] => ...
+ [MultiLang] => ...
+ Other modules
+ )
+
+ * You can set the maximum number of items, but not a start offset, unfortunately.
+ */
+ $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
+ // Copy the results to a new array, and overwrite the results portions to a new format
+ $find = $results;
+ $g2_thumb = '';
+ foreach ($results as $name => $module) {
+ if (count($module['results']) > 0) {
+ $this_module_results = array();
+ foreach ($module['results'] as $result) {
+ $excerpt = array();
+ $g2_thumb = '';
+ foreach ($result['fields'] as $field) {
+ if (preg_match("/$keys/i", $field['value'])) {
+ $excerpt[] = '<em>'.$field['key'] .':</em> '.
+ search_excerpt($keys, $field['value']);
+ }
+ }
+ $link = $urlGenerator->generateUrl(array('itemId' => $result['itemId']),
+ array('htmlEntities' => false));
+ if ($show_g2_thumbs) {
+ $params['itemId'] = $result['itemId'];
+ // No error checking. If it failed then no thumb is returned. Should be OK
+ // (maybe there is no thumb for that item)
+ list($ret, $g2_thumb, $head) = GalleryEmbed::getImageBlock($params);
+ if ($head) {
+ $g2_head[] = $head;
+ }
+ }
+ $this_module_results[] = array(
+ 'title' => $result['fields'][0]['value'],
+ 'link' => $link,
+ 'type' => '',
+ 'snippet' => implode('<br />', $excerpt),
+ 'extra' => array(),
+ 'g2_thumb' => $g2_thumb,
+ );
+ }
+ $find[$name]['results'] = $this_module_results;
+ }
+ }
+ // Try not to send the G2 head information multiple times
+ if ($g2_head) {
+ drupal_set_html_head(implode("\n", array_unique($g2_head)));
+ }
+ return $find;
+ }
+ }
+}
+
+/**
+ * Implementation of hook_search_page to override how to display the search results
+ */
+function _gallery_search_page($results) {
+ $num_items_per_row = variable_get('gallery_search_num_per_row', 3);
+ $max_rows_per_pager = variable_get('gallery_search_max_rows_per_pager', 5);
+ $max_items = variable_get('gallery_search_max_items', 50);
+ $header = array_fill(0, $num_items_per_row, '');
+
+ $output = '<dl class="search-results">';
+
+ foreach ($results as $entry) {
+ $output .= gallery_search_item($entry);
+ }
+ $output .= '</dl>';
+
+
+/**
+ * From /drupal/includes/pager.inc
+ * $pager_page_array[i] = page number (starts at 0) (eg 7)
+ * $pager_total[i] = total number of pages = ceil($pager_total_items[i] / limit) (eg 15)
+ * $pager_total_items[i] = total number of items in the pager (eg 75)
+ * where i is the pager ID (must be a number!!!) (for multiple pagers on a page)
+ * eg ?page=1,2,1
+ * => page 2 for pager1, page 3 for pager2, page 2 for pager 3
+ */
+ global $pager_page_array, $pager_total, $pager_total_items;
+ $page = isset($_GET['page']) ? $_GET['page'] : '';
+ $pager_page_array = explode(',', $page);
+
+ $output = '';
+ $element = 0;
+ // Split the search results from each module into individual pagers
+ foreach ($results as $module => $table) {
+ $search_items = array();
+ $row = 0;
+ $col = 0;
+ foreach ($table['results'] as $key => $item){
+ // Format the search results
+ $search_items[$row][$col++] = gallery_search_item($item);
+ if ($col >= $num_items_per_row) {
+ $row++;
+ $col = 0;
+ }
+ }
+ // Add the title for that pager
+ $output .= '<h2>';
+ $count = $table['count'];
+ if ($count > $max_items) {
+ $count = $max_items;
+ $count_text = t(' (>%count items found)', array(
+ '%count' => $count));
+ } else {
+ $count_text = t(' (%count %item found)', array(
+ '%item' => ($count == 1) ? t('item') : t('items'),
+ '%count' => $count));
+ }
+ $output .= t('%name Results', array('%name' => $table['name']));
+ $output .= $count_text . '</h2>';
+
+ if ($count > 0) {
+ $pager_total_items[$element] = ceil($count/ $num_items_per_row);
+ $pager_total[$element] = ceil($pager_total_items[$element] / $max_rows_per_pager);
+ $first_item = $pager_page_array[$element] * $max_rows_per_pager;
+ // Slice the array to display only the results for this page of the pager
+ $search_items = array_slice($search_items, $first_item, $max_rows_per_pager);
+ // Add empty cells if needed to complete the last row
+ $last_row = count($search_items) - 1;
+ if (count($search_items[$last_row]) < $num_items_per_row) {
+ $search_items[$last_row] = array_merge(
+ $search_items[$last_row],
+ array_fill(0, $num_items_per_row - count($search_items[$last_row]), ''));
+ }
+
+ $output .= theme('table', $header, $search_items);
+ $output .= theme('pager', NULL, $max_rows_per_pager, $element);
+ $element++;
+ }
+ }
+ return $output;
+}
+
+function gallery_search_item($item) {
+ $output = '';
+ if ($item['g2_thumb']) {
+ $output .= ' <dd>' . $item['g2_thumb'] . '</dd>';
+ } else {
+ $output = '<dt class="title"><a href="'. check_url($item['link']) .'">'.
+ check_plain($item['title']) .'</a></dt>';
+ }
+
+ $info = array();
+ if ($item['type']) {
+ $info[] = $item['type'];
+ }
+ if ($item['user']) {
+ $info[] = $item['user'];
+ }
+ if ($item['date']) {
+ $info[] = format_date($item['date'], 'small');
+ }
+ if (is_array($item['extra'])) {
+ $info = array_merge($info, $item['extra']);
+ }
+ $output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] . '</p>' : '') .
+ '<p class="search-info">' . implode(' - ', $info) .'</p></dd>';
+
+ return $output;
+}
+
+?> \ No newline at end of file
diff --git a/gallery_settings.inc b/gallery_settings.inc
new file mode 100644
index 0000000..782408c
--- /dev/null
+++ b/gallery_settings.inc
@@ -0,0 +1,971 @@
+<?php
+// $Id$
+
+/**
+ * gallery.module : gallery_settings.inc
+ * Settings functions
+ */
+
+/**
+ * Implementation of hook_settings
+ */
+function _gallery_settings() {
+ $output = '';
+ $extra = l(t('More information about directory settings (including examples).'),
+ 'admin/help/gallery');
+ $form['directory'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Directory settings'),
+ '#description' => $extra,
+ '#collapsible' => TRUE,
+ '#collapsed' => variable_get('gallery_valid', 0),
+ );
+
+ $form['directory']['gallery_uri'] = array(
+ '#type' => 'textfield',
+ '#title' => t('URI of Gallery2'),
+ '#default_value' => variable_get('gallery_uri', '/gallery2/'),
+ '#size' => 64,
+ '#maxlength' => 128,
+ '#description' => t('URI of the G2 standalone location. Path from docroot to the
+ Gallery2 directory where main.php is located. Protocol/hostname are
+ both optional.'),
+ );
+
+ $form['directory']['gallery_autodetect_dir'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Autodetect Settings'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gallery_autodetect_dir', 1),
+ '#description' => t('Autodetect the Gallery2 and Drupal settings (recommended). When
+ selected the values below are updated with the autodetect settings
+ when the submit button is clicked.'),
+ );
+
+ if (variable_get('gallery_autodetect_dir', 1)) {
+ $extra = t(' (Autodetected value)');
+ } else {
+ $extra = t(' (Manually entered value)');
+ }
+ $form['directory']['gallery_dir'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Location of Gallery2') . $extra,
+ '#default_value' => variable_get('gallery_dir', './gallery2/'),
+ '#size' => 64,
+ '#maxlength' => 128,
+ '#description' => t('Location of your gallery2 directory (absolute path or relative to the root
+ directory of your drupal installation).'),
+ );
+
+ $form['directory']['gallery_embed_uri'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Embed URI') . $extra,
+ '#default_value' => variable_get('gallery_embed_uri', '?q=gallery'),
+ '#size' => 64,
+ '#maxlength' => 128,
+ '#description' => t('URI to access G2 via drupal. Don\'t worry if you are using clean urls in drupal and this still ends in \'index.php?q=gallery\'. This is needed to get the Gallery2 URL rewrite module to work correctly and will not be visible.'),
+ );
+
+/**
+ * Remove this for now. It is not necessary when URL rewrite is working. Without URL rewrite there
+ * can still be issues, but these will be addressed in the documentation for now.
+ */
+/*
+ $form['directory']['gallery_cookie_path'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Cookie Path') . $extra,
+ '#default_value' => variable_get('gallery_cookie_path', ''),
+ '#size' => 64,
+ '#maxlength' => 128,
+ '#description' => t('Cookie path for embedded Gallery2 sessions.'),
+ ); */
+
+ // Fullname settings
+ if (module_exist('profile')) {
+ $form['fullname'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Full Name settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $form['fullname']['gallery_use_full_name'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable Full Name support'),
+ '#return_value' => 1,
+ '#default_value' => variable_get('gallery_use_full_name', 0),
+ '#description' => t('Use full name from profile module in Gallery2 user data. Note that
+ enabling/disabling this only updates Gallery2 user data when the
+ Drupal user is updated (ie no sync is done immediately).'),
+ );
+
+ $form['fullname']['gallery_profile_full_name_field'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Full name profile field'),
+ '#default_value' => variable_get('gallery_profile_full_name_field', 'profile_full_name'),
+ '#size' => 64,
+ '#maxlength' => 64,
+ '#description' => t('Name of "Full Name" field in profile module.'),
+ );
+ } else {
+ $form['fullname'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Full Name settings'),
+ '#description' => t('Full names in G2 can be supported using the profile module
+ with a "Full Name" field. However the profile module is not
+ installed, so this functionality is not available. If you install
+ it you will have more options here.'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE,
+ );
+ }
+
+ // Image Block settings
+ $typeMap = array(
+ 'randomImage' => t('Random image'),
+ 'recentImage' => t('Recent image'),
+ 'viewedImage' => t('Viewed image'),
+ 'randomAlbum' => t('Random album'),
+ 'recentAlbum' => t('Recent album'),
+ 'viewedAlbum' => t('Viewed album'),
+ 'dailyImage' => t('Daily image'),
+ 'weeklyImage' => t('Weekly image'),
+ 'monthlyImage' => t('Monthly image'),
+ 'dailyAlbum' => t('Daily album'),
+ 'weeklyAlbum' => t('Weekly album'),
+ 'monthlyAlbum' => t('Monthly album'),
+ );
+
+ $paramMap = array(
+ 'title' => t('Title'),
+ 'date' => t('Date'),
+ 'views' => t('View Count'),
+ 'owner' => t('Item owner'),
+ 'heading' => t('Heading'),
+ 'fullSize' => t('Full Size'),
+ );
+
+ $form['block'] = _gallery_block_settings($typeMap , $paramMap);
+ $form['filter'] = _gallery_filter_settings($typeMap , $paramMap);
+ $form['g2image'] = _gallery_g2image_settings();
+ $form['search'] = _gallery_search_settings($typeMap , $paramMap);
+ $form['links'] = _gallery_links_settings();
+
+ // Debug Settings
+ $form['error'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Error Logging settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $form['error']['gallery_error_mode'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Error logging'),
+ '#default_value' => variable_get('gallery_error_mode', array(1)),
+ '#options' => array(1 => t('Watchdog'),
+ 2 => t('Output to the browser')),
+ '#description' => t('Choose where errors are displayed.'),
+ );
+
+ $form['gallery_valid'] = array(
+ '#type' => 'value',
+ '#value' => variable_get('gallery_valid', 0),
+ );
+
+ return $form;
+}
+
+/**
+ * Settings for gallery image block
+ *
+ */
+function _gallery_block_settings($typeMap , $paramMap) {
+ $form['block'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Gallery Image Block settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $numimages = variable_get('gallery_block_num_images', 3);
+ $form['block']['gallery_block_num_images'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Number of images in block'),
+ '#default_value' => $numimages,
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Choose the number of images to appear. You will need to submit the form if you have increased the number in order to choose the image types.'),
+ );
+
+ $gallery_block_block = variable_get('gallery_block_block', array('randomImage'));
+ $form['block']['gallery_block_block'] = array(
+ '#tree' => 1,
+ );
+ $typeMap2 = array_merge(array('none' => t('None')), $typeMap);
+ for ($i=0; $i<$numimages; $i++) {
+ $form['block']['gallery_block_block'][$i] = array(
+ '#type' => 'select',
+ '#title' => '',
+ '#default_value' => $gallery_block_block[$i],
+ '#options' => $typeMap2,
+ '#description' => '',
+ );
+ }
+ $form['block']['gallery_block_block'][0]['#title'] = t('Image types');
+ $form['block']['gallery_block_block'][$i-1]['#description'] =
+ t('Pick the type of images you\'d like to see. You can select the same type more than once.');
+
+ $form['block']['gallery_block_show'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Image data'),
+ '#default_value' => variable_get('gallery_block_show', array('title', 'heading')),
+ '#options' => $paramMap,
+ '#description' => t('Choose the item metadata you\'d like to display.'),
+ );
+
+ $form['block']['gallery_maxsize'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Thumbnail size'),
+ '#default_value' => variable_get('gallery_maxsize', 150),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#description' => t('If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
+ );
+
+ $form['block']['gallery_album_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Album frame'),
+ '#default_value' => variable_get('gallery_album_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your Gallery2 install for a complete list. Use "none" or blank for no frame.'),
+ );
+
+ $form['block']['gallery_item_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Item frame'),
+ '#default_value' => variable_get('gallery_item_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your Gallery2 install for a complete list. Use "none" or blank for no frame.'),
+ );
+
+ $form['block']['gallery_link_target'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link target'),
+ '#default_value' => variable_get('gallery_link_target', ''),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a link target (eg "_blank", "_new").'),
+ );
+ return $form['block'];
+}
+
+/**
+ * Settings for gallery filter
+ *
+ */
+function _gallery_filter_settings($typeMap , $paramMap) {
+ $form['filter'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Gallery Filter settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+//we don't include specificItem, since it can be selected automatically if n=1
+ $form['filter']['gallery_filter_prefix'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Filter prefix'),
+ '#default_value' => variable_get('gallery_filter_prefix', 'G2'),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#description' => t('Prefix to use with filter. Example: \'G2\' means you use [G2: 999].'),
+ );
+
+ $form['filter']['gallery_filter_default_block_type'] = array(
+ '#type' => 'select',
+ '#title' => t('Image Block Type'),
+ '#default_value' => variable_get('gallery_filter_default_block_type', 'viewedImage'),
+ '#options' => $typeMap,
+ '#description' => t('Pick default type of image block you\'d like to use, default is Recent image. Viewed image is by most clicks.'),
+ );
+
+ $form['filter']['gallery_filter_can_cache'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Cache gallery filter pages'),
+ '#default_value' => variable_get('gallery_filter_can_cache', 1),
+ '#description' => t('By default the gallery filter output is cached by Drupal to speed up page loading. However, it will not cache the css class info for the frames. The best approach is the make sure that the sidebar image block and the gallery filter images use the same frames. If you are unable to do this you will have to deselect this option to force Drupal not to cache the pages, or else your frames will not appear. If you change this option you will need to go to <a href="%link">admin/filters</a> and re-save the image formats that use gallery filter.', array('%link' => url('admin/filters'))),
+ );
+
+ $form['filter']['gallery_filter_n_images'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default Number of Images'),
+ '#default_value' => variable_get('gallery_filter_n_images', 1),
+ '#size' => 3,
+ '#maxlength' => 3,
+ '#description' => t('How many images you want the default block to show. Best to keep at 1 and use the n parameter.'),
+ );
+//////*********in fact, should we remove this option all together? because the way it is now, if you change this to n>1
+//then instances where n was not specified and item_id is a specific item, the block breaks and nothing is shown.
+ $form['filter']['gallery_filter_default_show'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Default Image Block Settings'),
+ '#default_value' => variable_get('gallery_filter_default_show', array('none')),
+ '#options' => $paramMap,
+ '#description' => t('Choose the item metadata you\'d like to display by default. This will change all instances where show parameter was not specified.'),
+ );
+
+ $form['filter']['gallery_filter_default_size'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default thumbnail size'),
+ '#default_value' => variable_get("gallery_filter_default_size", "150"),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#description' => t('If no size is specified when calling the filter, this size will be used. If you want your size to be bigger than the thumbnail size for that image as defined in your Gallery2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
+ );
+
+ $form['filter']['gallery_filter_default_album_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default album frame'),
+ '#default_value' => variable_get('gallery_filter_default_album_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame. '),
+ );
+
+ $form['filter']['gallery_filter_default_item_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default item frame'),
+ '#default_value' => variable_get('gallery_filter_default_item_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use \'none\' or blank for no frame.'),
+ );
+
+ $form['filter']['gallery_filter_default_link_target'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default Link target'),
+ '#default_value' => variable_get('gallery_filter_default_link_target', ''),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a link target (eg "_blank", "_new").'),
+ );
+
+ $form['filter']['gallery_filter_default_div_class'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default class'),
+ '#default_value' => variable_get('gallery_filter_default_div_class', 'nowrap'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('left, right, or nowrap. (See gallery_filter.css to add more or modify these.)'),
+ );
+ return $form['filter'];
+}
+
+/**
+ * Settings for gallery search
+ *
+ */
+function _gallery_search_settings($typeMap , $paramMap) {
+ $form['search'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Search settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $form['search']['gallery_search_max_items'] = array(
+ '#type' => 'select',
+ '#title' => t('Max number of search results'),
+ '#default_value' => variable_get('gallery_search_max_items', 50),
+ '#options' => array(25=>25, 50=>50, 100=>100, 250=>250),
+ '#description' => t('Enter the maximum number of search results returned per Gallery2 Module. Higher numbers will give slower searching.'),
+ );
+
+ $form['search']['gallery_search_num_per_row'] = array(
+ '#type' => 'select',
+ '#title' => t('Number of search results per table row'),
+ '#default_value' => variable_get('gallery_search_num_per_row', 3),
+ '#options' => array(1=>1, 2=>2, 3=>3, 4=>4, 5=>5),
+ '#description' => t('Enter the number of search results per row in the paged table.'),
+ );
+
+ $form['search']['gallery_search_max_rows_per_pager'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Number of rows per page'),
+ '#default_value' => variable_get('gallery_search_max_rows_per_pager', 5),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#description' => t('Enter the number of search results per row in the paged table.'),
+ );
+
+ $form['search']['gallery_search_show_thumbs'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Display thumbnails'),
+ '#default_value' => variable_get('gallery_search_show_thumbs', 1),
+ '#description' => t('Display thumbnail images for the search results.'),
+ );
+
+ $form['search']['gallery_search_block_show'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Image data'),
+ '#default_value' => variable_get('gallery_search_block_show', array('title' => t('Title'))),
+ '#options' => $paramMap,
+ '#description' => t('Choose the item metadata you\'d like to display.'),
+ );
+
+ $form['search']['gallery_search_maxsize'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Thumbnail size'),
+ '#default_value' => variable_get('gallery_search_maxsize', 150),
+ '#size' => 10,
+ '#maxlength' => 10,
+ '#description' => t('If you want your size to be bigger than the thumbnail size for that image as defined in your G2, you must select "Full Size" above (but note that the full image will be returned and then resized by the browser, so it may take a while to download).'),
+ );
+
+ // Add album frames, item frames and link target (using modified code from MichelleC)
+ $form['search']['gallery_search_album_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Album frame'),
+ '#default_value' => variable_get('gallery_search_album_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use "none" or blank for no frame.'),
+ );
+
+ $form['search']['gallery_search_item_frame'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Item frame'),
+ '#default_value' => variable_get('gallery_search_item_frame', 'none'),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a frame name like notebook, polaroid, shadow, slide, wood, etc. See your G2 install for a complete list. Use "none" or blank for no frame.'),
+ );
+
+ $form['search']['gallery_search_link_target'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Link target'),
+ '#default_value' => variable_get('gallery_search_link_target_', ''),
+ '#size' => 20,
+ '#maxlength' => 20,
+ '#description' => t('Enter a link target (eg "_blank", "_new").'),
+ );
+ return $form['search'];
+}
+
+/**
+ * Settings for g2image
+ *
+ */
+function _gallery_g2image_settings() {
+ $form['g2image'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Gallery Image Assist (g2image) settings'),
+ '#description' => '',
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+
+ $form['g2image']['gallery_g2image_mode'] = array(
+ '#type' => 'select',
+ '#title' => t('Mode'),
+ '#default_value' => variable_get('gallery_g2image_mode', 'disabled'),
+ '#options' => array(
+ 'disabled' => t('Disabled'),
+ 'standalone' => t('Standalone'),
+ 'tinymce' => t('TinyMCE'),
+ ),
+ '#description' => t('Determines the mode of operation. For anything other than \'Disabled\' the g2image application has to be installed. See the INSTALL.txt instructions. In \'Standalone\' mode a button will be visible under textfields to launch the g2image window. In \'TinyMCE\' mode the g2image button can be used in the tinymce toolbar. Note that the TinyMCE version will NOT work wih Safari - use the standalone version instead.'),
+ );
+
+ $options = array(
+ t('Show on every page except the listed pages.'),
+ t('Show on only the listed pages.')
+ );
+ $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => theme('placeholder', 'blog'), '%blog-wildcard' => theme('placeholder', 'blog/*'), '%front' => theme('placeholder', '<front>')));
+
+ $form['g2image']['gallery_g2image_only_listed_pages'] = array(
+ '#type' => 'radios',
+ '#title' => t('Show g2image link on specific pages (Standalone mode only)'),
+ '#default_value' => variable_get('gallery_g2image_only_listed_pages', 1),
+ '#options' => $options,
+ );
+
+ $form['g2image']['gallery_g2image_std_pages'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Pages (Standalone mode only)'),
+ '#default_value' => variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages')),
+ '#description' => $description
+ );
+
+ $form['g2image']['gallery_g2image_sortby'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Sort Order'),
+ '#default_value' => variable_get('gallery_g2image_sortby', 'title_asc'),
+ '#options' => array(
+ 'title_asc' => t('Gallery2 Title (A-z)'),
+ 'title_desc' => t('Gallery2 Title (z-A)'),
+ 'name_asc' => t('Filename (A-z)'),
+ 'name_desc' => t('Filename (z-A)'),
+ 'mtime_desc' => t('Last Modification (newest first)'),
+ 'mtime_asc' => t('Last Modification (oldest first)'),
+ ),
+ '#description' => t('Determines the default sorting order.'),
+ );
+
+ $form['g2image']['gallery_g2image_images_per_page'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Number of images per page'),
+ '#default_value' => variable_get('gallery_g2image_images_per_page', 20),
+ '#options' => array(10=>10, 20=>20, 30=>30, 40=>40, 50=>50, 60=>60),
+ '#description' => t('Choose the default number of images per page.'),
+ );
+
+ $form['g2image']['gallery_g2image_display_filenames'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Display Options'),
+ '#default_value' => variable_get('gallery_g2image_display_filenames', 'thumbnails'),
+ '#options' => array(
+ 'thumbnails' => t('Thumbnails only'),
+ 'filenames' => t('Thumbnails with title and filename'),
+ ),
+ '#description' => t('Choose the default display option for images.'),
+ );
+
+ $form['g2image']['gallery_g2image_click_mode'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Click Mode'),
+ '#default_value' => variable_get('gallery_g2image_click_mode', 'one_click_insert'),
+ '#options' => array(
+ 'one_click_insert' => t('Insert using Default settings'),
+ 'show_advanced_options' => t('Open the Advanced Options Menu'),
+ ),
+ '#description' => t('The default settings for the "Results of clicking on an image:" option'),
+ );
+
+ $form['g2image']['gallery_g2image_click_mode_variable'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('"Results of clicking on an image:" option is available to user'),
+ '#default_value' => variable_get('gallery_g2image_click_mode_variable', 1),
+ '#description' => t('Determines if the user can change the "Results of clicking on an image:" option.'),
+ );
+
+ $form['g2image']['gallery_g2image_default_action'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Action'),
+ '#default_value' => variable_get('gallery_g2image_default_action', 'drupal_g2_filter'),
+ '#options' => array(
+ 'drupal_g2_filter' => t('Gallery Filter ID'),
+ 'thumbnail_image' => t('Thumbnail with link to image'),
+ 'thumbnail_album' => t('Thumbnail with link to parent album'),
+ 'thumbnail_custom_url' => t('Thumbnail with link to custom URL'),
+ 'thumbnail_only' => t('Thumbnail only'),
+ 'link_image' => t('Text link to image'),
+ 'link_parent' => t('Text link to parent album'),
+ ),
+ '#description' => t('Choose the default method of inserting the image info.'),
+ );
+
+ $form['g2image']['gallery_g2image_custom_url'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Default custom url'),
+ '#default_value' => variable_get('gallery_g2image_custom_url', 'http://'),
+ '#size' => 50,
+ '#maxlength' => 50,
+ '#description' => t('The default custom url. Used with \'Thumbnail with link to custom URL\' action setting'),
+ );
+
+ // Fix - G2 prefix
+
+ $gallery_g2image_custom_class = variable_get('gallery_g2image_custom_class', array());
+ $css_options = array(
+ 'none' => t('None'),
+ 'g2image_normal' => t('Normal'),
+ 'g2image_float_left' => t('Float Left'),
+ 'g2image_float_right' => t('Float Right'),
+ 'g2image_centered' => t('Centered'),
+ );
+
+ $add_css_options = array();
+ foreach ($gallery_g2image_custom_class as $key => $value) {
+ if ($value) {
+ $add_css_options[$value] = $value;
+ }
+ }
+ $css_options = array_merge($css_options, $add_css_options);
+
+ $form['g2image']['gallery_g2image_default_alignment'] = array(
+ '#type' => 'select',
+ '#title' => t('Default Alignment'),
+ '#default_value' => variable_get('gallery_g2image_default_alignment', 'none'),
+ '#options' => $css_options,
+ '#description' => t('Choose the default alignment of images.'),
+ );
+
+ $form['g2image']['gallery_g2image_custom_class'] = array(
+ '#tree' => 1,
+ );
+
+ for ($i=1; $i<=4; $i++) {
+ $form['g2image']['gallery_g2image_custom_class'][$i] = array(
+ '#type' => 'textfield',
+ '#title' => t('Custom Class %index', array('%index' => $i)),
+ '#default_value' => $gallery_g2image_custom_class[$i],
+ '#size' => 20,
+ '#maxlength' => 50,
+ );
+ }
+ $form['g2image']['gallery_g2image_custom_class'][$i-1]['#description'] =
+ t('Additional css classes to be available for selection (must be defined in .css file).');
+
+ $form['g2image']['gallery_g2image_class_mode'] = array(
+ '#type' => 'select',
+ '#title' => t('Alignment Class Insertion Point'),
+ '#default_value' => variable_get('gallery_g2image_class_mode', 'img'),
+ '#options' => array(
+ 'img' => t('<img class=...>'),
+ 'div' => t('<div class=...><img ...>'),
+ ),
+ '#description' => t('Determines where the alignment class will be inserted. If you choose \'&lt;div class=...&gt;&lt;img ...&gt;\', you will have to manually delete any &lt;div&gt; tags manually after deleting images from the TinyMCE window.'),
+ );
+ return $form['g2image'];
+}
+
+/**
+ * Settings for links section
+ *
+ */
+function _gallery_links_settings() {
+ if (variable_get('gallery_valid', 0)) {
+ $g2Uri = variable_get('gallery_embed_uri', '?q=gallery');
+ $desc = t('Here are some links to the parts of Gallery2 Site Admin most relevant to gallery.module.');
+ $desc .= '<ul>';
+ $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=core.AdminModules">Modules</a> : ' . t('To install, activate or configure the required and optional modules relating to gallery.module (Image Block, Image Frame, URL Rewrite, Album Select).') . '</li>';
+ $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=core.AdminThemes&g2_mode=defaults">Themes</a> : ' . t('To add/remove blocks in the sidebar.') . '</li>'; $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=rewrite.AdminRewrite&g2_mode=setup">Embedded URL Rewrite settings</a> : ' . t('To configure the correct .htaccess path and define the rewrite rules.') . '</li>';
+ $desc .= '<li><a href= "' . $g2Uri . '&g2_view=core.SiteAdmin&g2_subView=core.AdminCore">Cookie Settings</a> : '. t('Only needed for a small number of site configurations, such as the use of different subdomains for Gallery2 and Drupal.') . '</li>';
+ $desc .= '</ul>';
+ } else {
+ $desc = t('This section will contain links to the parts of Gallery2 Site Admin most relevant to gallery.module. It is only available when your Embedded Gallery installation is valid, which it currently is not.');
+ }
+ $form['links'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Links to Gallery2 Site Admin sections most relevant to Drupal (advanced)'),
+ '#description' => $desc,
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ return $form['links'];
+}
+
+
+/**
+ * Validate the gallery form settings
+ */
+function gallery_settings_form_validate($form_id, &$form) {
+ global $form_values;
+ include_once(drupal_get_path('module', 'gallery') . '/G2EmbedDiscoveryUtilities.class');
+ include_once(drupal_get_path('module', 'gallery') . '/G2EmbedTestUtilities.class');
+
+ $gallery_valid = 1;
+
+ // Store the original values for the variables
+ $orig['g2Uri'] = $form_values['gallery_uri'];
+ $orig['g2EmbedPath'] = $form_values['gallery_dir'];
+ $orig['embedUri'] = $form_values['gallery_embed_uri'];
+
+ // Check these variables
+ list($num_errors, $num_warnings, $new, $results) =
+ G2EmbedTestUtilities::checkLocations($orig, $form_values['gallery_autodetect_dir']);
+ if ($num_errors) {
+ $gallery_valid = 0;
+ }
+
+ // Update the variables with the new validated ones
+ $form_values['gallery_uri'] = $new['g2Uri'];
+ $form_values['gallery_dir'] = $new['g2EmbedPath'];
+ $form_values['gallery_embed_uri'] = $new['embedUri'];
+
+ // Perform pre-init tests. If they fail then do not init the gallery as there may be an issue
+ list($num_errors, $num_warnings, $pre_init_results) = G2EmbedTestUtilities::preInitTests();
+ $results = array_merge($results, $pre_init_results);
+ if ($num_errors) {
+ $gallery_valid = 0;
+ }
+
+ // If the filepaths seem correct then check Gallery2 works and has the correct module configs
+ // This code is modified from the WPG2 integration code -- Thanks.
+ if ($gallery_valid) {
+ // Gallery install is thought valid, so init it.
+ $title = t('Gallery2 Init:');
+ $vars['gallery_uri'] = $form_values['gallery_uri'];
+ $vars['gallery_dir'] = $form_values['gallery_dir'];
+ $vars['gallery_embed_uri'] = $form_values['gallery_embed_uri'];
+ $vars['gallery_valid'] = true;
+ list ($success, $ret) = _gallery_init(true, $vars);
+ if (!$success) {
+ // Gallery install was supposed to be valid, but it still failed. Something is wrong.
+ $results['gallery_init']['title'] = $title;
+ $results['gallery_init']['error'] = true;
+ $results['gallery_init']['notice'] = t('Everything seemed OK, but the Gallery could still not be initialised. Perhaps a manually entered value is incorrect.');
+ $gallery_valid = 0;
+ } else {
+ $results['gallery_init']['title'] = $title;
+ $results['gallery_init']['success'] = true;
+
+ list($num_errors, $num_warnings, $post_init_results) = G2EmbedTestUtilities::postInitTests();
+ if ($num_errors) {
+ $gallery_valid = 0;
+ }
+ // Check for changed embedUri
+ /* No longer needed as the URL Rewrite config below will do it
+ if ($form_values['gallery_embed_uri'] != variable_get('gallery_embed_uri', '?q=gallery')) {
+ $post_init_results['urlrewrite3']['title'] = t('Gallery2 URL Rewrite rules:');
+ $post_init_results['urlrewrite3']['warning'] = true;
+ $post_init_results['urlrewrite3']['notice'] = t('The \'Embed URI\' setting has changed. If you are using the URL Rewrite module in Gallery2 you will need to regenerate the rules (just click the \'save\' button on the Embedded URL Rewrite page).');
+ }*/
+
+ // Update the URL Rewrite Configuration
+ if ($post_init_results['urlrewrite']['success']) {
+ list($url_conf_num_errors, $url_conf_num_warnings, $post_init_results['urlrewrite2']) =
+ _gallery_configure_url_rewrite();
+ }
+
+ $results = array_merge($results, $post_init_results);
+
+ // Setup the cookie path - removed for now (see above)
+ /*
+ $path = $form_values['gallery_cookie_path'];
+ $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'cookie.path', $path);
+ */
+
+ GalleryEmbed::done();
+ }
+ }
+ // Validate the g2image settings
+ list($num_errors, $num_warnings, $results_g2image) =
+ _gallery_g2image_settings_form_validate(&$form_values);
+ if ($results_g2image) {
+ $results['gallery_g2image'] = $results_g2image;
+ }
+
+ // Test again for validity
+ if ($gallery_valid) {
+ $results['gallery_valid']['title'] = t('Overall Status:');
+ $results['gallery_valid']['success'] = true;
+ } else {
+ $results['gallery_valid']['title'] = t('Overall Status:');
+ $results['gallery_valid']['error'] = true;
+ $results['gallery_valid']['notice'] = t('You need to fix the above errors before Gallery2 will be embedded in Drupal.');
+ }
+
+ $message = t('Embedded Gallery2 Status: ').'<ul>';
+ foreach ($results as $key=>$result) {
+ $message .= '<li>' . t($result['title']) . ' ';
+ if (isset($result['success']) && $result['success']) {
+ $message .= '<span class=\'g2_embed_success\'>' . t('Success') . '</span>';
+ } else if (isset($result['warning']) && $result['warning']) {
+ $message .= '<span class=\'g2_embed_warning\'>' . t('Warning') . '</span>';
+ $message .= '<ul><li>' . t($result['notice']) . '</li></ul>';
+ } else if (isset($result['error']) && $result['error']) {
+ $message .= '<span class=\'g2_embed_error\'>' . t('Error') . '</span>';
+ $message .= '<ul><li>' . t($result['notice']) . '</li></ul>';
+ } else if (isset($result['advise']) && $result['advise']) {
+ $message .= '<span class=\'g2_embed_warning\'>' . t('Advisory') . '</span>';
+ $message .= '<ul><li>' . t($result['notice']) . '</li></ul>';
+ }
+ }
+ $message .= '</ul>';
+ drupal_set_message($message);
+ $form_values['gallery_valid'] = $gallery_valid;
+
+ // Gallery Image Block Settings validation
+ // Need to truncate the gallery_block_block variable to the entered number of blocks
+ if (count($form_values['gallery_block_block']) != $form_values['gallery_block_num_images']) {
+ $form_values['gallery_block_block'] = array_slice(
+ $form_values['gallery_block_block'], 0, $form_values['gallery_block_num_images']);
+ }
+}
+
+/**
+ * Configure URL rewrite (from WPG2 code)
+ */
+function _gallery_configure_url_rewrite() {
+ $num_errors = 0;
+ $num_warnings = 0;
+
+ // Find the public path to drupal from the base_url
+ global $base_url;
+ $http = 'http' . (isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] == 'on' ? 's' : '' : '');
+ $public_path = str_replace($http . '://' . $_SERVER['HTTP_HOST'],'', $base_url);
+
+
+ // Find the path to drupal. Will this always work?
+ // FIX NEEDED: This will fail if the module is installed in the sites/XXX/modules dir.
+ // Probably not a big deal for 99% of people.
+ $drupal_root = dirname(__FILE__);
+ $gallery_path = drupal_get_path('module', 'gallery');
+ $htaccess_path = str_replace($gallery_path, '', $drupal_root);
+
+ $title = t('Gallery2 URL Rewrite Module Auto-Configuration:');
+ $results['urlrewrite']['title'] = $title;
+
+ list ($ret, $rewriteApi) = GalleryCoreApi::newFactoryInstance('RewriteApi');
+ if ($ret) {
+ /* G2 Error handling */
+ // All other tests were run already
+ $results['urlrewrite']['error'] = true;
+ $results['urlrewrite']['notice'] =t(
+ 'Gallery2 Error when trying to access URL Rewrite Module status. %ret',
+ array('%ret' => $ret->getAsHtml()));
+ }
+ list ($ret, $params) = $rewriteApi->fetchEmbedConfig();
+
+ // Check if .htaccess exists. If not and path is writable, create it.
+ // This should only occur for multi-site installs as the main drupal dir always has a .htaccess
+ if (!file_exists($htaccess_path . '.htaccess')) {
+ // Better to check for the file, not the dir as if not writable fopen returns a visible warning
+ if (is_writable($htaccess_path . '.htaccess')) {
+ $f = fopen($htaccess_path . '.htaccess', 'w');
+ fclose($f);
+ } else {
+ $results['urlrewrite']['error'] = true;
+ $results['urlrewrite']['notice'] = t('There is no .htaccess file in your defined Drupal directory (%dir) and the directory is not writable. Please create a writable .htaccess file in that directory.', array('%dir' => $htaccess_path));
+ $num_errors++;
+ return array($num_errors, $num_warnings, $results['urlrewrite']);
+ }
+ }
+
+ if (file_exists($htaccess_path . '.htaccess')) {
+ if (is_writable($htaccess_path . '.htaccess')) {
+
+ // Set the G2 rewrite Values
+ $params['embeddedLocation'] = $public_path;
+ $params['embeddedHtaccess'] = $htaccess_path;
+
+ // Save the G2 rewrite Values
+ list ($ret, $code, $err) = $rewriteApi->saveEmbedConfig($params);
+
+ if ( $code > 0 ) {
+ list ($ret, $errstr) = $err;
+ $errstr = $code." - ".$errstr;
+ $results['urlrewrite']['error'] = true;
+ $results['urlrewrite']['notice'] = t('The Gallery2 URL Rewrite module returned the following error') . '<pre>' . $errstr . '</pre>';
+ $num_errors++;
+ }
+ $results['urlrewrite']['success'] = true;
+ } else {
+ $results['urlrewrite']['error'] = true;
+ $results['urlrewrite']['notice'] = t('The .htaccess file in your defined Drupal directory (%dir) is not writable. Please CHMOD it to 644 (or 666 if 644 does not work).', array('%dir' => $htaccess_path));
+ $num_errors++;
+ }
+ }
+ return array($num_errors, $num_warnings, $results['urlrewrite']);
+}
+
+/**
+ * Validate the gallery g2image settings and saves the config file if needed.
+ */
+function _gallery_g2image_settings_form_validate(&$form_values) {
+ switch ($form_values['gallery_g2image_mode']) {
+ case 'tinymce':
+ $mode = t('TinyMCE');
+ $path = drupal_get_path('module', 'tinymce');
+ $path .= '/tinymce/jscripts/tiny_mce/plugins/g2image';
+ break;
+ case 'standalone':
+ $mode = t('Standalone');
+ $path = drupal_get_path('module', 'gallery');
+ $path .= '/g2image';
+ break;
+ default:
+ return array(0, 0, array());
+ }
+ $title = 'Gallery2 Image Assist (g2image) Status:';
+ // Note that file_check_directory uses &$path and will strip the trailing '/'
+ if (!file_check_directory($path)) {
+ $results['gallery_g2image']['title'] = $title;
+ $results['gallery_g2image']['warning'] = true;
+ $results['gallery_g2image']['notice'] = t('g2image does not seem to be installed for %mode mode. Please see the INSTALL.txt for instructions.', array('%mode' => $mode));
+ $num_warnings++;
+ return array($num_errors, $num_warnings, $results['gallery_g2image']);
+ }
+ $cr = "\n";
+ $g2ic_gallery2_path = $form_values['gallery_dir'];
+ $g2ic_use_full_path = (substr($g2ic_gallery2_path, 0, 1) == '/') ? 'TRUE' : 'FALSE';
+ $form_values['gallery_g2image_custom_url'] =
+ check_url($form_values['gallery_g2image_custom_url']);
+ $g2ic_display_filenames = ($form_values['gallery_g2image_display_filenames'] == 'filenames') ?
+ 'TRUE' : 'FALSE';
+ $g2ic_custom_class = array();
+ foreach ($form_values['gallery_g2image_custom_class'] as $key => $value) {
+ $g2ic_custom_class[$key] = ($value) ? $value : 'not_used';
+ }
+
+ $g2ic_custom_class_1 = ($form_values['gallery_g2image_custom_class_1']) ?
+ $form_values['gallery_g2image_custom_class_1'] : 'not_used';
+ $g2ic_custom_class_2 = ($form_values['gallery_g2image_custom_class_2']) ?
+ $form_values['gallery_g2image_custom_class_2'] : 'not_used';
+ $g2ic_custom_class_3 = ($form_values['gallery_g2image_custom_class_3']) ?
+ $form_values['gallery_g2image_custom_class_3'] : 'not_used';
+ $g2ic_custom_class_4 = ($form_values['gallery_g2image_custom_class_4']) ?
+ $form_values['gallery_g2image_custom_class_4'] : 'not_used';
+
+ $content = '<?php' .$cr;
+ $content .= '// Configuration File for Gallery 2 Image Chooser for TinyMCE' . $cr;
+ $content .= '// Version 2.0 RC4 and above' . $cr;
+ $content .= '// By Kirk Steffensen - http://g2image.steffensenfamily.com/' . $cr;
+ $content .= '// Released under the GPL version 2.' . $cr;
+ $content .= '// A copy of the license is in the root folder of this plugin.' . $cr;
+ $content .= $cr . '// Automatically generated by gallery.module (admin/settings/gallery).' . $cr;
+ $content .= '// DO NOT EDIT' . $cr;
+ $content .= '$g2ic_image_ext_regex = \'@(jpg|jpeg|png|gif|bmp|svg)$@i\';' . $cr;
+ $content .= '$g2ic_gallery2_path = \'' . $g2ic_gallery2_path . '\';' . $cr;
+ $content .= '$g2ic_embedded_mode = TRUE;' . $cr;
+ $content .= '$g2ic_use_full_path = ' . $g2ic_use_full_path. ';' . $cr;
+ $content .= '$g2ic_gallery2_uri = \'' . $form_values['gallery_uri'] . '\';' . $cr;
+ $content .= '$g2ic_embed_uri = \'' . $form_values['gallery_embed_uri'] . '\';' . $cr;
+ $content .= '$g2ic_drupal_g2_filter = TRUE;' . $cr;
+ $content .= '$g2ic_language = \'en\';' . $cr;
+ $content .= '$g2ic_images_per_page = ' . $form_values['gallery_g2image_images_per_page'] . ';' . $cr;
+ $content .= '$g2ic_display_filenames = ' . $g2ic_display_filenames . ';' . $cr;
+ $content .= '$g2ic_default_alignment = \'' . $form_values['gallery_g2image_default_alignment'] . '\';' . $cr;
+ $content .= '$g2ic_custom_class_1 = \'' . $g2ic_custom_class[1] . '\';' . $cr;
+ $content .= '$g2ic_custom_class_2 = \'' . $g2ic_custom_class[2] . '\';' . $cr;
+ $content .= '$g2ic_custom_class_3 = \'' . $g2ic_custom_class[3] . '\';' . $cr;
+ $content .= '$g2ic_custom_class_4 = \'' . $g2ic_custom_class[4] . '\';' . $cr;
+ $content .= '$g2ic_class_mode = \'' . $form_values['gallery_g2image_class_mode'] . '\';' . $cr;
+ $content .= '$g2ic_click_mode = \'' . $form_values['gallery_g2image_click_mode'] . '\';' . $cr;
+ $content .= '$g2ic_click_mode_variable = ' . $form_values['gallery_g2image_click_mode_variable'] . ';' . $cr;
+ $content .= '$g2ic_default_action = \'' . $form_values['gallery_g2image_default_action'] . '\';' . $cr;
+ $content .= '$g2ic_sortby = \'' . $form_values['gallery_g2image_sortby'] . '\';' . $cr;
+ $content .= '$g2ic_custom_url = \'' . $form_values['gallery_g2image_custom_url'] . '\';' . $cr;
+
+ $filename = $path . '/config.php';
+ if (is_writable($filename) == false) {
+ $results['gallery_g2image']['title'] = $title;
+ $results['gallery_g2image']['warning'] = true;
+ $results['gallery_g2image']['notice'] = t('Could not write to g2image config file. Please check the permissions for %filename.', array('%filename' => $filename));
+ $num_warnings++;
+ return array($num_errors, $num_warnings, $results['gallery_g2image']);
+ }
+ $handle = fopen($filename, "w");
+ if (fwrite($handle, $content) === FALSE) {
+ $results['gallery_g2image']['title'] = $title;
+ $results['gallery_g2image']['warning'] = true;
+ $results['gallery_g2image']['notice'] = t('Could not write to g2image config file. Please check the permissions for %filename.', array('%filename' => $filename));
+ $num_warnings++;
+ return array($num_errors, $num_warnings, $results['gallery_g2image']);
+ } else {
+ $results['gallery_g2image']['title'] = $title;
+ $results['gallery_g2image']['success'] = true;
+ }
+ fclose($handle);
+ return array($num_errors, $num_warnings, $results['gallery_g2image']);
+}
+?> \ No newline at end of file
diff --git a/gallery_user.inc b/gallery_user.inc
new file mode 100644
index 0000000..52f4027
--- /dev/null
+++ b/gallery_user.inc
@@ -0,0 +1,308 @@
+<?php
+// $Id$
+
+/**
+ * gallery.module : gallery_user.inc
+ * User Modification Functions (create, update, delete...)
+ */
+
+$path = drupal_get_path('module', 'gallery');
+require_once($path . '/gallery_roles.inc');
+
+/**
+ * Insert new user
+ */
+function gallery_insert_user(&$edit, $user) {
+ list ($success, $ret) = _gallery_init();
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+
+ list ($success, $ret) = gallery_modify_user($user, 'create');
+ if ($ret) {
+ gallery_error(t('Error creating Gallery user'), $ret);
+ return;
+ }
+
+ GalleryEmbed::done();
+ return;
+}
+
+/**
+ * Update a user with new information
+ */
+function gallery_update_user(&$edit, $user) {
+ list ($success, $ret) = _gallery_init();
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+
+ // on update we can't be sure how much info $edit will contain.
+ // $user is a copy, so we can modify it here.
+ $user->name = ($edit['name']) ? $edit['name'] : $user->name;
+ $user->language = ($edit['language']) ? $edit['language'] : gallery_get_language($user);
+ $user->pass = ($edit['pass']) ? md5($edit['pass']) : $user->pass;
+ $user->status = ($edit['status']) ? $edit['status'] : $user->status;
+ $user->mail = ($edit['email']) ? $edit['mail'] : $user->mail;
+ // Note: $user->roles is organized as [$rid]=>[$role_name], but edit['roles'] is [$rid]=>[$position]
+ $user->roles = ($edit['roles']) ? $edit['roles'] : $user->roles;
+ // Use full name from profile if it exists
+ $fullnamefield = variable_get('gallery_profile_full_name_field', 'profile_full_name');
+ $usefullname = variable_get('gallery_use_full_name', 0) && module_exist('profile');
+ if (($edit[$fullnamefield] || $user->$fullnamefield) && $usefullname) {
+ $user->$fullnamefield = ($edit[$fullnamefield]) ? $edit[$fullnamefield] : $user->$fullnamefield;
+ } else {
+ $user->$fullnamefield = $name;
+ }
+
+ list ($success, $ret) = gallery_modify_user($user, 'update');
+ if ($ret) {
+ gallery_error(t('Error updating Gallery user'), $ret);
+ return;
+ }
+ GalleryEmbed::done();
+ return;
+}
+
+/**
+ * Delete the user from the Gallery
+ */
+function gallery_delete_user($user) {
+ list ($success, $ret) = _gallery_init();
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+ $ret = GalleryEmbed::deleteUser($user->uid);
+ if ($ret) {
+ gallery_error(t('Error deleting Gallery user'), $ret);
+ }
+ GalleryEmbed::done();
+ return;
+}
+
+/**
+ * Modify (create/update) a user
+ */
+function gallery_modify_user($user, $action = 'create') {
+ $fullnamefield = variable_get('gallery_profile_full_name_field', 'profile_full_name');
+ $usefullname = variable_get('gallery_use_full_name', 0) && module_exist('profile');
+ $fullname = ($user->$fullnamefield && $usefullname) ? $user->$fullnamefield : $user->name;
+ // Generate random password for gallery2 if user is blocked, to avoid them being able to login
+ // to gallery2 if not-embedded operation is allowed.
+ $pass = ($user->status == 1) ? $user->pass : user_password(20);
+
+ switch ($action) {
+ case 'create' :
+ $ret = GalleryEmbed::createUser($user->uid,
+ array('username' => $user->name,
+ 'email' => $user->mail,
+ 'fullname' => $fullname,
+ 'language' => gallery_get_language($user),
+ 'hashedpassword' => $pass,
+ 'hashmethod' => 'md5'));
+ if ($ret) {
+ return array(false, $ret);
+ }
+ // Add group info
+ gallery_sync_groups_for_user($user);
+ break;
+ case 'update' :
+ $ret = GalleryEmbed::updateUser($user->uid,
+ array('username' => $user->name,
+ 'fullname' => $fullname,
+ 'email' => $user->mail,
+ 'language' => gallery_get_language($user),
+ 'hashedpassword' => $pass,
+ 'hashmethod' => 'md5'));
+ if ($ret) {
+ // try to create user then.
+ $ret = GalleryEmbed::createUser($user->uid,
+ array('username' => $user->name,
+ 'fullname' => $fullname,
+ 'email' => $user->mail,
+ 'language' => gallery_get_language($user),
+ 'hashedpassword' => $pass,
+ 'hashmethod' => 'md5'));
+ if ($ret) {
+ return array(false, $ret);
+ }
+ }
+ // Add group info
+ gallery_sync_groups_for_user($user);
+ break;
+ }
+ return array(true, null);
+}
+
+/* --------------------------------------------------------------------------
+ * User View Functions (view all users, view specific users,...)
+ * --------------------------------------------------------------------------
+ */
+
+/**
+ * View Gallery user details for a specific user
+ */
+function gallery_view_user($user) {
+ $g2_userinfo = gallery_user_info($user, true);
+ if ($g2_userinfo['error_msg']) {
+ $form['gallery_view_user'] = array(
+ 'title' => t('Gallery2-Drupal Sync Status'),
+ 'value' => implode(',<br />', $g2_userinfo['error_msg']) . '<br />');
+ return array(t('Gallery2') => $form);
+ }
+}
+
+/**
+ * Gallery Users Page - view a set of users
+ */
+function _gallery_users() {
+// user.module and userlist.module inspired code with some G2 stuff from Mambo embed
+ $header = array(
+ array('data' => t('ID'), 'field' => 'u.uid', 'sort' => 'asc'),
+ array('data' => t('G2ID')),
+ array('data' => t('Username'), 'field' => 'u.name'),
+ array('data' => t('Status'), 'field' => 'u.status'),
+ array('data' => t('Sync Status')),
+ t('Operations'),
+ t('G2 Operations')
+ );
+ $sql = 'SELECT u.uid, u.name, u.status, u.mail, u.pass FROM {users} u WHERE uid != 0';
+ $sql .= tablesort_sql($header);
+ $result = pager_query($sql, 50);
+
+ $status = array(t('blocked'), t('active'));
+ $destination = drupal_get_destination();
+
+ list ($success, $ret) = _gallery_init(true);
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+ $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
+ while ($account = db_fetch_object($result)) {
+ // Check if user exists in G2 database and check its info
+ $g2_userinfo = gallery_user_info($account);
+
+ $link_url = $urlGenerator->generateUrl(array('view' => 'core.SiteAdmin',
+ 'subView' => 'core.AdminEditUser',
+ 'userId' => $g2_userinfo['g2_id']));
+ $link_url = '<a href="' . $link_url . '">' . t('edit G2') . '</a>';
+
+ $g2_edituserlink = ($g2_userinfo['g2_id']>=0) ? $link_url : t('N/A');
+ $g2_id = ($g2_userinfo['g2_id']>=0) ? $g2_userinfo['g2_id'] : t('N/A');
+
+ $rows[] = array($account->uid, $g2_id, theme_username($account),
+ $status[$account->status], implode(',<br />', $g2_userinfo['error_msg']),
+ l(t('edit'), "user/$account->uid/edit", array(), $destination),
+ $g2_edituserlink);
+ }
+
+ $pager = theme('pager', NULL, 50, 0, tablesort_pager());
+ if (!empty($pager)) {
+ $rows[] = array(array('data' => $pager, 'colspan' => '5'));
+ }
+ $output = theme('table', $header, $rows);
+ $output .= theme('pager', array(), 100);
+ GalleryEmbed::done();
+ return $output;
+}
+
+/**
+ * Helper to get Gallery2 user info
+ */
+function gallery_user_info($user, $full = false) {
+ list ($success, $ret) = _gallery_init(true);
+ if (!$success) {
+ $err_msg = t('Unable to initialize embedded Gallery. You need to <a href="%link">
+ configure your embedded Gallery</a>.',
+ array('%link' => url('admin/settings/gallery')));
+ gallery_error($err_msg, $ret);
+ return;
+ }
+ $g2_userinfo['error_msg'] = array();
+ $ret = GalleryEmbed::isExternalIdMapped($user->uid, 'GalleryUser');
+ if ($ret && !($ret->getErrorCode() & ERROR_MISSING_OBJECT)) {
+ $g2_userinfo['g2_id'] = -1;
+ $g2_userinfo['error_msg'][] = t('Missing from G2');
+ $g2_userinfo['sync_ok'] = 0;
+ return $g2_userinfo;
+ }
+ // There is an ExternalId, so load the info
+ list($ret, $g2_user) = GalleryCoreApi::loadEntityByExternalId($user->uid, 'GalleryUser');
+ // In some cases the ExternalId may be present, but the user may have been deleted
+ if ($ret) {
+ $g2_userinfo['g2_id'] = -1;
+ $g2_userinfo['error_msg'][] = t('Missing from G2');
+ $g2_userinfo['sync_ok'] = 0;
+ return $g2_userinfo;
+ }
+ // Go through a number of fields in both users and check for differences
+ // The G2 object seems to have changed from $g2_user->_id to $g2_user->id
+ $g2_userinfo['g2_id'] = $g2_user->id;
+ if ($g2_user->getuserName() != $user->name ){
+ $g2_userinfo['error_msg'][] = t('Different Usernames');
+ }
+ $usefullname = variable_get('gallery_use_full_name', 0) && module_exist('profile');
+ if ($usefullname) {
+ $fullnamefield = variable_get('gallery_profile_full_name_field', 'profile_full_name');
+ $fullnameresult = db_query("SELECT v.value FROM {profile_values} v INNER JOIN {profile_fields} f ON v.fid = f.fid AND v.uid=%d WHERE f.name = '%s'", $user->uid, $fullnamefield);
+ $fullname = db_fetch_object($fullnameresult);
+ $fullname = $fullname->value;
+ $msg = t('Drupal Full Name: "') . $fullname . t('" G2 Full Name: "') . $g2_user->getfullName().'"';
+
+ if ($g2_user->getfullName() != $fullname) {
+ $g2_userinfo['error_msg'][] = t('Different Full Names');
+ } else if (!$fullname) {
+ // If usefullname is turned on, but the field is not completed, this will occur.
+ $g2_userinfo['error_msg'][] = t('Full Name missing');
+ }
+ } else {
+ if ($g2_user->getfullName() != $user->name) {
+ $g2_userinfo['error_msg'][] = t('G2 Full Name incorrect');
+ }
+ }
+ if ($g2_user->getemail() != $user->mail) {
+ $g2_userinfo['error_msg'][] = t('Different E-Mails'); //FIX
+ }
+ if ($g2_user->gethashedPassword() != $user->pass) {
+ $g2_userinfo['error_msg'][] = ($user->status) ? t('Different Passwords') : t('Blocked User');
+ }
+
+ $g2_userinfo['sync_ok'] = (!$g2_userinfo['error_msg']);
+ if ($g2_userinfo['sync_ok']) {
+ $g2_userinfo['error_msg'][] = t('OK');
+ }
+ // Get full info if needed
+ if (!$full) {
+ return $g2_userinfo;
+ }
+ list($ret, $all_itemids) = GalleryCoreApi::fetchAllItemIdsByOwnerId($g2_userinfo['g2_id']);
+ $g2_userinfo['count_total'] = count($all_itemids);
+ $g2_userinfo['count_album'] = 0;
+ $g2_userinfo['album_id'] = array();
+ // Get all albums for this user
+ list($ret, $all_albumids) = GalleryCoreApi::fetchAllItemIds('GalleryAlbumItem');
+ foreach ($all_itemids as $id => $name) {
+ if (in_array($name, $all_albumids)) {
+ $g2_userinfo['count_album']++;
+ $g2_userinfo['album_id'][] = $name;
+ }
+ }
+ return $g2_userinfo;
+}
+?> \ No newline at end of file
diff --git a/po/fr.po b/po/fr.po
deleted file mode 100644
index d299ac0..0000000
--- a/po/fr.po
+++ /dev/null
@@ -1,105 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: Drupal Module Gallery v4.6.0 French Translation\n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: 2005-09-17 17:49+0100\n"
-"Last-Translator: Ludovic Dias http://www.flashtranslation.com <admin@flashtranslation.com>\n"
-"Language-Team: flashtranslation.com <admin@flashtranslation.com>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"X-Poedit-Language: French\n"
-
-#: gallery.module:10
-msgid "Integration with Gallery2 (%gallery_url)"
-msgstr "Intégration de la Gallerie (%gallery_url)"
-
-#: gallery.module:21
-#: ;131;145;163;0
-msgid "gallery"
-msgstr "Gallerie"
-
-#: gallery.module:35
-msgid "Location of Gallery2"
-msgstr "Emplacement de Gallery2"
-
-#: gallery.module:35
-msgid "relative path to your gallery2 directory. Please include a trailing slash (\"/\")."
-msgstr "Chemin relatif de l'arborescence vers gallery2. Merci d'utiliser un trailing slash (\"/\")."
-
-#: gallery.module:37
-msgid "Random Image"
-msgstr "Image au hasard"
-
-#: gallery.module:38
-msgid "Newest Image"
-msgstr "Image la plus récente"
-
-#: gallery.module:39
-msgid "Most Viewed Image"
-msgstr "Image la plus vue"
-
-#: gallery.module:40
-msgid "Random Album"
-msgstr "Album au hasard"
-
-#: gallery.module:41
-msgid "Newest Album"
-msgstr "Album le plus récent"
-
-#: gallery.module:42
-msgid "Most Viewed Album"
-msgstr "Album le plus vu"
-
-#: gallery.module:43
-msgid "Title"
-msgstr "Titre ou Nom"
-
-#: gallery.module:44
-msgid "Date"
-msgstr "Date"
-
-#: gallery.module:45
-msgid "Views"
-msgstr "Nombre de vues"
-
-#: gallery.module:46
-msgid "Owner"
-msgstr "Propriétaire"
-
-#: gallery.module:47
-msgid "Image Blocks"
-msgstr "Blocs d'images"
-
-#: gallery.module:48
-msgid "Show"
-msgstr "Voir"
-
-#: gallery.module:49
-msgid "Gallery Block"
-msgstr "Bloc de la Gallerie"
-
-#: gallery.module:70
-msgid "Error creating gallery user"
-msgstr "Erreur dans la création d'un utilisateur de la gallerie"
-
-#: gallery.module:88
-msgid "Error updating gallery user"
-msgstr "Erreur dans la mise a jour d'un utilisateur de la gallerie"
-
-#: gallery.module:98
-msgid "Error deleting gallery user"
-msgstr "Erreur dans la destruction du compte d'un utilsateur de la Gallerie"
-
-#: gallery.module:113
-msgid "Gallery Navigation"
-msgstr "Se déplacer dans la Gallerie"
-
-#: gallery.module:114
-msgid "Gallery Image Block"
-msgstr "Bloc d'Image de la Gallerie"
-
-#: gallery.module:284
-msgid "Home"
-msgstr "Début"
-
diff --git a/po/gallery-module.pot b/po/gallery-module.pot
deleted file mode 100644
index 18dae78..0000000
--- a/po/gallery-module.pot
+++ /dev/null
@@ -1,109 +0,0 @@
-# LANGUAGE translation of Drupal (gallery.module)
-# Copyright YEAR NAME <EMAIL@ADDRESS>
-# Generated from file: gallery.module,v 1.3 2005/02/17 04:09:06 walkah
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2005-03-02 23:06+0000\n"
-"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
-"Last-Translator: NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-
-#: gallery.module:10
-msgid "Integration with Gallery2 (%gallery_url)"
-msgstr ""
-
-#: gallery.module:21;131;145;163;0
-msgid "gallery"
-msgstr ""
-
-#: gallery.module:35
-msgid "Location of Gallery2"
-msgstr ""
-
-#: gallery.module:35
-msgid "relative path to your gallery2 directory. Please include a trailing slash (\"/\")."
-msgstr ""
-
-#: gallery.module:37
-msgid "Random Image"
-msgstr ""
-
-#: gallery.module:38
-msgid "Newest Image"
-msgstr ""
-
-#: gallery.module:39
-msgid "Most Viewed Image"
-msgstr ""
-
-#: gallery.module:40
-msgid "Random Album"
-msgstr ""
-
-#: gallery.module:41
-msgid "Newest Album"
-msgstr ""
-
-#: gallery.module:42
-msgid "Most Viewed Album"
-msgstr ""
-
-#: gallery.module:43
-msgid "Title"
-msgstr ""
-
-#: gallery.module:44
-msgid "Date"
-msgstr ""
-
-#: gallery.module:45
-msgid "Views"
-msgstr ""
-
-#: gallery.module:46
-msgid "Owner"
-msgstr ""
-
-#: gallery.module:47
-msgid "Image Blocks"
-msgstr ""
-
-#: gallery.module:48
-msgid "Show"
-msgstr ""
-
-#: gallery.module:49
-msgid "Gallery Block"
-msgstr ""
-
-#: gallery.module:70
-msgid "Error creating gallery user"
-msgstr ""
-
-#: gallery.module:88
-msgid "Error updating gallery user"
-msgstr ""
-
-#: gallery.module:98
-msgid "Error deleting gallery user"
-msgstr ""
-
-#: gallery.module:113
-msgid "Gallery Navigation"
-msgstr ""
-
-#: gallery.module:114
-msgid "Gallery Image Block"
-msgstr ""
-
-#: gallery.module:284
-msgid "Home"
-msgstr ""
-