jDownloads Support Forum

Older Versions => jDownloads 3.2 (Support ended) => Topic started by: i0wi on 22.12.2014 09:31:41

Title: PHP filemtime() in output
Post by: i0wi on 22.12.2014 09:31:41
Hey Arno,

just wanted to ask if it's possible to somehow output PHP filemtime for each file listed in the category view? I have this problem where it's necessarry to overwrite many files several times per week + to have at least a near-exact date/time of the update next to the download link. As I have FTP access to the server, it's easy to replace files, however I then need to manually modify each jDownloads download item and that's what takes tremendeous amounts of time. I was hoping {file_date} would do the trick, but it outputs just nothing, both in 2.5 and 3.2.

This question is actually for jD for Joomla 2.5, however I'm in the middle of upgrades, so it would be more beneficial to have it ready for jD 3.2 as well.

As always, I assume you'll tell me it's a piece of cake :)

Cheers!
Title: Re: PHP filemtime() in output
Post by: ColinM on 22.12.2014 21:09:16
Hi
By changing the Files Layout you can show the modified file date.  For example changing "Standard Files Layout without Checkboxes v2.5 (2)"  [first make copy of "Standard Files Layout without Checkboxes v2.5" by using Save As Copy then set it as the Active one]

The modified version will then show the modified date as illustrated in the attached pic.  I know you would also like the time but that is not available at present.

Original layout code in "Standard Files Layout without Checkboxes v2.5 (2)"
<table width="100%" style="padding:3px;">   
   <tr>
      <td width="75%" align="left" valign="top">{description}<br />{mp3_player}<br />{mp3_id3_tag}</td>
      <td valign="top">{screenshot_begin}<a href="{screenshot}" rel="lightbox"> <img src="{thumbnail}" align="right" /></a>{screenshot_end}
      </td>
      <td width="15%" valign="top"> {created_date_title}<br />{filesize_title}<br /> {hits_title}</td>
      <td text-align="right" width="10%" valign="top">{created_date_value}<br />{filesize_value}<br />{hits_value}</td>
   </tr>
</table>

is changed by adding {modified_date_title}"Standard Files Layout without Checkboxes v2.5 (2)" and {modified_date_value}"Standard Files Layout without Checkboxes v2.5 (2)" as indicated below
<table width="100%" style="padding:3px;">   
   <tr>
      <td width="75%" align="left" valign="top">{description}<br />{mp3_player}<br />{mp3_id3_tag}</td>
      <td valign="top">{screenshot_begin}<a href="{screenshot}" rel="lightbox"> <img src="{thumbnail}" align="right" /></a>{screenshot_end}
      </td>
      <td width="15%" valign="top"> {created_date_title}<br />{modified_date_title}<br /> {filesize_title}<br /> {hits_title}</td>
      <td text-align="right" width="10%" valign="top">{created_date_value}<br />{modified_date_value}<br />{filesize_value}<br />{hits_value}</td>
   </tr>
</table>


[gelöscht durch Administrator]
Title: Re: PHP filemtime() in output
Post by: i0wi on 22.12.2014 22:57:57
Hi Colin,

thank you for your reply!
Actually I am already using the {modified_date_value} placeholder variable, but the problem is I would like to read the modified date from the file itself, just as the filemtime() function does.
The {modified_date_value} reads the jDownloads item modified date (stored in the database). I would like to avoid having to re-save the item each time I replace the physical file, because this happens many times weekly, and on a number of files.
I would even consider modifying core files each time there's an update.
Is there a way / are you allowed to share the way to redefine what {modified_date_value} reads? I suppose there is a .php file which stores these variables and tells the component which info to fetch once in encounters them in layouts.

Thanks in advance, jD tech support is truly among the most helpful in the whole Joomla community.
Title: Re: PHP filemtime() in output
Post by: ColinM on 22.12.2014 23:31:28
Hi
jDownloads is open source.  So I will sort out where it could be changed to to get you the info you need. 

Could you please remind me as tomorrow we expect to release 2.5.19/3.2.19 which at last sorts out the ACL permission cascading.  This means I will be doing final testing for Arno

And of course three are several Christmas things I have to do!!

Please send me a PM if I appear to have forgotten

Colin
Title: Re: PHP filemtime() in output
Post by: i0wi on 19.03.2015 12:34:31
Just bumping this, following Colin's suggestion.
I considered opening a new topic, but I have it all explained here.
Just to note, using the latest jD update and the {file_date} is still not being properly recognized.

I wouldn't mind trying to fix this myself, with a little guidance from Arno or Colin.

Thanks to anyone in advance for any kind of solution, or even workaround - it would literally save me hours of work every week.
Title: Re: PHP filemtime() in output
Post by: ColinM on 21.03.2015 01:55:51
Hi
This is a little more 'interesting' than I first thougt!
There are four php files that refer to modified date. They all start from the site code in directory views. The relevant next level directories are category, download, downloads, and mydownloads. Each is followed by a tmpl directory, which in turn contains a file default.php
Examinhg these shows where the placeholders are processed.  Getting the file name is reasoably obvious in the part where place holder {file_name} is processed.  However we need the path and this means usig the category id to pick up the category name and the parent cat from the database. We then need the root directory from Config.

The cleanest solution would be to have another place holder say {modified_date_from_file} and include code that processed it in the relevant php files.  And finally to request Arno to take on board. I can assist in revising the code
Colin
Title: Re: PHP filemtime() in output
Post by: i0wi on 21.03.2015 11:37:56
Colin, thank you very much for your analysis. If it seems a bit complicated to you, then it's probably totally out of my league :) Hopefully you and Arno can make it work somehow - it won't be a problem for me to wait as long as it's necessary.

Cheers :)
Title: Re: PHP filemtime() in output
Post by: Arno on 27.03.2015 12:47:34
You ge not any data for the placeholder {file_date}?
Have you filled out the file date field in the Downloads Form?
Title: Re: PHP filemtime() in output
Post by: ColinM on 27.03.2015 14:20:48
Arno
The problem here is that after making the initial upload iOWi overwrites the file some time later directly by an FTP transfer with a file of the same name, and obviously in the same directory.  Now the date shown is the one original from the database.  To get around that iOWi then modifies the relevant database entry manually.  The suggestion is one I have put in "Suggestions" http://www.jdownloads.com/forum/index.php?topic=8002.0  Its a bit like having a 'Refresh' tool where relevant data such as file date and size could be updated or filled in if not given.  An option to maybe change the symbol according to the file type would be useful.

Actually I find it a pain to have to select the symbol when it could be handled automatically if I do not specify one.  So the default for symbol sect field would be 'Select' in which case it would find the symbol (file-pic) automatically from the type.

Colin
Title: Re: PHP filemtime() in output
Post by: Arno on 27.03.2015 15:23:01
Hi Colin,
QuoteThe problem here is that after making the initial upload iOWi overwrites the file some time later directly by an FTP transfer with a file of the same name, and obviously in the same directory.
Okay. We can add a tool as described or use a special handling for the {file_date} placeholder. So we can check at first whether the file 'date field' is empty. If so can we get the current date via filemtime().
Seems for me very easy?

A tool must be every time started again.
Title: Re: PHP filemtime() in output
Post by: ColinM on 27.03.2015 17:10:27
Arno
Actually I think both!!  For most people if they do not fill in the date then the special handling in {file_}date} placeholder is excellent.  But for more advanced users like iOWi then a tool is better as the data field is not empty but just out of date!  Starting the tool would be after a session of 'overwriting' update files.  It might take time but the time saving to the user is much, much more.
Colin
QuoteSeems for me very easy?
But not for others!! 
Title: Re: PHP filemtime() in output
Post by: Arno on 28.03.2015 00:56:32
Okay, i will try it in this way. ;)