Page 1 of 1

wrong use of S9Y_INCLUDE_PATH!?

Posted: Sun Jul 29, 2007 12:02 am
by stm999999999
in /include/lang.inc.php

old:

Code: Select all

    // The following variable can be set in serendipity_config_local.inc.php to force your templates being able to use language override includes
    if ($serendipity['useTemplateLanguage']) {
        @include (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/' . $charset .  'lang_' . $serendipity['lang'] . '.inc.php');
        @include (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php');
    }
new:

Code: Select all

    // The following variable can be set in serendipity_config_local.inc.php to force your templates being able to use language override includes
    if ($serendipity['useTemplateLanguage']) {
        @include (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/' . $charset .  'lang_' . $serendipity['lang'] . '.inc.php');
        @include (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php');
    }
because for normal installation, there is no difference. But for shared installation:

you can have the templates-folder either as a link to the s9y-core-installation/templates or as this-s9y-instance/templates - in both cases S9Y_DATA_PATH will point to the right location!

Posted: Wed Aug 01, 2007 1:57 am
by stm999999999
and there is another piece of code with this problem

serendipity_event_livesearch.php - line 133:

Code: Select all

                        case 'ls-js':
                            header('Content-Type: text/javascript');
                            echo file_get_contents(S9Y_INCLUDE_PATH . 'plugins/serendipity_event_livesearch/serendipity_event_livesearch.js');
                            break;
should be S9Y_DATA_PATH.

Posted: Sat Aug 04, 2007 1:28 pm
by garvinhicking
Hi!

S9Y_DATA_PATH is only available on shared installations, so using that at this place will break it on non-shared installations.

Regards,
Garvin

Posted: Sat Aug 04, 2007 2:18 pm
by stm999999999
hm, but in shared installation it is needed - because S9Y_INCLUDE_PATH points to the core-installation. And there is possibly no (up-to-date) plugins/templates-dir.

Isn't there a solution like setting S9Y_DATA_PATH to the value S9Y_INCLUDE_PATH for non-shared-situations - so that S9Y_DATA_PATH will work all the time?

...

OK, I see, there are places which check whether there is a shared installation by looking for the existing of S9Y_DATA_PATH, so it would be no good idea to define this allways. :-(


What is about this?

Code: Select all

case 'ls-js': 
  header('Content-Type: text/javascript'); 

if (defined('S9Y_DATA_PATH')) {

  echo file_get_contents(S9Y_DATA_PATH . 'plugins/serendipity_event_livesearch/serendipity_event_livesearch.js'); 
} else {
  echo file_get_contents(S9Y_INCLUDE_PATH . 'plugins/serendipity_event_livesearch/serendipity_event_livesearch.js'); 
 }
break;
and

Code: Select all

    if ($serendipity['useTemplateLanguage'] AND defined('S9Y_DATA_PATH')) { 
        @include (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/' . $charset .  'lang_' . $serendipity['lang'] . '.inc.php'); 
        @include (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php'); 
    }

    elseif ($serendipity['useTemplateLanguage']) { 
        @include (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/' . $charset .  'lang_' . $serendipity['lang'] . '.inc.php'); 
        @include (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php'); 
    }

Posted: Sat Aug 04, 2007 2:51 pm
by garvinhicking
Hi!

Hm, I'd really hate to have another IF-check in the lang.inc.php file, because it enlarges the overhead for every single page call. Instead of adding more checks there, I'd really like to remove it. Especially because the use of custom template languages is really only used in few s9y installations.

Is $serendipity['serendipityPath'] already available at this point?

For the quicksearch plugin, I instead suggest to simply use a different patch, I just committed one.

Regards,
Garvin

Posted: Sat Aug 04, 2007 3:22 pm
by stm999999999
Hm, I'd really hate to have another IF-check in the lang.inc.php file, because it enlarges the overhead for every single page call.
OK, but the we can make

Code: Select all

if ($serendipity['useTemplateLanguage'] {

  if (defined('S9Y_DATA_PATH')) { 
        @include (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/' . $charset .  'lang_' . $serendipity['lang'] . '.inc.php'); 
        @include (S9Y_DATA_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php'); 
    } 

    else  { 
        @include (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/' . $charset .  'lang_' . $serendipity['lang'] . '.inc.php'); 
        @include (S9Y_INCLUDE_PATH . 'templates/' . $serendipity['template'] . '/lang_en.inc.php'); 
    }
}
so, this is only used and expensive when someone wants to use the useTemplateLanguage-flag. Fo all other users there is no performance-change.
Instead of adding more checks there, I'd really like to remove it. Especially because the use of custom template languages is really only used in few s9y installations.
I did not this so - there are several questions for this feature to make own definitions for core- or plugin-text-definitions. Sadly this is not working all the time since the changes for the new authenticate mechanism, but it should not removed completly!
Is $serendipity['serendipityPath'] already available at this point?
I added after:

Code: Select all

if (!defined('serendipity_LANG_LOADED') || serendipity_LANG_LOADED !== true) {
    $charset = serendipity_getCharset();

echo "test";
echo $serendipity['serendipityPath'];
btw, very interesting: the output came twice (on the bottom of the page)! Why?

test
/home/path-to-my-core-installation/

it is not the place where S9Y_DATA_PATH points to.

Posted: Sat Aug 04, 2007 3:29 pm
by garvinhicking
Hi!

Fair enough, committed that. :)
btw, very interesting: the output came twice (on the bottom of the page)! Why?
s9y buffers all extra output and adds it both to the smarty output as well as pipes it through via PHP raw, that's why echos like this are shown twice.

HTH,
Garvin

Posted: Sat Aug 04, 2007 3:37 pm
by stm999999999
thanx! :D