plugins/CategoryList.php
author Dan
Sat, 16 May 2009 19:57:10 -0400
changeset 3 6d3aeed690d1
parent 2 125e913485a2
child 4 d5b2e522396d
permissions -rw-r--r--
Updated syntax summary
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/
3
6d3aeed690d1 Updated syntax summary
Dan
parents: 2
diff changeset
     5
Description: A simple parser hook to display the contents of a category within another page. Syntax is {{CategoryContents:<cat name>|sub=(on|off)|pages=(on|off)}}. (Both sub [subcategories] and pages default to on)
0
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
2
125e913485a2 Updated for Enano 1.1.6.
Dan
parents: 1
diff changeset
    12
$plugins->attachHook('render_wikiformat_veryearly', 'catlist_parser_hook($text);');
0
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('/\{\{
2
125e913485a2 Updated for Enano 1.1.6.
Dan
parents: 1
diff changeset
    17
                         CategoryContents:
0
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
    18
                         ([^|\r\n\a\t]+?)                                              # category name
2
125e913485a2 Updated for Enano 1.1.6.
Dan
parents: 1
diff changeset
    19
                         (\|(?:(?:[a-z0-9_]+)(?:[\s]*)=(?:[\s]*)(?:[^\}\r\n\a\t]+)))?  # parameters
0
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';
2
125e913485a2 Updated for Enano 1.1.6.
Dan
parents: 1
diff changeset
   109
    while ( $row = $db->fetchrow($q) )
0
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
      if ( $ticker == 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   117
      {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   118
        $ticker = 0;
1
eaeb479c52c9 Fixed typo that blanked out $html (oops)
Dan
parents: 0
diff changeset
   119
        $html .= '</tr><tr>';
0
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   120
        $class = ( $class == 'row1' ) ? 'row2' : 'row1';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   121
      }
1
eaeb479c52c9 Fixed typo that blanked out $html (oops)
Dan
parents: 0
diff changeset
   122
      $ticker++;
eaeb479c52c9 Fixed typo that blanked out $html (oops)
Dan
parents: 0
diff changeset
   123
      
0
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   124
      $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
   125
      $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
   126
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   127
    if ( !$have_subcats )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   128
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   129
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   130
      $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
   131
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   132
    // fill in the rest of the table
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   133
    while ( $ticker < 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   134
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   135
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   136
      $html .= '<td style="width: 33.3%;" class="' . $class . '"></td>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   137
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   138
    $html .= '</table></div>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   139
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   140
  if ( $do_subs && $do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   141
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   142
    $html .= '<h3>Pages</h3>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   143
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   144
  if ( $do_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   145
  {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   146
    // LIST: member pages
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   147
    $html .= '<div class="tblholder">';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   148
    $html .= '<table border="0" cellspacing="1" cellpadding="4">';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   149
    $html .= '<tr>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   150
    $ticker = 0;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   151
    $have_pages = false;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   152
    $class = 'row1';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   153
    // 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
   154
    do
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   155
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   156
      if ( !$do_subs && !isset($row) )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   157
        $row = $db->fetchrow();
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   158
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   159
      if ( !$row )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   160
        break;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   161
      
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   162
      $have_pages = true;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   163
      
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;
1
eaeb479c52c9 Fixed typo that blanked out $html (oops)
Dan
parents: 0
diff changeset
   167
        $html .= '</tr><tr>';
0
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
      }
1
eaeb479c52c9 Fixed typo that blanked out $html (oops)
Dan
parents: 0
diff changeset
   170
      $ticker++;
eaeb479c52c9 Fixed typo that blanked out $html (oops)
Dan
parents: 0
diff changeset
   171
      
0
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   172
      $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
   173
      $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
   174
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   175
    while ( $row = $db->fetchrow() );
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
    if ( !$have_pages )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   178
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   179
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   180
      $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
   181
    }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   182
    // fill in the rest of the table
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   183
    while ( $ticker < 3 )
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   184
    {
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   185
      $ticker++;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   186
      $html .= '<td style="width: 33.3%;" class="' . $class . '"></td>';
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
    $html .= '</table></div>';
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   189
  }
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   190
  return $html;
70fa9fdd6f25 First commit - plugin seems to be in a working state.
Dan
parents:
diff changeset
   191
}