mirror of
https://github.com/e107inc/e107.git
synced 2025-08-15 11:04:18 +02:00
Plugin script tests and PHP8 fixes.
This commit is contained in:
@@ -8,147 +8,160 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(__DIR__.'/../../class2.php');
|
||||
if (!e107::isInstalled('poll'))
|
||||
require_once(__DIR__ . '/../../class2.php');
|
||||
if(!e107::isInstalled('poll'))
|
||||
{
|
||||
e107::redirect();
|
||||
exit;
|
||||
}
|
||||
require_once(HEADERF);
|
||||
require_once(e_HANDLER."comment_class.php");
|
||||
$cobj = new comment;
|
||||
|
||||
if(!defined("USER_WIDTH") && !deftrue('BOOTSTRAP'))
|
||||
|
||||
if(!defined("USER_WIDTH"))
|
||||
{
|
||||
define("USER_WIDTH","width:95%");
|
||||
define("USER_WIDTH", "width:95%");
|
||||
}
|
||||
|
||||
e107::includeLan(e_PLUGIN."poll/languages/".e_LANGUAGE.".php");
|
||||
e107::plugLan('poll', null);
|
||||
|
||||
if(e_QUERY)
|
||||
|
||||
class oldpolls_front
|
||||
{
|
||||
|
||||
require_once('poll_class.php');
|
||||
|
||||
$query = "SELECT p.*, u.user_id, u.user_name FROM #polls AS p
|
||||
LEFT JOIN #user AS u ON p.poll_admin_id = u.user_id
|
||||
WHERE p.poll_type=1 AND p.poll_id=".intval(e_QUERY);
|
||||
|
||||
if($sql->gen($query))
|
||||
public static function init()
|
||||
{
|
||||
$pl = new poll;
|
||||
$row = $sql ->fetch();
|
||||
|
||||
$start_datestamp = $tp->toDate($row['poll_datestamp'], "long");
|
||||
$end_datestamp = $tp->toDate($row['poll_end_datestamp'], "long");
|
||||
$uparams = array('id' => $row['user_id'], 'name' => $row['user_name']);
|
||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
||||
$userlink = "<a href='".$link."'>".$row['user_name']."</a>";
|
||||
$ns = e107::getRender();
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
|
||||
if(e_QUERY)
|
||||
{
|
||||
|
||||
require_once('poll_class.php');
|
||||
|
||||
$query = "SELECT p.*, u.user_id, u.user_name FROM #polls AS p
|
||||
LEFT JOIN #user AS u ON p.poll_admin_id = u.user_id
|
||||
WHERE p.poll_type=1 AND p.poll_id=" . intval(e_QUERY);
|
||||
|
||||
if($sql->gen($query))
|
||||
{
|
||||
$pl = new poll;
|
||||
$row = $sql->fetch();
|
||||
|
||||
$start_datestamp = $tp->toDate($row['poll_datestamp'], "long");
|
||||
$end_datestamp = $tp->toDate($row['poll_end_datestamp'], "long");
|
||||
$uparams = array('id' => $row['user_id'], 'name' => $row['user_name']);
|
||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
||||
$userlink = "<a href='" . $link . "'>" . $row['user_name'] . "</a>";
|
||||
|
||||
|
||||
$text = $pl->render_poll($row, 'forum', 'oldpolls',true);
|
||||
$text = $pl->render_poll($row, 'forum', 'oldpolls', true);
|
||||
|
||||
|
||||
$text .= "
|
||||
$text .= "
|
||||
<div class='smalltext text-right'>
|
||||
<small>".LAN_POSTED_BY." ".$userlink."<br /> ".$tp->lanVars(POLLAN_50, array('x'=>$start_datestamp, 'y'=> $end_datestamp))."</small></div>
|
||||
<small>" . LAN_POSTED_BY . " " . $userlink . "<br /> " . $tp->lanVars(POLLAN_50, array('x' => $start_datestamp, 'y' => $end_datestamp)) . "</small></div>
|
||||
";
|
||||
|
||||
|
||||
/* $count = 0;
|
||||
|
||||
/* $count = 0;
|
||||
$barl = (file_exists(THEME."images/barl.png") ? THEME."images/barl.png" : e_PLUGIN."poll/images/barl.png");
|
||||
$barr = (file_exists(THEME."images/barr.png") ? THEME."images/barr.png" : e_PLUGIN."poll/images/barr.png");
|
||||
$bar = (file_exists(THEME."images/bar.png") ? THEME."images/bar.png" : e_PLUGIN."poll/images/bar.png");
|
||||
|
||||
$barl = (file_exists(THEME."images/barl.png") ? THEME."images/barl.png" : e_PLUGIN."poll/images/barl.png");
|
||||
$barr = (file_exists(THEME."images/barr.png") ? THEME."images/barr.png" : e_PLUGIN."poll/images/barr.png");
|
||||
$bar = (file_exists(THEME."images/bar.png") ? THEME."images/bar.png" : e_PLUGIN."poll/images/bar.png");
|
||||
|
||||
foreach($optionArray as $option)
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td style='width:40%; text-align: right' class='mediumtext'><b>".$tp -> toHTML($option, TRUE, 'TITLE')."</b> </td>
|
||||
<td class='smalltext'>
|
||||
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'>
|
||||
</div>
|
||||
<div style='background-image: url($bar); width: ".(floor($percentage[$count]) != 100 ? floor($percentage[$count]) : 95)."%; height: 14px; float: left;'>
|
||||
</div>
|
||||
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'>
|
||||
</div>
|
||||
".$percentage[$count]."% [".POL
|
||||
LAN_31.": ".$voteArray[$count]."]
|
||||
</td>
|
||||
</tr>\n";
|
||||
$count++;
|
||||
foreach($optionArray as $option)
|
||||
{
|
||||
$text .= "
|
||||
<tr>
|
||||
<td style='width:40%; text-align: right' class='mediumtext'><b>".$tp -> toHTML($option, TRUE, 'TITLE')."</b> </td>
|
||||
<td class='smalltext'>
|
||||
<div style='background-image: url($barl); width: 5px; height: 14px; float: left;'>
|
||||
</div>
|
||||
<div style='background-image: url($bar); width: ".(floor($percentage[$count]) != 100 ? floor($percentage[$count]) : 95)."%; height: 14px; float: left;'>
|
||||
</div>
|
||||
<div style='background-image: url($barr); width: 5px; height: 14px; float: left;'>
|
||||
</div>
|
||||
".$percentage[$count]."% [".POL
|
||||
LAN_31.": ".$voteArray[$count]."]
|
||||
</td>
|
||||
</tr>\n";
|
||||
$count++;
|
||||
|
||||
}
|
||||
*/
|
||||
$text .= e107::getComment()->compose_comment('poll', 'comment', intval($row['poll_id']), null, '', false, 'html');
|
||||
$ns->tablerender(LAN_PLUGIN_POLL_NAME . " #" . $row['poll_id'], $text);
|
||||
echo "<hr />";
|
||||
}
|
||||
}
|
||||
*/
|
||||
$text .= e107::getComment()->compose_comment('poll', 'comment', intval( $row['poll_id'] ), null, '', false, 'html');
|
||||
$ns->tablerender(LAN_PLUGIN_POLL_NAME." #".$row['poll_id'], $text);
|
||||
echo "<hr />";
|
||||
|
||||
|
||||
// Render List of Polls.
|
||||
|
||||
|
||||
$query = "SELECT p.*, u.user_name FROM #polls AS p
|
||||
LEFT JOIN #user AS u ON p.poll_admin_id = u.user_id
|
||||
WHERE p.poll_type=1
|
||||
ORDER BY p.poll_datestamp DESC";
|
||||
|
||||
if(!$array = $sql->retrieve($query, true))
|
||||
{
|
||||
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>" . LAN_NO_RECORDS_FOUND . "</div>");
|
||||
return null;
|
||||
}
|
||||
|
||||
$array = array_slice($array, 1);
|
||||
|
||||
if(empty($array))
|
||||
{
|
||||
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>" . LAN_NO_RECORDS_FOUND . "</div>");
|
||||
return null;
|
||||
}
|
||||
|
||||
$text = "<table class='table fborder' style='" . USER_WIDTH . "'>
|
||||
<colgroup>
|
||||
<col style='width: 55%;' />
|
||||
<col style='width: 15%;' />
|
||||
<col style='width: 30%;' />
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='fcaption'>" . LAN_TITLE . "</th>
|
||||
<th class='fcaption'>" . LAN_POSTED_BY . "</th>
|
||||
<th class='fcaption'>" . LAN_ACTIVE . "</th>
|
||||
</tr></thead><tbody>\n";
|
||||
|
||||
|
||||
foreach($array as $row)
|
||||
{
|
||||
|
||||
$from = $tp->toDate($row['poll_datestamp'], "short");
|
||||
$to = $tp->toDate($row['poll_end_datestamp'], "short");
|
||||
|
||||
$poll_title = $tp->toHTML($row['poll_title'], true, 'TITLE');
|
||||
|
||||
$uparams = array('id' => $row['poll_admin_id'], 'name' => $row['user_name']);
|
||||
|
||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
||||
|
||||
|
||||
$userlink = "<a href='" . $link . "'>" . $row['user_name'] . "</a>";
|
||||
$text .= "<tr>
|
||||
<td class='forumheader3' style='width: 55%;'><a href='" . e_SELF . "?" . $row['poll_id'] . "'>{$poll_title}</a></td>
|
||||
<td class='forumheader3' style='width: 15%;'>" . $userlink . "</td>
|
||||
<td class='forumheader3' style='width: 30%;'>" . $tp->lanVars(POLLAN_50, array('x' => $from, 'y' => $to)) . "</td>
|
||||
</tr>\n";
|
||||
}
|
||||
|
||||
$text .= "</tbody></table>";
|
||||
e107::getRender()->tablerender(POLLAN_28, $text);
|
||||
}
|
||||
}
|
||||
|
||||
require_once(HEADERF);
|
||||
|
||||
// Render List of Polls.
|
||||
|
||||
|
||||
$query = "SELECT p.*, u.user_name FROM #polls AS p
|
||||
LEFT JOIN #user AS u ON p.poll_admin_id = u.user_id
|
||||
WHERE p.poll_type=1
|
||||
ORDER BY p.poll_datestamp DESC";
|
||||
|
||||
if(!$array = $sql->retrieve($query,true))
|
||||
{
|
||||
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>".LAN_NO_RECORDS_FOUND."</div>");
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
}
|
||||
|
||||
$array = array_slice($array, 1);
|
||||
|
||||
if(empty($array))
|
||||
{
|
||||
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>".LAN_NO_RECORDS_FOUND."</div>");
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
}
|
||||
|
||||
$text = "<table class='table fborder' style='".USER_WIDTH."'>
|
||||
<colgroup>
|
||||
<col style='width: 55%;' />
|
||||
<col style='width: 15%;' />
|
||||
<col style='width: 30%;' />
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='fcaption'>".LAN_TITLE."</th>
|
||||
<th class='fcaption'>".LAN_POSTED_BY."</th>
|
||||
<th class='fcaption'>".LAN_ACTIVE."</th>
|
||||
</tr></thead><tbody>\n";
|
||||
|
||||
|
||||
foreach($array as $row)
|
||||
{
|
||||
|
||||
$from = $tp->toDate($row['poll_datestamp'], "short");
|
||||
$to = $tp->toDate($row['poll_end_datestamp'], "short");
|
||||
|
||||
$poll_title = $tp->toHTML($row['poll_title'], true, 'TITLE');
|
||||
|
||||
$uparams = array('id' => $row['poll_admin_id'], 'name' => $row['user_name']);
|
||||
|
||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
||||
|
||||
|
||||
$userlink = "<a href='".$link."'>".$row['user_name']."</a>";
|
||||
$text .= "<tr>
|
||||
<td class='forumheader3' style='width: 55%;'><a href='".e_SELF."?".$row['poll_id']."'>{$poll_title}</a></td>
|
||||
<td class='forumheader3' style='width: 15%;'>".$userlink."</td>
|
||||
<td class='forumheader3' style='width: 30%;'>".$tp->lanVars(POLLAN_50, array('x'=>$from, 'y'=> $to))."</td>
|
||||
</tr>\n";
|
||||
}
|
||||
|
||||
$text .= "</tbody></table>";
|
||||
e107::getRender()->tablerender(POLLAN_28, $text);
|
||||
require_once(FOOTERF);
|
||||
oldpolls_front::init();
|
||||
|
||||
require_once(FOOTERF);
|
||||
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
*/
|
||||
|
||||
require_once(__DIR__.'/../../class2.php');
|
||||
|
||||
if (!e107::isInstalled('poll'))
|
||||
{
|
||||
e107::redirect();
|
||||
@@ -23,8 +24,7 @@ require_once(HEADERF);
|
||||
|
||||
require(e_PLUGIN.'poll/poll_menu.php');
|
||||
|
||||
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
|
||||
|
||||
|
||||
|
@@ -675,7 +675,7 @@ class poll
|
||||
$opt = ($count==1) ? "poll_answer" : "";
|
||||
|
||||
$text .= "<div class='form-group' id='".$opt."'>
|
||||
".$frm->text('poll_option[]', $_POST['poll_option'][($count-1)], '200', array('placeholder' => POLLAN_4, 'id' => $opt))."
|
||||
".$frm->text('poll_option[]', varset($_POST['poll_option'][($count-1)]), '200', array('placeholder' => POLLAN_4, 'id' => $opt))."
|
||||
</div>";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user