plugins/CategoryList.php
author Dan
Fri, 15 Aug 2008 10:25:31 -0400
changeset 0 70fa9fdd6f25
child 1 eaeb479c52c9
permissions -rw-r--r--
First commit - plugin seems to be in a working state.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     1
<?php
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     2
/*
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     3
Plugin Name: Category list
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     4
Plugin URI: http://enanocms.org/
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     5
Description: A simple parser hook to display the contents of a category within another page. Syntax is {{Category:<cat name>|sub=(on|off)|pages=(on|off)}}. (Both sub [subcategories] and pages default to on)
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     6
Author: Dan Fuhry
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     7
Version: 1.0
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     8
Author URI: http://enanocms.org/
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
     9
*/
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    10
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    11
// attach parser hook
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    12
$plugins->attachHook('render_wikiformat_pre', 'catlist_parser_hook($text);');
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    13
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    14
function catlist_parser_hook(&$text)
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    15
{
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    16
  if ( preg_match_all('/\{\{
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    17
                         Category:
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    18
                         ([^|\r\n\a\t]+?)                                              # category name
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    19
                         (\|(?:(?:[a-z0-9_]+)(?:[\s]*)=(?:[\s]*)(?:[^\}\r\n\a\t]+)))   # parameters
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    20
                       \}\}/x', $text, $matches) )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    21
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    22
    foreach ( $matches[0] as $i => $match )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    23
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    24
      $cat_name =& $matches[1][$i];
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    25
      $params =& $matches[2][$i];
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    26
      $params = catlist_parse_params($params);
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    27
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    28
      $do_subs = ( isset($params['sub']) && $params['sub'] === 'off' ) ? false : true;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    29
      $do_pages = ( isset($params['pages']) && $params['pages'] === 'off' ) ? false : true;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    30
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    31
      $result = catlist_print_category($cat_name, $do_subs, $do_pages);
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    32
      $text = str_replace($match, $result, $text);
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    33
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    34
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    35
}
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    36
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    37
function catlist_parse_params($params)
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    38
{
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    39
  $params = trim($params, '|');
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    40
  $params = explode('|', $params);
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    41
  $return = array();
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    42
  foreach ( $params as $val )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    43
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    44
    if ( preg_match('/^([a-z0-9_]+)(?:[\s]*)=(?:[\s]*)([^\}\r\n\a\t]+)$/', $val, $match) )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    45
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    46
      $return[ $match[1] ] = $match[2];
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    47
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    48
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    49
  return $return;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    50
}
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    51
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    52
function catlist_print_category($cat_name, $do_subs, $do_pages)
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    53
{
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    54
  // nicely format and print the category out, then return HTML
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    55
  global $db, $session, $paths, $template, $plugins; // Common objects
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    56
  
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    57
  // make sane the category ID
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    58
  $cat_id = $db->escape(sanitize_page_id($cat_name));
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    59
  
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    60
  // if we're doing both, use the more complicated query
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    61
  if ( $do_subs && $do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    62
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    63
    
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    64
    $q = $db->sql_query('SELECT c.page_id, c.namespace, p.name, ( c.namespace = \'Category\' ) AS is_subcategory FROM ' . table_prefix . "categories AS c\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    65
                      . "  LEFT JOIN " . table_prefix . "pages AS p\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    66
                      . "    ON ( p.urlname = c.page_id AND p.namespace = c.namespace )\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    67
                      . "  WHERE c.category_id = '$cat_id'\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    68
                      . "  ORDER BY is_subcategory DESC;");
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    69
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    70
  else
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    71
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    72
    // nice little where clause...
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    73
    if ( $do_subs && !$do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    74
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    75
      $where = 'c.namespace = \'Category\'';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    76
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    77
    else if ( $do_pages && !$do_subs )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    78
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    79
      $where = 'c.namespace != \'Category\'';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    80
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    81
    else
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    82
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    83
      // ok, subs = off AND pages = off. some people are dummies.
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    84
      return '';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    85
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    86
    $q = $db->sql_query('SELECT c.page_id, c.namespace, p.name, ( c.namespace = \'Category\' ) AS is_subcategory FROM ' . table_prefix . "categories AS c\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    87
                      . "  LEFT JOIN " . table_prefix . "pages AS p\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    88
                      . "    ON ( p.urlname = c.page_id AND p.namespace = c.namespace )\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    89
                      . "  WHERE c.category_id = '$cat_id' AND $where\n"
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    90
                      . "  ORDER BY is_subcategory DESC;");
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    91
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    92
  if ( !$q )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    93
    $db->_die();
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    94
  
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    95
  $html = '';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    96
  if ( $do_subs && $do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    97
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    98
    $html .= '<h3>Subcategories</h3>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    99
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   100
  if ( $do_subs )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   101
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   102
    // LIST: subcategories
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   103
    $html .= '<div class="tblholder">';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   104
    $html .= '<table border="0" cellspacing="1" cellpadding="4">';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   105
    $html .= '<tr>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   106
    $ticker = 0;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   107
    $have_subcats = false;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   108
    $class = 'row1';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   109
    while ( $row = $db->fetchrow() )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   110
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   111
      if ( empty($row['is_subcategory']) )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   112
        break;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   113
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   114
      $have_subcats = true;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   115
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   116
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   117
      if ( $ticker == 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   118
      {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   119
        $ticker = 0;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   120
        $html = '</tr><tr>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   121
        $class = ( $class == 'row1' ) ? 'row2' : 'row1';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   122
      }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   123
      $inner = '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], false, true) . '">' . htmlspecialchars($row['name']) . '</a>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   124
      $html .= '<td style="width: 33.3%;" class="' . $class . '">' . $inner . '</td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   125
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   126
    if ( !$have_subcats )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   127
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   128
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   129
      $html .= '<td style="width: 33.3%;" class="' . $class . '">No subcategories.</td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   130
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   131
    // fill in the rest of the table
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   132
    while ( $ticker < 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   133
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   134
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   135
      $html .= '<td style="width: 33.3%;" class="' . $class . '"></td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   136
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   137
    $html .= '</table></div>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   138
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   139
  if ( $do_subs && $do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   140
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   141
    $html .= '<h3>Pages</h3>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   142
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   143
  if ( $do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   144
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   145
    // LIST: member pages
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   146
    $html .= '<div class="tblholder">';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   147
    $html .= '<table border="0" cellspacing="1" cellpadding="4">';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   148
    $html .= '<tr>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   149
    $ticker = 0;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   150
    $have_pages = false;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   151
    $class = 'row1';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   152
    // using do-while because the last row was already fetched if we had to do subcategories
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   153
    do
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   154
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   155
      if ( !$do_subs && !isset($row) )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   156
        $row = $db->fetchrow();
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   157
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   158
      if ( !$row )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   159
        break;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   160
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   161
      $have_pages = true;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   162
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   163
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   164
      if ( $ticker == 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   165
      {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   166
        $ticker = 0;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   167
        $html = '</tr><tr>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   168
        $class = ( $class == 'row1' ) ? 'row2' : 'row1';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   169
      }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   170
      $inner = '<a href="' . makeUrlNS($row['namespace'], $row['page_id'], false, true) . '">' . htmlspecialchars($row['name']) . '</a>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   171
      $html .= '<td style="width: 33.3%;" class="' . $class . '">' . $inner . '</td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   172
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   173
    while ( $row = $db->fetchrow() );
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   174
    
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   175
    if ( !$have_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   176
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   177
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   178
      $html .= '<td style="width: 33.3%;" class="' . $class . '">No pages in this category.</td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   179
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   180
    // fill in the rest of the table
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   181
    while ( $ticker < 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   182
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   183
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   184
      $html .= '<td style="width: 33.3%;" class="' . $class . '"></td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   185
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   186
    $html .= '</table></div>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   187
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   188
  return $html;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   189
}