possible to "catch" a javascript-variable to put it into php

A place for users and developers of the Xataface to discuss and receive support.

Postby shannah » Fri Jun 08, 2007 9:33 am

Have you overridden you Dataface_Main_Template.html file at all in your application's templates directory?Ê That would override any changes you make to the Dataface template files.

There is something fishy going on with that install, but it is difficult for me to diagnose from this vantage point.

If at all possible it is best to not make any changes to any of the files in the dataface directory because it will become more difficult for you to upgrade later on.Ê Best to use conf.ini file where possible.

And I guess another thing to confirm that we are talking about the same conf.ini file.Ê You are changing the conf.ini file in your application's directory and not the one in the dataface directory right?


-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Mon Jun 11, 2007 5:22 am

Hi Steve,
You are right, I copied some files from the Dataface templates directory to my application templates directory and made some
changes there. I thought this would override the original files in dataface/Dataface/templates.
I do not make any changes in files of dataface/Dataface/templates directory.
How about the templates_c directory in my application. Isn't that a kind of cache where my real templates for the application
come from? There are all the same templates as in the templates directory but named something like
%%08^08F^08FE976E%%Dataface_Main_Template.html.php
OK. I searched the forum and found http://framework.weblite.ca/forum/dataface-users/141833807/23945652/?searchterm=templates_c
and http://framework.weblite.ca/forum/dataface-users/127/2/?searchterm=templates_c
How does it exactly work? What happens when I delete everything but the folders in templates_c. I think that has to do with
my problems. I want the Dataface_Main_Template.html IN MY APPs templates folder to be the one which is used. And when I change it I want the
changed one there to be used and not the %%08^08F^08FE976E%%Dataface_Main_Template.html.php in templates_c.
I think this should be another thread. Maybe I should open one next time.
Now on my main problem with the odd special chars:
I changed my conf.ini in my app not the one in dataface directory. And I changed my Dataface_Main_Template.html in my
application back to the former state, that means I took out the static UTF-8 encoding and made it {ENV.APPLICATION.oe} again.
Nevertheless my special chars come out as ? in my app.
What more can I do?
Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Jun 11, 2007 9:16 am

Are all special chars coming out as ? or just the ones from the 2nd select list?

This is how dataface works for encodings:

1.Ê If you are using only one language, then Dataface will try to use ISO-8859-1 encoding (Latin-1).Ê If you have more than one language in your app, then it will always use UTF-8.Ê You can override the encoding by setting the io and oe parameters in the conf.ini file.Ê This will add a meta tag to the main template to indicate that it should use UTF-8.Ê If you are not using the Main template for the output in an action, then you should explicitly output an HTTP header to state the character set.

See dataface/actions/ajax_view_record_details.php for an example of this.Ê Note the line:

header('Content-type: text/html; charset='.$app->_conf['oe']);

This is important.

For javascript like your custom action is returning, you'll want to use text/javascript instead of text/html .

-Steve

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Mon Jun 11, 2007 10:26 am

Hi Steve,
just the special chars from 2nd select list come out as ?
I have at the very beginning of my conf.ini
oe=UTF-8
ie=UTF-8
I have my cutom action like this:
$app =& Dataface_Application::getInstance();
header('Content-type: text/javascript; charset='.$app->_conf['oe']);
//$app->_conf['oe'] stores the output encoding for the application which is probably UTF-8 right now
// Dient der Ausgabe von Sonderzeichen in UTF-8 Codierung
// actions_get_types sucht die zugehšrigen typen einer gewŠhlten typgruppe
class actions_get_types {
ÊÊÊ function handle(&$params){
ÊÊÊÊÊÊÊ if ( isset($_REQUEST['type_group']) ){
ÊÊÊÊÊÊÊÊÊÊÊ $sql = "select l_tid, L_GID, type from list_event_type where L_GID='".addslashes($_REQUEST['type_group'])."'";
ÊÊÊÊÊÊÊ } else {
ÊÊÊÊÊÊÊÊÊÊÊ $sql = "select l_tid, L_GID, type from list_event_type";
ÊÊÊÊÊÊÊ }
ÊÊÊÊÊÊÊ $res = mysql_query($sql, df_db());
ÊÊÊÊÊÊÊ if ( !$res ) trigger_error(mysql_error(df_db()), E_USER_ERROR);
ÊÊÊÊÊÊÊ header('Content-type: text/javascript');
ÊÊÊÊÊÊÊ echo '[';
ÊÊÊÊÊÊÊ $values = array();
ÊÊÊÊÊÊÊ while ( $row = mysql_fetch_assoc($res) ){
ÊÊÊÊÊÊÊÊÊÊÊ $values[] =Ê "{l_tid:'".$row['l_tid']."', type: '".addslashes($row['type'])."'}";
ÊÊÊÊÊÊÊ }
ÊÊÊÊÊÊÊ echo implode(',',$values);
ÊÊÊÊÊÊÊ echo ']';
ÊÊÊÊÊÊÊ exit;
ÊÊÊ }
ÊÊÊ
}
Nevertheless I do not get the right chars. And when I look into the source of my html, it is still:

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and in the head



Somehow frustrating I think. I t seems as if nothing ever changes.
Markus

Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Mon Jun 11, 2007 3:33 pm

Hi Markus,
A couple of things.Ê There are 2 separate things to be looking at... best to keep them separate so that things don't get confusing.
1. The get_types action.
2. The HTML source.
Since most of your HTML source looks OK, it is best to leave that alone.Ê Just focus on the get_types action.Ê (i.e. REmove all of the encoding stuff you added at the beginning of the conf.ini file).
Now for the get_types action, this is the problem:
Your header() function should be where the second header() function is called.Ê (Notice that you have 2 of them - the 2nd one is in the correct place, the first one is not.Ê You just need to change the 2nd one so that it looks like the first one - if that makes any sense.Ê e.g.
class actions_get_types {
ÊÊÊ function handle(&$params){
ÊÊÊÊÊÊÊ if ( isset($_REQUEST['type_group']) ){
ÊÊÊÊÊÊÊÊÊÊÊ $sql = "select l_tid, L_GID, type from list_event_type where L_GID='".addslashes($_REQUEST['type_group'])."'";
ÊÊÊÊÊÊÊ } else {
ÊÊÊÊÊÊÊÊÊÊÊ $sql = "select l_tid, L_GID, type from list_event_type";
ÊÊÊÊÊÊÊ }
ÊÊÊÊÊÊÊ $res = mysql_query($sql, df_db());
ÊÊÊÊÊÊÊ if ( !$res ) trigger_error(mysql_error(df_db()), E_USER_ERROR);
ÊÊÊÊÊÊÊ $app =& Dataface_Application::getInstance();
ÊÊÊÊÊÊÊ header('Content-type: text/javascript; charset='.$app->_conf['oe']);
ÊÊÊÊÊÊÊ echo '[';
ÊÊÊÊÊÊÊ $values = array();
ÊÊÊÊÊÊÊ while ( $row = mysql_fetch_assoc($res) ){
ÊÊÊÊÊÊÊÊÊÊÊ $values[] =Ê "{l_tid:'".$row['l_tid']."', type: '".addslashes($row['type'])."'}";
ÊÊÊÊÊÊÊ }
ÊÊÊÊÊÊÊ echo implode(',',$values);
ÊÊÊÊÊÊÊ echo ']';
ÊÊÊÊÊÊÊ exit;
ÊÊÊ }
ÊÊÊ
}
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Tue Jun 12, 2007 1:23 am

Hi Steve,

Thank you for that. I did not really regognize the double code. Now it works great and all of the special chars are written correctly. I hope we can close this thread now.

I have in mind the "How to" but still not enough spare time now.

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Tue Jun 12, 2007 12:49 pm

Phew... this thread really exposes some klunkiness in the Ploneboard forum.Ê Having to always click on "Page 2" is kind of a pain..Ê it was a long one.

Glad to hear it's working now.Ê

Best regards

Steve

--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Previous

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 29 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved