xoops forums

Anonymous

Posted on: 2009/12/2 16:19
Anonymous
Anonymous (Show more)
Posts: 0
Since:
#1

xoops 2.4.2 and SmartSection 2.13

Guys,

Something has changed in XOOPS 2.4.2 compared to 2.3.3 to cause a problem with files linked to SmartSection 2.13 articles.

See this page on my site as an example. As you can see, the first linked file is fubar; it displays normally on my 2.3.3 test site on the same server.

The template (smartsection_item.html) code that displays the linked files is this:

<!-- BEGIN DYNAMIC BLOCK -->
      <{foreach 
item=file from=$item.files}>
      <
tr>
         <
td valign="middle" class="odd" align="left">
        <
a href="<{$xoops_url}>/modules/smartsection/visit.php?fileid=<{$file.fileid}>" target="_blank"><img src="<{$smartsection_url}>images/icon/file.gif" title="<{$lang_download_file}>" alt="<{$lang_download_file}>"/>&nbsp;<b><{$file.name}></b></a>
        <
div><{$file.description}></div >
         <
td valign="middle" class="odd" align="center"><{$file.datesub}></td>
         <
td valign="middle" class="odd" align="center"><{$file.hits}></td>
     </
tr>
      <{/foreach}>
    <!-- 
END DYNAMIC BLOCK -->


visit.php, the file references above is:

<?php
/**
* $Id: visit.php,v 1.2 2005/08/29 17:17:37 malanciault Exp $
* Module: SmartSection
* Author: marcan <marcan@notrevie.ca>
* Licence: GNU
*/

include_once "header.php";

$fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : 0;

// Creating the item object for the selected item
$fileObj $smartsection_file_handler->get($fileid);
$fileObj->updateCounter();

if (!
preg_match("/^ed2k*:///i"$fileObj->getFileUrl())) {
    
Header("Location: " $fileObj->getFileUrl());
}

echo 
"<html><head><meta http-equiv="Refresh" content="0URL=".$myts->oopsHtmlSpecialChars($fileObj->getFileUrl()).""></meta></head><body></body></html>";
exit();
?>


The php code (from item.php) is this, I think:

// Creating the files object associated with this item
$filesObj $itemObj->getFiles();

$files = array();
$embeded_files = array();

foreach(
$filesObj as $fileObj)
{
    if (
$fileObj->mimetype() == 'application/x-shockwave-flash') {
        
$file['content'] = $fileObj->displayFlash();

        if (
strpos($item['maintext'], '[flash-' $fileObj->getVar('fileid') . ']')) {
            
$item['maintext'] = str_replace('[flash-' $fileObj->getVar('fileid') . ']'$file['content'], $item['maintext']);
        } else {
            
$embeded_files[] = $file;
        }
        unset(
$file);
    } else {
        
$file['fileid'] = $fileObj->fileid();
        
$file['name'] = $fileObj->name();
        
$file['description'] = $fileObj->description();
        
$file['name'] = $fileObj->name();
        
$file['type'] = $fileObj->mimetype();
        
$file['datesub'] = $fileObj->datesub();
        
$file['hits'] = $fileObj->counter();
        
$files[] = $file;
        unset(
$file);
    }

}
$item['files'] = $files;
$item['embeded_files'] = $embeded_files;


And before anyone asks, the database is correct; the files are referenced as they should be and adding a new file to the article causes the fubar one to display correctly.

Ideas?

trabis

Core Developer
Posted on: 2009/12/2 20:23
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#2

Re: xoops 2.4.2 and SmartSection 2.13

HI, in item.php use this:
$file = array(); // add this
$files = array();
$embeded_files = array();


Diference is in 2.4 is in include/common.php:
if ($xoopsModule->getVar('dirname''n') != 'system') {
        if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/' $xoopsConfig['language'] . '/main.php'))) {
            include_once 
$file;
        } else if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/english/main.php'))) {
            include_once 
$file;
        }
    }


We should use unset($file) on next XOOPS version. It would be wiser than ask module developers to prefix variables and make sure they are not global, lol. I would classify this as core bug yes.

OK, so forget what I said. Open include/common.php and add this:
if ($xoopsModule->getVar('dirname''n') != 'system') {
        if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/' $xoopsConfig['language'] . '/main.php'))) {
            include_once 
$file;
        } else if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/english/main.php'))) {
            include_once 
$file;
        }
    }
    unset(
$file); //add this

Anonymous

Posted on: 2009/12/2 20:37
Anonymous
Anonymous (Show more)
Posts: 0
Since:
#3

Re: xoops 2.4.2 and SmartSection 2.13

Thanks buddy - that's sorted it

PS: I understand why, too..... never too old to learn

Yurdal

Friend of XOOPS
Posted on: 2009/12/3 9:08
Yurdal
Yurdal (Show more)
Friend of XOOPS
Posts: 364
Since: 2005/3/27
#4

Re: xoops 2.4.2 and SmartSection 2.13

Is this problem also persist in 2.14 version ?

Anonymous

Posted on: 2009/12/3 9:14
Anonymous
Anonymous (Show more)
Posts: 0
Since:
#5

Re: xoops 2.4.2 and SmartSection 2.13

Quote:
Yurdal wrote:
Is this problem also persist in 2.14 version ?


I don't know; I didn't upgrade to 2.14 because this requires the installation of the SmartObjects framework and I was reluctant to install another framework just for one module.

However, I suspect that the problem will exist because, as trabis said, it is a "core" bug rather than a problem with the module.

It may be that other modules will be affected too? If you have problems then try trabis's solution (the include/common.php one) first.

HTH

allnewtome

Not too shy to talk
Posted on: 2009/12/24 4:18
allnewtome
allnewtome (Show more)
Not too shy to talk
Posts: 175
Since: 2005/11/30
#6

Re: xoops 2.4.2 and SmartSection 2.13 [and 2.14]

Yes, it did cause the same problem with Smartsection 2.14 and trabis's solution (adding a line to item.php) does solve it.

Thank you very much for raising this issue.

I've taken the liberty of marking this thread "solved"!