# HG changeset patch # User Dan # Date 1185401714 14400 # Node ID 88c954d2846c3896871a2fff9914b3ec5abb0440 # Parent 94af07c8f2f3d6c8f2a6c15e3bf4e5a70de0685b Added search functionality (WiP); removed stray .marks file diff -r 94af07c8f2f3 -r 88c954d2846c plugins/Gallery.php --- a/plugins/Gallery.php Wed Jul 25 16:43:47 2007 -0400 +++ b/plugins/Gallery.php Wed Jul 25 18:15:14 2007 -0400 @@ -34,9 +34,12 @@ img_time_mod int(12) NOT NULL DEFAULT 0, PRIMARY KEY ( img_id ) );'); + if ( !$q ) $db->_die(); + $q = $db->sql_query('CREATE FULLTEXT INDEX '.table_prefix.'gal_idx ON '.table_prefix.'gallery(img_title, img_desc);'); + setConfig('gallery_version', GALLERY_VERSION); } @@ -46,5 +49,6 @@ require( ENANO_ROOT . '/plugins/gallery/browser.php' ); require( ENANO_ROOT . '/plugins/gallery/upload.php' ); require( ENANO_ROOT . '/plugins/gallery/fetcher.php' ); +require( ENANO_ROOT . '/plugins/gallery/search.php' ); ?> diff -r 94af07c8f2f3 -r 88c954d2846c plugins/gallery/.upload.php.marks --- a/plugins/gallery/.upload.php.marks Wed Jul 25 16:43:47 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -!u;8818;8818 -!e;12994;12994 -!z;22686;22686 -!f;35274;35274 diff -r 94af07c8f2f3 -r 88c954d2846c plugins/gallery/browser.php --- a/plugins/gallery/browser.php Wed Jul 25 16:43:47 2007 -0400 +++ b/plugins/gallery/browser.php Wed Jul 25 18:15:14 2007 -0400 @@ -163,8 +163,9 @@ $breadcrumb_urlcache = ''; // CSS for gallery browser - $template->add_header(''); - $template->add_header(''); + // Moved to search.php + //$template->add_header(''); + //$template->add_header(''); $header = $template->getHeader(); @@ -226,6 +227,45 @@ // 1) The folder doesn't exist // 2) The folder exists but doesn't have any images in it + if ( sizeof($folders) < 1 ) + { + // Nothing in the root folder + + $first_row['folder_id'] = 'NULL'; + if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) ) + { + if ( empty($_POST['create_folder']) ) + { + $f_errors[] = 'Please enter a folder name.'; + } + if ( $_POST['create_folder'] == '_id' ) + { + $f_errors[] = 'The name "_id" is reserved for internal functions and cannot be used on any image or folder.'; + } + if ( count($f_errors) < 1 ) + { + $q = $db->sql_query('INSERT INTO '.table_prefix.'gallery(img_title, is_folder, folder_parent) VALUES(\'' . $db->escape($_POST['create_folder']) . '\', 1, ' . $first_row['folder_id'] . ');'); + if ( !$q ) + $db->_die(); + redirect(makeUrl($paths->fullpage), 'Folder created', 'The folder "' . htmlspecialchars($_POST['create_folder']) . '" has been created. Redirecting to last viewed folder...', 2); + } + } + + $html = ''; + if ( $session->user_level >= USER_LEVEL_ADMIN ) + { + $html .= '
'; + $html .= 'No images have been uploaded to the gallery yet.
' . $html); + } + /* $folders_old = $folders; $folders = array( @@ -303,8 +343,16 @@ $f_errors = array(); - if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) ) + if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) ) { + if ( !isset($first_row['folder_id']) ) + { + $first_row['folder_id'] =& $first_row['img_id']; + } + if ( !isset($first_row['folder_id']) ) + { + $f_errors[] = 'Internal error getting parent folder ID'; + } if ( empty($_POST['create_folder']) ) { $f_errors[] = 'Please enter a folder name.'; @@ -435,7 +483,7 @@ $per_page = $rows_in_browser * 5; - $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'start=%s', true), $start, $per_page, $callers, 'No image results.
'; + } +} + +?> diff -r 94af07c8f2f3 -r 88c954d2846c plugins/gallery/upload.php --- a/plugins/gallery/upload.php Wed Jul 25 16:43:47 2007 -0400 +++ b/plugins/gallery/upload.php Wed Jul 25 18:15:14 2007 -0400 @@ -41,6 +41,26 @@ $template->add_header(''); $template->add_header(''); + $max_size = @ini_get('upload_max_filesize'); + $max_size_field = ''; + if ( $max_size ) + { + if ( preg_match('/M$/i', $max_size) ) + { + $max_size = intval($max_size) * 1048576; + } + else if ( preg_match('/K$/i', $max_size) ) + { + $max_size = intval($max_size) * 1024; + } + else if ( preg_match('/G$/i', $max_size) ) + { + $max_size = intval($max_size) * 1048576 * 1024; + } + $max_size = intval($max_size); + $max_size_field = "\n" . '' . "\n"; + } + if ( isset($_GET['edit_img']) ) { $edit_parms = $_GET['edit_img']; @@ -284,6 +304,8 @@ echo '