plugins/gallery/browser.php
changeset 2 88c954d2846c
parent 0 7caf561c50ee
child 4 ad3b061a1c76
equal deleted inserted replaced
1:94af07c8f2f3 2:88c954d2846c
   161   $breadcrumbs[] = '<a href="' . makeUrlNS('Special', 'Gallery') . '">Gallery index</a>';
   161   $breadcrumbs[] = '<a href="' . makeUrlNS('Special', 'Gallery') . '">Gallery index</a>';
   162   
   162   
   163   $breadcrumb_urlcache = '';
   163   $breadcrumb_urlcache = '';
   164   
   164   
   165   // CSS for gallery browser
   165   // CSS for gallery browser
   166   $template->add_header('<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/browser.css" type="text/css" />');
   166   // Moved to search.php
   167   $template->add_header('<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/dropdown.css" type="text/css" />');
   167   //$template->add_header('<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/browser.css" type="text/css" />');
       
   168   //$template->add_header('<link rel="stylesheet" href="' . scriptPath . '/plugins/gallery/dropdown.css" type="text/css" />');
   168   
   169   
   169   $header = $template->getHeader();
   170   $header = $template->getHeader();
   170   
   171   
   171   if ( !empty($parms) )
   172   if ( !empty($parms) )
   172   {
   173   {
   223   if ( $db->numrows() < 1 )
   224   if ( $db->numrows() < 1 )
   224   {
   225   {
   225     // Nothing in this folder, for one of two reasons:
   226     // Nothing in this folder, for one of two reasons:
   226     //   1) The folder doesn't exist
   227     //   1) The folder doesn't exist
   227     //   2) The folder exists but doesn't have any images in it
   228     //   2) The folder exists but doesn't have any images in it
       
   229     
       
   230     if ( sizeof($folders) < 1 )
       
   231     {
       
   232       // Nothing in the root folder
       
   233       
       
   234       $first_row['folder_id'] = 'NULL';
       
   235       if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) )
       
   236       {
       
   237         if ( empty($_POST['create_folder']) )
       
   238         {
       
   239           $f_errors[] = 'Please enter a folder name.';
       
   240         }
       
   241         if ( $_POST['create_folder'] == '_id' )
       
   242         {
       
   243           $f_errors[] = 'The name "_id" is reserved for internal functions and cannot be used on any image or folder.';
       
   244         }
       
   245         if ( count($f_errors) < 1 )
       
   246         {
       
   247           $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'] . ');');
       
   248           if ( !$q )
       
   249             $db->_die();
       
   250           redirect(makeUrl($paths->fullpage), 'Folder created', 'The folder "' . htmlspecialchars($_POST['create_folder']) . '" has been created. Redirecting to last viewed folder...', 2);
       
   251         }
       
   252       }
       
   253       
       
   254       $html = '';
       
   255       if ( $session->user_level >= USER_LEVEL_ADMIN )
       
   256       {
       
   257         $html .= '<p><a href="' . makeUrlNS('Special', 'GalleryUpload') . '">Upload an image</a></p>';
       
   258         $html .= '<div class="select-outer">Create new folder';
       
   259         $html .= '<div class="select-inner" style="padding-top: 4px;">';
       
   260         $html .= '<form action="' . makeUrl($paths->fullpage) . '" method="post">';
       
   261         $html .= '<input type="text" name="create_folder" size="30" /> <input type="submit" value="Create" />';
       
   262         $html .= '</form></div>';
       
   263         $html .= '</div><div class="select-pad">&nbsp;</div><br />';
       
   264       }
       
   265       
       
   266       die_friendly('No images', '<p>No images have been uploaded to the gallery yet.</p>' . $html);
       
   267     }
   228     
   268     
   229     /*
   269     /*
   230     $folders_old = $folders;
   270     $folders_old = $folders;
   231     $folders = array(
   271     $folders = array(
   232       0 => $folders_old[0]
   272       0 => $folders_old[0]
   301     $db->sql_data_seek(0, $img_query);
   341     $db->sql_data_seek(0, $img_query);
   302   }
   342   }
   303   
   343   
   304   $f_errors = array();
   344   $f_errors = array();
   305   
   345   
   306   if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) && isset($first_row['folder_id']) )
   346   if ( $session->user_level >= USER_LEVEL_ADMIN && isset($_POST['create_folder']) )
   307   {
   347   {
       
   348     if ( !isset($first_row['folder_id']) )
       
   349     {
       
   350       $first_row['folder_id'] =& $first_row['img_id'];
       
   351     }
       
   352     if ( !isset($first_row['folder_id']) )
       
   353     {
       
   354       $f_errors[] = 'Internal error getting parent folder ID';
       
   355     }
   308     if ( empty($_POST['create_folder']) )
   356     if ( empty($_POST['create_folder']) )
   309     {
   357     {
   310       $f_errors[] = 'Please enter a folder name.';
   358       $f_errors[] = 'Please enter a folder name.';
   311     }
   359     }
   312     if ( $_POST['create_folder'] == '_id' )
   360     if ( $_POST['create_folder'] == '_id' )
   433     $start = intval($_GET['start']);
   481     $start = intval($_GET['start']);
   434   }
   482   }
   435   
   483   
   436   $per_page = $rows_in_browser * 5;
   484   $per_page = $rows_in_browser * 5;
   437   
   485   
   438   $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'start=%s', true), $start, $per_page, $callers, '<table border="0" cellspacing="8"><tr>', '</tr></table>');
   486   $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', true), $start, $per_page, $callers, '<table border="0" cellspacing="8"><tr>', '</tr></table>');
   439   echo $html;
   487   echo $html;
   440   
   488   
   441   if ( $session->user_level >= USER_LEVEL_ADMIN )
   489   if ( $session->user_level >= USER_LEVEL_ADMIN )
   442   {
   490   {
   443     echo '<div class="select-outer">Create new folder';
   491     echo '<div class="select-outer">Create new folder';