Attachtable-Talk
PHP 8.0 error
Warning: Undefined array key "text" in /home/public/wiki.obormot.net/cookbook/attachtable/attachtable.php on line 205
Hi Said, can you by any chance take over the maintenance? Eemeli Aro has moved on, see his page for our last exchange and the license. I don't use this recipe and cannot easily test it in various conditions. --Petko
Open attachments in a new window
I'm looking for a way to get the attachment links generated by the recipe to open in a new window?
The recipe doesn't have a configurable link snippet like $UrlLinkFmt
, so not natively. OTOH you can add a small JavaScript that adds the target='_blank'
to these links in the browser. Add this to your config.php (below). --Petko
$HTMLFooterFmt['atnewwin'] = "<script> document.querySelectorAll('.attachtable a:not(.createlink)') .forEach(a=>a.target='_blank');</script>";
PHP 7.4 Error
Running php version 7.4.25 this recipe doesn't work. PHP reports:Type: ErrorException; Message: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?; File: .../cookbook/attachtable/attachtable.php; Line: 377
So I replaced "continue" with "continue 2" on lines 376 and 387 to make (:attachtable:)
show the list of attachments.
I haven't tested actions yet.
SteP November 06, 2021, at 05:18 PM
continue
with break
, no? —Said Achmiz November 10, 2021, at 04:37 PM
Fileinfo does not work
Fileinfo does not work with latest attachtable & php73:
PHP Fatal error: Uncaught Error: Call to undefined function eregi() in /var/www/farm/Farm-2.2.135/cookbook/attachtable/getid3/getid3.php
-Johan Bengtsson
Throws errors with PHP 7.3:
Not being fluent in PHP, I don't dare to replace the continue by break. OliverBetz
It probably needs to be "continue 2" like PHP suggested, otherwise Eemeli would have written "break". --Petko February 08, 2020, at 08:07 PM
Are you sure about this? https://www.php.net/manual/en/migration73.incompatible.php writes "continue statements targeting switch control flow structures will now generate a warning. In PHP such continue statements are equivalent to break, while they behave as continue 2 in other languages." (highlighting by me).
https://www.php.net/manual/en/control-structures.continue.php tells me "If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop" and "The default value is 1, thus skipping to the end of the current loop". I find no indication that earlier versions used a different default value. OliverBetz 2020-02-19 08:10Z
I didn't say it worked differently in the past. I can see that inside the "switch" control Eemeli used both "break" and "continue", which are identical inside "switch". It makes me think he may have missed the particularity of PHP that "continue" inside a "switch" inside a loop breaks out of the "switch" only, while in other languages it moves directly to the next loop (in PHP you would do "continue 2" for this). Reading the code at line 317 also supports this: if it is a deleted file, and deleted files shouldn't be listed, it should not only break out of the "switch" but directly to the next file. Hence I suspect "continue 2" was intended. This recipe is in need for a maintainer, see message from Eemeli -- if you want to take over the maintenance and support, please make any changes you feel necessary. --Petko February 19, 2020, at 09:41 AM
Thanks for the clarification. I'm not capable providing the necessary quality maintaining other than trivial PHP code. OliverBetz 2020-02-23 16:22Z
Filter out
Is it possible to have filter=-19*
Not directly, you need to define in config.php a custom pattern like $AttachListPatterns['mylistwithout19'] = "-19*"; then in the directive use list=mylistwithout19. --Petko April 07, 2020, at 09:06 AM
Attachment listing order
Is it possible to specify the display order of the attachments, e.g. descending filename or descending file size?
No. --Petko December 01, 2019, at 07:24 AM
Php 7.2 update
Hi Eemeli, may I ask the 7.2 update? Actually Attachtable partially works, but I have those two messages:
- Warning: count(): Parameter must be an array or an object that implements Countable in .../attachtable/attachtable.php on line 361
- Deprecated: Function create_function() is deprecated in .../pmwiki.php on line 481 (I have the same one for Maxi)
Thanks in advance.
P.S. Why this extremely useful recipe is not yet an integral part of pmwiki (core)?
You are probably busy and you missed the request, I repeat it so it will appear again in the page AllRecentChanges list.
Eemeli no longer builds sites with PmWiki, and the last major update was by HansB. I was hoping a user/admin who regularly uses this addon could update and test it but apparently not. Please test this versionΔ and report if all works as expected. Superficially it appears to work on 7.2 but I don't use it, so I cannot know if every feature works fine. --Petko June 19, 2018, at 08:53 PM
Thank you, everything works fine for me. -- Frank June 19, 2018, at 11:09 PM
I have run into this issue that I am taking a stripped down version of a site to install somewhere else with all the plug-ins. I have a sitepath.php that gets imported as a required inclusion into the config file that takes into account whether I am on the localhost or an external server utilizing PHP Server Global Variables. It works just fine except now I have an error on the localhost with only the attachtable module. The functionality works, but I am getting file-info error messages and I guess I do not understand from where they are coming.
Warning: finfo_file() [function.finfo-file]: File or path not found 'uploads/Main/FAQ/arise_1t.png' in G:\xampp\htdocs\bytemark\pmwiki_master\pmwiki\cookbook\attachtable\attachtable-util.php on line 38 Warning: finfo_file() [function.finfo-file]: File or path not found 'uploads/Main/FAQ/capernaum_1.png' in G:\xampp\htdocs\bytemark\pmwiki_master\pmwiki\cookbook\attachtable\attachtable-util.php on line 38 Warning: finfo_file() [function.finfo-file]: File or path not found 'uploads/Main/FAQ/dawn_1t.png' in G:\xampp\htdocs\bytemark\pmwiki_master\pmwiki\cookbook\attachtable\attachtable-util.php on line 38
These errors go on for however many files I have attached to the page. I can still do everything I need to with the files, but these warning messages are really annoying. I would think that either they need to be suppressed or they need to be handled in the original script. They do not come up on the external hosting account.
--Marcus, 20180428
HansB: Perhaps you can set in config just for the case of server localhost the variable $UploadDir
with a full path, not just the default 'uploads', i.e. something like:
$UploadDir
= "G:\xampp\htdocs\bytemark\pmwiki_master\pmwiki\uploads";
That negates the issue of full portability by relative directory. --Marcus
Line 56 of the recipe is currently as follows:
SDV( $AttachtablePubDirUrl, "$PubDirUrl
/attachtable" );
But this is incompatible with wikifarms (as it looks for the recipe files in the local, i.e. per-farm, pub/
directory, which is usually not where a wikifarm has recipes.
Perhaps this instead:
SDV( $AttachtablePubDirUrl, ($FarmPubDirUrl
?:$PubDirUrl
) . "/attachtable" );
This would use
if it was defined, otherwise would default to $FarmPubDirUrl
.
$PubDirUrl
I'm open to suggestions for how to improve this. More specifically, I'd be interested to hear about the following: --EemeliAro November 25, 2007, at 04:58 PM
- What other information columns should there be?
- Is there a need for more fine-tuned control of the action links?
- Should the JavaScript prompts and confirmations be replaced by HTML pages?
HansB:This is a great recipe, thanks! But I fail to understand from the documentation how to display thumb images in an attachtable or better when hovering with the mouse over an image link of the attachtable (onmouseover => css popup of thumb image). how can attachtable use thumb images? I do understand setting a thumb pattern with $FileInfoThumbnailFmt.
Hi. Thanks for this useful recipe, I really needed this! I have two request for the deleted files.
- Could you please change the link on the filename with a normal download link (or maybe better no link at all), and add two superscript commands like for the visible files: "r" to restore the file, and "x" to physically delete the deleted file from the directory.
- The "x", "Δ" and "r" links, as well as the deleted file names should be displayed only to users with 'upload' rights. Thanks! --Petko November 24, 2007, at 09:58 AM
$EnableDirectDownload
=1; it is possible to download a deleted file for review even if the server sends it as binary. But never mind, I am not sure if it will be really used. Thanks again.) --Petko November 24, 2007, at 05:16 PM
$EnableAttachtableLinkDeleted
. --EemeliAro November 27, 2007, at 06:08 AM
$EnableDirectDownload
and with the proper MIME types, so should display correctly in the browser. --EemeliAro November 27, 2007, at 06:01 PM
$AttachtableSkipPattern = "/^th\\d+---/";
and (:attachtable skip="/^th\\d+---/":)
will allow us to not display thumbnails created by ThumbList.[1] And skip=none
to display all files. About the JavaScript: I believe it's fine. Most webmasters have decent browsers, and a JS prompt is very easy, fast and straightforward. Additionally, it is preventing search robots from messing with the attachments (for example, on completely open wikis). Thanks. --Petko November 27, 2007, at 09:54 AM
HandlePostUpload
until it does. Also page histories could tell who and when first referred to an attachment, which is relatively synonymous to a file creation date. --EemeliAro November 27, 2007, at 06:01 PM
# added after "if ( @$matchext &&..." if(function_exists(@$AttachtableFileCheck) && !$AttachtableFileCheck($file, $opt) ) continue; $filelist[$file] = $file; # current line 266
$AttachtableFileCheck
doesn't assume the static variable is FALSE if the property you're looking for isn't in the (:attachtable:)
directive. --EemeliAro November 29, 2007, at 02:17 PM
I have now this idea of implementing a parameter like list= in pagelists, and an array similar to $SearchPatterns
which admins can define. May be much better and flexible than skip=
. This could be a lot of work, I don't know yet, so unless you like it a lot and are impatient, I'll write it in a couple of days. :-) --Petko November 29, 2007, at 01:01 PM
I've modified Attachtable to use UserAuth to support specific page and group auth access i.e. <action>_group/page. You can download it here: attachtable_userauth.phpΔ //Aidin
Nice recipe, but I have one Question: I've added this recipe to our project wiki (http://crrcsim.sourceforge.net/wiki), but deleting files doesn't work. I don't seem to have delattach permissions (action link not displayed, only upload and rename) even when I'm logged in as admin. The wiki does not use any advanced auth mechanisms (AuthUser, UserAuth, ...), just definitions for the $DefaultPasswords
admin, upload and attr. How do I gain "postattr" permissions? The PmWiki docs say nothing about it. --Jan R
Hi. Somehow I have had similar problems, so here is my local configuration:
$HandleAuth['deldelattach'] = 'admin'; $HandleAuth['delattach'] = 'upload'; $HandleAuth['renameattach'] = 'upload'; include_once("$FarmD/cookbook/attachtable.php");
This allows me to delete the "deleted" files as admin. Hope that helps. --Petko June 11, 2008, at 01:04 AM
$HandleAuth
that are set in upload.php which in many cases is included after attachtable.php. --Eemeli Aro April 17, 2009, at 08:02 AM
How would one go about changing the display of filesize from bytes to KB, or even to MB? thanks!
overtones99 June 18, 2008, at 06:08 PM
//$s .= '<td>'.number_format($stat['size']).'</td>'; /// original this is where the byte size is created/calculated $s .= '<td>'.bytesToNBytesFunc($stat['size']).'</td>'; /// *** call func to convert to KB
/// from [[http://php.net/manual/en/function.number-format.php#72969]] function bytesToNBFunc($a) { $unim = array("B","KB","MB","GB","TB","PB"); $c = 0; while ($a>=1024) { $c++; $a = $a/1024; } //return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c]; return number_format($a,($c ? 1 : 0))." ".$unim[$c]; // using decimals instead of commas, and only 1 decimal point... }
Hi. How can I prevent attachtable from redirecting to the confirmation on Group.Page?action=upload..., and instead just go back to the page where I was uploading from (in this case, Group/Uploads)? Even better, I'd love to be able to have an options field like this:
(:attachtable MyGroup.MyUploadPage redirect=MyGroup.MyUploadPage#currentUploads:)
Is something like this possible? Thanks, overtones99 June 22, 2008, at 04:58 PM
// *** Prevent confirmation page - Placed in both deleteattach and renameattach functions ***// //Redirect($pagename,"{\$PageUrl}?action=upload&uprname=$upname&upresult=$result"); if(stristr($pagename,"Uploads")) { // skip uploads page, and redirect right back to page's uploads // good if upload list is at the bottom of the page Redirect( $pagename, "{\$PageUrl}#currentUploads" ); } else { // DEFAULT ACTION Redirect( $pagename, "{\$PageUrl}?action=upload&uprname=$upname&$result" ); // original redirect }
Brilliant! Great work, thanks so much for this recipe! /Elk
I just downloaded the latest version. It seems to be failing (as if in an infinite loop?) on line 371:
$html = MarkupToHTML( $pn, $pg['text'] );
When I comment out this line it seems to work. I can't find that anything is done with the $html variable anyway, so maybe this is leftover code from the previous version? ~Kory -> mailto:webmaster [snail] herpsofarkansas [period] com, April 18, 2009
$AttachtableProperReferenceLookupMaxPages = 0;
I'm hoping to use this recipe in conjunction with ThumbList. Do you have suggestions about how to get the most out of this combination? ...such as, I would like to HIDE the thumbnail files created by ThumbList. ~Kory -> mailto:webmaster [snail] herpsofarkansas [period] com, April 18, 2009
filter=
parameter. For ThumbList, I believe the following may be appropriate:
(:attachtable filter="!^th\d+---!":)
$AttachtableDefaultFilter
. —Eemeli Aro April 20, 2009, at 06:46 AM
Have you considered adding a thumbnailing capability to the recipe? (Maybe as a separate column, or on mouse-over)
Thanks. ~Kory -> mailto:webmaster [snail] herpsofarkansas [period] com, April 18, 2009
$FileInfoThumbnailFmt
to get this to work. —Eemeli Aro April 27, 2009, at 02:06 PM
Currently the CSS clutters every page. Could you add a simple expression to include attachtable conditionally for all used actions?
Is looking for upload|attach|downloaddeleted sufficient? OliverBetz
(:attachtable:)
from Site.UploadQuickReference, the following conditional should do the trick:
if (in_array( $action, array('upload','delattach','renameattach','downloaddeleted') ) include_once("$FarmD/cookbook/attachtable.php");
$HTMLStylesFmt['attachtable'] = '';
There seems to be an issue with the show
parameter in version 2009-04-28. show=deleted
and show=normal
does not work as expected. It shows the whole table without the filtered filenames. show=linkonly
does what it is supposed to do.
Thanks for the great recipe! I am trying to hide the thumbnails created by the Thumblist recipe using the "filter=xxx" feature but am geting errors. This is what I have:
(:attachtable filter=!th*:)
I get the following errors:
Warning: preg_grep() [function.preg-grep]: No ending delimiter '!' found in [snip]/pmwiki.php on line 604 Warning: array_diff() [function.array-diff]: Argument #2 is not an array in [snip]/pmwiki.php on line 604 Warning: Cannot modify header information - headers already sent by (output started at [snip]/pmwiki.php:604) in [snip]/pmwiki.php on line 1079
Also, the (:attachtable -sortable:)
does not work...
Am I doing something wrong? skumar? May 20, 2009, at 10:40 AM
You should use (:attachtable filter='!^th\d+---[0-9a-f]{6}?--!':)
to not list the thumbnails.
JL May 20, 2009, at 04:00 PM
(:attachtable filter='!th*!':)
. But this seems to be case-sensitive. I am still seeing the "Thumbs.db" file show up in the list. Any tricks to making this case-insensitive? skumar? May 22, 2009, at 03:00 PM
(:attachtable filter='!th*!i':)
. But keep in mind that this will filter out every file that has a 'th' in its filename, not just at the beginning. JL May 24, 2009, at 04:47 PM
I am trying to display the attachtable cookbook, but everytime I do, it literally just displays (:attachtable)
on the page. I have followed the instructions exactly, and re-installed the cookbook twice. What am I doing wrong?
- Make sure you're using
(:attachtable:)
and not(:attachtable)
. - Make sure you've set
$EnableUpload = 1;
before including the recipe. - Make sure you've copied the whole switch statement from the installation instructions to your config file.
- If it still doesn't work, tell me exactly what you've got in your config file for Attachtable.
—Eemeli Aro July 27, 2009, at 04:51 AM
A minor possible enhancement: for show=
and data=
provide a "-" parameter where, say show=default,-delete
etc. Thanks simon August 22, 2009, at 09:13 PM
It seems to have problems with filenames with spaces; lots of zero references when files are referenced, lots of "missing files" that are the substring to the left of the first space. I have set $AttachtableReferenceListPatterns['limit'] = '';
but it made no difference.
Maxim? September 02, 2009, at 04:46 AM
I have
and $UploadPrefixFmt
='/$Group/$Name';(:attachtable *:)
shows this:
file name size (bytes) refs last modified MIME type total 3 directories, 0 files
no matter what
is set to. But the description seems to indicate that I should be able to browse the directories. So, shouldn't this work? - Rogutės
$EnableDirectDownload
The cookbook works fine but I have got a 'PHP errors' with attachtable.
I am using a pmwiki FARM.
Here is a typical error from apache2 logs
[Thu Feb 25 16:23:41 2010] [error] [client 127.0.0.1] File does not exist: /wiki/fields/PLANCK/planck, referer: [(approve links)
edit
diff]
It appears with any URL !!
It looks like the cookbook does not scan the correct directory, it should be /wiki/fields/PLANCK/uploads/ or /wiki/fields/PLANCK/wiki.d/ ???
I have echoed all configuration variables, they look fine.
It is very difficult to track which 'fopen','readdir'... functions used in the cookbook have not the correct
filepath.
Of course, I tried $AttachtableProperReferenceLookupMaxPages=0; No EFFECT
I have tested version 2.2.6 and 2.2.13 of pmwiki.
Thursday 25 february 2010, Pierre PRIOUL, Institute of Astrophysics of Paris, Planck Team, France
I found the error in my configuration. In case of a wiki farm, I have to copy all /pub/attachtable.css in the sub-directory of the farm:
/wiki/fields/PLANCK/pub/
This way the apache2 server is able to find css files and js files.
I had the same problem with the css file of the PmCal cookbook.
How does attachtable know if the name is for a group or a page.
(:attachtable NAME:)
- Shows the attachments of the group or page NAME.
I'd like to list all attachments for a group, but I don't get the expected result
Added EmbedBtn and AttachBtn to my version of the attachtable recipe
Hi Eemeli. i wonder if this might of use to you and the community using this recipe? i've modified the recipe so that in the far left column there are buttons that quickly post the necessary attach/embed code for each file into the edit window. i've been using a modified version of an earlier attachtable recipe for years without a hitch. i just updated to the newest version of the recipe, and added and refined my modifications. here's how to test it:
1. download: attachtable-embedBtns.zipΔ
2. substitute my version of cookbook/attachtable/attachtable.php
for the one normally used with the last distribution
3. add cookbook/attachtable/attachFileBtn03.php
4. in your pub/
directory, add the embedBtns folder
5. when adding or updating an attachtable (for instance on Site.EditForm), simply add embedBtn=1
or attachBtn=1
:
(:attachtable NAME embedBtn=1 ... :)
(:quicktime:)
, (:flash:)
, or as an image) are assigned an "embed" button. all other files are given a "link" button which simply posts the file using the "Attach:
" markup.
(:attachtable NAME attachBtn=1 ... :)
i can provide more in-depth info later. the buttons are using code by PM from guiedit.php. i haven't done extensive testing on this newer version, so there may be some bugs i've missed. if you think this would be an interesting feature to add to the core of the recipe, i'd be happy to write-up more extensive documentation that could be added to the main page. otherwise, maybe i should just post it somewhere else as an alternative version of the recipe?
thanks for the feedback. overtones99 June 23, 2010, at 01:32 AM
Is there a way of having attachtable display all files for a group when attachments are organised per per page?
How do I specify the sort table of the file list, eg name descending?
Under Windows Attachtable should not be case sensitive, eg I have Attach:fn.doc
but the document uploaded is FN.doc
, the refs count says 0, even though under windows the link works correctly.
When renaming under windows (ironically) I cannot simply change FN.doc
to fn.doc
using attach table, nothing happens.
It seems that references to image files by the Mini gallery generator don't get counted as references by Attachtable. Can that be fixed?
This, as with quite a lot of cookbook code, does not like PHP version 5.5, the /e evaluation modifier. See http://www.pmwiki.org/wiki/PmWiki/CustomMarkup (Migration to PHP 5.5 and Markup_e()) for more background.
Talk page for the Attachtable recipe (users).