includes/functions.php
changeset 298 39c132e69781
parent 276 acfdccf7a2bf
child 299 ce2873735506
equal deleted inserted replaced
292:b3cfaf0a505c 298:39c132e69781
   549 }
   549 }
   550 
   550 
   551 /**
   551 /**
   552  * Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths.
   552  * Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths.
   553  */
   553  */
   554 
       
   555  /*
       
   556 function show_category_info()
       
   557 {
       
   558   global $db, $session, $paths, $template, $plugins; // Common objects
       
   559   dc_here('functions: showing category info');
       
   560   // if($template->no_headers && !strpos($_SERVER['REQUEST_URI'], 'ajax.php')) return '';
       
   561   if ( $paths->namespace == 'Category' )
       
   562   {
       
   563     $q = $db->sql_query('SELECT page_id,namespace FROM '.table_prefix.'categories WHERE category_id=\''.$paths->cpage['urlname_nons'].'\' AND namespace=\'Category\' ORDER BY page_id;');
       
   564     if(!$q) $db->_die('The category information could not be selected.');
       
   565     $ticker = -1;
       
   566     echo '<h3>Subcategories</h3>';
       
   567     if($db->numrows() < 1) echo '<p>There are no subcategories in this category.</p>';
       
   568     echo '<table border="0" cellspacing="1" cellpadding="4">';
       
   569     while($row = $db->fetchrow())
       
   570     {
       
   571       $ticker++;
       
   572       if ( $ticker == 3 )
       
   573       {
       
   574         $ticker = 0;
       
   575       }
       
   576       if ( $ticker == 0 )
       
   577       {
       
   578         echo '<tr>';
       
   579       }
       
   580       echo '<td style="width: 200px;"><a href="' . makeUrlNS($row['namespace'], $row['page_id']) . '">' . htmlspecialchars($paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name']) . '</a></td>';
       
   581       if ( $ticker == 2 )
       
   582       {
       
   583         echo '</tr>';
       
   584       }
       
   585     }
       
   586     $db->free_result();
       
   587     if($ticker) echo '</tr>';
       
   588     echo '</table>';
       
   589 
       
   590     $q = $db->sql_query('SELECT page_id,namespace FROM '.table_prefix.'categories WHERE category_id=\''.$paths->cpage['urlname_nons'].'\' AND namespace!=\'Category\' ORDER BY page_id;');
       
   591     if ( !$q )
       
   592     {
       
   593       $db->_die('The category information could not be selected.');
       
   594     }
       
   595     $ticker = -1;
       
   596     echo '<h3>Pages</h3>';
       
   597     if ( $db->numrows() < 1 )
       
   598     {
       
   599       echo '<p>There are no pages in this category.</p>';
       
   600     }
       
   601     echo '<table border="0" cellspacing="1" cellpadding="4">';
       
   602     while($row = $db->fetchrow())
       
   603     {
       
   604       $ticker += ( $ticker == 3 ) ? -3 : 1;
       
   605       if ( $ticker == 0 )
       
   606       {
       
   607         echo '<tr>';
       
   608       }
       
   609       echo '<td style="width: 200px;"><a href="'.makeUrlNS($row['namespace'], $row['page_id']).'">'.htmlspecialchars($paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name']).'</a></td>';
       
   610       if ( $ticker == 2 )
       
   611       {
       
   612         echo '</tr>';
       
   613       }
       
   614     }
       
   615     $db->free_result();
       
   616     if($ticker) echo '</tr>';
       
   617     echo '</table><br /><br />';
       
   618   }
       
   619   $q = $db->sql_query('SELECT category_id FROM '.table_prefix.'categories WHERE page_id=\''.$paths->cpage['urlname_nons'].'\' AND namespace=\''.$paths->namespace.'\'');
       
   620   if(!$q) $db->_die('The error seems to have occurred during selection of category data.');
       
   621   if($db->numrows() > 0) {
       
   622     echo '<div class="mdg-comment" style="margin-left: 0;">Categories: ';
       
   623     $i=0;
       
   624     while($r = $db->fetchrow())
       
   625     {
       
   626       if($i>0) echo ', ';
       
   627       $i++;
       
   628       echo '<a href="'.makeUrlNS('Category', $r['category_id']).'">'.$paths->pages[$paths->nslist['Category'].$r['category_id']]['name'].'</a>';
       
   629     }
       
   630     if( ( $paths->wiki_mode && !$paths->page_protected ) || ( $session->get_permissions('edit_cat') && $session->get_permissions('even_when_protected') ) ) echo ' [ <a href="'.makeUrl($paths->page, 'do=catedit', true).'" onclick="ajaxCatEdit(); return false;">edit categorization</a> ]</div>';
       
   631   } 
       
   632   else
       
   633   {
       
   634     echo '<div class="mdg-comment" style="margin-left: 0;">Categories: ';
       
   635     echo '(Uncategorized)';
       
   636     if( ( $paths->wiki_mode && !$paths->page_protected ) || ( $session->get_permissions('edit_cat') && $session->get_permissions('even_when_protected') ) ) echo ' [ <a href="'.makeUrl($paths->page, 'do=catedit', true).'" onclick="ajaxCatEdit(); return false;">edit categorization</a> ]</div>';
       
   637     else echo '</div>';
       
   638   }
       
   639   $db->free_result();
       
   640 }
       
   641 */
       
   642 
   554 
   643 function show_category_info()
   555 function show_category_info()
   644 {
   556 {
   645   global $db, $session, $paths, $template, $plugins; // Common objects
   557   global $db, $session, $paths, $template, $plugins; // Common objects
   646   
   558