forked from nodesman/wp-autoresponder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtmltemplates.lib.php
57 lines (46 loc) · 1.68 KB
/
htmltemplates.lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
function CreateNewTemplateSwitcherButton($nameOfCKEditorObject,$nameOfTextArea,$number="")
{
$pluginpath = str_replace(basename(__FILE__),"",__FILE__);
$templateFilesDirectory = "$pluginpath/htmltemplates/";
$dir = opendir($templateFilesDirectory);
$listOfTemplates = array();
while ($item = readdir($dir))
{
if (preg_match("@(\.html|\.htm)$@",$item))//if the file ends with .html, add to the list.
{
$listOfTemplates[$item] = preg_replace("@(.html|.htm)@","",str_replace("_"," ",$item));
}
}
$home = get_bloginfo("home");
$path = PLUGINDIR;
$fullpath = $home."/?wpr-template="
?>
<script>
var fullPath = "<?php echo $fullpath ?>";
//list of documents
function changeTemplate<?php echo $number?>(editorObject, nameOfTextArea,selectObject)
{
var filename = selectObject.options[selectObject.selectedIndex].value;
if (!filename)
return;
urloffiletoget = fullPath+filename;
var return_value= jQuery.ajax({ type: "GET", url: urloffiletoget, async: false }).responseText;
editorObject.setData(return_value);
}
function getCode()
{
}
function codeReady()
{
}
</script>
<?php
$formItem = '<div style="float:right; display:block;">Choose Template: <select name="templateChanger" onchange="changeTemplate'.$number.'('.$nameOfCKEditorObject.',\''.$nameOfTextArea.'\',this)"><option></option>';
foreach ($listOfTemplates as $filename=>$templateName)
{
$formItem .= '<option value="'.$filename.'">'.$templateName.'</option>';
}
$formItem .= "</select></div>";
echo $formItem;
}