Форуми / Cotonti / Extensions / Parsing HTML in custom module question

lukgoh
#1 25.01.2012 22:12

Hey guys!

I'm writing a new module for my website and it requires user input via the text editor (I am using CKEditor) the text it outputs shows html, for example <p> the paragraph tags. I was wondering how to fix this.

Thanks in advance,

Luke.

ez
#2 25.01.2012 22:33

You cannot this is default ck.... I think

you can prevent it using shift enter in stead of enter

this thing really bugs me too, i always tend to edit in pure html when ck is used

but other less skillfull users cannot do this, i never give my clients ck unless they really really ask for it

==- I say: Keep it EZ -==
lukgoh
#3 25.01.2012 22:38

Yeah, I couldnt get the other editors working at all for some reason. Followed all the instructions but CKEditor is the only one that will work. I guess I want to use it exactly how it used in the forums here, just not for the forums.

Added 1 minute later:

I am assigning it to a tag by the way, like this: 

cot_textarea('jobs_info', $form['jobs_info'], 24, 120, '', 'input_textarea_editor'),
Trustmaster
#4 26.01.2012 06:02

If the problem is that it shows you page source after you submit it, it might be because of 2 things.

First, make sure you allow HTML upon variable import, so use HTM filter instead of TXT:

$form['jobs_info'] = cot_import('jobs_info', 'P', 'HTM');

Then, make sure you don't apply htmlspecialchars to it. So the output is something like this:

'MY_TEXT' => cot_parse($form['jobs_info']),

About the editor selection question, that is done by site administrator, not by user. Administrator picks a default parser and associates an editor with it. It is Cotonti's duty then to display that editor in modules. You can use a different parser in your module though, that is achieved by setting $sys['parser'] variable and passing it as a 3rd parameter to cot_parse().

May the Source be with you!

Відредаговано: Trustmaster (26.01.2012 06:34, 12 років тому)
lukgoh
#5 26.01.2012 10:41

Thank you Trustmaster, seems to of fixed it! I have another question, about how Cotonti uploads files to the avatar folder. I need something similar for my module. 

I am trying to see how I can upload images to a certain folder the same way Cotonti does. I have been looking through the core files but I cant seem to find where this happens.

Luke.

Trustmaster
#6 26.01.2012 13:34
May the Source be with you!
lukgoh
#7 26.01.2012 13:41

Was looking in completely the wrong place, thanks once again Trustmaster. 

Added 5 minutes later:

Although, this is a little over my head as I am knew to php, everything I have learnt so far is from backwards engineering what I can understand from the core files...


Відредаговано: lukgoh (26.01.2012 13:47, 12 років тому)
Trustmaster
#8 26.01.2012 14:48

Basicly it's just old plain PHP file uploads.

May the Source be with you!
lukgoh
#9 26.01.2012 16:41

Oh, okay and then checks to make sure the uploaded file is supported as an image file?

Trustmaster
#10 26.01.2012 18:00

This piece of code checks file extension, runs cot_file_check() to check if file contents is secure and uses cot_safename() to generate safe filename for storage:

$gd_supported = array('jpg', 'jpeg', 'png', 'gif');
$file_ext = strtolower(end(explode(".", $file['name'])));
$fcheck = cot_file_check($file['tmp_name'], $file['name'], $file_ext);
if(in_array($file_ext, $gd_supported) && $fcheck == 1)
{
	$file['name']= cot_safename($file['name'], true);
	$filename_full = $usr['id'].'-'.strtolower($file['name']);
May the Source be with you!
lukgoh
#11 02.02.2012 19:20

I have a new question:

I am trying to set a start and end date for a page in my custom module (not an actual page in the page module). To set the date the page is submitted I am using this: (int)$sys['now'] which is working just fine. What I would like to know is how to automatically add 1 week to that value and set it as the end date?

Thanks,

Luke.

Added 8 minutes later:

Is this a safe method: 604800 + time()


Відредаговано: lukgoh (02.02.2012 19:28, 12 років тому)
Xerora
#12 02.02.2012 20:08

Is this a safe method: 604800 + time()
 

Yup, that's exactly it

lukgoh
#13 02.02.2012 22:42

Thanks Xerora!