plugins/Gallery.php
author Dan Fuhry <dan@enanocms.org>
Sun, 01 Aug 2010 12:42:21 -0400
changeset 39 e9a7e37bdadd
parent 37 3afbd6374442
child 42 7c6e2e97aa08
permissions -rw-r--r--
Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
     1
<?php
39
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     2
/**!info**
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     3
{
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     4
  "Plugin Name"  : "Snapr",
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     5
  "Plugin URI"   : "http://enanocms.org/plugin/snapr",
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     6
  "Description"  : "Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration.",
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     7
  "Author"       : "Dan Fuhry",
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     8
  "Version"      : "0.1b3",
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
     9
  "Author URI"   : "http://enanocms.org/",
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    10
  "Version list" : ['0.1b1', '0.1b2', '0.1 beta 3', '0.1b3']
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    11
}
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    12
**!*/
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    13
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    14
global $db, $session, $paths, $template, $plugins; // Common objects
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    15
18
c1c398349651 Added initial support for notes (aka tags) on images, done completely (including initial load of metadata) with AJAX. They're not fixed at 100x100 like on Facebook either.
Dan
parents: 9
diff changeset
    16
define('GALLERY_VERSION', '0.1b2');
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    17
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    18
if ( !defined('ENANO_ATLEAST_1_1') )
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    19
{
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    20
  $fn = basename(__FILE__);
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    21
  setConfig("plugin_$fn", '0');
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    22
  die_semicritical('Snapr can\'t load on this site', '<p>This version of Snapr requires Enano 1.1.6 or later.</p>');
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    23
}
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    24
39
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    25
$magick_path = getConfig('imagemagick_path', '/usr/bin/convert');
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    26
$have_gd_scale_support = function_exists('imagecreatetruecolor') && function_exists('imagejpeg') && function_exists('imagecopyresampled');
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    27
if ( (!file_exists($magick_path) || !is_executable($magick_path)) && !$have_gd_scale_support )
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    28
{
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    29
  $fn = basename(__FILE__);
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    30
  // set disabled flag with new plugin system
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    31
  if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') )
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    32
  {
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    33
    $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = plugin_flags | " . PLUGIN_DISABLED . " WHERE plugin_filename = 'Gallery.php';");
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    34
    if ( !$q )
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    35
      $db->_die();
37
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    36
	  
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    37
    // kill off cache
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    38
    global $cache;
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    39
    $cache->purge('plugins');
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    40
  }
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    41
  else
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    42
  {
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    43
    // old plugin system
3afbd6374442 Fixed some 1.1.7 PHP warnings
Dan
parents: 29
diff changeset
    44
    setConfig("plugin_$fn", '0');
29
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    45
  }
205d0534a0f2 Fixed a few issues with the img_tags column; added some checks for Enano 1.1.x
Dan
parents: 26
diff changeset
    46
  
39
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    47
  die_semicritical('Snapr can\'t load on this site', '<p>You must have ImageMagick or GD installed and working to use this plugin. The plugin has been disabled, please setup ImageMagick and then re-enable it.</p>');
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    48
}
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    49
39
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    50
/**!install dbms="mysql"; **
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    51
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    52
CREATE TABLE {{TABLE_PREFIX}}gallery(
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    53
	img_id int(12) NOT NULL auto_increment,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    54
	is_folder tinyint(1) NOT NULL DEFAULT 0,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    55
	folder_parent int(12) DEFAULT NULL,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    56
	img_title varchar(255) NOT NULL DEFAULT '',
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    57
	img_desc longtext NOT NULL DEFAULT '',
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    58
	print_sizes longtext NOT NULL DEFAULT '',
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    59
	img_filename varchar(255) NOT NULL,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    60
	img_time_upload int(12) NOT NULL DEFAULT 0,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    61
	img_time_mod int(12) NOT NULL DEFAULT 0,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    62
	img_tags longtext,
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    63
	PRIMARY KEY ( img_id )
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    64
);
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    65
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    66
CREATE FULLTEXT INDEX {{TABLE_PREFIX}}gal_idx ON {{TABLE_PREFIX}}gallery(img_title, img_desc);
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    67
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    68
INSERT INTO {{TABLE_PREFIX}}gallery(img_title,img_desc,img_filename,img_time_upload,img_time_mod,img_tags) VALUES
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    69
	('Welcome to Snapr!',
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    70
	 'You''re past the hard part - Snapr is set up and working on your server. What you''re looking at now is what most users will see when they look at an image in your gallery. The next step is to [[Special:GalleryUpload|upload some images]]. After that, make your gallery publicly accessible by adding a link to the [[Special:Gallery|browser]], if you haven''t already done so. See the README file included with Snapr for more information.',
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    71
	 'snapr-logo.png',
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    72
	 UNIX_TIMESTAMP(),
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    73
	 UNIX_TIMESTAMP(),
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    74
	 '[]');
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    75
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    76
**!*/
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    77
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    78
/**!uninstall dbms="mysql"; **
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    79
ALTER TABLE {{TABLE_PREFIX}}gallery DROP INDEX {{TABLE_PREFIX}}gal_idx;
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    80
DROP TABLE {{TABLE_PREFIX}}gallery;
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    81
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    82
**!*/
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    83
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    84
/**!upgrade dbms="mysql"; from="0.1b1"; to="0.1b2"; **
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    85
ALTER TABLE {{TABLE_PREFIX}}gallery ADD COLUMN img_tags longtext;
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    86
**!*/
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    87
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    88
/**!upgrade dbms="mysql"; from="0.1b2"; to="0.1b3"; **
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    89
**!*/
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    90
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    91
/**!upgrade dbms="mysql"; from="0.1 beta 3"; to="0.1b3"; **
e9a7e37bdadd Fixed some PHP warnings and display issues. Brought up to date with 1.1.x plugin management/install/upgrade system.
Dan Fuhry <dan@enanocms.org>
parents: 37
diff changeset
    92
**!*/
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    93
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    94
require( ENANO_ROOT . '/plugins/gallery/functions.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    95
require( ENANO_ROOT . '/plugins/gallery/nssetup.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    96
require( ENANO_ROOT . '/plugins/gallery/viewimage.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    97
require( ENANO_ROOT . '/plugins/gallery/browser.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    98
require( ENANO_ROOT . '/plugins/gallery/upload.php' );
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
    99
require( ENANO_ROOT . '/plugins/gallery/fetcher.php' );
2
88c954d2846c Added search functionality (WiP); removed stray .marks file
Dan
parents: 0
diff changeset
   100
require( ENANO_ROOT . '/plugins/gallery/search.php' );
5
c0c324f0eeb5 Added the Random Image sidebar block
Dan
parents: 2
diff changeset
   101
require( ENANO_ROOT . '/plugins/gallery/sidebar.php' );
26
023a21c8f47c Added support for embedding Snapr images as wikitext code into regular pages
Dan
parents: 18
diff changeset
   102
require( ENANO_ROOT . '/plugins/gallery/imagetag.php' );
0
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
   103
7caf561c50ee Initial population; browser, viewer, uploader, and security are working
Dan
parents:
diff changeset
   104
?>