<?
class admin_dialog_custompages extends admin_dialog {

var $params = array("target", "mode", "lang", "id");

    function makeData() {
        parent::makeData();
        $this->langs = array();
        $langs = parse_ini_file("lang/langs.ini", true);


        if (isset($this->lang))
        {
           $this->custompages = func_new("custompages", $this->id);
           $l = $this->custompages->getCustompagesList($this->lang);
           $this->list = $l['data'];


           foreach($langs as $k => $v)
              if ($v['langid']==$this->lang) {
                 $this->langname = $v['display'];
                 break;
              }
        }


        switch($this->mode) {

            case "edit":
                $this->form_fields = $this->custompages->row;
                break;

            default:
                foreach($langs as $k => $v) {
                   $this->langs[] = $v;
                }
                break;


        }
    }


    function action_new_custompage() {
          $this->db->insert(_DB_TABLE_PREFIX."custompages",
                                        array("lang"    => $_REQUEST["lang"],
                                              "title"   => $_REQUEST["nc_name"],
                                              "content" => $_REQUEST["nc_description"]));
    }

    function action_save_custompage() {
          $this->db->update(_DB_TABLE_PREFIX."custompages",
                                        array("lang"    => $_REQUEST["lang"],
                                              "title"   => $_REQUEST["title"],
                                              "content" => $_REQUEST["content"]), "id='".$_REQUEST["id"]."'" );
    }

    function action_delete() {
          $this->db->delete(_DB_TABLE_PREFIX."custompages",
                                          "id='".$_REQUEST["id"]."'");
    }
}


?>