plugins/Gallery.php
changeset 39 e9a7e37bdadd
parent 37 3afbd6374442
child 42 7c6e2e97aa08
equal deleted inserted replaced
38:512951548faa 39:e9a7e37bdadd
     1 <?php
     1 <?php
     2 /*
     2 /**!info**
     3 Plugin Name: Snapr
     3 {
     4 Plugin URI: http://enanocms.org/plugin/snapr
     4   "Plugin Name"  : "Snapr",
     5 Description: Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration.
     5   "Plugin URI"   : "http://enanocms.org/plugin/snapr",
     6 Author: Dan Fuhry
     6   "Description"  : "Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration.",
     7 Version: 0.1 beta 3
     7   "Author"       : "Dan Fuhry",
     8 Author URI: http://enanocms.org/
     8   "Version"      : "0.1b3",
     9 */
     9   "Author URI"   : "http://enanocms.org/",
       
    10   "Version list" : ['0.1b1', '0.1b2', '0.1 beta 3', '0.1b3']
       
    11 }
       
    12 **!*/
    10 
    13 
    11 global $db, $session, $paths, $template, $plugins; // Common objects
    14 global $db, $session, $paths, $template, $plugins; // Common objects
    12 
    15 
    13 define('GALLERY_VERSION', '0.1b2');
    16 define('GALLERY_VERSION', '0.1b2');
    14 
    17 
    17   $fn = basename(__FILE__);
    20   $fn = basename(__FILE__);
    18   setConfig("plugin_$fn", '0');
    21   setConfig("plugin_$fn", '0');
    19   die_semicritical('Snapr can\'t load on this site', '<p>This version of Snapr requires Enano 1.1.6 or later.</p>');
    22   die_semicritical('Snapr can\'t load on this site', '<p>This version of Snapr requires Enano 1.1.6 or later.</p>');
    20 }
    23 }
    21 
    24 
    22 $magick_path = getConfig('imagemagick_path');
    25 $magick_path = getConfig('imagemagick_path', '/usr/bin/convert');
    23 if ( !file_exists($magick_path) || !is_executable($magick_path) )
    26 $have_gd_scale_support = function_exists('imagecreatetruecolor') && function_exists('imagejpeg') && function_exists('imagecopyresampled');
       
    27 if ( (!file_exists($magick_path) || !is_executable($magick_path)) && !$have_gd_scale_support )
    24 {
    28 {
    25   $fn = basename(__FILE__);
    29   $fn = basename(__FILE__);
    26   // set disabled flag with new plugin system
    30   // set disabled flag with new plugin system
    27   if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') )
    31   if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') )
    28   {
    32   {
    38   {
    42   {
    39     // old plugin system
    43     // old plugin system
    40     setConfig("plugin_$fn", '0');
    44     setConfig("plugin_$fn", '0');
    41   }
    45   }
    42   
    46   
    43   die_semicritical('Snapr can\'t load on this site', '<p>You must have ImageMagick installed and working to use this plugin. The plugin has been disabled, please setup ImageMagick and then re-enable it.</p>');
    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>');
    44 }
    48 }
    45 
    49 
    46 if ( !getConfig('gallery_version') )
    50 /**!install dbms="mysql"; **
    47 {
    51 
    48   $q = $db->sql_query('CREATE TABLE '.table_prefix.'gallery(
    52 CREATE TABLE {{TABLE_PREFIX}}gallery(
    49                         img_id int(12) NOT NULL auto_increment,
    53 	img_id int(12) NOT NULL auto_increment,
    50                         is_folder tinyint(1) NOT NULL DEFAULT 0,
    54 	is_folder tinyint(1) NOT NULL DEFAULT 0,
    51                         folder_parent int(12) DEFAULT NULL,
    55 	folder_parent int(12) DEFAULT NULL,
    52                         img_title varchar(255) NOT NULL DEFAULT \'\',
    56 	img_title varchar(255) NOT NULL DEFAULT '',
    53                         img_desc longtext NOT NULL DEFAULT \'\',
    57 	img_desc longtext NOT NULL DEFAULT '',
    54                         print_sizes longtext NOT NULL DEFAULT \'\',
    58 	print_sizes longtext NOT NULL DEFAULT '',
    55                         img_filename varchar(255) NOT NULL,
    59 	img_filename varchar(255) NOT NULL,
    56                         img_time_upload int(12) NOT NULL DEFAULT 0,
    60 	img_time_upload int(12) NOT NULL DEFAULT 0,
    57                         img_time_mod int(12) NOT NULL DEFAULT 0,
    61 	img_time_mod int(12) NOT NULL DEFAULT 0,
    58                         img_tags longtext,
    62 	img_tags longtext,
    59                         PRIMARY KEY ( img_id )
    63 	PRIMARY KEY ( img_id )
    60                       );');
    64 );
    61   
    65 
    62   if ( !$q )
    66 CREATE FULLTEXT INDEX {{TABLE_PREFIX}}gal_idx ON {{TABLE_PREFIX}}gallery(img_title, img_desc);
    63     $db->_die();
    67 
    64   
    68 INSERT INTO {{TABLE_PREFIX}}gallery(img_title,img_desc,img_filename,img_time_upload,img_time_mod,img_tags) VALUES
    65   $q = $db->sql_query('CREATE FULLTEXT INDEX '.table_prefix.'gal_idx ON '.table_prefix.'gallery(img_title, img_desc);');
    69 	('Welcome to Snapr!',
    66   
    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.',
    67   if ( !$q )
    71 	 'snapr-logo.png',
    68     $db->_die();
    72 	 UNIX_TIMESTAMP(),
    69   
    73 	 UNIX_TIMESTAMP(),
    70   $q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title,img_desc,img_filename,img_time_upload,img_time_mod,img_tags) VALUES(\'Welcome to Snapr!\', \'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.\', \'snapr-logo.png\', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), \'[]\');');
    74 	 '[]');
    71   
    75 
    72   if ( !$q )
    76 **!*/
    73     $db->_die();
    77 
    74   
    78 /**!uninstall dbms="mysql"; **
    75   setConfig('gallery_version', GALLERY_VERSION);
    79 ALTER TABLE {{TABLE_PREFIX}}gallery DROP INDEX {{TABLE_PREFIX}}gal_idx;
    76 }
    80 DROP TABLE {{TABLE_PREFIX}}gallery;
    77 if ( getConfig('gallery_version') == '0.1b1' )
    81 
    78 {
    82 **!*/
    79   $q = $db->sql_query('ALTER TABLE ' . table_prefix . 'gallery ADD COLUMN img_tags longtext;');
    83 
    80   if ( !$q )
    84 /**!upgrade dbms="mysql"; from="0.1b1"; to="0.1b2"; **
    81     $db->_die();
    85 ALTER TABLE {{TABLE_PREFIX}}gallery ADD COLUMN img_tags longtext;
    82   setConfig('gallery_version', '0.1b2');
    86 **!*/
    83 }
    87 
       
    88 /**!upgrade dbms="mysql"; from="0.1b2"; to="0.1b3"; **
       
    89 **!*/
       
    90 
       
    91 /**!upgrade dbms="mysql"; from="0.1 beta 3"; to="0.1b3"; **
       
    92 **!*/
    84 
    93 
    85 require( ENANO_ROOT . '/plugins/gallery/functions.php' );
    94 require( ENANO_ROOT . '/plugins/gallery/functions.php' );
    86 require( ENANO_ROOT . '/plugins/gallery/nssetup.php' );
    95 require( ENANO_ROOT . '/plugins/gallery/nssetup.php' );
    87 require( ENANO_ROOT . '/plugins/gallery/viewimage.php' );
    96 require( ENANO_ROOT . '/plugins/gallery/viewimage.php' );
    88 require( ENANO_ROOT . '/plugins/gallery/browser.php' );
    97 require( ENANO_ROOT . '/plugins/gallery/browser.php' );