[ x Close ]  
"> "> title="CopyTemp"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("templates?Action=Copy&TempID=$TempID"); $FORM->MakeForm("Copy Template"); $FORM->output = "Complete the form below to copy the selected template.
" . $FORM->output; $OUTPUT.=MakeBox("Copy Template",$FORM->output); $OUTPUT .= ' '; } if($Action == "Add") { $DontDo = 1; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Template Name"]="textfield|Name:100:44:"; $HELP_ITEMS["Name"]["Title"] = "Template Name"; $HELP_ITEMS["Name"]["Content"] = "The template name will only be used in the control panel to help you identify this template."; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Format"]="select|Format:1:2->HTML;1->Text;3->HTML and Text"; $HELP_ITEMS["Format"]["Title"] = "Format"; $HELP_ITEMS["Format"]["Content"] = "Which type of template would you like to create? Text, HTML or both?"; $FORM_ITEMS[-1]="submit|Next »:1-templates"; $FORM=new AdminForm; $FORM->title="AddTemplate"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("templates?Action=AddTemplate"); $FORM->MakeForm("New Template Details"); $FORM->output = "Complete the form below to create a new template.
Click on the \"Next\" button to continue." . $FORM->output; $OUTPUT = MakeBox("Create Template (Step 1 of 2)",$FORM->output); $OUTPUT .= ' '; } if($Action=="AddTemplate"){ mysql_query("INSERT INTO " . $TABLEPREFIX . "templates SET TemplateName='".addslashes($Name)."', Format='".addslashes($Format)."', DateCreated='".addslashes($SYSTEMTIME)."', AdminID='" . addslashes($CURRENTADMIN["AdminID"]) . "'"); $TempID=mysql_insert_id(); $Action="EditTemplate"; } if($Action=="DeleteTemplate"){ mysql_query("DELETE FROM " . $TABLEPREFIX . "templates WHERE TemplateID='".addslashes($TempID)."'"); $Action=""; } if($Action=="EditTemplate") { if($Save) { $DoSave = true; if (isset($_POST['HTMLFile']) && $_POST['HTMLFile'] != '' && $_POST['HTMLFile'] != 'http://') { $HTMLFile = $_POST['HTMLFile']; if(substr($HTMLFile, 0,7) == 'http://') { // Try and grab the external file $HTMLBODY = ''; if($fp = fopen($HTMLFile, 'rb')) { while(!feof($fp)) { $HTMLBODY .= fgets($fp, 1024); } fclose($fp); } else { $OUTPUT = MakeErrorBox("Invalid Content File", "The file '$HTMLFile' couldn't be loaded. The URL you specified may be invalid."); $DoSave = false; } } else { // Invalid file $OUTPUT = MakeErrorBox("Invalid Content File", "The URL you specified must start with 'http://'."); $DoSave = false; } } $html_content = ReadUploadedFile('HTMLContentFile'); if (!$html_content) { $OUTPUT = MakeErrorBox("Invalid Content File", "Unable to find contents of uploaded file."); $DoSave = false; } if ($html_content != '-1') { $HTMLBODY = $html_content; } $HTMLBODY = stripslashes($HTMLBODY); $HTMLBODY = str_replace($BAD_ENCODED_CHARS, $PROPER_ENCODED_CHARS, $HTMLBODY); if (isset($_POST['TextFile']) && $_POST['TextFile'] != '' && $_POST['TextFile'] != 'http://') { $TextFile = $_POST['TextFile']; if(substr($TextFile, 0,7) == 'http://') { // Try and grab the external file $TEXTBODY = ''; if($fp = fopen($TextFile, 'rb')) { while(!feof($fp)) { $TEXTBODY .= fgets($fp, 1024); } fclose($fp); } else { $OUTPUT = MakeErrorBox("Invalid Content File", "The file '$TextFile' couldn't be loaded. The URL you specified may be invalid."); $DoSave = false; } } else { // Invalid file $OUTPUT = MakeErrorBox("Invalid Content File", "The URL you specified must start with 'http://'."); $DoSave = false; } } $text_content = ReadUploadedFile('TextContentFile'); if (!$text_content) { $OUTPUT = MakeErrorBox("Invalid Content File", "Unable to find contents of uploaded file."); $DoSave = false; } if ($text_content != '-1') { $TEXTBODY = $text_content; } $TEXTBODY = stripslashes($TEXTBODY); if ($DoSave) { mysql_query("UPDATE " . $TABLEPREFIX . "templates SET TemplateName = '".addslashes($Name)."', Format='".addslashes($Format)."', HTMLContent='" . addslashes($HTMLBODY) . "', TextContent='" . addslashes($TEXTBODY) . "' WHERE TemplateID='".addslashes($TempID)."'"); $OUTPUT = MakeSuccessBox("Template Saved Successfully", "The selected template has been saved successfully.", MakeAdminLink("templates?Action=")); } } else { $TemplateType = ''; $Composed = mysql_fetch_assoc(mysql_query("SELECT * FROM " . $TABLEPREFIX . "templates WHERE TemplateID = '".addslashes($TempID)."'")); $Composed = stripslashes_array($Composed); $Format = $Composed['Format']; // just in case, we'll set the default to html. if($Format == '' || $Format < 1 || $Format > 3) $Format = 2; switch($Format) { default: case 1: $TemplateType = 'text'; break; case 2: $TemplateType = 'HTML'; break; case 3: $TemplateType = 'mixed'; break; } $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Template Name"]="textfield|Name:100:100:" . $Composed["TemplateName"]; $HELP_ITEMS["Name"]["Title"] = "Template Name"; $HELP_ITEMS["Name"]["Content"] = "Enter a name for this template. The template name will be used in the control panel for your reference only."; // $FORM_ITEMS[-2]="spacer| "; $FORM_ITEMS[-20]="hidden|Format:$Format"; $FORM_ITEMS[-21]="hidden|TemplateID:$TempID"; if($Format == 2 || $Format == 3) { $FORM_ITEMS['-400'] = 'spacer|
  HTML Content
'; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "HTML Template Content"]="wysiwyg|HTMLBODY:64:10:".str_replace("|", "|",str_replace(":",'$$COLON$$', $Composed["HTMLContent"])); $HELP_ITEMS["HTMLBODY"]["Title"] = "HTML Template Content"; $HELP_ITEMS["HTMLBODY"]["Content"] = "Enter the HTML for your newsletter template here."; $FORM_ITEMS[-9]="spacer|
[ Insert HTML Custom Field ]"; $FORM_ITEMS[-3]="spacer|
"; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "OR HTML Content from URL"]="textfield|HTMLFile:1000:100:http://"; $HELP_ITEMS["HTMLFile"]["Title"] = "HTML Content from URL"; $HELP_ITEMS["HTMLFile"]["Content"] = "If you have already uploaded your newsletter as a HTML file, enter the URL of the file and it will be downloaded and saved as the content of your newsletter."; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "OR HTML Content From File"]="file|HTMLContentFile"; $HELP_ITEMS["HTMLContentFile"]["Title"] = "HTML Content from File"; $HELP_ITEMS["HTMLContentFile"]["Content"] = "Select a file from your local hard drive to use as content for this newsletter."; } if($Format == 3) { $FORM_ITEMS[-7]="spacer|
[ Extract Text from HTML »
Note: On some browsers, you may lose line breaks. As a workaround, simply select all the content in the HTML editor (Ctrl A), then copy and paste into the Text editor below.')\" src='" . $ROOTURL . "admin/images/help.gif' width='24' height='16' border='0'>"; } if($Format == 1 || $Format == 3) { $FORM_ITEMS['-300'] = 'spacer|

  Text Content
'; $FORM_ITEMS[$FORM_REQUIRED_ITEM . "Text Template Content"]="textarea|TEXTBODY:60:30:".str_replace("|", "|",str_replace(":",'$$COLON$$', str_replace("\r\n", " ", $Composed["TextContent"]))); $HELP_ITEMS["TEXTBODY"]["Title"] = "Text Template Content"; $HELP_ITEMS["TEXTBODY"]["Content"] = "Enter the text for your newsletter template here."; $FORM_ITEMS[-11]="spacer|
[Insert Text Custom Field]"; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "OR Text Content from URL"]="textfield|TextFile:1000:100:http://"; $HELP_ITEMS["TextFile"]["Title"] = "Text Content from URL"; $HELP_ITEMS["TextFile"]["Content"] = "If you have already uploaded your newsletter as a text file, enter the URL of the file and it will be downloaded and saved as the content of your newsletter."; $FORM_ITEMS[$FORM_NOT_REQUIRED_ITEM . "OR Text Content From File"]="file|TextContentFile"; $HELP_ITEMS["TextContentFile"]["Title"] = "Text Content from File"; $HELP_ITEMS["TextContentFile"]["Content"] = "Select a file from your local hard drive to use as content for this newsletter."; } $OUTPUT = ' '; $FORM_ITEMS[-1]="submit|Save:1-templates"; $RandomKey=uniqid("t"); $FORM_ITEMS[-12]="hidden|RandomKey:$RandomKey"; $FORM=new AdminForm; $FORM->title="EditTemplate"; $FORM->items=$FORM_ITEMS; $FORM->action=MakeAdminLink("templates?Action=EditTemplate&TempID=$TempID&Save=Yes"); $FORM->MakeForm("Template Content"); if($Editing == "") { $OUTPUT .= MakeBox("Create Template (Step 2 of 2)",$FORM->output); $FORM->output = "Complete the form below to create a $TemplateType template." . $FORM->output; } else { $OUTPUT .= MakeBox("Update Newsletter Template",$FORM->output); $FORM->output = "Complete the form below to update this newsletter template." . $FORM->output; } } } if($Action=='') { if($CURRENTADMIN['Manager'] == 1) { $templates=mysql_query("SELECT * FROM " . $TABLEPREFIX . "templates ORDER BY TemplateName ASC"); } else { $templates=mysql_query("SELECT * FROM " . $TABLEPREFIX . "templates WHERE AdminID = '" . addslashes($CURRENTADMIN['AdminID']) . "' ORDER BY TemplateName ASC"); } if(mysql_num_rows($templates) > 0) { $TO = ' '; while($temp=mysql_fetch_assoc($templates)) { $temp = stripslashes_array($temp); $Format = ''; switch($temp['Format']) { case 1: $Format = 'Text'; break; case 2: $Format = 'HTML'; break; case 3: $Format = 'HTML + Text'; break; } $TO .= ' '; } $TO.='
  Template Name Format Date Created Action
' . $temp["TemplateName"] . ' ' . $Format . ' ' . DisplayDate($temp["DateCreated"]) . ' '; $TO .= MakeLink("templates?Action=PreviewPopup&TempID=".$temp["TemplateID"],"View",0,0, "_blank") . "   "; $TO .= MakeLink("templates?Action=EditTemplate&TempID=".$temp["TemplateID"]."&Editing=1","Edit") . "   "; $TO .= MakeLink("templates?Action=CopyForm&TempID=".$temp["TemplateID"],"Copy") . "   "; $TO .= MakeConfirmBox("templates?Action=DeleteTemplate&TempID=".$temp["TemplateID"],"Delete","Are you sure you wish to delete this template?"); $TO .= '
'; $TO = 'Use the form below to review, edit and delete templates.
To create a new template, click on the "Create Template" button below.



' . $TO; } else { // There are no templates in the list $TO = 'No templates have been created. Click "Create Template" to create one.



'; } $OUTPUT.=MakeBox("Manage Templates", $TO); } ?>