<title>Page Title</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>Page Title</h1> </div><!-- /header --> <div data-role="content">
<title>Page Title</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" /> </head> <body> <div data-role="page"> <div data-role="header"> <h1>Page Title</h1> </div><!-- /header --> <div data-role="content">
...
$pt_content_header = htmlentities($_POST['pt_content_header'], ENT_QUOTES);
$pt_content_footer = htmlentities($_POST['pt_content_footer'], ENT_QUOTES);
$user_id = $modx->user->get('id');
$sql = "insert into test_templates
(pt_client, pt_client_edited_by, pt_name, pt_content_css, pt_content_header, pt_content_footer)
Values ('" . $clientid . "','" . $user_id . "','" . $pt_name . "', '" . $pt_content_css . "', '" . $pt_content_header . "', '" . $pt_content_footer . "')";
$results = $modx->query($sql);
echo $results;echo '<form id="theme" method="post" action="index.php?id=' . $id . '&tid=' . $tid . '&task=2">'; echo "<b>Header</b> (<a href=\"javascript:DefaultHeader();\">Default</a>)<br>\n"; echo '<textarea rows="8" cols="50" name="pt_content_header" type="text">'. ($row['pt_content_header']). '</textarea>';
This question has been answered by multiple community members. See the first response.
<!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> [[$head]] </head> <body> [[$navbar]] <div class="row content"> [[*id:isnot=`[[++site_start]]`:then=`[[$breadcrumb]]`]] [[$content]] [[$footer]] </div> </body> </html>
Manage and edit your poll templates. [[polladmin_template_edit_select]]
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
/*
// Show all POST/GET events.
foreach ($_REQUEST as $key=>$val)
{
echo $key .' = '. htmlentities($val) . '<br />';
}
*/
if(isset($_GET['id']))
{
$id = (int)$_GET['id'];
}
if(isset($_GET['task']))
{
$tasktype = (int)$_GET['task'];
}
if(isset($_GET['task']))
{
$tasktype = (int)$_GET['task'];
}
if(isset($_GET['tid']))
{
$tid = (int)$_GET['tid'];
}
?>
<script type="text/javascript">
function DefaultHeader()
{
$('#pt_content_header').val('<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">\n</head>\n<body>\n<h1>Vote Now</h1>');
}
</script>
<?php
// Default text
if (empty($_POST) && $tasktype==0 )
{
// Display the groups a user is in:
echo "You are listed with the following user group creditials: <br><br>";
foreach($modx->user->getUserGroupNames( ) as $group) {
echo "{$group}<br>";
}
echo '<br><a href="index.php?id=' . $id . '&task=2">Create a new template</a>';
}
// If the page is being Saved
if (!empty($_POST))
{
if(isset($_POST['pt_id']))
{
$pt_id = (int)$_POST['pt_id'];
}
if($pt_id) // means it's an update.
{
//$pt_content_header = $modx->sanitizeString($_POST['pt_content_header']); // sanitizeString removes all codes and other stuff. Don't use yet.
$pt_name = htmlentities($_POST['pt_name'], ENT_QUOTES);
$pt_content_css = htmlentities($_POST['pt_content_css'], ENT_QUOTES);
$pt_content_footer = htmlentities($_POST['pt_content_footer'], ENT_QUOTES);
$pt_content_header = htmlentities($_POST['pt_content_header'], ENT_QUOTES);
//update the record now.
$sql = "UPDATE polls_templates SET
pt_name = '" . $pt_name . "',
pt_content_css = '" . $pt_content_css . "',
pt_content_header = '" . $pt_content_header . "',
pt_content_footer = '" . $pt_content_footer . "'
WHERE pt_id= '". $pt_id . "'";
$results = $modx->query($sql);
} else
{
// echo "t";
if(($_POST['pt_new']=='new') && ($_GET['task']=='2'))
{
// it's a new entry.
//$pt_content_header = $modx->sanitizeString($_POST['pt_content_header']); // recommended!
//clientid
$clientid = htmlentities($_POST['clientid'], ENT_QUOTES);
$pt_name = htmlentities($_POST['pt_name'], ENT_QUOTES);
$pt_content_css = htmlentities($_POST['pt_content_css'], ENT_QUOTES);
$pt_content_header = htmlentities($_POST['pt_content_header'], ENT_QUOTES);
$pt_content_footer = htmlentities($_POST['pt_content_footer'], ENT_QUOTES);
$user_id = $modx->user->get('id');
$sql = "insert into polls_templates
(pt_client, pt_client_edited_by, pt_name, pt_content_css, pt_content_header, pt_content_footer)
Values ('" . $clientid . "','" . $user_id . "','" . $pt_name . "', '" . $pt_content_css . "', '" . $pt_content_header . "', '" . $pt_content_footer . "')";
echo $sql;
//$sql = "SELECT * FROM `polls_templates` where pt_id = '" . $tid . "' LIMIT 1";
$results = $modx->query($sql);
//echo $sql;
echo $results;
echo '<a href="index.php?id=' . $id . '">Continue</a>';
}
}
if ($results)
{ echo "Changes saved"; } else { echo "Save failed"; };
}
// Standard Page
if($tasktype==0)
{
$templates = array();
foreach($modx->user->getUserGroups( ) as $group) {
$templates[] = $group;
}
$templates_id = "'" . implode("', '", $templates ) . "'";
$query = "SELECT * FROM voting_modx.polls_templates where pt_client IN($templates_id)";
// echo $query;
echo "<br><br>";
echo "Your Available templates:<br>\n";
foreach ($modx->query($query) as $row)
{
echo '<div class="theme_names"><a href="index.php?id=' . $id . '&tid=' . $row['pt_id'] .'">' . $row['pt_name'] .'</a> - ';
echo '<a href="index.php?id=' . $id . '&tid=' . $row['pt_id'] .'&task=1">Edit</a></div>';
}
}
// Means we are editing the selected template
if($tasktype==1)
{
$sql = "SELECT * FROM `polls_templates` where pt_id = '" . $tid . "' LIMIT 1";
echo "<br>";
echo "<b>Your Current Theme Code:</b><br>\n";
echo "<p><a href=\"vote/view_template.php?tid=" . $tid ."&preview=1\" onclick=\"positionedPopup(this.href,'TemplatePreview','300','600','100','200','yes');return false\">Preview this template</a></p>";
echo "<br>";
echo '<form id="theme" method="post" action="index.php?id=' . $id . '&tid=' . $tid . '&task=1">';
foreach ($modx->query($sql) as $row)
{
echo "<b>Theme Name</b><br>\n";
echo '<input name="pt_name" id="pt_name" type="text" value="' . $row['pt_name']. '">';
echo '<input name="pt_id" id="pt_id" type="hidden" value="' . $row['pt_id'] . '">';
echo '<input name="pt_client" id="pt_client" type="hidden" value="' . $row['pt_client']. '">';
echo "<b>CSS</b><br>\n";
echo '<textarea rows="8" cols="50" name="pt_content_css" id="pt_content_css" type="text">'. $row['pt_content_css']. '</textarea>';
echo "<b>Header</b> (<a href=\"javascript:DefaultHeader();\">Default</a>)<br>\n";
echo '<textarea rows="8" cols="50" name="pt_content_header" id="pt_content_header" type="text">'. $row['pt_content_header']. '</textarea>';
echo "<b>Footer</b><br>\n";
echo '<textarea rows="8" cols="50" name="pt_content_footer" id="pt_content_footer" type="text">' . $row['pt_content_footer']. '</textarea>';
echo "<br><br>";
}
echo '<input type="submit" name="submit" value="Save Results" />';
echo '<input type="reset" name="reset" value="Reset" />';
echo '<a href="index.php?id=' . $id . '">Cancel</a>';
echo '</form>';
}
// Means we are creating a new template
if($tasktype==2)
{
echo "<br>";
echo "<b>Your Current Theme Code:</b><br>\n";
echo "<p>Preview available when you first save this template.</p>";
echo "<br>";
echo '<form id="theme" method="post" action="index.php?id=' . $id . '&tid=' . $tid . '&task=2">';
echo '<input name="pt_id" id="pt_id" type="hidden">';
echo '<input name="pt_new" id="pt_new" type="hidden" value="new">';
echo '<input name="pt_client" id="pt_client" type="hidden">';
echo "<b>Theme Account</b>:<br>";
echo "<Select id=\"clientid\" name=\"clientid\">";
$query = "SELECT * FROM modx_member_groups, modx_membergroup_names WHERE user_group = modx_membergroup_names.id AND modx_member_groups.member = '" . $modx->user->get('id') . "'";
foreach ($modx->query($query) as $row)
{
if($row['name']!= "Protected") // not allowed to add things to the protected default templates.
{
echo '<option value=' . $row['user_group'] .'">' . $row['name'] .'</option> - ';
}
}
echo "</select><br><br>\n";
echo "<b>Theme Name</b><br>\n";
echo '<input name="pt_name" id="pt_name" type="text" >';
echo "<b>CSS</b><br>\n";
echo '<textarea rows="8" cols="50" name="pt_content_css" id="pt_content_css" type="text">'. $row['pt_content_css']. '</textarea>';
echo "<b>Header</b> (<a href=\"javascript:DefaultHeader();\">Default</a>)<br>\n";
echo '<textarea rows="8" cols="50" name="pt_content_header" type="text">'. htmlentities($row['pt_content_header']). '</textarea>';
echo "<b>Footer</b><br>\n";
echo '<textarea rows="8" cols="50" name="pt_content_footer" id="pt_content_footer" type="text">' . $row['pt_content_footer']. '</textarea>';
echo "<br><br>";
echo '<input type="submit" name="submit" value="Save Results" />';
echo '<input type="reset" name="reset" value="Reset" />';
echo '<a href="index.php?id=' . $id . '">Cancel</a>';
echo '</form>';
}
return $output;
This is why I'm using them. Heaps of permissions, and lots of permissions. 