Bug report: Phoca Gallery 3.1.2 - external links of images
Posted: 27 Mar 2012, 11:29
Problem: The external links of images were displayed (category view), even though no external links were given. I've dived into the scripts and ran into the following 'problems':
File: /administrator/components/com_phocagallery/models/phocagalleryimg.php (line 190+)
The code in itself doesn't "need" to be a problem. I'm not sure why you want to store any external link information when no external link ($data['extlink2link'] and $data['extlink2link']) is given, but it's not necessarily "wrong". The problem arises in the next piece:
File: /components/com_phocagallery/views/category/view.html.php (line 1502+)
The problem here is the use of isset():
if (isset($items[$iS]->extlink1[0]) && isset($items[$iS]->extlink1[1]))
... because you already FORCING those variables to always exist:
else { $data['extlink1'] = $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon']; }
You need to do one of two things: drop all external link information if no external link url is given: else { $data['extlink1'] =""} , or use !empty() either instead of isset() or along side of isset().
NOTE: The external links are used in a variety of scripts. I haven't checked the other scripts, but they are most likely facing the same problem; no external link was given, but because the variable still exists as an empty variable, it still tries to display the external links.
File: /administrator/components/com_phocagallery/models/phocagalleryimg.php (line 190+)
Code: Select all
if ($data['extlink1link'] != '') {...
} else {
$data['extlink1'] = $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon'];
}
if ($data['extlink2link'] != '') {...
} else {
$data['extlink2'] = $data['extlink2link'] . '|'.$data['extlink2title'].'|'.$data['extlink2target'].'|'.$data['extlink2icon'];
}
File: /components/com_phocagallery/views/category/view.html.php (line 1502+)
Code: Select all
$items[$iS]->displayiconextlink1 = 0;
if (isset($items[$iS]->extlink1)) {
$items[$iS]->extlink1 = explode("|", $items[$iS]->extlink1, 4);
if (isset($items[$iS]->extlink1[0]) && isset($items[$iS]->extlink1[1])) {
...
}
} else {
$items[$iS]->displayiconextlink1 = 0;
}
}
$items[$iS]->displayiconextlink2 = 0;
if (isset($items[$iS]->extlink2)) {
$items[$iS]->extlink2 = explode("|", $items[$iS]->extlink2, 4);
if (isset($items[$iS]->extlink2[0]) && isset($items[$iS]->extlink2[1])) {
...
}else {
$items[$iS]->extlink2[4] = $items[$iS]->extlink2[1];
$items[$iS]->extlink2[5] = 'style="text-decoration:underline"';
}
} else {
$items[$iS]->displayiconextlink2 = 0;
}
}
if (isset($items[$iS]->extlink1[0]) && isset($items[$iS]->extlink1[1]))
... because you already FORCING those variables to always exist:
else { $data['extlink1'] = $data['extlink1link'] . '|'.$data['extlink1title'].'|'.$data['extlink1target'].'|'.$data['extlink1icon']; }
You need to do one of two things: drop all external link information if no external link url is given: else { $data['extlink1'] =""} , or use !empty() either instead of isset() or along side of isset().
NOTE: The external links are used in a variety of scripts. I haven't checked the other scripts, but they are most likely facing the same problem; no external link was given, but because the variable still exists as an empty variable, it still tries to display the external links.