plugins/CategoryList.php
changeset 2 125e913485a2
parent 1 eaeb479c52c9
child 3 6d3aeed690d1
equal deleted inserted replaced
1:eaeb479c52c9 2:125e913485a2
     7 Version: 1.0
     7 Version: 1.0
     8 Author URI: http://enanocms.org/
     8 Author URI: http://enanocms.org/
     9 */
     9 */
    10 
    10 
    11 // attach parser hook
    11 // attach parser hook
    12 $plugins->attachHook('render_wikiformat_pre', 'catlist_parser_hook($text);');
    12 $plugins->attachHook('render_wikiformat_veryearly', 'catlist_parser_hook($text);');
    13 
    13 
    14 function catlist_parser_hook(&$text)
    14 function catlist_parser_hook(&$text)
    15 {
    15 {
    16   if ( preg_match_all('/\{\{
    16   if ( preg_match_all('/\{\{
    17                          Category:
    17                          CategoryContents:
    18                          ([^|\r\n\a\t]+?)                                              # category name
    18                          ([^|\r\n\a\t]+?)                                              # category name
    19                          (\|(?:(?:[a-z0-9_]+)(?:[\s]*)=(?:[\s]*)(?:[^\}\r\n\a\t]+)))   # parameters
    19                          (\|(?:(?:[a-z0-9_]+)(?:[\s]*)=(?:[\s]*)(?:[^\}\r\n\a\t]+)))?  # parameters
    20                        \}\}/x', $text, $matches) )
    20                        \}\}/x', $text, $matches) )
    21   {
    21   {
    22     foreach ( $matches[0] as $i => $match )
    22     foreach ( $matches[0] as $i => $match )
    23     {
    23     {
    24       $cat_name =& $matches[1][$i];
    24       $cat_name =& $matches[1][$i];
   104     $html .= '<table border="0" cellspacing="1" cellpadding="4">';
   104     $html .= '<table border="0" cellspacing="1" cellpadding="4">';
   105     $html .= '<tr>';
   105     $html .= '<tr>';
   106     $ticker = 0;
   106     $ticker = 0;
   107     $have_subcats = false;
   107     $have_subcats = false;
   108     $class = 'row1';
   108     $class = 'row1';
   109     while ( $row = $db->fetchrow() )
   109     while ( $row = $db->fetchrow($q) )
   110     {
   110     {
   111       if ( empty($row['is_subcategory']) )
   111       if ( empty($row['is_subcategory']) )
   112         break;
   112         break;
   113       
   113       
   114       $have_subcats = true;
   114       $have_subcats = true;