/photogallery/singapore_gallery_files/tools/localecache.php |
---|
File deleted |
/photogallery/singapore_gallery_files/tools/index.html |
---|
File deleted |
/photogallery/singapore_gallery_files/tools/convertdb.php |
---|
File deleted |
\ No newline at end of file |
/photogallery/singapore_gallery_files/tools/mod_rewrite.htaccess |
---|
File deleted |
\ No newline at end of file |
/photogallery/singapore_gallery_files/tools/cleanup.php |
---|
File deleted |
/photogallery/singapore_gallery_files/tools/compile.php |
---|
File deleted |
/photogallery/singapore_gallery_files/tools/extract.php |
---|
File deleted |
/photogallery/singapore_gallery_files/tools/generate.php |
---|
File deleted |
\ No newline at end of file |
/photogallery/singapore_gallery_files/tools/merge.php |
---|
File deleted |
/photogallery/singapore_gallery_files/tools/tools.css |
---|
File deleted |
\ No newline at end of file |
/photogallery/tools/cleanup.php |
---|
0,0 → 1,59 |
<?php |
/** |
* This file attempts to recursively make all files in the parent directory |
* (i.e. the singapore root directory) writable. This will, in general, only |
* succeed on server-owned content hence making it deletable by FTP users. |
* |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
* @copyright (c)2004 Tamlyn Rhodes |
* @version $Id: cleanup.php,v 1.4 2006/03/02 16:14:03 tamlyn Exp $ |
*/ |
/** |
* Recursively attempts to make all files and directories in $dir writable |
* |
* @param string full directory name (must end with /) |
*/ |
function makeWritable($dir) |
{ |
if (is_dir($dir)) { |
$d = dir($dir); |
while (($file = $d->read()) !== false) { |
//ignore current and parent dirs and php files |
if ($file == '.' || $file == '..' || substr($file, strlen($file)-4)=='.php') continue; |
$fullfile = $d->path . $file; |
if(@chmod($fullfile,0777)) |
echo "Made $fullfile writable.<br />"; |
if (is_dir($fullfile)) |
makeWritable($fullfile."/"); |
} |
} |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>cleanup script</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>Fixing file permissions</h1> |
<p><?php |
//start with parent directory (singapore root) |
makeWritable("../"); |
?></p> |
<p>All done! <a href="index.html">Return</a> to tools.</p> |
</body> |
</html> |
/photogallery/tools/compile.php |
---|
0,0 → 1,215 |
<?php |
/** |
* This file merges the two PO template files (singapore.pot and singapore.admin.pot) |
* with all existing language files (singapore.LANG.po) |
* |
* @author Joel Sjögren <joel dot sjogren at nonea dot se> |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
* @copyright (c)2003-2005 Tamlyn Rhodes |
* @version $Id: compile.php,v 1.9 2006/04/29 16:18:52 tamlyn Exp $ |
*/ |
// Programs to call (insert path to them if necessary) |
$GETTEXT_MERGE = "msgmerge"; |
$BASEPATH = realpath("..")."/"; |
//require config class |
require_once $BASEPATH."includes/config.class.php"; |
//get config object |
$config = sgConfig::getInstance(); |
$config->loadConfig($BASEPATH."singapore.ini"); |
$OUTPUTPATH = $BASEPATH.$config->pathto_locale; |
$standardPot = $OUTPUTPATH."singapore.pot"; |
$adminPot = $OUTPUTPATH."singapore.admin.pot"; |
$createbackups = true; |
/** |
* Parses a directory and returns full path to all the files |
* matching the filter (file name suffix) |
* |
* @param string $dir full directory name (must end with /) |
* @param string $filter file name suffixes separated by | (optional, default don't filter) |
* @return array an array with all files |
**/ |
function parseDirectory ($dir, $filter = 'php|html|tpl|inc') |
{ |
$ret = array(); |
if (is_dir($dir)) { |
$d = dir($dir); |
while (($file = $d->read()) !== false) { |
if ($file == '.' || $file == '..') continue; |
$fullfile = $d->path . $file; |
if (is_dir($fullfile)) $ret = array_merge($ret,parseDirectory($fullfile."/")); |
else if (!$filter || preg_match("/\.({$filter})$/i", $file)) $ret[] = $fullfile; |
} |
} |
return $ret; |
} |
/** |
* Parses a PO file and writes a file with |
* serialized strings for PHP |
* |
* @param string $input file to read from |
* @param string $output file to write to |
* @return bool success |
**/ |
function parsePO ($input, $output) |
{ |
// Open PO-file |
file_exists($input) or die("The file {$input} doesn't exit.\n"); |
$fp = @fopen($input, "r") or die("Couldn't open {$input}.\n"); |
$type = 0; |
$strings = array(); |
$escape = "\n"; |
$string = ""; |
$plural = 0; |
$header = ""; |
while (!feof($fp)) { |
$line = trim(fgets($fp,1024)); |
if ($line == "" || $line[0] == "#") continue; |
// New (msgid "text") |
if (preg_match("/msgid[[:space:]]+\"(.+)\"$/i", $line, $m)) { |
$type = 1; |
$string = stripcslashes($m[1]); |
// New id on several rows (msgid "") or header |
} elseif (preg_match("/msgid[[:space:]]+\"\"$/i", $line, $m)) { |
$type = 2; |
$string = ""; |
// Add to id on several rows ("") |
} elseif (preg_match("/^\"(.*)\"$/i", $line, $m) && ($type == 1 || $type == 2 || $type == 3)) { |
$type = 3; |
$string .= stripcslashes($m[1]); |
// New string (msgstr "text") |
} elseif (preg_match("/msgstr[[:space:]]+\"(.+)\"$/i", $line, $m) && ($type == 1 || $type == 3) && $string) { |
$strings[$string] = stripcslashes($m[1]); |
$type = 4; |
// New string on several rows (msgstr "") |
} elseif (preg_match("/msgstr[[:space:]]+\"\"$/i", $line, $m) && ($type == 1 || $type == 3) && $string) { |
$type = 4; |
$strings[$string] = ""; |
// Add to string on several rows ("") |
} elseif (preg_match("/^\"(.*)\"$/i", $line, $m) && $type == 4 && $string) { |
$strings[$string] .= stripcslashes($m[1]); |
/////Plural forms///// |
// New plural id (msgid_plural "text") |
} elseif (preg_match("/msgid_plural[[:space:]]+\".*\"$/i", $line, $m)) { |
$type = 6; |
// New plural string (msgstr[N] "text") |
} elseif (preg_match("/msgstr\[(\d+)\][[:space:]]+\"(.+)\"$/i", $line, $m) && ($type == 6) && $string) { |
$plural = $m[1]; |
$strings[$string][$plural] = stripcslashes($m[2]); |
$type = 6; |
// New plural string on several rows (msgstr[N] "") |
} elseif (preg_match("/msgstr\[(\d+)\][[:space:]]+\"\"$/i", $line, $m) && ($type == 6) && $string) { |
$plural = $m[1]; |
$strings[$string][$plural] = ""; |
$type = 6; |
// Add to plural string on several rows ("") |
} elseif (preg_match("/^\"(.*)\"$/i", $line, $m) && $type == 6 && $string) { |
$strings[$string][$plural] .= stripcslashes($m[1]); |
/////Header section///// |
// Start header section |
} elseif (preg_match("/msgstr[[:space:]]+\"(.+)\"$/i", $line, $m) && $type == 2 && !$string) { |
$header = stripcslashes($m[1]); |
$type = 5; |
// Start header section |
} elseif (preg_match("/msgstr[[:space:]]+\"\"$/i", $line, $m) && !$string) { |
$header = ""; |
$type = 5; |
// Add to header section |
} elseif (preg_match("/^\"(.*)\"$/i", $line, $m) && $type == 5) { |
$header .= stripcslashes($m[1]); |
// Reset |
} else { |
unset($strings[$string]); |
$type = 0; |
$string = ""; |
$plural = 0; |
} |
} |
// Close PO-file |
fclose($fp); |
// Extract plural forms from header |
if(preg_match("/Plural-Forms:[[:space:]]+(.+)/i", $header, $m)) { |
$pluralString = str_replace("n","\$n",$m[1]); |
$pluralString = str_replace(" plural","\$plural",$pluralString); |
} else { |
$pluralString = "\$nplurals=1; \$plural=\$n==1?0:1;"; |
} |
// Extract character set from header |
if(preg_match("/Content-Type:(.+)charset=(.+)/i", $header, $m)) |
$charset = $m[2]; |
else |
$charset = ""; |
// Extract language name from header |
if(preg_match("/Language-Team:[[:space:]]+([^<\n]+)/i", $header, $m)) |
$language = $m[1]; |
else |
$language = "Unknown"; |
$strings[0]["charset"] = $charset; |
$strings[0]["language"] = $language; |
$strings[0]["plural"] = $pluralString; |
// Open data file for writing |
$fp = @fopen($output, "wb") or die("Couldn't open file ({$output}).\n"); |
fwrite($fp, serialize($strings)); |
fclose($fp); |
//set permissions on new PMO file |
@chmod($output, octdec($GLOBALS['config']->file_mode)); |
// Return |
return true; |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>i18n po compiler</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>i18n po compiler</h1> |
<p><?php |
$files = parseDirectory($OUTPUTPATH, 'po'); |
foreach ($files as $file) { |
if (!preg_match("/singapore\.(admin\.)?[\w]+\.po$/i", $file)) continue; |
$outfile = preg_replace("/\.[^\.]+$/", ".pmo", $file); |
if(parsePO($file, $outfile)) |
echo "Parsed $file to $outfile<br />"; |
else |
echo "Could not parse $file<br />"; |
} |
?> |
</p> |
<p>All operations complete. <a href="index.html">Return</a> to tools.</p> |
</body> |
</html> |
/photogallery/tools/convertdb.php |
---|
0,0 → 1,278 |
<?php |
//permissions bit flags |
define("SG_GRP_READ", 1); |
define("SG_GRP_EDIT", 2); |
define("SG_GRP_ADD", 4); |
define("SG_GRP_DELETE", 8); |
define("SG_WLD_READ", 16); |
define("SG_WLD_EDIT", 32); |
define("SG_WLD_ADD", 64); |
define("SG_WLD_DELETE", 128); |
function getGallery($path) |
{ |
$gal = new sgGallery('.'); |
$fp = @fopen($path."/metadata.csv","r"); |
if($fp) { |
while($temp[] = fgetcsv($fp,2048)); |
fclose($fp); |
@list( |
$gal->filename, |
, |
$gal->owner, |
$gal->groups, |
$gal->permissions, |
$gal->categories, |
$gal->name, |
$gal->artist, |
$gal->email, |
$gal->copyright, |
$gal->desc, |
$gal->summary, |
$gal->date |
) = $temp[1]; |
for($i=0;$i<count($temp)-3;$i++) { |
$gal->images[$i] = new sgImage(); |
list( |
$gal->images[$i]->filename, |
$gal->images[$i]->thumbnail, |
$gal->images[$i]->owner, |
$gal->images[$i]->groups, |
$gal->images[$i]->permissions, |
$gal->images[$i]->categories, |
$gal->images[$i]->name, |
$gal->images[$i]->artist, |
$gal->images[$i]->email, |
$gal->images[$i]->copyright, |
$gal->images[$i]->desc, |
$gal->images[$i]->location, |
$gal->images[$i]->date, |
$gal->images[$i]->camera, |
$gal->images[$i]->lens, |
$gal->images[$i]->film, |
$gal->images[$i]->darkroom, |
$gal->images[$i]->digital |
) = $temp[$i+2]; |
//don't get image size and type |
} |
} else { |
//selected gallery does not exist or no metadata |
return null; |
} |
return $gal; |
} |
function putGallery($gallery, $path) { |
//backup data file |
copy($path."/metadata.csv", $path."/metadata.bak"); |
$fp = fopen($path."/metadata.csv","w"); |
if(!$fp) return false; |
$success = true; |
$success &= (bool) fwrite($fp,"filename,thumbnail,owner,group(s),permissions,catergories,image name,artist name,artist email,copyright,image description,image location,date taken,camera info,lens info,film info,darkroom manipulation,digital manipulation"); |
$success &= (bool) fwrite($fp,"\n\"". |
$gallery->filename."\",,". |
$gallery->owner.",". |
$gallery->groups.",". |
$gallery->permissions.",". |
$gallery->categories.',"'. |
str_replace('"','""',$gallery->name).'","'. |
str_replace('"','""',$gallery->artist).'","'. |
str_replace('"','""',$gallery->email).'","'. |
str_replace('"','""',$gallery->copyright).'","'. |
str_replace('"','""',$gallery->desc).'","'. |
str_replace('"','""',$gallery->summary).'","'. |
str_replace('"','""',$gallery->date).'"' |
); |
for($i=0;$i<count($gallery->images);$i++) |
$success &= (bool) fwrite($fp,"\n\"". |
$gallery->images[$i]->filename."\",". |
$gallery->images[$i]->thumbnail.",". |
$gallery->images[$i]->owner.",". |
$gallery->images[$i]->groups.",". |
$gallery->images[$i]->permissions.",". |
$gallery->images[$i]->categories.',"'. |
str_replace('"','""',$gallery->images[$i]->name).'","'. |
str_replace('"','""',$gallery->images[$i]->artist).'","'. |
str_replace('"','""',$gallery->images[$i]->email).'","'. |
str_replace('"','""',$gallery->images[$i]->copyright).'","'. |
str_replace('"','""',$gallery->images[$i]->desc).'","'. |
str_replace('"','""',$gallery->images[$i]->location).'","'. |
str_replace('"','""',$gallery->images[$i]->date).'","'. |
str_replace('"','""',$gallery->images[$i]->camera).'","'. |
str_replace('"','""',$gallery->images[$i]->lens).'","'. |
str_replace('"','""',$gallery->images[$i]->film).'","'. |
str_replace('"','""',$gallery->images[$i]->darkroom).'","'. |
str_replace('"','""',$gallery->images[$i]->digital).'"' |
); |
$success &= (bool) fclose($fp); |
return $success; |
} |
function setPerms($obj) { |
$obj->permissions = 0; |
if(!empty($_POST["sgGrpRead"])) $obj->permissions |= SG_GRP_READ; |
if(!empty($_POST["sgGrpEdit"])) $obj->permissions |= SG_GRP_EDIT; |
if(!empty($_POST["sgGrpAdd"])) $obj->permissions |= SG_GRP_ADD; |
if(!empty($_POST["sgGrpDelete"])) $obj->permissions |= SG_GRP_DELETE; |
if(!empty($_POST["sgWldRead"])) $obj->permissions |= SG_WLD_READ; |
if(!empty($_POST["sgWldEdit"])) $obj->permissions |= SG_WLD_EDIT; |
if(!empty($_POST["sgWldAdd"])) $obj->permissions |= SG_WLD_ADD; |
if(!empty($_POST["sgWldDelete"])) $obj->permissions |= SG_WLD_DELETE; |
$obj->groups = $_REQUEST["sgGroups"]; |
$obj->owner = $_REQUEST["sgOwner"]; |
return $obj; |
} |
function convertDirectory ($path) |
{ |
if (is_dir($path)) { |
$gallery = getGallery($path); |
echo "<ul><li>Checking $path<br />\n"; |
if($gallery) { |
if($gallery->summary != "" && empty($_REQUEST["convertOverwrite"])) |
echo "Did NOT overwrite non-empty summary in $path<br />\n"; |
else { |
if($_REQUEST["convertType"]!='none') |
$gallery->summary = $gallery->desc; |
if($_REQUEST["convertType"]=='move') |
$gallery->desc = ""; |
} |
$gallery = setPerms($gallery); |
for($i=0; $i<count($gallery->images); $i++) |
$gallery->images[$i] = setPerms($gallery->images[$i]); |
if(putGallery($gallery,$path)) |
echo "Successfully converted $path<br />\n"; |
else |
echo "Problem saving data file for $path<br />\n"; |
} else |
echo "Skipping $path<br />\n"; |
$d = dir($path); |
while (($file = $d->read()) !== false) { |
if ($file == '.' || $file == '..') continue; |
$path = $d->path."/".$file; |
if (is_dir($path)) { |
convertDirectory($path); |
} |
} |
echo "</li></ul>\n"; |
} |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>database converter</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>database converter</h1> |
<?php |
if(isset($_REQUEST["convertType"])) { |
include "../includes/config.class.php"; |
include "../includes/gallery.class.php"; |
include "../includes/image.class.php"; |
$config = new sgConfig("../singapore.ini"); |
$config->base_path = "../"; |
//echo "<ul>\n"; |
convertDirectory($config->base_path.$config->pathto_galleries); |
//echo "</ul>\n"; |
echo "<p>All operations complete.</p>\n"; |
} else { ?> |
<p>This will convert all your metadata files from singapore 0.9.6, 0.9.7, 0.9.8 or 0.9.9 to 0.9.10.</p> |
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>"> |
<h3>summary field</h3> |
<p>There is a new gallery summary field that is displayed instead of the |
description in the parent gallery. You can choose to either copy or move the |
old description field to the summary field or leave both untouched:</p> |
<p><input type="radio" class="radio" name="convertType" value="copy" checked="true" /> Copy<br /> |
<input type="radio" class="radio" name="convertType" value="move" /> Move<br /> |
<input type="radio" class="radio" name="convertType" value="none" /> Neither<br /> |
<p>By default only empty summary fields will be written to. Check this option to |
allow the summary field to be overwritten <input type="checkbox" class="checkbox" name="convertOverwrite" /></p> |
<h3>permissions</h3> |
<p>This version introduces multiple authorised users and image & gallery |
permissions. Please choose the default permissions that you would like all |
objects to be set to. The default permissions selected below are recommended as |
they will make all images & galleries readable by everyone but only |
modifiable by administrators. See the readme for more information on the |
permissions model used by singapore.</p> |
<table> |
<tr> |
<td>Owner</td> |
<td><input type="text" name="sgOwner" value="__nobody__" /></td> |
</tr> |
<tr> |
<td>Groups</td> |
<td><input type="text" name="sgGroups" value="" /></td> |
</tr> |
<tr> |
<td>Group permissions</td> |
<td><div class="inputbox"> |
<input type="checkbox" class="checkbox" name="sgGrpRead" checked="true"/> Read |
<input type="checkbox" class="checkbox" name="sgGrpEdit" /> Edit |
<input type="checkbox" class="checkbox" name="sgGrpAdd" /> Add |
<input type="checkbox" class="checkbox" name="sgGrpDelete" /> Delete |
</div></td> |
</tr> |
<tr> |
<td>World permissions</td> |
<td><div class="inputbox"> |
<input type="checkbox" class="checkbox" name="sgWldRead" checked="true"/> Read |
<input type="checkbox" class="checkbox" name="sgWldEdit" /> Edit |
<input type="checkbox" class="checkbox" name="sgWldAdd" /> Add |
<input type="checkbox" class="checkbox" name="sgWldDelete" /> Delete |
</div></td> |
</tr> |
</table> |
<p>Please note that while the script will create backups of your metadata files |
it is highly recommended that you create your own backups for added security.</p> |
<input type="submit" class="button" value="Go" /></p> |
</form> |
<?php } ?> |
<p><a href="index.html">Return</a> to tools.</p> |
</body> |
</html> |
/photogallery/tools/extract.php |
---|
0,0 → 1,133 |
<?php |
/** |
* This file searches for strings in all project files matching the filter and |
* creates two PO template files (singapore.pot and singapore.admin.pot) |
* |
* @author Joel Sjögren <joel dot sjogren at nonea dot se> |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
* @copyright (c)2003-2005 Tamlyn Rhodes |
* @version $Id: extract.php,v 1.14 2006/06/24 22:36:15 tamlyn Exp $ |
*/ |
// Programs to call (insert path to them if necessary) |
$GETTEXT_EXTRACT = "xgettext"; |
$BASEPATH = realpath("..")."/"; |
//require config class |
require_once $BASEPATH."includes/config.class.php"; |
//get config object |
$config = sgConfig::getInstance(); |
$config->loadConfig($BASEPATH."singapore.ini"); |
$OUTPUTPATH = $BASEPATH.$config->pathto_locale; |
$standardPot = $OUTPUTPATH."singapore.pot"; |
$adminPot = $OUTPUTPATH."singapore.admin.pot"; |
/** |
* Parses a directory and returns full path to all the files |
* matching the filter (file name suffix) |
* |
* @param string $dir full directory name (must end with /) |
* @param string $filter file name suffixes separated by | (optional, default don't filter) |
* @return array an array with all files |
**/ |
function parseDirectory ($dir, $filter = "php|html|tpl|inc") |
{ |
$ret = array(); |
if (is_dir($dir)) { |
$d = dir($dir); |
while (($file = $d->read()) !== false) { |
if ($file == '.' || $file == '..') continue; |
$fullfile = $d->path . $file; |
if (is_dir($fullfile)) $ret = array_merge($ret,parseDirectory($fullfile."/")); |
else if (!$filter || preg_match("/\.({$filter})$/i", $file)) $ret[] = $fullfile; |
} |
} |
return $ret; |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>i18n string extractor</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>i18n string extractor</h1> |
<p><?php |
// Create tempfile |
$temp = $OUTPUTPATH."/".'~tempfile'; |
$fp = fopen($temp, 'wb') or die("Couldn't open tempfile {$temp} for writing.\n"); |
// Get all files matching pattern in current template |
$files = parseDirectory("../".$config->pathto_templates.$config->default_template.'/'); |
$files[] = "../includes/image.class.php"; |
$files[] = "../includes/item.class.php"; |
$files[] = "../includes/gallery.class.php"; |
$files[] = "../includes/singapore.class.php"; |
$files[] = "../includes/user.class.php"; |
fwrite($fp, implode("\n", $files)); |
// Close tempfile |
fclose($fp); |
// Call gettext |
$res = shell_exec("{$GETTEXT_EXTRACT} --debug --keyword=_g --keyword=_ng:1,2 --keyword=__g -C -F --output=\"" . $standardPot . "\" --files-from=\"" . $temp . "\""); |
if (trim($res)) die("Something seemed to go wrong with gettext:\n" . $res . "\n"); |
else echo "Standard strings extracted $standardPot<br />"; |
// Remove tempfile |
unlink($temp); |
//set permissions on new POT file |
@chmod($standardPot, octdec($config->file_mode)); |
///////admin/////////// |
// Create tempfile |
$temp = $OUTPUTPATH."/".'~tempfile'; |
$fp = fopen($temp, 'w') or die("Couldn't open tempfile {$temp} for writing.\n"); |
// Get all files matching pattern in current template |
$files = parseDirectory("../".$config->pathto_templates.$config->admin_template_name.'/'); |
$files[] = "../includes/admin.class.php"; |
$files[] = "../admin.php"; |
fwrite($fp, implode("\n", $files)); |
// Close tempfile |
fclose($fp); |
// Call gettext |
$res = shell_exec("{$GETTEXT_EXTRACT} --debug --keyword=_g --keyword=_ng:1,2 -C -F -x \"" . $standardPot . "\" --output=\"" . $adminPot . "\" --files-from=\"" . $temp . "\""); |
if (trim($res)) die("Something seemed to go wrong with gettext:\n" . $res . "\n"); |
else echo "Admin strings extracted to $adminPot<br />"; |
// Remove tempfile |
unlink($temp); |
//set permissions on new POT file |
@chmod($adminPot, octdec($config->file_mode)); |
?> |
</p> |
<p>You may now <a href="merge.php">merge</a> the strings into all previously |
translated PO files.</p> |
</body> |
</html> |
/photogallery/tools/generate.php |
---|
0,0 → 1,68 |
<?php |
/** |
* Use this script to batch generate all main and preview thumbnails for all |
* galleries. Galleries which contain sub-galleries are skipped as are hidden |
* galleries. |
* |
* Currently this is a bit of a hack. Hopefully a later version of the script |
* will be built more robustly using the singapore class to greater advantage. |
* |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
* @copyright (c)2004-2005 Tamlyn Rhodes |
* @version 0.1 |
*/ |
//relative path to the singapore base installation |
$basePath = '../'; |
//remove the built in time limit |
set_time_limit(0); |
// require main class |
require_once $basePath."includes/singapore.class.php"; |
//create singapore object |
$sg = new Singapore($basePath); |
function showAllThumbnails(&$sg, &$gal) |
{ |
echo "<li>Entering <code>".$gal->name()."</code></li>\n"; |
echo "<ul>\n"; |
echo "<li>".$gal->thumbnailHTML()."</li>\n"; |
if($gal->isGallery()) { |
foreach($gal->galleries as $subgal) |
showAllThumbnails($sg, $sg->io->getGallery($subgal->id, $gal)); |
} else |
foreach($gal->images as $img) |
echo "<li>".$img->thumbnailHTML().$img->thumbnailHTML("","preview")."</li>\n"; |
echo "</ul>\n"; |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>batch thumbnail generator</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>Generating thumbnails</h1> |
<?php |
//start recursive thumbnail generation |
showAllThumbnails($sg, $sg->gallery); |
?> |
<p>All done! <a href="index.html">Return</a> to tools.</p> |
</body> |
</html> |
/photogallery/tools/index.html |
---|
0,0 → 1,58 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>singapore tools</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>singapore tools</h1> |
<p>This is a collection of tools for use with the singapore image gallery. They |
must be located in a child directory of the main singapore directory |
(<code>tools/</code> by default). Since they are PHP scripts they must be run |
on a PHP enabled web server</p> |
<h1>language tools</h1> |
<p>These tools are to aid translators. They require GNU Gettext to be available |
on the host system but do not require the Gettext PHP extension. Please |
see the <a href="../docs/Translation.html">translation</a> readme for more |
information.</p> |
<ol> |
<li><a href="extract.php">Extractor</a> - for developers. Extracts |
translatable strings from singapore files and current template and creates |
PO template files. Unless you have edited text in the sources you do not need |
to execute this.</li> |
<li><a href="merge.php">Merger</a> - for translators. Merges new strings from |
the PO templates with all currently available PO files.</li> |
<li><a href="compile.php">Compiler</a> - for translators. Compiles all |
currently available PO files into PHP serialized objects for use with singapore.</li> |
<li><a href="localecache.php">Cache updater</a> - for anyone. Caches the names |
of all installed languages for use with the language flipper.</li> |
</ol> |
<h1>misc tools</h1> |
<ul> |
<!--<li><a href="convertdb.php">Database converter</a> - copies or moves the |
gallery description field of pre v0.9.10 to the summary field of v0.9.10.</li>--> |
<li><a href="generate.php">Batch thumbnail generator</a> - use to generate all |
album and preview thumbnails for all galleries in one go. Particularly useful |
on slow servers to run overnight.</li> |
<li><a href="cleanup.php">Cleanup script</a> - use this script to make all |
server generated content world readable allowing you to delete it. Since this |
script does not actually delete anything it is safe to be run by anyone.</li> |
<li><a href="mod_rewrite.htaccess">mod_rewrite</a> - The .htaccess file you |
need for use with Apache mod_rewrite. See readme for more info.</li> |
</ul> |
<p><a href="../">Return</a> to singapore.</p> |
</body> |
</html> |
/photogallery/tools/localecache.php |
---|
0,0 → 1,98 |
<?php |
/** |
* This file merges the two PO template files (singapore.pot and singapore.admin.pot) |
* with all existing language files (singapore.LANG.po) |
* |
* @author Joel Sjögren <joel dot sjogren at nonea dot se> |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
* @version $Id: localecache.php,v 1.5 2005/12/15 17:18:47 tamlyn Exp $ |
*/ |
//require config class |
$BASEPATH = "../"; |
require_once $BASEPATH."includes/config.class.php"; |
require_once $BASEPATH."includes/translator.class.php"; |
//get config object |
$sgConfig = sgConfig::getInstance(); |
$sgConfig->loadConfig($BASEPATH."singapore.ini"); |
$sgConfig->base_path = $BASEPATH; |
$OUTPUTPATH = $sgConfig->base_path.$sgConfig->pathto_locale; |
$OUTPUTFILE = $sgConfig->base_path.$sgConfig->pathto_data_dir."languages.cache"; |
/** |
* Parses a directory and returns full path to all the files |
* matching the filter (file name suffix) |
* |
* @param string $dir full directory name (must end with /) |
* @param string $filter file name suffixes separated by | (optional, default don't filter) |
* @return array an array with all files |
**/ |
function parseDirectory ($dir, $filter = 'php|html|tpl|inc') |
{ |
$ret = array(); |
if (is_dir($dir)) { |
$d = dir($dir); |
while (($file = $d->read()) !== false) { |
if ($file == '.' || $file == '..') continue; |
$fullfile = $d->path . $file; |
if (is_dir($fullfile)) $ret = array_merge($ret,parseDirectory($fullfile."/")); |
else if (!$filter || preg_match("/\.({$filter})$/i", $file)) $ret[] = $fullfile; |
} |
} |
return $ret; |
} |
function saveCache($availableLanguages, $output) |
{ |
// Open data file for writing |
$fp = @fopen($output, "wb") or die("Couldn't open file ({$output}).\n"); |
fwrite($fp, serialize($availableLanguages)); |
return fclose($fp); |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>language cache updater</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>language cache updater</h1> |
<p><?php |
$files = parseDirectory($OUTPUTPATH, 'pmo'); |
$availableLanguages = array(); |
foreach ($files as $file) { |
if (!preg_match("/singapore\.([\w]+)\.pmo$/i", $file, $matches)) continue; |
$i18n = Translator::getInstance($matches[1]); |
$i18n->readLanguageFile($sgConfig->base_path.$sgConfig->pathto_locale."singapore.".$i18n->language.".pmo"); |
$availableLanguages[$matches[1]] = $i18n->languageStrings[0]['language']; |
echo "Added $matches[1] => ".$i18n->languageStrings[0]['language']." to available languages.<br />\n"; |
} |
//add english which has no translation files |
$availableLanguages["en"] = "English"; |
ksort($availableLanguages); |
if(saveCache($availableLanguages, $OUTPUTFILE)) |
echo "Cache file saved as ".$OUTPUTFILE; |
else |
echo "Could not save cache file as ".$OUTPUTFILE; |
?> |
</p> |
<p>All operations complete. <a href="index.html">Return</a> to tools.</p> |
</body> |
</html> |
/photogallery/tools/merge.php |
---|
0,0 → 1,115 |
<?php |
/** |
* This file merges the two PO template files (singapore.pot and singapore.admin.pot) |
* with all existing language files (singapore.LANG.po) |
* |
* @author Joel Sjögren <joel dot sjogren at nonea dot se> |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
* @copyright (c)2003-2005 Tamlyn Rhodes |
* @version $Id: merge.php,v 1.8 2006/05/08 09:40:02 thepavian Exp $ |
*/ |
// Programs to call (insert path to them if necessary) |
$GETTEXT_MERGE = "msgmerge"; |
$BASEPATH = realpath("..")."/"; |
//require config class |
require_once $BASEPATH."includes/config.class.php"; |
//get config object |
$config = sgConfig::getInstance(); |
$config->loadConfig($BASEPATH."singapore.ini"); |
$OUTPUTPATH = $BASEPATH.$config->pathto_locale; |
$standardPot = $OUTPUTPATH."singapore.pot"; |
$adminPot = $OUTPUTPATH."singapore.admin.pot"; |
$createbackups = true; |
/** |
* Parses a directory and returns full path to all the files |
* matching the filter (file name suffix) |
* |
* @param string $dir full directory name (must end with /) |
* @param string $filter file name suffixes separated by | (optional, default don't filter) |
* @return array an array with all files |
**/ |
function parseDirectory ($dir, $filter = 'php|html|tpl|inc') |
{ |
$ret = array(); |
if (is_dir($dir)) { |
$d = dir($dir); |
while (($file = $d->read()) !== false) { |
if ($file == '.' || $file == '..') continue; |
$fullfile = $d->path . $file; |
if (is_dir($fullfile)) $ret = array_merge($ret,parseDirectory($fullfile."/")); |
else if (!$filter || preg_match("/\.({$filter})$/i", $file)) $ret[] = $fullfile; |
} |
} |
return $ret; |
} |
?> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<title>i18n string merger</title> |
<link rel="stylesheet" type="text/css" href="tools.css" /> |
</head> |
<body> |
<h1>i18n string merger</h1> |
<p><?php |
$files = parseDirectory($OUTPUTPATH, 'po'); |
foreach ($files as $file) { |
if (!preg_match("/singapore\.[\w]+\.po$/i", $file)) continue; |
$backup = $file . '.bak'; |
if (file_exists($backup)) @unlink($backup); |
@rename($file, $backup); |
$res = shell_exec("{$GETTEXT_MERGE} --strict \"{$backup}\" \"" . $standardPot . "\" > \"{$file}\""); |
if (trim($res)) echo "Something seemed to go wrong with msgmerge:\n" . $res . "\n"; |
else echo "$standardPot merged with $file<br />"; |
// Remove backup? |
if (!@$createbackups) @unlink($backup); |
//set permissions on new POT file |
@chmod($standardPot, octdec($config->file_mode)); |
} |
///////admin/////////// |
$files = parseDirectory($OUTPUTPATH, 'po'); |
foreach ($files as $file) { |
if (!preg_match("/singapore\.admin\.[\w]+\.po$/i", $file)) continue; |
$backup = $file . '.bak'; |
if (file_exists($backup)) @unlink($backup); |
@rename($file, $backup); |
$res = shell_exec("{$GETTEXT_MERGE} --strict \"{$backup}\" \"" . $adminPot . "\" > \"{$file}\""); |
if (trim($res)) echo "Something seemed to go wrong with msgmerge:\n" . $res . "\n"; |
else echo "$adminPot merged with $file<br />"; |
// Remove backup? |
if (!@$createbackups) @unlink($backup); |
//set permissions on new POT file |
@chmod($adminPot, octdec($config->file_mode)); |
} |
?> |
</p> |
<p>Once you have translated the updated PO files you may |
<a href="compile.php">compile</a> them into PHP serialized objects for use with |
singapore.</p> |
</body> |
</html> |
/photogallery/tools/mod_rewrite.htaccess |
---|
0,0 → 1,33 |
# WHAT YOU NEED TO EDIT |
# |
# There are just two things you need to edit to make this file work on your |
# installation. On each of the two lines below starting 'RewriteRule' about |
# half way along the line there is a '/singapore/'. Change this to the full |
# path to your installation (e.g. the bit after the .com, .org or whatever) |
# then rename this file to .htaccess and put it in the singapore root |
# directory (the one containing thumb.php). Finally don't forget to turn on |
# use_mod_rewrite and update the base_path in singapore.ini. Voila! |
Options +FollowSymlinks |
RewriteEngine On |
# rewrite galleries |
# url must end in / and gallery names must not contain commas (,) |
# example: /singapore/gallery/subgallery,20/ |
# becomes: /singapore/index.php?gallery=gallery/subgallery&startat=20 |
RewriteRule ^([^,]+)(,([0-9]+))?/$ /singapore/index.php?gallery=$1&startat=$3&%{QUERY_STRING} [ne] |
# rewrite images |
# do not rewrite requests to files and directories that really exist |
RewriteCond %{REQUEST_FILENAME} !-d |
RewriteCond %{REQUEST_FILENAME} !-f |
# example: /singapore/gallery/subgallery/myphoto.jpeg |
# becomes: /singapore/index.php?gallery=gallery/subgallery&image=myphoto.jpeg |
RewriteRule ^((.*)/)?([^/]+\.(jpeg|jpg|jpe|png|gif|bmp|tif|tiff))$ /singapore/index.php?gallery=$2&image=$3&%{QUERY_STRING} [ne,nc] |
# rewrite feed.xml to the rss template |
# example: /singapore/gallery/feed.xml |
# becomes: /singapore/index.php?gallery=gallery&template=rss |
RewriteRule ^((.*)/)?feed.xml$ /singapore/index.php?gallery=$2&template=rss&%{QUERY_STRING} [ne] |
/photogallery/tools/tools.css |
---|
0,0 → 1,82 |
body { |
margin: 1em; |
font: small sans-serif; |
color: #000; |
background-color: #fff; |
} |
p, td, th, li, dd, dt { |
font: small sans-serif; |
} |
h1, h2, h3, h4{ |
color: #f60; |
} |
h1, h2 { |
font-size: medium; |
border-bottom: 1px solid #ccc; |
letter-spacing: 0.3em; |
text-transform: uppercase; |
} |
code, pre { |
color: #444; |
} |
p, td, th, li, dt, h3, h4, pre { |
margin-left: 2em; |
} |
dd { |
margin-left: 3em; |
} |
dt { |
margin-top: 0.5em; |
} |
a:link { |
color: #09f; |
text-decoration: underline; |
} |
a:visited { |
color: #05a; |
text-decoration: underline; |
} |
a:hover { |
text-decoration: none; |
} |
input, textarea, select, .inputbox { |
border: 1px solid #f60; |
color: #000; |
background-color: #fff; |
} |
input.radio { |
border: none; |
background-color: #fff; |
} |
input.button { |
font-weight: bold; |
border: 1px outset #fff; |
color: #fff; |
background-color: #f60; |
} |
ul.things > li { |
margin-top: 0.75em; |
} |
.note { |
color: #d00; |
} |
.boxed, .note { |
border: 1px dashed #ccc; |
padding: 0.5em; |
} |