jDiction Forum

English => Install & Configure jDiction => Topic started by: joebarrus on August 25, 2013, 02:22:19 am

Title: Installation not working
Post by: joebarrus on August 25, 2013, 02:22:19 am
Hi,
I've installed the latest version of JDiction - 0.9.9.10
I'm using Joomla 3.1.5
I'm using Spanish language pack es-ES - 3.1.5.1 from Communidad Joomla

Symptoms:
1.  I see the translate flags next to content and can bring up the input pages.  But when I save, Joomla says content successfully saved but no content is saved.  I've looked in the database table _jd_store (the only one I find that I think is yours) and it has no entries.  I have set the database driver to jdiction_mysqli.

2.  When in Spanish Mode I click to a page that uses a Single Article as the content and my site goes into a never ending redirect loop between 302 and 303.  Also links to other components just don't load.   I'll try to install a different language pack using a different dialect of Spanish and see if that makes a difference.  It could be the pack I'm using.  But not sure if this should affect Symptom #1

Thanks
Joe




Title: Re: Installation not working
Post by: Harald Leithner on August 25, 2013, 09:54:41 am
Part one is strange... do you use a custom editor?

2. Is the permission level of the content language.
Title: Re: Installation not working
Post by: joebarrus on August 25, 2013, 09:17:36 pm
I'm using JCE.  But I tried with no editor or Tiny MCE and it's the same, not storing.  One thing I noticed in the JDiction Check is that it says Multiple Plugins have the same loading position (0) but everything else looks good.

The permission level of the Content Language (language manager/content) are all Public.

I'll do some more digging and see if I can figure out what happens when I save. I'll open the code and do some debugging and report back.  But I need to pick a language content manager very soon and I had hope this one would work as I had heard good things.  I haven't tried the others yet though.

thanks
Title: Re: Installation not working
Post by: joebarrus on August 26, 2013, 02:16:14 am
Ok I've narrowed it down.  The values status are coming in as Unchanged.  In your save function the values for $langdata and $status are as follows:

$langdata = array (
  'es-ES' =>
  array (
    'title' => 'new title',
    'alias' => 'new-alias',
    'metakey' => '',
    'metadesc' => '',
    'articletext' => '',
  ),
  'idJdStore' =>
  array (
  ),
  'tags' => NULL,
)

$status = array (
  'es-ES' =>
  array (
    'title' => 'unchanged',
    'alias' => 'unchanged',
    'metakey' => 'unchanged',
    'metadesc' => 'unchanged',
    'articletext' => 'unchanged',
  ),
)


I can see that you use Javascript to change it.  The boxes are changing to Orange as I add input so the JS is working there but looks like the jQuery call isn't happening. Do you have a jQuery conflict?  If so I haven't figured out how to remove that yet.   I'll work on that unless you find something else or can tell me how to resolve this

thanks
Title: Re: Installation not working
Post by: joebarrus on August 26, 2013, 09:26:16 am
Ok the jQuery call definitely isn't working.  I changed the value of one of the status input fields manually in the browser to 'changed' and the data saves fine.  Not sure what the issue is but does sound like a jQuery conflict.  But I haven't figured out how to fix that.  I've tried the various methods I've Googled but none seem to work.  Suggestions?
Title: Re: Installation not working
Post by: Harald Leithner on August 26, 2013, 09:32:14 am
If you can plz send me a supersdmin account per pm
Title: Re: Installation not working
Post by: joebarrus on August 26, 2013, 06:45:44 pm
I sent you access via PM but it doesn't show up in the sent folders.  Let me know if you didn't receive it

Thanks
Joe
Title: Re: Installation not working
Post by: joebarrus on August 27, 2013, 01:25:50 am
I figured it out.  You have a conflict between JQuery and Mootools.  I have jQuery loaded twice on my page, once before moot0ols and once after,  I'm not really sure what is loading the first one but all I did was wrap your code that is using Mootools with the following:

// For Mootols scripts
(function($){

// set a local $ variable only available in this block as an alias
// to Mootools document.id
... here is your Mootools specific code ...

})(document.id);

This allows your Mootools to work without conflict as you localized scope of the $ variable to only mean an id selector.  Only problem is I don't know where throughout your code you use Mootools where I need to fix that.  It would be nice if you can release a patch that wraps all your Mootools code this way.  Alternatively, I can try to find out what extension I am using that is loading jQuery first but that might take some time but also leaves your code vulnerable to future extensions that might reload jQuery first.

I took away super admin access as you don't need it anymore.  But please let me know if you can release a patch or let me know where in your code you use Mootools so I can patch it myself.

Thanks
Joe
Title: Re: Installation not working
Post by: joebarrus on August 27, 2013, 08:01:20 am
Ok I solved the backend issue but now I have a frontend issue.  Translating articles seem to work fine but my menus are not translating.  The data is being stored and when I sniff the db load I can see the data being retrieved but the menu never renders translated. 

I've restored access to the super user account I gave you in PM.  Please feel free to use it to see if you can figure out why.  If I can get articles and menus to work I think I'm golden

thanks
Title: Re: Installation not working
Post by: Harald Leithner on August 27, 2013, 10:18:34 am
Ok thx for the debugging.

2 things.

1st jdiction should not use mootools anymore in Joomla 3.x environment, if you its a bug. I found some mootools code in Joomla 3 part of the component, I will replace it and release a new version here in this thread.

2nd the problem that a menu is not translated has mostly todo with another plugin or template engine. First you have todo for this is to make sure the jdiction plugin is loaded on position 1 and all other plugins on position 2 or later.

if this doesn't help some plugin is badly coded.

Title: Re: Installation not working
Post by: Harald Leithner on August 27, 2013, 03:20:41 pm
This version use less mootools in Joomla 3+
I didn't replaced the formvalidation and tooltip handling because I didn't found a jquery replacement... maybe I missed it.
Title: Re: Installation not working
Post by: joebarrus on August 27, 2013, 11:53:33 pm
Harald,
Got things working.  I think your latest patch made a difference.  I also removed some extensions I no longer needed including some plugins that were at position 0.  I moved all plugins to position 2 except one - Crosstec.de Contentbuilder.  I had to place it at position 1 to work.  But only the Language Filter is at position 0 and jDiction and Contentbuilder at position 1 with everything else position 2 or higher.

so far everything seems to work including the menus.  Not sure what fixed that.  :)

Thanks for the help.  Nice component, very intuitive to use.

Joe
Title: Re: Installation not working
Post by: joebarrus on August 28, 2013, 07:42:36 am
Ok things were working until I tried to load my Contentbuilder froms.  Contentbuilder is a forms type extension from Crosstec.de.   If I tried to load the form it broke.  After many more hours of debugging I figured it out.  Your database driver searches for table name of #__content to decide if it should translate.  When Contentbuilder loads a form, it sends this query through the driver

sql = '
            Select
                forms.config,
                forms.verification_required_view,
                forms.verification_required_new,
                forms.verification_required_edit,
                forms.verification_days_view,
                forms.verification_days_new,
                forms.verification_days_edit,
                forms.verification_url_view,
                forms.verification_url_new,
                forms.verification_url_edit,
                contentbuilder_users.userid,
                forms.limit_add,
                forms.limit_edit,
                (Select count(id) From #__facileforms_records Where form = 3 And user_id = 407)  As amount_records,
                contentbuilder_users.verified_view,
                contentbuilder_users.verified_new,
                contentbuilder_users.verified_edit,
                contentbuilder_users.verification_date_view,
                contentbuilder_users.verification_date_new,
                contentbuilder_users.verification_date_edit,
                contentbuilder_users.limit_add As user_limit_add,
                contentbuilder_users.limit_edit As user_limit_edit,
                contentbuilder_users.published
                ,\'0\' As edited
            From
                #__contentbuilder_forms As forms
                Left Join
                    #__contentbuilder_users As contentbuilder_users
                On ( contentbuilder_users.form_id = forms.id And contentbuilder_users.userid = 407 )
               
            Where
                forms.id = 32
            And
                forms.published = 1

As you can see, it selects from a table called #_contentbuilder which equates to TRUE in a strpos() search in your driver in the translateQuery() function within this piece of code
      //search for a supported table
      $tables = $this->jd->getTable();
      foreach($tables as $table) {
        if (strpos($this->sql, $table->name) !== false) {
          $translate = true;
        }
Well the condition evaluates to TRUE since #__content is the beginning #__contentbuilder.  You need to search for for an exact match.

I patched it by concatenating a space after $table->name but I think the best answer is to replace strpos with a regex match.

Joe
Title: Re: Installation not working
Post by: Harald Leithner on August 28, 2013, 08:26:53 am
The problem is not so easy to solve. A regex maybe work but the table name could have some forms like space or return or enclosed.

And speed is a factor at this position. Starting a regex has a hugh overhead. But if you have ine I will consider it.

Thx
Title: Re: Installation not working
Post by: joebarrus on August 28, 2013, 09:52:17 am
regex is not so bad on speed.  But I've run into another problem.

Same contentbuilder is joining #__content in a query like this part of a query.
.......
                From
                    #__contentbuilder_records As records
                    Left Join #__contentbuilder_forms As form On ( form.`type` = records.`type` And form.reference_id = records.reference_id )
                    Left Join #__contentbuilder_articles As article On ( form.`type` = records.`type` And form.reference_id = records.reference_id And article.form_id = form.id And article.record_id = records.record_id )
                    Left Join #__content As content On ( form.`type` = records.`type` And form.reference_id = records.reference_id And article.article_id = content.id And article.form_id = form.id And article.record_id = records.record_id )

So my forms load still keeps failing.   Getting late here, will work on it more tomorrow.  Do other translation extensions have the same issue?

thanks
Title: Re: Installation not working
Post by: Harald Leithner on August 28, 2013, 10:51:23 am
I have no information about other translation extensions, I only know falang/joomfish which do the same as jdiction, maybe with a better query parser.

But your fix (with whitespace) should fix this problem. By the way thats a complex query that could easily fail by the query parser, do you have the modified query?
Title: Re: Installation not working
Post by: joebarrus on August 28, 2013, 11:45:56 pm
Thanks to you I have now become an expert Php programmer  LOL.  Really, I hadn't installed any sophisticated tools and have simply been peppering my code with output statements.  But in order to continue to debug I had to install Eclipse with XDebug and learn how to use them  :)  So thank you.  :)

Anyway, below is both the entire original query and the modified one.  Your modified query changed the FROM clause to FRO losing the M.

sql =
                Select
                    form.id As form_id,
                    form.act_as_registration,
                    form.default_category,
                    form.registration_name_field,
                    form.registration_username_field,
                    form.registration_email_field,
                    form.registration_email_repeat_field,
                    form.`last_update`,
                    article.`article_id`,
                    form.`title_field`,
                    form.`create_articles`,
                    form.`name`,
                    form.`use_view_name_as_title`,
                    form.`protect_upload_directory`,
                    form.`reference_id`,
                    records.`record_id`,
                    form.`type`,
                    form.`published_only`,
                    form.`own_only`,
                    form.`own_only_fe`,
                    records.`last_update` As record_last_update,
                    article.`last_update` As article_last_update
                From
                    #__contentbuilder_records As records
                    Left Join #__contentbuilder_forms As form On ( form.`type` = records.`type` And form.reference_id = records.reference_id )
                    Left Join #__contentbuilder_articles As article On ( form.`type` = records.`type` And form.reference_id = records.reference_id And article.form_id = form.id And article.record_id = records.record_id )
                    Left Join #__content As content On ( form.`type` = records.`type` And form.reference_id = records.reference_id And article.article_id = content.id And article.form_id = form.id And article.record_id = records.record_id )
                Where
                    form.`published` = 1
                And
                    form.create_articles = 1
                And
                    form.`type` = records.`type`
                And
                    form.reference_id = records.reference_id
                And
                   (
                     (
                        article.form_id = form.id
                      And
                        article.record_id = records.record_id
                      And
                        article.article_id = content.id
                      And
                        ( content.state = 1 Or content.state = 0 )
                      And
                      (
                        form.`last_update` > article.`last_update`   
                       Or
                        records.`last_update` > article.`last_update`
                      )
                     )
                     Or
                     (
                        form.id Is Not Null And records.id Is Not Null And content.id Is Null And article.id Is Null
                     )
                   )
                Limit 50

Modified query

sql =
                Select
                    form.id As form_id,
                    form.act_as_registration,
                    form.default_category,
                    form.registration_name_field,
                    form.registration_username_field,
                    form.registration_email_field,
                    form.registration_email_repeat_field,
                    form.`last_update`,
                    article.`article_id`,
                    form.`title_field`,
                    form.`create_articles`,
                    form.`name`,
                    form.`use_view_name_as_title`,
                    form.`protect_upload_directory`,
                    form.`reference_id`,
                    records.`record_id`,
                    form.`type`,
                    form.`published_only`,
                    form.`own_only`,
                    form.`own_only_fe`,
                    records.`last_update` As record_last_update,
                    article.`last_update` As article_last_update
                Fro, records.id AS JD_MAGIC_KEY_1, form.id AS JD_MAGIC_KEY_2, article.id AS JD_MAGIC_KEY_3, content.id AS JD_MAGIC_KEY_4 m
                    #__contentbuilder_records As records
                    Left Join #__contentbuilder_forms As form On ( form.`type` = records.`type` And form.reference_id = records.reference_id )
                    Left Join #__contentbuilder_articles As article On ( form.`type` = records.`type` And form.reference_id = records.reference_id And article.form_id = form.id And article.record_id = records.record_id )
                    Left Join #__content As content On ( form.`type` = records.`type` And form.reference_id = records.reference_id And article.article_id = content.id And article.form_id = form.id And article.record_id = records.record_id )
                Where
                    form.`published` = 1
                And
                    form.create_articles = 1
                And
                    form.`type` = records.`type`
                And
                    form.reference_id = records.reference_id
                And
                   (
                     (
                        article.form_id = form.id
                      And
                        article.record_id = records.record_id
                      And
                        article.article_id = content.id
                      And
                        ( content.state = 1 Or content.state = 0 )
                      And
                      (
                        form.`last_update` > article.`last_update`   
                       Or
                        records.`last_update` > article.`last_update`
                      )
                     )
                     Or
                     (
                        form.id Is Not Null And records.id Is Not Null And content.id Is Null And article.id Is Null
                     )
                   )
                Limit 50

I'll keep digging to see if I an find more.  In the meantime I do have another issue showing itself but haven't had time to tackle that one yet.  It seems that my links keep tacking on additional language parameters to the URL.  Like http://localhost/es/es/index.php.   Any clue why this might be happening?  It might be my next debug project.  :)

Thanks
Title: Re: Installation not working
Post by: joebarrus on August 28, 2013, 11:48:49 pm
correction, after looking at the query again, it looks like your code inserted the additional select items into the middle of the word FROM

Title: Re: Installation not working
Post by: Harald Leithner on August 29, 2013, 12:34:36 am
I use a query parser to get the from position and this parser isn't always right...

If the query would use the Jdatabasequery class it there would be no problem... but so its really hard to prevent this error.

Mostly because I missed 2 deadlines and have not much time atm for jdiction... especially because 3rd party components are still not supported...

the other problem does normally happen if the access level of the content language is wrong... but maybe not in this case.
Title: Re: Installation not working
Post by: joebarrus on August 29, 2013, 02:37:29 am
yeah I found where it was breaking.  I guess I'm going to have to hack his code to make it work and suggest he use the solution you suggest.  I have deadlines too and need to get this done. :)  But if I can fix it as  I go, with a little help from you, I can get it to work.  I'll keep you informed of any other issues I see.

I may get back to you on the second issue if it persists, but it may be a result of this issue.  I haven't seen it come back during my debug sessions today.  I changed the position number in the debugger and everything would load fine after that.  But you know that may simply mean that I just unblocked one door just so I can see another blocked door  :)

Thanks!
Title: Re: Installation not working
Post by: joebarrus on August 29, 2013, 04:37:39 am
Well, Harald I rewrote that query using jDatabaseQuery as you suggested and it works!  :)  It was a bit of a pain to write and I was worried if I left some of the more complex clauses as longer strings it wouldn't work, but instead I was happily surprised!  :)  so, the second issue did not show up so I think that was a result of the funky behavior caused by the first.  So far so good.

I'll suggest to the extension author he do this as well to ensure compatibility with other extensions like yours.

I appreciate the good work and I'll let you know if I run into anything else.
Thanks
Title: Re: Installation not working
Post by: Harald Leithner on August 29, 2013, 10:42:19 am
Thx good to know.

jDiction only needs 2 things from the query
1. all direct tables (FROM and JOINS) in including the alias, but not from subqueries.
2. the Position of FROM statement to inject the Primary keys of all tables

There is much optimization potential. I'm not good at regex but I think this information could be "easy" parsed by the regex.
Title: Re: Installation not working
Post by: joebarrus on August 30, 2013, 02:17:08 am
Regex is one of those things that is a little daunting at first but once you understand the syntax becomes fairly easy and very powerful. Used with Php's regex functions it is really easy to pull exact pattern matching content out of large text strings such as articles.  I used the following resources to help

http://www.regular-expressions.info/reference.html
This is just a nice syntax reference

http://txt2re.com/
This is a great tool to help you develop regex expressions and understand exactly how it works!

Joe
Title: Re: Installation not working
Post by: joebarrus on August 31, 2013, 10:28:01 am
So I continue to have the double language tags like en/en or es/es on my links after logging in.  Any suggestions?  I haven't found much on it yet on the Internet and I'm having trouble debugging it.
Title: Re: Installation not working
Post by: joebarrus on September 01, 2013, 10:39:11 am
nevermind. I ended up writing a plugin to strip the extra codes out.  I couldn't figure out what was causing it though I suspect it might be caused by a component reloading the page and causing the language filter to fire twice combined with SEF mode.  The language filter definitely was the code that was doing this in the build rules.
Title: Re: Installation not working
Post by: Harald Leithner on September 08, 2013, 10:45:14 pm
That shouldn't happend... i need Some more information