Pman.Gnumeric.js
[Pman.Core] / MailTemplateList.php
index dfaf8e3..64eb9c6 100644 (file)
@@ -1,17 +1,53 @@
 <?php
 
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
+require_once 'ConvertStyle.php';
 
-/**
- * Description of MailTemplateList
- *
- * @author edward
- */
-class MailTemplateList {
-    //put your code here
-}
+class Pman_Core_MailTemplateList extends Pman_Core_ConvertStyle
+{
+    
+    function get($v, $opts=array())
+    {
+        $fopts = HTML_FlexyFramework::get()->HTML_Template_Flexy;
+        
+        $templateDir = explode(PATH_SEPARATOR, $fopts['templateDir']);
+        
+        $base = 'http://' . $_SERVER['SERVER_NAME'] . $this->rootURL;
+        
+//        $path = '/home/edward/gitlive/web.madeinnz/Pman/Shop/templates/mail/register.body.html';
+//        
+//        $data = $this->convertStyle($base, $path, false);
+//        
+//        print_r($data);exit;
+        
+        $ret = array();
+        
+        foreach ($templateDir as $dir){
+            
+            if(!file_exists($dir . '/mail')){
+                continue;
+            }
+              
+            if ($handle = opendir($dir . '/mail')) {
+                while (false !== ($entry = readdir($handle))) {
+                    if ($entry == "." || $entry == ".." || !preg_match('/\.html$/', $entry)) {
+                        continue;
+                    }
+                    
+                    $path = "$dir/mail/$entry";
+                    
+                    $ret[] = array(
+                        'file' => $entry,
+                        'content' => $this->convertStyle($base, $path, false)
+                    );
+                }
+                
+                closedir($handle);
+            }
+            
+        }
 
-?>
+        $this->jok($ret);
+        
+    }
+     
+}