wrong use of S9Y_INCLUDE_PATH!?

Discussion corner for Developers of Serendipity.
Post Reply
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

wrong use of S9Y_INCLUDE_PATH!?

Post 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!
Last edited by stm999999999 on Wed Aug 01, 2007 1:57 am, edited 1 time in total.
Ciao, Stephan
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post 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.
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post 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'); 
    }
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post 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.
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

thanx! :D
Ciao, Stephan
Post Reply