Strict Standards: Non-static method Flyspray::absoluteURI() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/constants.inc.php on line 29 Strict Standards: Non-static method Flyspray::get_tmp_dir() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/constants.inc.php on line 78 Warning: session_start(): open(/data/web/tmp/sessions/sess_t5vtpp6v9250h1hdbassqnh0u6, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_3b4su0ohd5tgrgt8spt1fio5a1, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_e2pvfvf1s2iaif23lvlub7ri22, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_qdie1gp32v5oq753s78or9eui5, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_d63ri84rf1krfq7hpq5idt41o0, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_g2l5r8s681tug9sdtio764uq20, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_db4j764l6fvec1crns7v9hjfg5, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_5ieq4q6acej5b3gea85um3qdp0, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_bre413aois1g8f1k8th3277au7, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 732 Warning: session_start(): open(/data/web/tmp/sessions/sess_687t6r2si0s3digbtguu4ocmh1, O_RDWR) failed: Disk quota exceeded (122) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 750 Strict Standards: Non-static method Flyspray::base_version() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/header.php on line 29 Strict Standards: Non-static method Flyspray::base_version() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/header.php on line 29 Strict Standards: Non-static method Req::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/header.php on line 39 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 26 Strict Standards: Non-static method Req::num() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/header.php on line 40 Strict Standards: Non-static method Req::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 32 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 26 Strict Standards: Non-static method Filters::num() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 32 Strict Standards: Non-static method Req::num() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/header.php on line 42 Strict Standards: Non-static method Req::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 32 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 26 Strict Standards: Non-static method Filters::num() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 32 Warning: Cannot modify header information - headers already sent by (output started at /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php:26) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 677 Strict Standards: Non-static method Req::enum() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 20 Strict Standards: Non-static method Req::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 37 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 26 Strict Standards: Non-static method Filters::enum() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 37 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 26 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 26 Strict Standards: Non-static method Cookie::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 33 Strict Standards: Non-static method Get::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 41 Strict Standards: Non-static method Get::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 100 Warning: Cannot modify header information - headers already sent by (output started at /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php:26) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 82 Warning: Cannot modify header information - headers already sent by (output started at /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php:26) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 83 Warning: Cannot modify header information - headers already sent by (output started at /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php:26) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 84 Warning: Cannot modify header information - headers already sent by (output started at /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php:26) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 87 Warning: Cannot modify header information - headers already sent by (output started at /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php:26) in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 88 Strict Standards: Non-static method Get::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 100 Strict Standards: Non-static method Get::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 100 Strict Standards: Non-static method Flyspray::requestDuplicated() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 109 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/index.php on line 148 Strict Standards: Non-static method Req::num() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/scripts/details.php on line 15 Strict Standards: Non-static method Req::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 32 Strict Standards: Non-static method Req::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 26 Strict Standards: Non-static method Filters::num() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 32 Strict Standards: Non-static method Flyspray::GetTaskDetails() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/scripts/details.php on line 17 Strict Standards: Non-static method Flyspray::GetAssignees() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.flyspray.php on line 358 Strict Standards: Non-static method Get::val() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/scripts/details.php on line 34 Strict Standards: Non-static method Get::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.gpc.php on line 100 Strict Standards: Non-static method Post::has() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/scripts/details.php on line 34 Strict Standards: Non-static method TextFormatter::render() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/scripts/details.php on line 128 FS#73 : Allow "translation" of images

Anwiki CMS

Anwiki CMS : the first wiki/CMS dedicated to multilingual contents
Tasklist

FS#73 - Allow "translation" of images

Attached to Project: Anwiki CMS
Opened by Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 281 Wladimir Palant (trev) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Wednesday, 10 March 2010, 09:24 GMT
Task Type Feature Request
Category Core
Status Unconfirmed
Assigned To No-one
Operating System All
Severity High
Priority Normal
Reported Version Anwiki 0.2.1
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

I am using different images for different languages on my site. As it is now, doing this with Anwiki is problematic - images cannot be turned into Anwiki pages, consequently you cannot have the image link auto-adapted depending on language. For now my work-around is a special content type for images plus an override for view action to allow output of raw images (both in the attached ZIP file). Originally I thought about keeping HTML output for the view action and displaying the raw image in a new action but that makes URLs more verbose and caching is more difficult. The downside is that you cannot go directly into translation mode from fr/images/test.png - you have to add "?a=translate" manually. The other problem with this content type is that you have to enter image data in base64 format, uploading a file directly isn't possible.

Oh, and I had to modify $asREGEXP_LINKS in class_page.php as well - it has to check src attribute.
This task depends upon

Comment by Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 281 anw (anw) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Wednesday, 10 March 2010, 23:26 GMT
Yes, files uploading is something which absolutely needs to be added to Anwiki.
A new attribute type "file" will be supported for contentclasses (with options to restrict size/filename), so that you won't have to copy/paste the image data in base64 format.
It would also give better performances to not store the file data directly into the "anw_page" table - even if cached, it's weird to store image data into structured XML :-)
It may also slow down the AutoSync algorithm when updating the field value...
We may store the file data into a dedicated blobs table + cache system, or maybe directly on the filesystem...
The import/export script will be updated to generate an archive for including these files. Also for the translation screen, which should allow uploading "translated" files - when file attribute is translatable.

Anyway thanks for your contentclass suggestion, it's a nice workaround for managing translations of images - at least a temporarily solution!
Have a look to attached file - I added a parameter to only output image data when giving parameter "?rawimg=1" (had to implement AnwCachedOutputKeyDynamic on the contentclass for caching issues). That way, action_view is not broken - this action also doesn't need anymore to be overriden.

It looks also a bit weird to manually hack the "src" attribute for linking the image by URL, and getting it analyzed with $asREGEXP_LINKS.
Maybe an abstraction "tag" such as <anwimg name="myimage"/>, which would automatically resolve appropriate image translation by its name and link with the ?rawimg=1 parameter, would be more appropriated.
You an "easily" implement this with a plugin based on vhook_outputhtml_clean_body_html (for transforming content value before caching, so that transformation doesn't affect attribute value, and only affects its rendering). Have a look to the plugin_smilies or plugin_commontags... don't hesitate for any question!

I can't give ETA for file upload attribute, as it will have various impacts (import/export, translation form, file or database structure...).
I also think we need a more flexible solution for quickly "attaching" files directly to a specific content, without leaving the edition form of the main content. So I'd prefer to be sure of an optimal solution before implementing it. Suggestions are welcome!
Comment by anw (anw) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Wednesday, 10 March 2010, 23:28 GMT
Oops, I forgot a debug trace on line 36... (print "!")
Comment by anw (anw) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Wednesday, 10 March 2010, 23:33 GMT
Ah, the 2 plugins I mentionned are "unofficial" and not released. They can be found on SVN:
http://svnweb.tuxfamily.org/listing.php?repname=anwiki%2Fanwiki&path=%2Ftrunk%2Fanwiki-addons%2F&#path_trunk_anwiki-addons_
Comment by Wladimir Palant (trev) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Thursday, 11 March 2010, 07:54 GMT
I'm less worried about performance because I don't plan to run PHP for users who aren't logged in - the current version of the site uses a "cache" built of static files already, same will be done here. This is also one reason why I prefer having images display with undecorated URLs.

As to <anwimg> tag, I have been also thinking about doing something like that - to have the alt attribute generated automatically from image title. Ideally, width and height attributes would also be generated automatically. Using vhook_outputhtml_run_body will be necessary then because the image can change independently of the page (as I said, I'm not very worried about performance). But my current work-around will do for now.
Comment by Wladimir Palant (trev) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Tuesday, 07 September 2010, 08:08 GMT
Attaching current version of my add-on, it no longer relies on hacking Anwiki source code. The raw output is produced by the new "show" action. The "view" action on the other hand still shows the menu, this makes things easier. In addition to the attached files I use the following code in vhook_outputhtml_run_body to bind image tags and add ?a=show automatically:

// Bind images to the correct target
$sHtml = preg_replace_callback('/(<img\b[^<>]*\ssrc=")([^"]+)(")/', array(&$this, 'bindImage'), $sHtml);

[...]

private function bindImage($matches)
{
$sLink = $matches[2];
if (strstr($sLink, '://') || substr($sLink,0,1) == '#' || substr($sLink,0,1) == '/' || !AnwPage::isValidPageName($sLink))
{
return $matches[0];
}

$oPageTarget = AnwPageByName::getByNameOrSecondChance($sLink);
if (!$oPageTarget)
{
return $matches[0];
}

$sPreferedLang = $this->oPage->getLang();
$oPageTarget = $oPageTarget->getPageGroup()->getPreferedPage($sPreferedLang);

$sLinkTarget = AnwUtils::link($oPageTarget->getName(), "show");
return $matches[1] . $sLinkTarget . $matches[3];
}

The way the action connects to the content class could be improved of course. Translators still see raw base64-encoded string - I would like to eventually use the File API (https://developer.mozilla.org/en/Using_files_from_web_applications) and btoa() to encode a file on the client side if browsers that support it.
Comment by Strict Standards: array_map() expects parameter 1 to be a valid callback, non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 281 rafit (rafit) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Wednesday, 01 February 2012, 00:41 GMT
Maybe it's an old solution, but it is very interesting and it is what I need for my website - but I don't know how to use it.

I downloaded last images.zip, installed. Now I have a test image: "/pl/test.png" and it translation "/en/test.png". I can see two different images:

http://example.com/pl/test.png?a=show
http://example.com/en/test.png?a=show

Then I found vhook_outputhtml_run_body in /sources/classes/plugin/class_plugin.php (you wrote "Attaching current version of my add-on, it no longer relies on hacking Anwiki source code." - how to do that mod without hacking sources?)
I changed function to:

<code>
protected function vhook_outputhtml_run_body($sHtml){
// Bind images to the correct target
$sHtml = preg_replace_callback('/(<img\b[^<>]*\ssrc=")([^"]+)(")/', array(&$this, 'bindImage'), $sHtml);
return $sHtml;
}
</code>

of course i added bindImage function before.

But then I get no effect. I inserted my test image into page as:

<img src="/pl/test.png"\> - no image
<img src="/pl/test.png?a=show"\> - i get an image, but no changes when I change page translation.

What I do wrong? How to use this extension?
Comment by anw (anw) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Friday, 10 February 2012, 00:18 GMT
Hi,
Sorry for the downtime...

There was something missing in the plugin to retrieve current page, luckily we can use another hook to get it.
I published an addon here and will add it to the download page: http://www.anwiki.com/en/addons/addon_image

@trev: is the "show" action really needed or better than output directly from the contentclass?
If you look to my uploaded version, we don't need a dedicate action, just using a GET parameter and reusing the 'view' action.
Comment by Wladimir Palant (trev) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Friday, 10 February 2012, 14:53 GMT
The "show" action is necessary if you want to edit/translate images - otherwise all you get is a raw image and you have to add ?a=translate to the URL manually.
Comment by anw (anw) - Strict Standards: Non-static method Filters::noXSS() should not be called statically in /data/web/a5/4e/8e/bugs.anwiki.com/htdocs/includes/class.tpl.php on line 613 Friday, 10 February 2012, 20:54 GMT
With last version uploaded, it should work exactly same without needing additional action, thanks to an additional parameter processed in toHtml() which is called from view action:
- /pl/test.png?a=view -> standard output (<img src="/pl/test.png?a=view&show=1"/>) - like the show action
- /pl/test.png?a=view&show=1 -> raw output

It's just to get less code to maintain and less things to configure

Loading...

Warning: Unknown: open(/data/web/tmp/sessions/sess_687t6r2si0s3digbtguu4ocmh1, O_RDWR) failed: Disk quota exceeded (122) in Unknown on line 0 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (0;660;/data/web/tmp/sessions) in Unknown on line 0