Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues
Author Message
zeromechanic
Hangin' Around



Joined: Dec 15, 2005
Posts: 40
Location: Netherlands

PostPosted: Tue Oct 28, 2008 3:43 pm Reply with quote

Hello there,

I encounterd an issue with RN2.30

When I upgraded to the latest version of RN and NukedGallery the layout of the gallery was messed up due to not loading the gallery css files.

At nukedgallery they pointed me to the index.php of NG that led me to this "solution":

In the index.php of the NG they use the following to include the css into the header with a fopen of the header.php of RN:

Code:


........
$header .= $line;
            if (strstr($line, "<head")) {
                foreach($css as $stylesheet) {
                    $links = $stylesheet;
                    $links = str_replace('"', '\"', $links);
                    $header .= 'echo "' . $links. '\n";' . "\n";
                }
                foreach($javascript as $script) {
                    $scriptline = $script;
                    $scriptline = str_replace('"','\"',$scriptline);
                    $header .= 'echo "' . $scriptline. '\n";'."\n";
                }


So it searchs for <head in header.php
After comparing the RN2.20 header.php with the RN2.30 version, the "problem" is with the if statement to the mimetype.php,and this file excist in RN2.30 jumping to the <head in that file and skipping the one in the header.php

after renaming the mimetype.php forcing the statement to false, the NG css files are loaded, and the NG theme is displayed properly.

can the mimetype.php be missed, or do you advise another solution to this.

grtz ZeroMechanic
 
View user's profile Send private message
999
Regular
Regular



Joined: Sep 12, 2006
Posts: 58
Location: Dsm, IA

PostPosted: Tue Oct 28, 2008 4:25 pm Reply with quote

Had the same issue. It looks like it loads both the css and js specific to that theme. All I did was grab the css file from the gallery2 theme I used, name it the same as the theme. In this case I use carbon, so carbon.css. Copied it into my site's theme/style folder, and added
Code:
define ('RN_MODULE_CSS','carbon.css');
above
Code:
function g2_message($mess) {

    global $admin, $bgcolor2, $module_name, $admin_file;
    include ("header.php");
to the top of the ng index.php.

Fixes the theme issue however js can't be included that way.
 
View user's profile Send private message Visit poster's website MSN Messenger
zeromechanic







PostPosted: Tue Oct 28, 2008 4:47 pm Reply with quote

Did almost the same thing, defining an own in header.php with the path to the css (i use the standard matrix)
It showed the theme,but in the plugin admin, the images where not showing, and it was not possible to upgrade somethings, links missing

The way i did it, it seems that the javascript is loaded.
And the images and so are displayed etc.
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Oct 28, 2008 6:23 pm Reply with quote

zeromechanic wrote:
can the mimetype.php be missed, or do you advise another solution to this.


If by "missed" you mean comment it out then the answer is no. The mimetype file automatically sets the correct <!DOCTYPE> and some other settings that are needed for (X)HTML compliance as well as some <meta> information. It is a core file and is needed. Actually that logic in NG is ill conceived as it is written (as you found out) to expect the <head> section (header.php) to always look the same.

If it were me I would modify that routine to something like the following. Since I am not able to see the entire block of logic you will/may need to shift my suggested code around.
Code:
if (!isset($headTagFound)) $headTagFound = false; //Initialize $headTagFound variable

$header .= $line;
            if (strstr($line, "<head") && $headTagFound==false) {
                $headTagFound = true; // Allows only 1 occurrence of <head
                foreach($css as $stylesheet) {
                    $links = $stylesheet;
                    $links = str_replace('"', '\"', $links);
                    $header .= 'echo "' . $links. '\n";' . "\n";
                }
                foreach($javascript as $script) {
                    $scriptline = $script;
                    $scriptline = str_replace('"','\"',$scriptline);
                    $header .= 'echo "' . $scriptline. '\n";'."\n";
                }
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Tue Oct 28, 2008 6:25 pm Reply with quote

Well, I definitely do not like the way NukedGallery has done this. Maybe we need to also add a RN_MODULE_JS... actually, NukedGallery should add that at the end anyways rather than in the header (makes for faster site loading)... but, I have no idea what the impact of that would be on Gallery2.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Wed Oct 29, 2008 12:35 pm Reply with quote

They are looking at the issue over on NukedGallery. I posted a link to this discussion over there and gave them some information about how to detect RN2.30 (and above).

Zeromechanic and 999 ... thanks. I was having similar issues but wasn't able to trace it down as well as you did. It would be best if we could get the NukedGallery folks to come up with a solution that works while preserving mimetype.php as is.

I've had periodic issues with the slideshow in embedded mode but the one problem I always see if that if I go into embedded site admin and bring up the themes screen the drop down boxes don't populate. On my test system I tried zero's solution of renaming mimetype.php and the problem went away. But of course that is not really what we need, as Raven explained. So I passed that all on to NukedGallery.
 
View user's profile Send private message Visit poster's website
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Thu Nov 06, 2008 8:05 pm Reply with quote

After reading here and reading at NukedGallery....all I can say...is we have "Issues"!.

I know alot of the folks on the dev team on RN are more into Code and such....but there is a HUGH following between Nuke and Gallery. This issue needs a "Proper" resolution. I myself live and die by Gallery. It is the 1/2 the bread and 1/2 the butter of my sites.

I have a development site up and running. I can have Gallery on it in no time flat. If anyone (Cough Cough...Dev Team) would like access to it. Shoot me a PM and I will open her up for you.

(Makes Cup of Coffee)

It is going to be a long night!~

Dawg
 
View user's profile Send private message
fkelly







PostPosted: Thu Nov 06, 2008 9:51 pm Reply with quote

I feel for your pain Dawg. I have a test site at fkelly.org that people can use for testing this too and I've spent a little time trying to figure out the issues. I have also posted the latest RN 2.30 code over there at NukedGallery for them to look at. Unfortunately it looks to me like there is one person who works on this and that is hit or miss with his other responsibilities. And unless you know some Gallery internals it is really hard to diagnose this stuff.

Maybe you could post exactly which issues you are seeing. The ones that I can reproduce are that you can't see any theme drop down boxes when you are in site admin and go to administer themes. Also the slideshow doesn't work most of the time in embedded mode. Both of these functions seem to work in non-embedded mode leading me to think that it is an integration issue ... as some of the code fragments posted earlier in this thread also indicate.
 
sixf00t4
Regular
Regular



Joined: Nov 05, 2006
Posts: 96

PostPosted: Wed Nov 12, 2008 8:56 pm Reply with quote

same problem here, and same situation as Dawg.

_________________
blog - music - video 
View user's profile Send private message Visit poster's website AIM Address
fkelly







PostPosted: Thu Nov 13, 2008 12:51 pm Reply with quote

I wasted about 2 hours so far today hacking at this. The problem is with the way the NukedGallery index.php approaches loading css and js files in the header when Gallery is loaded. Just as background, I believe different albums can use different themes so I'm not sure that an approach that defines one RN_MODULE_CSS will work. In addition some of the themes have javascript files in them and others don't. And at least one theme (Gallery theme that is) has more than one JS file. So I don't think M's solution of defining a RN_MODULE_JS is going to work.

What the NukedGallery index.php does is read in, through the file system, the contents of header.php and then parse it. It removes the beginning and ending php tags and does a few other parsing tasks. It looks for <head and then it uses built in Gallery functions to include all the CSS and Javascript files for the currently operative Gallery theme. Since we moved the head tag to mimetype.php in RN 2.30 this approach won't work.

I tried something like this:

Code:
    $to_open = '';

    if (file_exists('includes/mimetype.php')) {
       $to_open = 'includes/mimetype.php';
   }
    elseif (file_exists('../includes/mimetype.php')) {
       $to_open = '../includes/mimetype.php';
      }
   echo 'to_open ' . $to_open . '<br />';
    if ($fd = fopen('header.php', 'r')) {
        while (!feof($fd)) {
            $line = fgets($fd, 1024);
            $line = str_replace('<?php', '', $line);
            if (strstr($line, '/includes/mimetype.php')) {
               if (!empty($to_open)) {
                  if ($fd2 = fopen($to_open, 'r')) {
                     while (!feof($fd2)) {
                        $line = fgets($fd2, 1024);
                          $line = str_replace('<?php', '', $line);
                        $line = str_replace(' ?>', '', $line);

                        $header .= $line;
                           if (strstr($line, "<head")) {
                               foreach($css as $stylesheet) {
                                $links = $stylesheet;
                                $links = str_replace('"', '\"', $links);
                                $header .= 'echo "' . $links. '\n";' . "\n";
                            }
                            foreach($javascript as $script) {
                                $scriptline = $script;
                                $scriptline = str_replace('"','\"',$scriptline);
                                $header .= 'echo "' . $scriptline. '\n";'."\n";
                            }
                        }
                                                echo $line;
                  }
               }
            }
         }
            $line = str_replace(' ?>', '', $line);
         $line = preg_replace('/(@?)include\("includes\/javascript.php"\)\;/','',$line);
         if(defined('NUKE_EVO')) {
                $evo_version = explode('.',NUKE_EVO);
                if(intval($evo_version[0]) >= 1) {
                    $line = str_replace("require_once(dirname(__FILE__).'/mainfile.php');","require_once('mainfile.php');",$line);
                }
            }
            $header .= $line;
            if (strstr($line, "<head")) {
                foreach($css as $stylesheet) {
                    $links = $stylesheet;
                    $links = str_replace('"', '\"', $links);
                    $header .= 'echo "' . $links. '\n";' . "\n";
                }
                foreach($javascript as $script) {
                    $scriptline = $script;
                    $scriptline = str_replace('"','\"',$scriptline);
                    $header .= 'echo "' . $scriptline. '\n";'."\n";
                }
            }
        }
    }


Basically my thought was to extend the parsing to the mimetype.php file at the point in header.php where mimetype is included. This approach would only be operative where the mimetype file exists and we'd include the css and js files for the Gallery theme right after the header statement.

Unfortunately it looks like I'm doing something that won't work. I can parse right down to
Code:
<?php } else if (DOCTYPE == "math") { ?>

at line 109 in mimetype and then it just dies. The doctypes don't come out nor does the header and I don't go back to parsing the header.php file after that. Maybe it's something minor. I'll look again later.

Actually though the whole approach of parsing header.php and mimetype.php looks like a seriously blown approach to me. We ought to find a way to build the integration right into header.php so the proper css and js files can get included there ... but that would require RN to know more about Gallery than it currently does. But if we could do that then all the index.php of Gallery would need to do is include header.php like any other module does. Probably that section of code in header should only be executed if Gallery is installed and activated.

I'll keep looking but anyone who wants to contribute is welcome to do so.
 
fkelly







PostPosted: Fri Nov 14, 2008 4:00 pm Reply with quote

Okay, I think I have this problem fixed or at least have gone a long way towards it. The whole idea of parsing header.php (and then embedding a parse of mimetype.php inside that for 2.3) struck me as nuts but it took a lot of experimenting to figure an alternative. I know that at NukedGallery they may have wanted to do the integration without touching any Nuke code (such as in header.php) but the result is a much more complicated and unreliable program. So here is what I recommend ... I'll describe it first then post the code.

First, Gallery knows which css and js files go along with each theme. This data is in a variable called g2moddata['headHtml']. Note that if you want to echo it you will need to htmlentity it first. "echo htmlentities(g2moddata['headHtml] for instance.

The two foreach loops in the gallery integration index.php essentially pull out the css and js files needed for the header into stylesheet and js links that header.php can access.

So what I did is create a new variable called $rn_header that is filled in the index.php and then modify header.php from the RN 2.3 distribution to link to these whenever the $rn_header is set.

Here is the code for index.php:

Code:
    if (isset($g2moddata['headHtml'])) {    

            list($title, $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
    }
    if($title != "") {
        $pagetitle = "&raquo; ".trim($title);
    }
    $rn_header = '';
    foreach($css as $key => $value) {
          $links = $value;
 //         $links = str_replace('"', '\"', $links);
          $rn_header .= $links. "\n";

     }
     foreach($javascript as $script) {
          $scriptline = $script;
//          $scriptline = str_replace('"','\"',$scriptline);
          $rn_header.= $scriptline. "\n";
    }
    // show error message if isDone is not defined
    if (!isset($g2moddata['isDone'])) {
        echo 'isDone is not defined, something very bad must have happened.';
        exit;
    }

    // die if it was a binary data (image) request
    if ($g2moddata['isDone']) {
        exit; // uploads module does this too
    }

    // Main G2 error message

    if ($ret) {
        echo $ret->getAsHtml();
    }

    $g2bodyHtml = $updateCheck;
    $g2bodyHtml .= $g2moddata['bodyHtml'];
}
include('header.php');


Note that header.php can now be included instead of eval'ng (ughhh) a long variable that's constructed by parsing header.php. The foreach loops for the stylesheets and js also don't need to do the string replaces, in fact I'm fairly sure they screw things up.

Now once you've done that you need to fix up header.php. Go into the head function and globalize $rn_header. The add a conditional access to the gallery stylesheets and js files. I'll try to bold the changes below.

Code:
function head() {

   global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle,$rn_header;
   $ThemeSel = get_theme();
   // Meta tags cannot be used because they are resolved after the headers are sent - Mantis issue 0000925
   // This will allow everything to function as it has been which is acceptable and still allows for future enhancements
   if (file_exists('includes/mimetype.php')) include('includes/mimetype.php');
   elseif (file_exists('../includes/mimetype.php')) include('../includes/mimetype.php');
   else {
      header('Content-Type: ' . _MIME . ';charset=' . _CHARSET);
      header('Vary: Accept');
      /***echo '<?xml version="1.0" encoding="' . _MIME . '"?>';***/
      echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
      echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en">', "\n";
      echo '<head>', "\n";
   }
   include_once 'themes/' . $ThemeSel . '/theme.php';
   // Tolerant baseURL Hack - VinDSL (Lenon.com)
   global $name;
   $base_url = $_SERVER['HTTP_HOST'];
   //echo '<base href="http://' . $base_url . '/" />';
   // Tolerant baseURL Hack - VinDSL (Lenon.com)
   //If Dynamic Titles are turned on, use them, otherwise, use default PHP-Nuke page titles
   global $useDynamicTitles;
   if (isset($useDynamicTitles) && $useDynamicTitles && file_exists(INCLUDE_PATH . 'includes/dynamic_titles.php')) {
      include_once INCLUDE_PATH . 'includes/dynamic_titles.php';
   } else {
      echo '<title>', $sitename, ' ', $pagetitle, '</title>', "\n";
   }
   //End of Dynamic Titles changes
   include_once 'includes/meta.php';
   include_once 'includes/javascript.php';
   if (isset($rn_header)) {
      echo "\n". ($rn_header);
   }
   if (file_exists('themes/' . $ThemeSel . '/images/favicon.ico')) {
      echo '<link rel="shortcut icon" href="themes/', $ThemeSel, '/images/favicon.ico" type="image/x-icon" />', "\n";
   }
   echo '<link rel="StyleSheet" href="themes/ravennuke.css" type="text/css" />', "\n";
   echo '<link rel="StyleSheet" href="themes/', $ThemeSel, '/style/style.css" type="text/css" />', "\n";
   //


I didn't quote the code for the whole function. Nor did I test on anything other than Ravennuke 2.3. I suspect this would work on a range of RN's and also some other Gallery releases (I'm using 2.4).

This seems to fix a range of problems. For instance I get the themes drop down boxes in site administration. And slide shows (not the full screen ones but the embedded ones) seem to work. On my sites I have a recent hack I published that only shows the G2Sidebar when Gallery is the active theme working too.

If you are going to try this (a) you should have some familiarity with PHP coding and (b) you should back your existing files up. I welcome feedback. I'm not the brightest light on the xmas tree with regard to PHP coding and will also welcome suggestions on making the code more reliable or efficient. However it has to be a big improvement over the standard integration index.php.


Last edited by fkelly on Fri Nov 14, 2008 6:34 pm; edited 1 time in total 
999







PostPosted: Fri Nov 14, 2008 4:37 pm Reply with quote

From what I can tell, that fixed it. Nicely done. May want to remove the bold tags so some don't leave them in by accident.
 
fkelly







PostPosted: Fri Nov 14, 2008 6:38 pm Reply with quote

Thanks 999, I just edited the post to remove the bold tags. They don't work within a code block anyway.

I'm not sure this is a 100% solution; I saw some weirdness when I had an album with one Gallery theme being accessed in the sidebar and a different theme operative on the main Gallery page. I think it is a step in the right direction and all my instincts tell me it is much more efficient (and reliable) than parsing header.php.
 
montego







PostPosted: Sat Nov 15, 2008 7:00 am Reply with quote

Once you feel really comfortable that this is a "proper" fix, I would suggest making a Sticky out of the final code changes.

This is great work Fkelly! Thanks!
 
fkelly







PostPosted: Sat Nov 15, 2008 7:11 am Reply with quote

Thanks M. I am testing it on one other site now ... seems to work. Then I have one more site to do and then I want to upgrade all the sites to the latest Gallery release (assuming that works on my test site) and then we'll be ready to go and I'll sticky-ize it.

Should we consider the code change to header.php as part of the distribution for 2.3.01 or 2.4? It is one more if statement that will be evaluated and be true only when the variable $rn_header is set so there should be minimal effect on non-Gallery users. The Gallery index.php people will still have to get on their own unless NukedGallery decides to integrate using my approach ... and that would be difficult for them I think because every distributions header.php would have to be modified. It could get like the code change instructions in the Patch series.
 
Raven







PostPosted: Sat Nov 15, 2008 9:55 am Reply with quote

Frank,

Let's leave this for 2.4. Once this thread is complete, please summarize it in a new thread to either the Quick Fixes forum: [ Only registered users can see links on this board! Get registered or login! ]
or the Converting/Creating Other forum: [ Only registered users can see links on this board! Get registered or login! ] In fact, you could actually place it in one and then shadow it in the other if you wanted Wink
 
sixf00t4







PostPosted: Sat Nov 15, 2008 11:16 am Reply with quote

excellent. Seems to be working fine with my 2.3 RN and gallery 2.2 installation. one problem, which seems to be with the ravenice theme is that the gallery text links are very small and hard to read, so something with the font size in the CSS I would assume... I'll upgrade to gallery 2.3 and see what happens.
 
fkelly







PostPosted: Sat Nov 15, 2008 12:19 pm Reply with quote

Yeah, sixf00t4, I have been wondering about CSS styles "stepping" on each other. Using the Gallery Sidebar I found that if the random image it was loading was from an album that had a theme besides your default theme (talking Gallery themes here) it (the sidebar) would load the css file for that theme. And since this was in a block on the left side of the screen this css file would be loaded after the one in the header and thus any styles with the same name would get overwritten. I'm thinking then that when the home page of Gallery loads it could be using a mix of styles ... the ones from the sidebar would be loaded last and take precedence (right?) and then any styles from the default theme that were not overwritten would still be in effect. I'm also thinking that the same thing could be true with Ravenice styles. I haven't traced this all the way through to verify that this is what's happening but without some naming conventions to keep styles separate it is very likely.
 
fkelly







PostPosted: Sat Nov 15, 2008 12:51 pm Reply with quote

Just upgraded to 2.3 of Gallery. The slideshow feature is TOO COOL. Note that the upgrade will overwrite your /gallery2/index.php with gallery's so you will need to recopy that back up.
 
sixf00t4







PostPosted: Sat Nov 15, 2008 2:59 pm Reply with quote

fkelly wrote:
Just upgraded to 2.3 of Gallery. The slideshow feature is TOO COOL. Note that the upgrade will overwrite your /gallery2/index.php with gallery's so you will need to recopy that back up.

haha, the fact that you took the time to say it, makes me wonder if you struggled for an hour trying to figure out what broke before you realized. Laughing
 
fkelly







PostPosted: Sun Nov 16, 2008 9:04 am Reply with quote

More like 20 minutes sitting there puzzled. Still I did three sites in less than an hour. The Gallery installation program is very sweet.

And Raven, I tried posting in the fixes area but it doesn't recognize me as a moderator. I'm in no rush but if you can look at it sometime that would be good.
 
Raven







PostPosted: Sun Nov 16, 2008 9:21 am Reply with quote

Sorry about that Wink. You weren't singled out. I hadn't added the Moderator group to the forum. Should be fixed!
 
Dawg







PostPosted: Thu Nov 20, 2008 7:56 am Reply with quote

Even after the upgrade I am still lossing the Themes dropdown. I have not looked as to why....but it is not populating. Not a problem for me....just wanted to let you know.

Dawg
 
fkelly







PostPosted: Thu Nov 20, 2008 9:38 am Reply with quote

Take a look at view source at what css and js files are getting loaded. Also, do you have the G2 Sidebar block loading? I think that there can be a problem if the album that's loading in the sidebar uses a different theme than the default album. Because the sidebar loads after header.php I think you can get a different css file overwriting the one that should be on the main page. I haven't had time to confirm this nor to see if that's what's causing the problem but it is something to look at.

And, just to put the reminder in this thread: please make sure you have the latest version of the fixes from:

http://www.ravenphpscripts.com/posts16683-highlight-.html

These were posted November 19 and affect the security of header.php so it is important to have them. A full version of header.php and index.php for RN 2.3 is posted there.
 
fkelly







PostPosted: Thu Nov 20, 2008 11:55 am Reply with quote

Just did some more testing. I don't know if this is what's causing your problems, but if you make your default theme in Gallery be different from the one that most albums use, it definitely fouls up when used in conjunction with the G2Sidebar block. Most of my albums were using the Matrix theme and when I just, for testing purposes, turned the default theme to Siriux the G2 Sidebar gave an error message and the main admin (site admin) within Gallery was fouled up.

I don't have the time or motivation to start trying to fix the G2 Sidebar or keep it from interfering with the rest of the screens. Best to just use one theme if you ask me.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.3 RN Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©