Codice PHP:
<?php /** * @version 1.5 * @package VehicleManagerTop * @copyright 2009 OrdaSoft * @author 2009 Sergey Drughinin-OrdaSoft(Sergey.dru@gmail.com) * @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL * @description VehicleTop for VehicleManager Component */ /** ensure this file is being included by a parent file */ defined( '_JEXEC' ) or die( 'Restricted access' ); $database = &JFactory::getDBO(); if( !function_exists( 'sefreltoabs')) { function sefRelToAbs( $value ) { //Need check!!! // Replace all & with & as the router doesn't understand & $url = str_replace('&', '&', $value); if(substr(strtolower($url),0,9) != "index.php") return $url; $uri = JURI::getInstance(); $prefix = $uri->toString(array('scheme', 'host', 'port')); return $prefix.JRoute::_($url); } } //Common parameters $sort_top_by = $params->def('sort_by_top', 0); //Get how to sort the top items $show_published = $params->def('only_published', 1); //Get if we only show published items $show_covers = $params->def('covers', 0 ); //Get if we Real Estate photos $cover_height = $params->def('cover_height', "50"); //Get Real Estate photos $show_extra = $params->def('extras', 1 ); //Get if we show second column with additional info $show_ranking = $params->def('ranking', 0 ); //Get if we show the ranking next to them $showprice = $params->get ('price', 1); //Individual parameters $count_vehicle= intval($params->def('books',1)); //Definition of Sorts switch($sort_top_by) { case 0: $sql_sort_top = "hits"; break; case 1: $sql_sort_top = "date"; break; // case 2: // $sql_sort_top = "rating"; // break; } //Check if only display published items if ($show_published==1) { $sql_published = "WHERE published=1"; } else { $sql_published = ""; } if($count_vehicle!='' && $count_vehicle!=0) { $selectstring = "SELECT vtitle,id,image_link,hits,catid,price FROM #__vehiclemanager_vehicles " .$sql_published." ORDER BY ".$sql_sort_top." DESC LIMIT 0, $count_vehicle;"; $database->setQuery($selectstring); $rows_vehicle= $database->loadObjectList(); } $selectstring = "SELECT id FROM #__menu WHERE link='index.php?option=com_vehiclemanager'"; $database->setQuery($selectstring); $ItemId_tmp = $database->loadResult(); function DisplayVM($rows, $name, $show_ranking, $show_covers, $show_extra, $cover_height, $ItemId_tmp,$showprice) { $rank_count = 0; $span=0; if($show_ranking!=0) $span++; if($show_covers!=0) $span++; if($show_extra!=0) $span++; ?> <table cellpadding="0" cellspacing="0" class="moduletable" width="100%" border="0"> <?php foreach ($rows as $row) { $rank_count = $rank_count + 1; //start ranking $link1 ="index.php?option=com_vehiclemanager&task=view&id=" .$row->id."&catid=".$row->catid."&Itemid=".$ItemId_tmp; $imageURL = $row->image_link ; if($imageURL != '' && substr($imageURL,0,4) != "http") { $imageURL = "./components/com_vehiclemanager/photos/".$row->image_link; } if($imageURL == ''){ $imageURL = "./components/com_vehiclemanager/images/no-img_eng.gif"; } ?> <tr> <?php if($show_ranking==1) { echo "<td>".$rank_count.":</td>"; } //Add Column for Ranking if param set ?> <?php if ($show_covers==1) {?> <td> [img]<?php echo $imageURL; ?>[/img]vtitle; ?>" hspace="2" vspace="2" border="0" height="<?php echo $cover_height; ?>" /> </td> <?php } ?> <td width="160" <?php if($span!=0) echo "colspan='$span'";?>> [url="<?php echo sefRelToAbs( $link1 ); ?>"]<?php echo $row->vtitle; ?>[/url] <?php if ($showprice == "1") { echo "
".$row->price; } else { echo ""; } ?> </td> <?php if($show_extra==1) {?> <td align="right"> <font class='small'>(<?php echo $row->hits; ?>)</font> </td> <?php } ?> </tr> <?php } ?> </table> <?php } ?> <?php if(count($rows_vehicle)) { DisplayVM($rows_vehicle, "Top Vehicles", $show_ranking, $show_covers, $show_extra,$cover_height, $ItemId_tmp,$showprice); } ?> <div style="text-align: center;">[url="http://ordasoft.com"]Powered by OrdaSoft![/url]</div>
ecco il codice iniziale, poi l'ho modificato un po:
Codice PHP:
<?php /** * @version 1.5 * @package VehicleManagerTop * @copyright 2009 OrdaSoft * @author 2009 Sergey Drughinin-OrdaSoft(Sergey.dru@gmail.com) * @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL * @description VehicleTop for VehicleManager Component */ /** ensure this file is being included by a parent file */ defined( '_JEXEC' ) or die( 'Restricted access' ); $database = &JFactory::getDBO(); if( !function_exists( 'sefreltoabs')) { function sefRelToAbs( $value ) { //Need check!!! // Replace all & with & as the router doesn't understand & $url = str_replace('&', '&', $value); if(substr(strtolower($url),0,9) != "index.php") return $url; $uri = JURI::getInstance(); $prefix = $uri->toString(array('scheme', 'host', 'port')); return $prefix.JRoute::_($url); } } //Common parameters $sort_top_by = $params->def('sort_by_top', 0); //Get how to sort the top items $show_published = $params->def('only_published', 1); //Get if we only show published items $show_covers = $params->def('covers', 0 ); //Get if we Real Estate photos $cover_height = $params->def('cover_height', "50"); //Get Real Estate photos $show_extra = $params->def('extras', 1 ); //Get if we show second column with additional info $show_ranking = $params->def('ranking', 0 ); //Get if we show the ranking next to them $showprice = $params->get ('price', 1); //Individual parameters $count_vehicle= intval($params->def('books',1)); //Definition of Sorts switch($sort_top_by) { case 0: $sql_sort_top = "hits"; break; case 1: $sql_sort_top = "date"; break; // case 2: // $sql_sort_top = "rating"; // break; } //Check if only display published items if ($show_published==1) { $sql_published = "WHERE published=1"; } else { $sql_published = ""; } if($count_vehicle!='' && $count_vehicle!=0) { $selectstring = "SELECT vtitle,id,image_link,hits,catid,price FROM #__vehiclemanager_vehicles " .$sql_published." ORDER BY ".$sql_sort_top." DESC LIMIT 0, $count_vehicle;"; $database->setQuery($selectstring); $rows_vehicle= $database->loadObjectList(); } $selectstring = "SELECT id FROM #__menu WHERE link='index.php?option=com_vehiclemanager'"; $database->setQuery($selectstring); $ItemId_tmp = $database->loadResult(); function DisplayVM($rows, $name, $show_ranking, $show_covers, $show_extra, $cover_height, $ItemId_tmp,$showprice) { $rank_count = 0; $span=0; if($show_ranking!=0) $span++; if($show_covers!=0) $span++; if($show_extra!=0) $span++; ?> <table cellpadding="0" cellspacing="0" class="moduletable" width="100%" border="0"> <?php foreach ($rows as $row) { $rank_count = $rank_count + 1; //start ranking $link1 ="index.php?option=com_vehiclemanager&task=view&id=" .$row->id."&catid=".$row->catid."&Itemid=".$ItemId_tmp; $imageURL = $row->image_link ; if($imageURL != '' && substr($imageURL,0,4) != "http") { $imageURL = "./components/com_vehiclemanager/photos/".$row->image_link; } if($imageURL == ''){ $imageURL = "./components/com_vehiclemanager/images/no-img_eng.gif"; } ?> <tr> <?php if($show_ranking==1) { echo "<td>".$rank_count.":</td>"; } //Add Column for Ranking if param set ?> <?php if ($show_covers==1) {?> <td> [img]<?php echo $imageURL; ?>[/img]vtitle; ?>" hspace="2" vspace="2" border="0" height="<?php echo $cover_height; ?>" /> </td> <?php } ?> <td width="160" <?php if($span!=0) echo "colspan='$span'";?>> [url="<?php echo sefRelToAbs( $link1 ); ?>"]<?php echo $row->vtitle; ?>[/url] <?php if ($showprice == "1") { echo "
".$row->price; } else { echo ""; } ?> </td> <?php if($show_extra==1) {?> <td align="right"> <font class='small'>(<?php echo $row->hits; ?>)</font> </td> <?php } ?> </tr> <?php } ?> </table> <?php } ?> <?php if(count($rows_vehicle)) { DisplayVM($rows_vehicle, "Top Vehicles", $show_ranking, $show_covers, $show_extra,$cover_height, $ItemId_tmp,$showprice); } ?> <div style="text-align: center;">[url="http://ordasoft.com"]Powered by OrdaSoft![/url]</div>