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