Piwigo.org

You are not logged in. (Register / Login)

Announcement

Post a reply

Write your message and submit

Click in the dark area of the image to send your post.

Go back

Topic review (newest first)

plg
2011-12-29 10:59:47

topic:18582

rvelices
2011-01-18 11:43:54

plg wrote:

After another investigation, I noticed that the list of CSS files was correct if I purge compiled templates each time I change the $conf['local_dir_site']. If I set $conf['template_force_compile'] = true then it's OK (but it's not a solution).

I suppose the list of CSS files is in the compiled template and that the template "key" is not related to the $conf['local_dir_site'] (of course).

This it not a big deal, since I consider each site should have a distinct _data directory, once you set a distinct $conf['local_data_dir'] for each site, the problem disappears. We will have to make it obvious in the documentation.

It is normal because the local css is a smarty prefilter. A smarty prefilter is called only when compiling the template. I have asked P@t to use a prefilter so that we don't look at every page hit weather the local css file is there

plg
2011-01-18 11:26:23

rvelices wrote:

no, i didn't make those tests. to be honest i don't get exactly what you are trying to do - it seems to me you are doing more than just replace 'local' with 'local2', otherwise i don't see why it should not work

After another investigation, I noticed that the list of CSS files was correct if I purge compiled templates each time I change the $conf['local_dir_site']. If I set $conf['template_force_compile'] = true then it's OK (but it's not a solution).

I suppose the list of CSS files is in the compiled template and that the template "key" is not related to the $conf['local_dir_site'] (of course).

This it not a big deal, since I consider each site should have a distinct _data directory, once you set a distinct $conf['local_data_dir'] for each site, the problem disappears. We will have to make it obvious in the documentation.

rvelices
2011-01-18 07:00:51

plg wrote:

rvelices wrote:

it seems ok to me ...

You mean you made the test with a local/config/multisite.inc.php with the following code:

Code:

<?php
$conf['local_dir_site'] = 'local2/';
?>

and you didn't see any problem?

(and change again to local3 for example)

no, i didn't make those tests. to be honest i don't get exactly what you are trying to do - it seems to me you are doing more than just replace 'local' with 'local2', otherwise i don't see why it should not work

plg
2011-01-18 01:22:40

rvelices wrote:

it seems ok to me ...

You mean you made the test with a local/config/multisite.inc.php with the following code:

Code:

<?php
$conf['local_dir_site'] = 'local2/';
?>

and you didn't see any problem?

(and change again to local3 for example)

rvelices
2011-01-17 21:38:04

it seems ok to me ...

plg
2011-01-17 19:48:43

I've commited my current code in [Subversion] r8722

plg
2011-01-17 19:17:15

That seems to be the way for having a common local + site local, but this is not the problem. The problem is that the site with "local" as local dir should use the local/css/* files and not the local2/css/* files.

grum
2011-01-17 19:06:01

you have to keep the hard coded 'local' lines, something like :

Code:

@@ -797,13 +797,13 @@
     $css = array();
     foreach ($smarty->get_template_vars('themes') as $theme)
     {
      $flocal = 'local/css/'.$theme['id'].'-rules.css';
      $flocal_galery = PWG_LOCAL_DIR.'css/'.$theme['id'].'-rules.css';
       if (file_exists(PHPWG_ROOT_PATH.$flocal))
       {
         array_push($css, "{combine_css path='$flocal' order=10}");
       }

       if (file_exists(PHPWG_ROOT_PATH.$flocal_galery))
       {
         array_push($css, "{combine_css path='$flocal_galery' order=10}");
       }
     }
    $flocal = 'local/css/rules.css';
    $flocal_galery = PWG_LOCAL_DIR.'css/rules.css';

and you will have 2 files :
one in the local directory
another one in the LOCAL_DIR directory


the best way seems to implement a function with one paramete and called twice (with 'local' and LOCAL_DIR as parameter)

plg
2011-01-17 18:57:23

grum wrote:

I'not sure to understand... what are the expected results ?

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ cat local/combined/123abc.css | grep '^\/\*BEGIN'
/*BEGIN themes/default/theme.css */
/*BEGIN themes/default/print.css */
/*BEGIN themes/clear/theme.css */
/*BEGIN local/css/clear-rules.css */
/*BEGIN local/css/rules.css */

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ cat local2/combined/456def.css | grep '^\/\*BEGIN'
/*BEGIN themes/default/theme.css */
/*BEGIN themes/default/print.css */
/*BEGIN themes/clear/theme.css */
/*BEGIN local2/css/clear-rules.css */
/*BEGIN local2/css/rules.css */

grum
2011-01-17 18:34:50

I'not sure to understand... what are the expected results ?

plg
2011-01-17 18:04:59

I have made changes and it seems to work fine for language files, database connection settings and configuration settings, but I still have problems with CSS files.

Here are the changes I made:

Code:

$ svn diff include/constants.php include/template.class.php 
Index: include/constants.php
===================================================================
--- include/constants.php       (revision 8719)
+++ include/constants.php       (working copy)
@@ -27,6 +27,7 @@
 define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
 
 define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
+define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
 
 // Required versions
 define('REQUIRED_PHP_VERSION', '5.0.0');
Index: include/template.class.php
===================================================================
--- include/template.class.php  (revision 8719)
+++ include/template.class.php  (working copy)
@@ -797,13 +797,13 @@
     $css = array();
     foreach ($smarty->get_template_vars('themes') as $theme)
     {
-      $f = 'local/css/'.$theme['id'].'-rules.css';
+      $f = PWG_LOCAL_DIR.'css/'.$theme['id'].'-rules.css';
       if (file_exists(PHPWG_ROOT_PATH.$f))
       {
         array_push($css, "{combine_css path='$f' order=10}");
       }
     }
-    $f = 'local/css/rules.css';
+    $f = PWG_LOCAL_DIR.'css/rules.css';
     if (file_exists(PHPWG_ROOT_PATH.$f))
     {
       array_push($css, "{combine_css path='$f' order=10}");
@@ -1133,7 +1133,7 @@
 /*Allows merging of javascript and css files into a single one.*/
 final class FileCombiner
 {
-  const OUT_SUB_DIR = 'local/combined/';
+  const OUT_SUB_DIR = PWG_COMBINED_DIR;
   private $type; // js or css
   private $files = array();
   private $versions = array();

but:

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ cat local/combined/uw2xo6.css | grep '^\/\*BEGIN'
/*BEGIN themes/default/theme.css */
/*BEGIN themes/default/print.css */
/*BEGIN themes/clear/theme.css */
/*BEGIN local2/css/clear-rules.css */
/*BEGIN local2/css/rules.css */

the local combined script uses the local2 CSS files :-/

plg
2011-01-17 14:50:12

grum proposed me an interesting solution by private email and here is a summary:

Code:

if (is_file(local/config/multi.inc.php))
{
  include(local/config/multi.inc.php);
  // sets $conf['local_dir_site']
  define('PWG_LOCAL_DIR', $conf['local_dir_site']);
}
else
{
  define('PWG_LOCAL_DIR', 'local/');
}

@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php');

[...]

include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH.'local/config/config.inc.php');
if (isset($conf['local_dir_site']))
{
  @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
}

I really like this solution because the "local" directory is considered as the "common" local directory, at least for the config.inc.php file. This way you can have a common configuration for all your sites and a specific configuration for a given site. The local/config/multisite.inc.php is designed to fill the $conf['local_dir_site'] parameter. We will provide examples to fill it depending on the URL or on a web server parameter: this can be very flexible.

rvelices
2011-01-14 18:03:10

plg wrote:

would that be better? (so that we can use get_root_url().PWG_LOCAL_DIR somewhere else ?)

Yes :). It must be used when sending to the browser combined_css and combined_url in template.php . It is required to be different if we have question_mark_in_url = false

plg
2011-01-14 16:22:07

rvelices wrote:

Please no PHPWG_ROOT_PATH. It should be relative to the root ! Let the code use PHPWG_ROOT_PATH or get_root_url depending on the page ...

would that be better? (so that we can use get_root_url().PWG_LOCAL_DIR somewhere else ?)

Code:

define(
  'PWG_LOCAL_DIR',
  isset($_SERVER['PWG_LOCAL_DIR'])
    ? $_SERVER['PWG_LOCAL_DIR']
    : 'local/'
);

@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php');
[...]
include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
@include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');

Board footer

Powered by FluxBB

About this website · Donate · Contact Piwigo project © 2002-2014