Skip to content

Commit

Permalink
Fixes #4890 - Quick fix for PHP8 undefined constant error.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Oct 19, 2022
1 parent ae6c117 commit c41d2f4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 24 deletions.
34 changes: 21 additions & 13 deletions e107_handlers/search/comments_download.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,33 @@
*
*/

if (!defined('e107_INIT')) { exit; }
if(!defined('e107_INIT'))
{
exit;
}

//TODO Rework to v2 standards into e107_plugins/download/e_search.php

$comments_title = LAN_PLUGIN_DOWNLOAD_NAME;
$comments_title = defset('LAN_PLUGIN_DOWNLOAD_NAME');
$comments_type_id = '2';
$comments_return['download'] = "d.download_id, d.download_name";
$comments_table['download'] = "LEFT JOIN #download AS d ON c.comment_type=2 AND d.download_id = c.comment_item_id";
/**
* @param $row
* @return array
*/
function com_search_2($row) {
global $con;
$datestamp = $con -> convert_date($row['comment_datestamp'], "long");
$res['link'] = "download.php?view.".$row['download_id'];
$res['pre_title'] = $row['download_name'] ? LAN_SEARCH_70.": " : "";
$res['title'] = $row['download_name'] ? $row['download_name'] : LAN_SEARCH_9;

/**
* @param $row
* @return array
*/
function com_search_2($row)
{

$datestamp = e107::getParser()->toDate($row['comment_datestamp'], "long");
$res['link'] = "download.php?view." . $row['download_id'];
$res['pre_title'] = !empty($row['download_name']) ? defset('LAN_SEARCH_70') . ": " : "";
$res['title'] = !empty($row['download_name']) ? $row['download_name'] : defset('LAN_SEARCH_9');
$res['summary'] = $row['comment_comment'];
preg_match("/([0-9]+)\.(.*)/", $row['comment_author'], $user);
$res['detail'] = LAN_SEARCH_7."<a href='user.php?id.".$user[1]."'>".$user[2]."</a>".LAN_SEARCH_8.$datestamp;
$res['detail'] = defset('LAN_SEARCH_7') . "<a href='user.php?id." . $user[1] . "'>" . $user[2] . "</a>" . defset('LAN_SEARCH_8') . $datestamp;

return $res;
}

10 changes: 6 additions & 4 deletions e107_handlers/search/comments_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

if (!defined('e107_INIT')) { exit; }

$comments_title = ADLAN_0;
//TODO Rework to v2 standards into e107_plugins/news/e_search.php

$comments_title = defset('ADLAN_0');
$comments_type_id = 0;
$comments_return['news'] = "n.news_title";
$comments_table['news'] = "LEFT JOIN #news AS n ON c.comment_type=0 AND n.news_id = c.comment_item_id";
Expand All @@ -22,11 +24,11 @@ function com_search_0($row) {
global $con;
$datestamp = $con -> convert_date($row['comment_datestamp'], "long");
$res['link'] = "comment.php?comment.news.".$row['comment_item_id'];
$res['pre_title'] = $row['news_title'] ? LAN_SEARCH_71.": " : "";
$res['title'] = $row['news_title'] ? $row['news_title'] : LAN_SEARCH_9;
$res['pre_title'] = $row['news_title'] ? defset('LAN_SEARCH_71').": " : "";
$res['title'] = $row['news_title'] ? $row['news_title'] : defset('LAN_SEARCH_9');
$res['summary'] = $row['comment_comment'];
preg_match("/([0-9]+)\.(.*)/", $row['comment_author'], $user);
$res['detail'] = LAN_SEARCH_7."<a href='user.php?id.".$user[1]."'>".$user[2]."</a>".LAN_SEARCH_8.$datestamp;
$res['detail'] = defset('LAN_SEARCH_7')."<a href='user.php?id.".$user[1]."'>".$user[2]."</a>".defset('LAN_SEARCH_8').$datestamp;
return $res;
}

32 changes: 25 additions & 7 deletions e107_handlers/search/search_comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

if (!defined('e107_INIT')) { exit; }

// TODO Rework all of this to v2 standards while maintaining BC.

// advanced
$advanced_where = "";
if (isset($_GET['type']) && $_GET['type'] != 'all') {
Expand All @@ -33,16 +35,32 @@
//basic
$return_fields = 'c.comment_item_id, c.comment_author_id, comment_author_name, c.comment_datestamp, c.comment_comment, c.comment_type';

foreach ($search_prefs['comments_handlers'] as $h_key => $value) {
if (check_class($value['class'])) {
$path = ($value['dir'] == 'core') ? e_HANDLER.'search/comments_'.$h_key.'.php' : e_PLUGIN.$value['dir'].'/search/search_comments.php';
if (is_readable($path)) {
foreach($search_prefs['comments_handlers'] as $h_key => $value)
{
if(check_class($value['class']))
{
if($value['dir'] == 'core')
{
$path = e_HANDLER . 'search/comments_' . $h_key . '.php';
}
else
{
if(!e107::isInstalled($value['dir']))
{
continue;
}

$path = e_PLUGIN . $value['dir'] . '/search/search_comments.php';
}
$path = ($value['dir'] == 'core') ? e_HANDLER . 'search/comments_' . $h_key . '.php' : e_PLUGIN . $value['dir'] . '/search/search_comments.php';
if(is_readable($path)) // TODO Rework this to use e_search.php
{
require_once($path);
$in[] = "'".$value['id']."'";
$in[] = "'" . $value['id'] . "'";
$join[] = $comments_table[$h_key];
$return_fields .= ', '.$comments_return[$h_key];
$return_fields .= ', ' . $comments_return[$h_key];
}

}
}

Expand Down

0 comments on commit c41d2f4

Please sign in to comment.