Joomla File Handling - Variable name not passed - joomla

I made a component with a "file" field type, but the content of that single field are not passed at all, I was under the impression it should save the file name as text at least, if I change the field type to "text" the name saves so I know everything else is functioning. All the other fields are being passed. What am I doing wrong?
File handling aside, I just want it to save the name.
A detailed explanation would be appreciated, or even better, can I get someone who knows what he's doing re-write this component using MVC so I can compare.
Thanks

Can't really help with what you have so far as you haven't provided any code, however our website have recently made a small simple component for Joomla 2.5 for file uploading using the SWFUpload framework, should you want to use it.
http://joomjunk.co.uk/products/component-home/swfupload.html

Related

Adding custom data based attributes based on Response object

Halo ! I'm trying to implement dropzonejs in a very specific way. Actually I follow the standard implementation described on the official page. Everything works perfectly.
But I'm willing to attach the server's generated URI for each uploaded file directly when uploaded : when uploading it's creating a database entry with some stuff like a page uri with title etc. This mean that the server would return as a response the id of the database saved file in order to attach the href attribute with its value to the the element in front.
This is quite ok to do this when only one file is uploaded, but it becomes trickier when bulk uploading.
So maybe I didn't understand the documentation well (and I'm quite sure I didn't), but is there any way to add custom data-dz-like attributes based on my server's response ? I'd like something like data-dz-url where the url points to a database entity (not the file itself).
Or if not if there is an "easy way" to handle this.
Thanks a lot
Here is the answer :
myDropzone.on('success', (file, response) => {
file.previewElement.href = "/admin/media/"+response.id+"/show/"
})
file is reference to the current uploaded element. It's possible to extend it's html attributes through previewElement. Setting the data-type attribute in the template before, then assigning it the right value works aswell.
Hope this will help some.

How to recuperate field value in others forms in section template in Orbeon

I have a section Template'Section_library',in 'Section_library' i have a field 'first-name' who recuperate the value field from another section in my form so i used this expression
xxf:component-context()/root()/form/Section_TWO/mycontrol.
this expression not worked totally,the recuperation is done when i try to write in this field 'first-name'. i want a solution that automatically recuperate the value within any interaction of user.
I find this issue #3008 but i didn't understand it.
As of 2016.2, there is no reliable and supported way for code inside a section template to access information about the form it is used in. This is by design, but there are reasonable use cases that call for a section template being able to access things from the "outer form", and you're correct pointing to RFE 3008. For now I'd recommend you follow this issue.

Joomla component "attachments" allow html in input

this question might be a bit special. I am using this Joomla 2.5 extensions to give authors the abilty to add Attachments to articles: Joomla Attachments
The extension renders an input field called "description" in a backend form to insert an file description for the provided file. Unfortunately it´s not taking HTML tags which I need. By saving the form it seems a strip_tags() or preg_replace() or something similar cleans the input. I combed through the code of the attachments extension but couldn´t find a place where the input is cleaned or saved.
To hopefully stay in the Question + Answer rule of Stackoverflow:
Is there a class which extensions inherit from the Joomla Core to save form data to a DB-table ( which also could be responsible to clean and validate user input )?
thanks for any idea,
tony
You should see how the field is defined first:
1. Form definition
look into the
administrator/component/yourcomponent/models/forms/somename.xml
there you could find a form definition, if so it will also specify the field type: depending on the type there are several available filters; for example the default textarea will strip html, and you need to set
filter="raw"
in order to enable it. see http://docs.joomla.org/Standard_form_field_and_parameter_types for a list of fields, click and you can find the available format options.
2. model
If the model inherits from JModelAdmin or JModelForm or other JModel* it will automatically handle binding of the forms' data to the database, look for the Save function which should receive the form $data.
3. more
There are at least another dozen possibilities. If the above didn't help, try finding the form: possibly you could find it just by looking at the markup. Once you have the form, check the following fields:
option
task
view
This should help you find the php code that is invoked based on the form:
if view is set, maybe in ./views/someview/view.html.php you could find the saving logic.
if task is set, look for a function with the same name in ./controller.php
if task contains a ".", look for the controller in the ./controllers/ folder.
if option is not the name of your component, your component is sending the data to another component for saving, and most likely set a return-url

Adding Extra fields on Joomla Registration Form

How to add extra fields in Joomla2.5 registration form? I am using profile plugin but i also want to change the order of the fields. Any Suggestion?
Copy the profile plugin and change it to do what you want, then install it and unpublish the old one.
You can add additional fields to the registration form by changing the database and a core component file.
First of all take a look of components\com_users\models\forms directory and there is a XML file called registration.xml. This is the file joomla creates the registration form fields. I hope you can understand this file and add what ever the necessary fields you want.
And after that check out your data base table called #__users and add the extra fields you want. (ex: if you want to add Telephone number add filed calld tp_no). And make sure to use the same name that you use in XML file "field name" for the database table column as well.
I imagine you are looking for something like this?
http://extensions.joomla.org/extensions/access-a-security/site-access/authentication/14303
Probably the safest solution in the short and long term. I've not used it but it looks like it does what you want and from an interface rather than changing hard code.
There is manual how do it. Turn on subtitles visit http://www.youtube.com/watch?v=a6xsKLiXF40

Spring MVC Upload File - How is Content Type determine?

I'm using Spring 3 ability to upload a file. I would like to know the best way to validate that a file is of a certain type, specifically a csv file. I'm rather sure that checking the extension is useless and currently I am checking the content type of the file that is uploaded. I just ensure that it is of type "text/csv". And just to clarify this is a file uploaded by the client meaning I have no control of its origins.
I'm curious how Spring/the browser determines what the content type is? Is this the best/safest way to determine what kind of file has been uploaded? Can I ever be 100% certain?
UPDATE: Again I'm not wondering how to determine what the content type is of a file but how the content type gets determined. How does spring/the browser know that the content type is a "text/csv" based on the file uploaded?
You can use
org.springframework.web.multipart.commons.CommonsMultipartFile object.
it hasgetContentType(); method.
Look at the following example http://www.ioncannon.net/programming/975/spring-3-file-upload-example/
you can just add the simple test on CommonsMultipartFile object and redirect to error page if it the content type is incorrect.
So you can also count the number of commas in the file per line.There should normally be the same amount of commas on each line of the file for it to be a valid CSV file.
Why you don't just take the file name in you validator and split it, the file type is fileName.split("\.")[filename.length()-1] string
Ok, in this case i suggest you to use the Csvreader java library. You just have to check your csvreader object and that's all.
As far as I'm aware the getContentType(String) method gets its value from whatever the user agent tells it - so you're right to be wary as this can easily be spoofed.
For binary files you could check the magic number or use a library, such as mime-util or jMimeMagic. There's also Files.probeContentType(String) since Java 7 but it only works with files on disk and bugs have been reported on some OSes.

Resources