Mediawiki Coppermine Photo Gallery last photo

From Meta, a Wikimedia project coordination wiki

Jump to: navigation, search
Blue Glass Arrow.svg MediaWiki logo.png
This page should be moved to MediaWiki.org.
Please do not move the page by hand. It will be imported by a MediaWiki.org administrator with the full edit history. In the meantime, you may continue to edit the page as normal.

This is the wiki page about Mediawiki Coppermine Photo Gallery last photo, an extension of Mediawiki. This extension can be downloaded from its home page and contains authoritative information about the project.

License: GNU GPL

Description: Shows last added photo from Coppermine Gallery

Comments:

  • Need some cleaning (almost raw from dpLastPost),
  • Set your coding at the end of te code (return function).

[edit] Source code

<?php
# BASED on runphp Mediawiki Extension http://meta.wikimedia.org/wiki/Runphp
# BASED on dpLastPost from PostNuke

# To use extension type at your wiki: <gallast></gallast>

# To activate the extension, include it from your LocalSettings.php
# with: include("extensions/gallast.php");

# Przemyslaw Stanislaw Knycz
# JID: djrzulf@kol.net.pl
# Written for http://czechowice.net/

$wgExtensionFunctions[] = "wfRunCoppermineLast";

function wfRunCoppermineLast() {
    global $wgParser;
    $wgParser->setHook( "gallast", "GCL" );
}


function GCL() {
        $ipb_path = "http://gallery.somewhere.at.net/";
        $ipb_table_prefix = "prefix";
        $ipb_dbhost = "localhost";
        $ipb_dbuser = "dbuser";
        $ipb_dbpass = "dbpass";
        $ipb_dbname = "dbname";

        $content = '';
        $db_link = mysql_connect($ipb_dbhost, $ipb_dbuser, $ipb_dbpass);
        $sql = "SELECT pid, aid, filepath, filename, hits, owner_id, owner_name, title FROM "
                . $ipb_table_prefix."_pictures WHERE approved='YES' ORDER BY pid DESC LIMIT 1";
        mysql_select_db( $ipb_dbname, $db_link );
        $result = mysql_db_query($ipb_dbname, $sql, $db_link);

        $content .= '<table align="center" width="100%" cellpadding="5" cellspacing="0" border="0">';
        while( $rows = mysql_fetch_object($result))
        {
                $filename = $rows->filename;
                $autor = $rows->owner_name;
                $autorid = $rows->owner_id;
                $title = $rows->title;

                $tid = $rows->pid;
                $replies = $rows->aid;

                $last_poster_id = $rows->owner_id;
                $forum_id = $rows->filepath;
                $last_post = $rows->aid;
                $views = $rows->hits;

                $content .= '<tr><td align="center" style="background-color: #F2ECE9; border: 1px solid  #FFFFFF;"><b>Ostatnio dodane</b><hr />'.$title.'<br /><br />';
                $linkthumb = $ipb_path.'albums/'.$forum_id.'thumb_'.rawurlencode($filename);
                $linknormal = $ipb_path.'displayimage.php?album=lastup&cat=0&pos=0';
                $content .= '<a target="_BLANK" href="'.$linknormal.'"><img src="'.$linkthumb.'"></a><br />Dodał: <a href="http://gallery.somewhere.at.net/profile.php?uid='.$autorid.'">'.$autor.'</a><br />Obejrzeń: '.$views.'</td>';
                $content .= '</tr>';
        }
                        $content .= '</table>';

        return mb_convert_encoding($content,'UTF-8', 'ISO-8859-2');
}



?>


[edit] Page

http://www.czechowice.net/wiki/Mediawiki_Coppermine_Photo_Gallery_last_photo