1 <?php |
1 <?php |
2 /* |
2 /* |
3 Plugin Name: Snapr |
3 Plugin Name: Snapr |
4 Plugin URI: http://enanocms.org/Enano.Img_Gallery |
4 Plugin URI: http://enanocms.org/plugin/snapr |
5 Description: Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration. |
5 Description: Provides an intuitive image gallery system with a browser, viewer for individual images, upload interface, and comment system integration. |
6 Author: Dan Fuhry |
6 Author: Dan Fuhry |
7 Version: 0.1 beta 2 |
7 Version: 0.1 beta 3 |
8 Author URI: http://enanocms.org/ |
8 Author URI: http://enanocms.org/ |
9 */ |
9 */ |
10 |
10 |
11 global $db, $session, $paths, $template, $plugins; // Common objects |
11 global $db, $session, $paths, $template, $plugins; // Common objects |
12 |
12 |
13 define('GALLERY_VERSION', '0.1b2'); |
13 define('GALLERY_VERSION', '0.1b2'); |
14 |
14 |
|
15 if ( !defined('ENANO_ATLEAST_1_1') ) |
|
16 { |
|
17 $fn = basename(__FILE__); |
|
18 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>'); |
|
20 } |
|
21 |
15 $magick_path = getConfig('imagemagick_path'); |
22 $magick_path = getConfig('imagemagick_path'); |
16 if ( !file_exists($magick_path) || !is_executable($magick_path) ) |
23 if ( !file_exists($magick_path) || !is_executable($magick_path) ) |
17 { |
24 { |
18 $fn = basename(__FILE__); |
25 $fn = basename(__FILE__); |
19 setConfig("plugin_$fn", '0'); |
26 setConfig("plugin_$fn", '0'); |
20 die('Snapr: You must have ImageMagick installed and working to use this plugin. The plugin has been disabled, please setup ImageMagick and then re-enable it.'); |
27 // set disabled flag with new plugin system |
|
28 if ( defined('ENANO_ATLEAST_1_1') && defined('PLUGIN_DISABLED') ) |
|
29 { |
|
30 $q = $db->sql_query('UPDATE ' . table_prefix . "plugins SET plugin_flags = plugin_flags | " . PLUGIN_DISABLED . " WHERE plugin_filename = 'Gallery.php';"); |
|
31 if ( !$q ) |
|
32 $db->_die(); |
|
33 } |
|
34 |
|
35 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>'); |
21 } |
36 } |
22 |
37 |
23 if ( !getConfig('gallery_version') ) |
38 if ( !getConfig('gallery_version') ) |
24 { |
39 { |
25 $q = $db->sql_query('CREATE TABLE '.table_prefix.'gallery( |
40 $q = $db->sql_query('CREATE TABLE '.table_prefix.'gallery( |
30 img_desc longtext NOT NULL DEFAULT \'\', |
45 img_desc longtext NOT NULL DEFAULT \'\', |
31 print_sizes longtext NOT NULL DEFAULT \'\', |
46 print_sizes longtext NOT NULL DEFAULT \'\', |
32 img_filename varchar(255) NOT NULL, |
47 img_filename varchar(255) NOT NULL, |
33 img_time_upload int(12) NOT NULL DEFAULT 0, |
48 img_time_upload int(12) NOT NULL DEFAULT 0, |
34 img_time_mod int(12) NOT NULL DEFAULT 0, |
49 img_time_mod int(12) NOT NULL DEFAULT 0, |
35 img_tags longtext DEFAULT NULL, |
50 img_tags longtext, |
36 PRIMARY KEY ( img_id ) |
51 PRIMARY KEY ( img_id ) |
37 );'); |
52 );'); |
38 |
53 |
39 if ( !$q ) |
54 if ( !$q ) |
40 $db->_die(); |
55 $db->_die(); |
42 $q = $db->sql_query('CREATE FULLTEXT INDEX '.table_prefix.'gal_idx ON '.table_prefix.'gallery(img_title, img_desc);'); |
57 $q = $db->sql_query('CREATE FULLTEXT INDEX '.table_prefix.'gal_idx ON '.table_prefix.'gallery(img_title, img_desc);'); |
43 |
58 |
44 if ( !$q ) |
59 if ( !$q ) |
45 $db->_die(); |
60 $db->_die(); |
46 |
61 |
47 $q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title,img_desc,img_filename,img_time_upload,img_time_mod) 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());'); |
62 $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(), \'[]\');'); |
48 |
63 |
49 if ( !$q ) |
64 if ( !$q ) |
50 $db->_die(); |
65 $db->_die(); |
51 |
66 |
52 setConfig('gallery_version', GALLERY_VERSION); |
67 setConfig('gallery_version', GALLERY_VERSION); |
53 } |
68 } |
54 if ( getConfig('gallery_version') == '0.1b1' ) |
69 if ( getConfig('gallery_version') == '0.1b1' ) |
55 { |
70 { |
56 $q = $db->sql_query('ALTER TABLE ' . table_prefix . 'gallery ADD COLUMN img_tags longtext DEFAULT NULL'); |
71 $q = $db->sql_query('ALTER TABLE ' . table_prefix . 'gallery ADD COLUMN img_tags longtext;'); |
57 if ( !$q ) |
72 if ( !$q ) |
58 $db->_die(); |
73 $db->_die(); |
59 setConfig('gallery_version', '0.1b2'); |
74 setConfig('gallery_version', '0.1b2'); |
60 } |
75 } |
61 |
76 |