Random Gallery block tweaks

Creating and modifying plugins.
Post Reply
superpowerup
Regular
Posts: 11
Joined: Sun Jun 17, 2007 5:21 am

Random Gallery block tweaks

Post by superpowerup »

I am currently running the Random Gallery block plugin, and it's working great. What I'd like to do is remove the details that are posted with the image, like the part that says "Random Image," the filename, date, and views. I only want the image to show. Can anyone tell me what part of the code I need to remove in the plugin in order to do this? Any help is appreciated. Thanks!!

Code: Select all

<?php # $Id: serendipity_plugin_gallery_menalto_random.php,v 1.13 2006/12/01 09:00:54 garvinhicking Exp $

require_once S9Y_PEAR_PATH . 'HTTP/Request.php';


if (IN_serendipity !== true) {
    die ("Don't hack!");
}

// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
    include $probelang;
}

include dirname(__FILE__) . '/lang_en.inc.php';

class serendipity_plugin_gallery_menalto_random extends serendipity_plugin {
    var $title = PLUGIN_GALLERYRANDOMBLOCK_NAME;

    function introspect(&$propbag)
    {
        $this->title = $this->get_config('title', $this->title);

        $propbag->add('name',          PLUGIN_GALLERYRANDOMBLOCK_NAME);
        $propbag->add('description',   PLUGIN_GALLERYRANDOMBLOCK_DESC);
        $propbag->add('stackable',     false);
        $propbag->add('author',        'Andrew Brown, Tadashi Jokagi');
        $propbag->add('version',       '1.8');
        $propbag->add('requirements',  array(
            'serendipity' => '0.8',
            'smarty'      => '2.6.7',
            'php'         => '4.1.0'
        ));
        $propbag->add('groups', array('IMAGES'));
        $propbag->add('configuration', array('title', 'path', 'file', 'repeat', 'gversion'));
    }

    function introspect_config_item($name, &$propbag)
    {
        global $serendipity;

        switch($name) {
            case 'title':
                $propbag->add('type',        'string');
                $propbag->add('name',        TITLE);
                $propbag->add('description', TITLE);
                $propbag->add('default',     '');
                break;

            case 'itemId':
                $propbag->add('type',        'string');
                $propbag->add('name',        PLUGIN_GALLERYRANDOMBLOCK_ITEMID);
                $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_ITEMID_DESC);
                $propbag->add('default',     '');
                break;

            case 'path':
                if ((int)$serendipity['serendipityUserlevel'] < (int)USERLEVEL_ADMIN) {
                    return false;
                }
                $propbag->add('type',        'string');
                $propbag->add('name',        PLUGIN_GALLERYRANDOMBLOCK_URL_NAME);
                $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_URL_DESC);
                $propbag->add('default',     $serendipity['baseURL'] . '/gallery/');
                break;

            case 'file':
                if ((int)$serendipity['serendipityUserlevel'] < (int)USERLEVEL_ADMIN) {
                    return false;
                }

                $propbag->add('type',        'string');
                $propbag->add('name',        PLUGIN_GALLERYRANDOMBLOCK_FILE_NAME);
                $propbag->add('description', '');
                $propbag->add('default',     'block-random.php');
                break;

            case 'repeat':
                $propbag->add('type',        'string');
                $propbag->add('name',        PLUGIN_GALLERYRANDOMBLOCK_NUMREPEAT_NAME);
                $propbag->add('description', PLUGIN_GALLERYRANDOMBLOCK_NUMREPEAT_DESC);
                $propbag->add('default',     '1');
                break;

            case 'gversion':
                $propbag->add('type',        'select');
                $propbag->add('name',        PLUGIN_GALLERYRANDOMBLOCK_VERSION);
                $propbag->add('description', '');
                $propbag->add('default',     1);
                $propbag->add('select_values', array(
                                                1  => '1.x',
                                                2  => '2.x'
                ));

                break;

            default:
                    return false;
        }
        return true;
    }

    function generate_content(&$title) {
        global $serendipity;

        $title = $this->get_config('title');
        $path  = $this->get_config('path');
        $file  = $this->get_config('file');
        $repeat = $this->get_config('repeat');

        if (!is_numeric($repeat)) {
            $repeat = 1;
        }

        if ($path != "") {
            if (substr($path,-1) != '/') {
                $path .= '/';
            }

            if ((int)$this->get_config('gversion') === 2) {
                $file = 'main.php?g2_view=imageblock:External&g2_blocks=randomImage&g2_itemFrame=none';
                $gid  = $this->get_config('itemId');
                if ($gid > 0) {
                    $file .='&g2_itemId=' . $gid;
                }
            }

            if (empty($file)) {
                $file = 'block-random.php';
            }

            for ($i=1; $i <= $repeat; $i++) {

                $options = array();
                $req = new HTTP_Request($path.$file,$options);
                $req_result = $req->sendRequest();
                if ( PEAR::isError( $req_result)) {
                    echo PLUGIN_GALLERYRANDOMBLOCK_ERROR_CONNECT . "<br />\n";
                } else {
                    $res_code = $req->getResponseCode();
                    if ($res_code != "200") {
                        printf( PLUGIN_GALLERYRANDOMBLOCK_ERROR_HTTP . "<br />\n", $res_code);
                    } else {
                        echo $req->getResponseBody();
                    }
                }
                if ($i < $repeat) {
                    echo '<hr />';
                }
            }
        }
    }
}
/* vim: set sts=4 ts=4 expandtab : */
?>
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

You might take a look at the "Unified Sidebar Image Display". I expanded the Gallery section a while ago to give slightly more control over what fields are displayed. You just need to set the the "Image Source" option to "Menalto Gallery URL" and then choose "2.x" (or whatever it is).

If you need help figuring out the options feel free to post and I can try to remember what everything is.
superpowerup
Regular
Posts: 11
Joined: Sun Jun 17, 2007 5:21 am

Wow!

Post by superpowerup »

Awesome! That works perfectly. Exactly what I wanted!!! Thank you :D

Been working on getting this up and running today (including editing an existing template to the colors I wanted) and I'm really happy with it now.

http://www.superpowerup.com
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

It looks good! Glad you are enjoying Serendipity!
chigo58
Regular
Posts: 12
Joined: Tue Jun 19, 2007 8:35 am
Contact:

Post by chigo58 »

Dear mgroeninger,

Please take a look at the site I am trying to put together: http://sliemascouts.org/content

The problem I have is that I am using the "Unified Sidebar Image Display" in conjunction with G2.1.2. you can get to the gallery here http://sliemascouts.org/gallery. The error I seem to be getting is "Security Violation-The action you attempted is not permitted" Also note that the URL link "Back to the gallery" is mal-constructed.

Could you please help me resolve this error?

Thanks and regards,
Donald
scottwalsh
Regular
Posts: 17
Joined: Sun May 20, 2007 9:05 am
Contact:

Post by scottwalsh »

Hi chigo58

Have you had a look at http://board.s9y.org/viewtopic.php?t=8296 ?
Sounds a simliar issue...
------

Scott Walsh

http://zone3.net.nz/
profile, journal of travels and photos
chigo58
Regular
Posts: 12
Joined: Tue Jun 19, 2007 8:35 am
Contact:

Post by chigo58 »

Yep did that thanks.

I resolved it by installing Coppermine and using the plugin mentioned above.

Anybody know if there is an import tool for Gallery1.x albums into coppermine?
Post Reply