<?
class admin_dialog_templates extends admin_dialog {


var $params = array("target", "mode");
var $tpl_dir = "templates/includes/";


    function makeData() {
        parent::makeData();



        $this->tpl_list = array();
        $dh = opendir($this->tpl_dir);
        while (($dir = readdir($dh)) !== false) {
            if(($dir != ".") && ($dir != "..")) {
                $this->tpl_list[] = $dir;
            }
        }


        if($this->mode == "edit") {
            $this->form_fields["tpl_content"] = file_get_contents($this->tpl_dir.$_REQUEST["fname"]);
            $this->tpl_fname = $_REQUEST["fname"];
        }
    }


    function action_save() {
        if(isset($_REQUEST["fname"])) {
            $fp = fopen($this->tpl_dir.$_REQUEST["fname"], "w+");
            fwrite($fp, $_REQUEST["tpl_content"]);
            fclose($fp);
            $this->mode = "";
        }
    }
    
}
?>