plugins/gallery/browser.php
changeset 14 e47e4be549ad
parent 11 3c4304fae21e
parent 13 f6ca7cead82c
child 17 ecb96b051d08
equal deleted inserted replaced
12:3893b99cd443 14:e47e4be549ad
    35  
    35  
    36 class SnaprFormatter
    36 class SnaprFormatter
    37 {
    37 {
    38   
    38   
    39   /**
    39   /**
    40    * Counter for how many cells we've printed out in this row.
       
    41    * @var int
       
    42    */
       
    43   
       
    44   var $cell_count = 0;
       
    45   
       
    46   /**
       
    47    * Icons to print per row.
       
    48    * @var int
       
    49    */
       
    50   
       
    51   var $icons_per_row = 5;
       
    52   
       
    53   /**
       
    54    * Main render method, called from pagination function
    40    * Main render method, called from pagination function
    55    * @access private
    41    * @access private
    56    */
    42    */
    57   
    43   
    58   function render($column_crap, $row, $row_crap)
    44   function render($column_crap, $row, $row_crap)
    59   {
    45   {
    60     global $db, $session, $paths, $template, $plugins; // Common objects
    46     global $db, $session, $paths, $template, $plugins; // Common objects
    61     
    47     
    62     $out = '';
    48     $out = '<li class="snapr-icon">';
    63     
       
    64     if ( $this->cell_count == $this->icons_per_row )
       
    65     {
       
    66       $out .= '</tr><tr>';
       
    67       $this->cell_count = 0;
       
    68     }
       
    69     $this->cell_count++;
       
    70     
    49     
    71     $title_safe = $row['img_title'];
    50     $title_safe = $row['img_title'];
    72     $title_safe = htmlspecialchars($title_safe);
    51     $title_safe = htmlspecialchars($title_safe);
    73     
    52     
    74     if ( $row['is_folder'] == 1 )
    53     if ( $row['is_folder'] == 1 )
    92     }
    71     }
    93     
    72     
    94     $image_url_js = addslashes($image_link);
    73     $image_url_js = addslashes($image_link);
    95     $jsclick = ( $session->user_level < USER_LEVEL_ADMIN ) ? ' onclick="window.location=\'' . $image_url_js . '\'"' : '';
    74     $jsclick = ( $session->user_level < USER_LEVEL_ADMIN ) ? ' onclick="window.location=\'' . $image_url_js . '\'"' : '';
    96     
    75     
    97     $out .= '<td style="text-align: center;">
    76     $out .= '<div class="gallery_icon"' . $jsclick . '>';
    98             <div class="gallery_icon"' . $jsclick . '>';
    77     
    99     
    78     $out .= '<a class="snapr-imagelink" href="' . $image_link . '"><img alt="&lt;Thumbnail&gt;" class="gallery_thumb" src="' . $image_url . '" /></a>';
   100     $out .= '<a href="' . $image_link . '"><img alt="&lt;Thumbnail&gt;" class="gallery_thumb" src="' . $image_url . '" /></a>';
       
   101     
    79     
   102     if ( $session->user_level < USER_LEVEL_ADMIN )
    80     if ( $session->user_level < USER_LEVEL_ADMIN )
   103     {
    81     {
   104       $out .= $title_safe . ( isset($row['score']) ? "<br /><small>Relevance: {$row['score']}</small>" : '' );
    82       $out .= '<span class="snapr-icon-label">' . $title_safe . ( isset($row['score']) ? "<br /><small>Relevance: {$row['score']}</small>" : '' ) . '</span>';
   105     }
    83     }
   106     else if ( $session->user_level >= USER_LEVEL_ADMIN )
    84     else if ( $session->user_level >= USER_LEVEL_ADMIN )
   107     {
    85     {
   108       $out .= '<div class="menu_nojs" style="text-align: center;"><a href="#" onclick="return false;" style="width: 74px;">' . $title_safe . ( isset($row['score']) ? "<br /><small>Relevance: {$row['score']}</small>" : '' ) . '</a>';
    86       $out .= '<div class="menu_nojs snapr-icon-label" style="text-align: center;"><a href="#" onclick="return false;" style="width: 74px;">' . $title_safe . ( isset($row['score']) ? "<br /><small>Relevance: {$row['score']}</small>" : '' ) . '</a>';
   109       
    87       
   110       $url_delete = makeUrlNS('Special', 'GalleryUpload', 'rm=' . $row['img_id'], true);
    88       $url_delete = makeUrlNS('Special', 'GalleryUpload', 'rm=' . $row['img_id'], true);
   111       $url_edit   = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $row['img_id'], true);
    89       $url_edit   = makeUrlNS('Special', 'GalleryUpload', 'edit_img=' . $row['img_id'], true);
   112       
    90       
   113       // Tools menu
    91       // Tools menu
   119       $out .= '<span class="menuclear"></span>';
    97       $out .= '<span class="menuclear"></span>';
   120     }
    98     }
   121     
    99     
   122     $out .= '  </div>';
   100     $out .= '  </div>';
   123     
   101     
   124     $out .= '</td>';
   102     $out .= '</li>';
   125     
   103     
   126     return $out;
   104     return $out;
   127   }
   105   }
   128   
   106   
   129 }
   107 }
   484   if ( isset($_GET['start']) && preg_match('/^[0-9]+$/', $_GET['start']) )
   462   if ( isset($_GET['start']) && preg_match('/^[0-9]+$/', $_GET['start']) )
   485   {
   463   {
   486     $start = intval($_GET['start']);
   464     $start = intval($_GET['start']);
   487   }
   465   }
   488   
   466   
   489   $per_page = $rows_in_browser * 5;
   467   $per_page = 25;
   490   
   468   
   491   $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', false), $start, $per_page, $callers, '<table border="0" cellspacing="8"><tr>', '</tr></table>');
   469   $html = paginate($img_query, '{img_id}', $db->numrows($img_query), makeUrl($paths->fullpage, 'sort=' . $sort_column . '&order=' . $sort_order . '&start=%s', false), $start, $per_page, $callers, '<ul class="snapr-gallery">', '</ul><span class="menuclear"></span>');
   492   echo $html;
   470   echo $html;
   493   
   471   
   494   if ( $session->user_level >= USER_LEVEL_ADMIN )
   472   if ( $session->user_level >= USER_LEVEL_ADMIN )
   495   {
   473   {
   496     echo '<div class="select-outer">Create new folder';
   474     echo '<div class="select-outer">Create new folder';