In light of religious terrorist attacks in Paris, please see Category:blasphemy!

Freedom Porn:free technology/CategoryHits

From Freedom Porn
Jump to: navigation, search

This extension was originally developed at http://www.mediawiki.org/wiki/Extension:CategoryHits

You can see this extensions with the changes below at work here.

Licence

Available under the terms of GNU General Public License 3.0

Produced in the year 2013.
GPLv3
For more information please see Freedom Porn:copyrights.


Changes

In CategoryHits_body.php change $query definition to (note your namespaces will differ

        $namespaces = 'page_namespace = '.NS_MAIN.
                ' OR page_namespace = '.NS_PROJECT.
                ' OR page_namespace = '.NS_GALLERY.
                ' OR page_namespace = '.NS_IMAGE.
                ' OR page_namespace = '.NS_TEXT.
                ' OR page_namespace = '.NS_AUDIO.
                ' OR page_namespace = '.NS_VIDEO;
        $query='SELECT cl_to, SUM(page_counter) AS pcount, COUNT(page_id) AS pages, category_counter FROM '.
               '  (SELECT * FROM ' . $dbr->tableName('categorylinks') .
               '    LEFT JOIN (SELECT page_id, page_namespace, page_title, page_counter FROM '.
                      $dbr->tableName('page') .
               '      WHERE '.$namespaces.') AS mypages'.
               '    ON cl_from = page_id'.
               '    ORDER BY cl_to ASC) AS mytemptable'.
               '  LEFT JOIN (SELECT page_title, page_counter AS category_counter '.
               '    FROM '.$dbr->tableName('page').' WHERE page_namespace = 14) AS mycategory'.
               '  ON cl_to = mycategory.page_title '.
               'GROUP BY cl_to ORDER BY pcount DESC;';

change the header of the table to

         . XML::openElement('tr')
         . XML::openElement('th')
         . 'Category'
         . XML::closeElement('th')
         . XML::openElement('th')
         . '№ Topics'
         . XML::closeElement('th')
         . XML::openElement('th')
         . '№ Category Topics Hits'
         . XML::closeElement('th')
         . XML::openElement('th')
         . '№ Category Page Hits'
         . XML::closeElement('th')
         . XML::closeElement('tr');

and add when the table body is generated after pcount add

             . XML::openElement('td', array('align' => 'center', 'bgcolor' => $bgcolor))
             . $row->category_counter
             . XML::closeElement('td')

It's nice to remove underscores from the user's view by:

             . XML::openElement('a', array('href' => $mypage))
             . str_replace('_', ' ', $row->cl_to)
             . XML::closeElement('td')

You may also wish to change the definition of $mypage to something along the lines of

$mypage = "/smut/Category:$row->cl_to";

although your directory will probably be different.