Skip to Content Skip to Menu

developing simple plugin, little help required.

  • radio
  • radio
  • OFFLINE
  • Posts: 18
  • Thanks: 0
  • Karma: 6
16 years 8 months ago #57550 by radio
I'm currently in the process of learning PHP and programming in general Iv mastered the basics of it but I'm not fully up to speed on the object orientated aspect of it yet. Anyway I'm trying to develop a very simple plug in for cb that will show the x number of latest photos added to the cb gallery in thumbnail format. Iv managed to get a prototype working but im just using html to resize the images to specified height and width parameters. This is obviously not very good as the images are displayed distorted so Id like to use the GD library functions resample the image so the images are displayed without distortion and in the correct aspect ratio based on either max height and max width params. I know this can be achived in cb via the imagetoolbox class but i just cant figure out how to apply it to what i already have.

Here is my working code so far if somebody can show me how to apply imagetoolbox to this then ill be a very happy man:

[code:1]/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );


/**
* Basic tab extender. Any plugin that needs to display a tab in the user profile
* needs to have such a class. Also, currently, even plugins that do not display tabs (e.g., auto-welcome plugin)
* need to have such a class if they are to access plugin parameters (see $this->params statement).
*/
class getlatestphotosTab extends cbTabHandler {
/**
* Construnctor
*/
function getlatestphotosTab() {
$this->cbTabHandler();
}

/**
* Generates the HTML to display the user profile tab
* @param object tab reflecting the tab database entry
* @param object mosUser reflecting the user being displayed
* @param int 1 for front-end, 2 for back-end
* @returns mixed : either string HTML for tab content, or false if ErrorMSG generated
*/
function getDisplayTab($tab,$user,$ui) {
global $database, $my;

$return = null;
$params = $this->params; // get parameters (plugin and related tab)


$count = intval($params->get( 'count', 3) );
$widththumbcb = intval( $params->get( 'width_thumbcb', 60) );
$heightthumbcb = intval( $params->get( 'height_thumbcb', 80) );

if($tab->description != null) {
$return .= "\t\t<div class=\"tab_Description\">"
. $tab->description // html content is allowed in descriptions
. "</div>\n";
}



$query = "SELECT*"
."\n FROM jos_comprofiler_plug_profilegallery"
."\n WHERE userid=".$user->id
. "\n ORDER BY pgitemdate DESC"
. "\n LIMIT ".$count;



$database->setQuery($query);
$rows=$database->loadObjectList();

foreach($rows as $row) {

$PGItemPath= "images/comprofiler/plug_profilegallery/";
$pgitemfilename = $row->pgitemfilename;
$PGItemUserPath = $PGItemPath . $user->id . "/".$pgitemfilename ;



if ( $row->pgitempublished != 1 || $row->pgitemapproved != 1 ) {

$return =' ';
}

else


$img = "<img width=\"".$widththumbcb."\" height=\"".$heightthumbcb."\" src=\"".$PGItemUserPath."\" alt=\" "." \" border=\"0\"/>";

$return .= "\t\t<div class=\"connectionBox\" >\n"
. "<p>".$img


. "</p>"
. "</div>\n";





}
return $return;
} // end or getDisplayTab function
} // end of gethelloworldTab class
?>[/code:1]

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
16 years 8 months ago #57575 by nant
Nice learning exercise - personally I have programmed this as a module (CB Gallery module) displaying gallery items from all users.

You can use the module logic to resize the larger images down to smaller dimensions without physically resizing the images.

Please Log in or Create an account to join the conversation.

  • radio
  • radio
  • OFFLINE
  • Posts: 18
  • Thanks: 0
  • Karma: 6
16 years 8 months ago #57630 by radio
ok I see the logic in there, but I take it there is no resampling being done with the gd library functions which is what i was really looking for.

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
16 years 8 months ago #57633 by nant
radio wrote:

ok I see the logic in there, but I take it there is no resampling being done with the gd library functions which is what i was really looking for.


Why do you need re-sampling?

To re-sample, you would need to store the outcome somewhere. To store you need to give it a name, etc...

Please Log in or Create an account to join the conversation.

  • radio
  • radio
  • OFFLINE
  • Posts: 18
  • Thanks: 0
  • Karma: 6
16 years 8 months ago #57637 by radio
I was just trying to gain the best quality output. I probably dont need it Im in the process of trying it with the logic from your module.

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in or Create an account to join the conversation.

  • radio
  • radio
  • OFFLINE
  • Posts: 18
  • Thanks: 0
  • Karma: 6
16 years 8 months ago #57640 by radio
I got it working using the logic from your module but the images still look a bit blocky. Im going to try and incorporate some resampling to smooth them out. I take it i should use the standard gd library functions in php and not the imagetoolbox?


So you cant resample on the fly? Id have to store it on hard drive as a file it cant be store in memory?

Post edited by: radio, at: 2008/02/27 00:10

Interested in improving Joomla as a social networking platform? If yes join joomlaplazza.com

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum