Jump to content

Custom Charts Database Problem


Thomas Rozanov

Recommended Posts

Okay, So I use jantorre (thanks!) custom charts database code which is:

<h3>Procedures and Information</h3>
<table width="98%" align="center">

       <tr style="background-color: #333; color: #FFF;">
               <td>Charts for <?php echo $schedule->depicao?></td>
               <td>Charts for <?php echo $schedule->arricao?></td>
       </tr>
       <tr align="center">
               <td width="50%" valign="top">
                       <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->chartlink; ?>" target="_blank">
                       <img border="0" src="http://www.yoursite.com/images/charts/<?php echo $schedule->depicao?>.gif"
                               width="387px" height="594px" alt="No chart available" /></a><br>
                       <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->vacc; ?>" target="_blank">Local VACC</a> 
               </td>
               <td width="50%" valign="top">
                       <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->chartlink; ?>" target="_blank">
                       <img border="0" src="http://www.yoursite.com/images/charts/<?php echo $schedule->arricao?>.gif" 
                               width="387px" height="594px" alt="No chart available" /></a><br>
                               <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->vacc; ?>" target="_blank">Local VACC</a> 
               </td>

       </tr>
</table>

And everything works great but i need it to work for both .png and .gif .

So Lorathon (Big Thanks!) wrote a small piece of code to help me out.

public function displayChart($icao)
{
   $chart = SITE_ROOT.'/images/charts/'.$icao.'.png';          

   if(!file_exists($chart))
   {
       // PNG image Does NOT exist so look for GIF image
       $chart = SITE_ROOT.'/images/charts/'.$icao.'.gif';

       if(!file_exists($chart))
       {
               // GIF image does not exist either
               return false;
       }
   }

   // Return image path
   return $chart;
}

And suggested to insert it like so in schdule_brief.tpl

<h3>Procedures and Information</h3>
<table width="98%" align="center">

       <tr style="background-color: #333; color: #FFF;">
               <td>Charts for <?php echo $schedule->depicao?></td>
               <td>Charts for <?php echo $schedule->arricao?></td>
       </tr>
       <tr align="center">
               <td width="50%" valign="top">
                       <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->chartlink; ?>" target="_blank">
                       <img border="0" src="<?php echo self::displayChart($schedule->depicao)?>"
                               width="387px" height="594px" alt="No chart available" /></a><br>
                       <a href="<?php $data = OperationsData::GetAirportInfo($schedule->depicao); echo $data->vacc; ?>" target="_blank">Local VACC</a> 
               </td>
               <td width="50%" valign="top">
                       <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->chartlink; ?>" target="_blank">
                       <img border="0" src="<?php echo self::displayChart($schedule->arricao)?>" 
                               width="387px" height="594px" alt="No chart available" /></a><br>
                               <a href="<?php $data = OperationsData::GetAirportInfo($schedule->arricao); echo $data->vacc; ?>" target="_blank">Local VACC</a> 
               </td>

       </tr>
</table>

<?php
public function displayChart($icao)
{
   $chart = SITE_ROOT.'/images/charts/'.$icao.'.png';          

   if(!file_exists($chart))
   {
       // PNG image Does NOT exist so look for GIF image
       $chart = SITE_ROOT.'/images/charts/'.$icao.'.gif';

       if(!file_exists($chart))
       {
               // GIF image does not exist either
               return false;
       }
   }

   // Return image path
   return $chart;
}
?>

And I'm getting : Parse error: syntax error, unexpected T_PUBLIC in /home/brtvirtu/public_html/lib/skins/ObsessBlue/schedule_briefing.tpl on line 140

And line 140 is

public function displayChart($icao)

Please Help! Or suggest something else

Thanks!

Link to comment
Share on other sites

Sorry I did not get back to you right away with your PM.

Remove the word "public" and see how it works.

Okay now it works (kind of) except the page is totally deformated and in the charts part it says : Fatal error: Call to undefined method TemplateSet::displayChart() in /home/brtvirtu/public_html/lib/skins/ObsessBlue/schedule_briefing.tpl on line 125

line 125 is :

      <img border="0" src="<?php echo self::displayChart($schedule->depicao)?>"

Link to comment
Share on other sites

Guest lorathon

Like I said in my PM's, I think you are going to have to write a class. Then stick the code I wrote in there. Then call the function from that class. Look in the core/common for the class files. See how they work and try and figure it out.

OR

Like was initially suggested, do the easy thing and change all the files to the same type :)

Link to comment
Share on other sites

Like I said in my PM's, I think you are going to have to write a class. Then stick the code I wrote in there. Then call the function from that class. Look in the core/common for the class files. See how they work and try and figure it out.

OR

Like was initially suggested, do the easy thing and change all the files to the same type :)

Wait so i put your code into a seperate .php or .tpl file and i just put include file. In the schedule_brief.tpl

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...