Commit Graph

150 Commits

Author SHA1 Message Date
Mikael Nordfeldth
adf896bc12 Add support for plugins to resize images
This also adds an event hook to get more metadata of the ImageFile.
Such as if it's animated or so.
2014-06-05 13:29:36 +02:00
Mikael Nordfeldth
db443e9374 File::processNew now static and always throws exception on failure 2014-06-02 02:11:23 +02:00
Mikael Nordfeldth
d6f52f5939 File::processNew can return -1 which was not true for empty()
Also, File->getEnclosure() now throws exception if not enough metadata.
2014-06-02 01:46:09 +02:00
Mikael Nordfeldth
2755e23707 Clear out stored files and reltaed thumbnails when a File is deleted. 2014-05-12 15:16:41 +02:00
Mikael Nordfeldth
214a10ddec File_thumbnail fixes (run scripts/upgrade.php)
We're now capable of doing image rotation for thumbnails based on
EXIF orientation data. Also, thumbnails are tracked by filenames and
thus we can delete them from storage when we feel like it.
2014-05-12 14:33:41 +02:00
Mikael Nordfeldth
a7a4eeef09 width and height are now properties in the File class 2014-05-07 09:51:37 +02:00
Mikael Nordfeldth
621533a7c2 Bad variable reference in event hook. 2014-05-06 23:40:45 +02:00
Mikael Nordfeldth
1776c90cb9 Moved oEmbed stuff out to a plugin (Oembed). 2014-05-06 23:32:13 +02:00
Mikael Nordfeldth
cd6bd07c9d Handle File thumbnail errors better 2014-04-28 20:26:32 +02:00
Mikael Nordfeldth
37ce1f4766 Better fallback on UnsupportedMediaException 2014-04-28 12:12:06 +02:00
Mikael Nordfeldth
e526909bd8 File width and height is now properly set for File 2014-04-22 12:09:24 +02:00
Mikael Nordfeldth
d59eb5e184 Dynamically generate thumbnails (see full text)
The File object now stores width and height of files that can
supply this kind of information. Formats which we can not read
natively in PHP do not currently benefit from this. However an
event hook will be introduced later.

The CreateFileImageThumbnail event is renamed to:
CreateFileImageThumbnailSource to clarify that the hooks should not
generate their own thumbnails but only the source image. Also it now
accepts File objects, not MediaFile objects.

The thumbnail generation is documented in the source code. For
developers, call 'getThumbnail' on a File object and hope for the best.

Default thumbnail sizes have increased to be more appealing.
2014-04-21 20:46:11 +02:00
Mikael Nordfeldth
b3bf036975 Preparing File for dynamic thumbnail generation. 2014-04-21 12:33:26 +02:00
Mikael Nordfeldth
43a3f5ea90 File_oembed::saveNew are File::saveNew are static
Also did some non-backwards-compatible (to StatusNet) code cleanup.
2014-04-20 16:10:05 +02:00
Mikael Nordfeldth
d3b4a8616d Original name preserved in uploaded file.
Avoiding collisions with date (shorter than before) and 4 character
random alphanumeric string. I bet someone could mass-upload files
and generate all combinations of aaaa-zzzz during the course of a
day, but then maybe that user should be disabled anyway :)
(filling the collision space will cause a never-ending loop).
2014-04-16 23:17:27 +02:00
Mikael Nordfeldth
06d4cecf7f MediaFile thumbnail event hooks + VideoThumbnails plugin
The exception thrown from MediaFile will be caught and simply result in
no thumbnail at all right now. In the future we might use a catch-all
and have a "cannot generate preview"-icon or something.

VideoThumbnails requires php5-ffmpeg and php5-gd.
2014-04-16 21:48:58 +02:00
Mikael Nordfeldth
639f1a01e0 File class no longer depends on MIME
+ minor tweaks to MediaFile
2014-03-08 03:51:47 +01:00
Jean Baptiste Favre
29f0922705 Add check after oembed API call. In case of error, returned value is false which generate error messages 'Trying to get property of non-object'. 2014-03-02 15:06:06 +01:00
Mikael Nordfeldth
73fe8a81b7 Slight cleanup in typing and syntax of File and File_* classes 2013-11-10 14:33:45 +01:00
Mikael Nordfeldth
48da97f204 MediaFile code improvements, preparing to implement multi-attachments
Maybe in the future we can use this for anonymous file uploads too?
With some kind of anonymous/pseudonymous profile. That'd be neat.
2013-10-05 18:47:45 +02:00
Mikael Nordfeldth
b3e61ce7d0 Stronger typing, require array where param array 2013-08-29 10:27:39 +02:00
Mikael Nordfeldth
2a4dc77a63 The overloaded DB_DataObject function staticGet is now called getKV
I used this hacky sed-command (run it from your GNU Social root, or change the first grep's path to where it actually lies) to do a rough fix on all ::staticGet calls and rename them to ::getKV

   sed -i -s -e '/DataObject::staticGet/I!s/::staticGet/::getKV/Ig' $(grep -R ::staticGet `pwd`/* | grep -v -e '^extlib' | grep -v DataObject:: |grep -v "function staticGet"|cut -d: -f1 |sort |uniq)

If you're applying this, remember to change the Managed_DataObject and Memcached_DataObject function definitions of staticGet to getKV!

This might of course take some getting used to, or modification fo StatusNet plugins, but the result is that all the static calls (to staticGet) are now properly made without breaking PHP Strict Standards. Standards are there to be followed (and they caused some very bad confusion when used with get_called_class)

Reasonably any plugin or code that tests for the definition of 'GNUSOCIAL' or similar will take this change into consideration.
2013-08-18 13:13:56 +02:00
Mikael Nordfeldth
1a9a8ea730 staticGet for sub-Managed_DataObject classes now calls parent
The parent class for our database objects, Managed_DataObject, has a
dynamically assigned class in staticGet which objects get put into,
leaving us with less code to do the same thing.

We will probably have to move away from the DB_DataObject 'staticGet'
call as it is nowadays deprecated.
2013-08-12 19:46:44 +02:00
Siebrand Mazeland
2624afbcd4 Crazy gettext way to support two plurals in one string. 2011-12-28 12:44:42 +01:00
Evan Prodromou
e3c010a870 try to check whether file exists over and over and over 2011-09-30 13:03:42 -04:00
Evan Prodromou
9ca3c3d1c3 move core schema to class files 2011-08-22 17:52:02 -04:00
Evan Prodromou
9a84907d17 Remove unused File::getAttachments() 2011-08-02 23:11:41 -04:00
Evan Prodromou
44bcc942b8 Break up stream code to use separate notice stream classes
Rearchitect (again!) notice stream code to delegate different functionality up and down the stack.

Now, different classes implement NoticeStream.
2011-03-24 18:04:19 -04:00
Evan Prodromou
0b35ce7c37 New NoticeStream class to reify streams of notices
We've been muddling through with 6- or 8-argument functions for managing streams. I'd
like to start thinking of streams as their own thing, and give them some more value.

So, the new NoticeStream class takes over the Notice::stream() function and Notice::getStreamByIds().

There's probably some fine-tuning to do on the object interface.
2011-03-23 11:29:55 -04:00
Brion Vibber
b896a37da0 Use cachedQuery on File::getAttachments, plus other cleanups:
* dropped unnecessary join on notice table
* made the function actually static, since it makes no sense as an instance variable. The only caller (in AttachmentList) is updated.
2011-01-31 12:22:50 -08:00
Evan Prodromou
d31397bd45 method to count notices linking to an URL 2010-12-28 13:44:49 -08:00
Evan Prodromou
faf0081a8b Fixes from testing File::stream() 2010-12-28 12:57:31 -08:00
Evan Prodromou
bf4c5cb41a Stream of notices linking to an URL 2010-12-28 11:58:55 -08:00
Brion Vibber
e1ffbfed04 doc comments on File::processNew 2010-11-15 11:00:42 -08:00
Brion Vibber
dbb95b76a4 Allow YouTube-style media links to be counted as enclosures for purposes of listing attachments/thumbs 2010-11-09 12:04:07 -08:00
Brion Vibber
6d7f02ff31 Pass file attachment thumbnails along with oEmbed data. 2010-11-08 17:22:01 -08:00
Brion Vibber
a2994e3aa2 Testing... using photo info for temp thumbnails 2010-11-08 15:50:06 -08:00
Brion Vibber
883f7a6c0b Avoid marking files as attachments that are not locally uploaded, unless they're really oembedable. HTML-y things now excluded properly. 2010-11-08 13:27:54 -08:00
Siebrand Mazeland
6aeba0cb7c i18n/L10n updates. 2010-11-04 18:33:39 +01:00
Brion Vibber
2692b5fc84 Fix for ticket #2853: fix for some unknown MIME type error cases by adjusting the PEAR error handling temporarily around MIME_Type_Extension usage. 2010-11-03 17:05:26 -07:00
Evan Prodromou
b31c49c5d4 Make HTTPS urls in File::url() if necessary 2010-10-14 14:22:17 -04:00
Siebrand Mazeland
b03ece26eb * i18n/L10n and translator documentation updates.
* whitespace and indentation updates
2010-09-28 23:21:09 +02:00
Siebrand Mazeland
8f8588026b Fixes for messages after review by Brion. 2010-07-30 19:25:55 +02:00
Siebrand Mazeland
5813ecada2 * add translator documentation
* mark strings for translation
* add FIXME for unclear/confusing message
2010-07-29 13:01:04 +02:00
Siebrand Mazeland
e694da24a9 Number parameters 2010-07-28 22:17:54 +02:00
Brion Vibber
dcfe5b24f6 Fix regression in 92ded7c6cb56056a89bc8b3caabd08049104898e: spewed PHP notices when checking for enclosures due to uninitialized variables. 2010-06-28 15:20:50 -04:00
Brion Vibber
696aeea113 Merge branch 'testing' of gitorious.org:statusnet/mainline into 0.9.x
Conflicts:
	lib/language.php
	plugins/OpenID/finishaddopenid.php
2010-05-27 14:57:32 -07:00
Brion Vibber
95159112b2 Hotpatch for infinite redirection-following loop seen processing URLs to http://clojure.org/ -- if we end up with an unstable redirect target (final item in a redirect chain ends up redirecting us somewhere else when we visit it again), just save the last version we saw instead of trying to start over.
Pretty much everything in File and File_redirection initial processing needs to be rewritten to be non-awful; this code is very hard to follow and very easy to make huge bugs. A fair amount of the complication is probably obsoleted by the redirection following being built into HTTPClient now.
2010-05-25 13:09:21 -07:00
Nick Holliday
92ded7c6cb Fixes problem with IRC URLs showing as attachments 2010-03-26 18:16:44 -04:00
Craig Andrews
74fd755556 A null mimetype is not an enclosure (more likely than not means there was an error) 2010-03-11 17:27:25 -05:00
Brion Vibber
c6f09306b1 Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x 2010-03-10 17:04:51 -08:00
Brion Vibber
294b290dd9 Fixup script for files w/ bogus data saved into file record ('h bug') 2010-03-10 15:13:16 -08:00
Brion Vibber
f02cb7c718 Fix for attachment "h bug": posting a shortened link to an oembed-able resource that has been previously used in the system would incorrectly save "h" as the item's type and title. 2010-03-10 15:13:16 -08:00
Brion Vibber
b218aee94e Merge commit 'origin/testing' into 0.9.x
Conflicts:
	lib/action.php
	lib/adminpanelaction.php
2010-03-04 06:07:28 -08:00
Brion Vibber
79ffebb51b OStatus: save file records for enclosures
Also stripping id from foreign HTML messages (could interfere with UI) and disabled failing attachment popup for a.attachment links that don't have a proper id, so you can click through instead of getting an error.

Issues:
* any other links aren't marked and saved
* inconsistent behavior between local and remote attachments (local displays in lightbox, remote doesn't)
* if the enclosure'd object isn't referenced in the content, you won't be offered a link to it in our UI
2010-03-02 16:36:08 -08:00
Craig Andrews
c30f95c55c Updated some references to the long gnone "isEnclosure" function to the new "getEnclosure" 2010-03-02 14:25:06 -08:00
Craig Andrews
a0114f2006 Correctly handle the case when MIME/Type doesn't know what file extension a mime type maps to 2010-03-01 21:44:42 -05:00
Brion Vibber
d5cbfe8071 Merge branch 'testing' into 0.9.x
Conflicts:
	lib/iomaster.php
2010-02-16 09:25:09 -08:00
Evan Prodromou
31461e120f let files go to SSL dir too 2010-02-11 17:06:57 -05:00
Brion Vibber
f4c81fa1e1 Merge branch 'testing' of git@gitorious.org:statusnet/mainline into 0.9.x 2010-02-02 09:57:50 -08:00
Brion Vibber
51c3606715 Fix regression breaking file attachments. This is what I get for rushing fixes and not properly testing them. :P 2010-02-02 09:32:28 -08:00
Brion Vibber
027c7e61fd Fix regression breaking file attachments. This is what I get for rushing fixes and not properly testing them. :P 2010-02-02 09:30:15 -08:00
Brion Vibber
6159edcebb Improve name validation checks on local File references 2010-02-01 08:49:59 -08:00
Brion Vibber
84ab0156b4 Improve name validation checks on local File references 2010-02-01 08:48:31 -08:00
Craig Andrews
672126968f Updated some references to the long gnone "isEnclosure" function to the new "getEnclosure" 2010-01-22 10:12:26 -05:00
Evan Prodromou
866dfa6822 Merge branch 'master' into 0.9.x
Conflicts:
	classes/Memcached_DataObject.php
2010-01-10 14:18:19 -08:00
Evan Prodromou
f463329b9a check before inserting File_oembed and File_thumbnail 2010-01-10 13:18:53 -08:00
Craig Andrews
250bcfa8dc Require users to login to view attachments on private sites
Thank you jeff-themovie for this implementation!
2010-01-05 17:49:28 -05:00
Craig Andrews
fc2426d7ce Fix some bugs in the URL linkification, and fixed the unit test. 2009-09-27 16:52:15 -04:00
Craig Andrews
a535ccdc4e Merge remote branch 'laconica/0.8.x' into 0.9.x
Conflicts:
	lib/common.php
	lib/twitter.php
2009-09-02 16:42:15 -04:00
Craig Andrews
efcfd209ef Check "Files" of type 'application/xhtml+xml' for oEmbed in addition to just text/html 2009-09-01 23:18:39 -04:00
Evan Prodromou
c0d03fc279 make URL analyzer save new info on URLs 2009-08-27 20:23:31 -07:00
Evan Prodromou
a08c76a434 Merge branch '0.9.x' of git@gitorious.org:laconica/mainline into 0.9.x
Conflicts:
	classes/laconica.ini
2009-08-27 14:52:32 -07:00
Craig Andrews
504c42aa7d Fix some stupid bugs, such as a mispelling of oembed 2009-08-26 21:51:54 -04:00
Craig Andrews
6d60d74093 Display linked oembed resources as enclosures if they are of non-html mime types 2009-08-26 15:40:51 -04:00
Evan Prodromou
df86aa7214 define LACONICA and accept LACONICA for backwards compatibility 2009-08-26 10:41:36 -04:00
Evan Prodromou
865b716f09 change LACONICA to STATUSNET 2009-08-25 18:42:34 -04:00
Evan Prodromou
4737563b95 a distributed -> the distributed 2009-08-25 18:14:12 -04:00
Evan Prodromou
c8b8f07af1 change Laconica and Control Yourself to StatusNet in PHP files 2009-08-25 18:12:20 -04:00
Brett Taylor
3243612e76 Prevents redirect URLs that have canonical URLs longer than 255 chars from being written to the database as their canonical. Redirecting URLs will instead be saved to the database as given.
The reason for this is that table 'file' column 'url' is a VARCHAR(255) in MySQL and it silently truncates URLs longer than 255 characters, breaking the url.

The proper fix for this is to improve this column, making its type TEXT, but there are no database changes for 0.8.x, so this is the next best thing for data integrity. A migration script for 0.9.x could be written to audit the database checking for redirects and updating these urls to their proper canonical url.
2009-08-12 16:17:02 +12:00
Evan Prodromou
3af5774769 throw an exception rather than die() 2009-07-30 16:55:09 -04:00
Evan Prodromou
8371aea9c1 remove debugging code about processing a new URL 2009-07-30 16:38:50 -04:00
Brenda Wallace
28b62f357d fixed SQL in checking for monthly quota - works in postgres and mysql 2009-07-22 17:10:41 +12:00
Brenda Wallace
2aa47096b8 missing AND in the SQL 2009-07-22 17:10:20 +12:00
Craig Andrews
a35794e3c3 Try oEmbed discovery before using oohembed 2009-07-15 17:10:36 -04:00
Craig Andrews
c97957cf3e HTML "File"/attachments should probably not be considered enclosures. 2009-07-14 13:38:26 -04:00
Craig Andrews
593af9feb6 Moved the decision logic as to whether an attachment should be an enclosure to the File class 2009-07-14 13:33:40 -04:00
Craig Andrews
5f72423523 File classes does not use the $FILES array directly, as users of this class aren't necessarily from the web 2009-07-07 15:55:10 -04:00
Evan Prodromou
638905c270 avoid getting duplicate errors on upload 2009-06-25 11:10:34 -07:00
Evan Prodromou
a21a9f26c5 append uploads to content rather than showing them double 2009-06-23 07:29:43 -07:00
Zach Copley
d9bebfd651 Attachment upload server and path now configurable 2009-06-22 22:48:31 +00:00
Evan Prodromou
2e9fc34d4f change staticGet() from DB_DataObject to Memcached_DataObject for file classes 2009-06-22 14:24:40 -07:00
Evan Prodromou
05e5122802 Database changes for file tables
Some minor database changes for file tables. Namely:

 * Added a timestamp to all tables
 * Added a filename column for local files
 * Change some tables that had unnecessary auto-increment primary
   keys when they had another unique column that should act as
   the primary key
 * Change engine from MyISAM to InnoDB for a couple of files.

Also, rebuilt the DB_DataObject files for all these tables.
2009-06-22 14:19:41 -07:00
Evan Prodromou
aec6456c91 Update copyright dates in files modified in 2009 2009-06-20 16:12:55 -07:00
Evan Prodromou
793a6a1155 change Controlez-Vous to Control Yourself 2009-06-20 16:00:04 -07:00
Robin Millette
1505e3a4c3 Fixed recent attachment bug that required URLs to be posted twice to be taken into account. 2009-06-17 16:21:50 -04:00
Robin Millette
f8dae2bbc9 Refactored some attachment code and fixed upload bug in interface. 2009-05-31 21:03:55 -04:00
Robin Millette
fecb8c706d Attachments and their list now provide "ajax" view. Also added a few sidebars relating tags and attachments. 2009-05-15 15:04:58 -04:00
Robin Millette
3b7ee5a5f9 rewrote short url stuff to handle new file/url classes (redirections, oembed, mimetypes, etc.) 2009-05-13 14:27:32 -04:00
Robin Millette
d010d811ba db stuff for URLs: redirections, oembed, etc. 2009-05-11 13:45:00 -04:00