Loading...
 
Skip to main content

Custom Share Module 0.1dev

Features / Usability

Features / Usability


Suggestion and solution for Wiki Upload image beahviour

posts: 23 Germany

Hi,
first i like tikiwiki. But we noticed there is some strange behaviour in the possibility to upload directly images to a wikipage (not the image gallery) while you edit this page: Upload an image with an name already existing just overwrites the original image, without any checkings. So if 2 people on differents pages are using an image like "screenshot.jpg" they disturb each other.
We discussed this problem and now have a suggestion to make life easier for users. Here comes the idea and the needed code.
There are 3 possible cases:

  1. CASE: you are editing page "A" and want to upload image A.jpg. A.jpg doesn't exists on any page in this wiki-domain, so we just act like before. Uploading image to wik_up/$tikiDomain/A.jpg and adding tag at bottom of page.
  2. CASE: you are editing page "A" and try to upload A.jpg, but A.jpg already exists and is already linked from "A". So we guess the user want to upload a new version of A.jpg. We update A.jpg in wiki_up and dont't add the tag to bottom of page, couse the picture-tag is already there.
  3. CASE: you are editing page "A" and try to upload B.jpg, but B.jpg already exist in wiki_up/$tikidomain (e.g. in this wiki) and is linked from an other page. So we guess the user does not know this and want to upload a new image. So we find a new name for his file, saving his image with the new name in wiki_up/$domainname and and the picture tag at bottom of page with the new filename.

Hope this idea to handle the image uploads is useable for other too. Below follows the code. To get it to work you have to insert this code into tiki-editpage.php (in tiki-root-dir) instead of the old "Upload pictures here" code (look for the comment in the code).

CODE

Copy to clipboard
// Upload pictures here if (($feature_wiki_pictures == 'y') && (isset($tiki_p_upload_picture)) && ($tiki_p_upload_picture == 'y')) { if (isset($_FILES['picfile1']) && is_uploaded_file($_FILES['picfile1']['tmp_name'])) { $picname = $_FILES['picfile1']['name']; // if filename not exists behave like before, if not: // if filename exists already on other page create new filename filename_xxx.extension with xxx is a number // if filename exists already on this page just overwrite the file with the new version and dont create a tag on bottom of page if ( is_file("img/wiki_up/$tikidomain" . $picname) ) { //file already there //test if filename exists as picture link in pagesourcecode if (substr_count( $_REQUEST["edit"],"{picture file=img/wiki_up/$tikidomain" . $picname ."}" )>0) { //file already used by this page, just change it move_uploaded_file($_FILES['picfile1']['tmp_name'], "img/wiki_up/$tikidomain" . $picname); } else { //file already in other page, create new name $tmp_counter = 1; do { $new_picname = $tmp_counter ."_".$picname; $tmp_counter++; } while ( is_file("img/wiki_up/$tikidomain". $new_picname) ); move_uploaded_file($_FILES['picfile1']['tmp_name'], "img/wiki_up/$tikidomain" . $new_picname); $_REQUEST["edit"] = $_REQUEST["edit"] . "{picture file=img/wiki_up/$tikidomain$new_picname}"; } } else { //new file move_uploaded_file($_FILES['picfile1']['tmp_name'], "img/wiki_up/$tikidomain" . $picname); $_REQUEST["edit"] = $_REQUEST["edit"] . "{picture file=img/wiki_up/$tikidomain$picname}"; } } }


Greetings
Andreas

posts: 2881 United Kingdom

Hi Andreas!

Would you be interested in joining us on the development list at Sourceforge?

Damian

posts: 23 Germany

> Damian:
> Hi Andreas!
>
> Would you be interested in joining us on the development list at Sourceforge?
>
> Damian
Hi Damian,
why not. If this is the best way to add some minor improvements to tiki. My background to use tiki (1.8RC2 at the moment) is for some self aided elearning setups and for an internal knowledge database. So i dont have to much time but a good background in what users want and need and how to give them the opportunity for there wishes as easy as possible in mind of usability. So tell me where I can find out how to join you.
Greetings
Andreas


posts: 23 Germany

> Damian:
> Hi Andreas!
>
> Would you be interested in joining us on the development list at Sourceforge?
>
> Damian
Hi Damian,
why not. If this is the best way to add some minor improvements to tiki. My background to use tiki (1.8RC2 at the moment) is for some self aided elearning setups and for an internal knowledge database. So i dont have to much time but a good background in what users want and need and how to give them the opportunity for there wishes as easy as possible in mind of usability. So tell me where I can find out how to join you.
Greetings
Andreas


Upcoming Events

1)  18 Jul 2024 14:00 GMT-0000
Tiki Roundtable Meeting
2)  15 Aug 2024 14:00 GMT-0000
Tiki Roundtable Meeting
3)  19 Sep 2024 14:00 GMT-0000
Tiki Roundtable Meeting
4) 
Tiki birthday
5)  17 Oct 2024 14:00 GMT-0000
Tiki Roundtable Meeting
6)  21 Nov 2024 14:00 GMT-0000
Tiki Roundtable Meeting
7)  19 Dec 2024 14:00 GMT-0000
Tiki Roundtable Meeting