function export($filename = '')
 {
     $search = array('"', "'", "", "\n", "\r", "");
     //\x08\\x09, not required
     $replace = array('\\"', "\\'", '\\0', '\\n', '\\r', '\\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->direction}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $sql = "SELECT * FROM %slanguage_text WHERE language_code='%s' ORDER BY variable, term";
     $rows_text = queryDB($sql, array(TABLE_PREFIX, $this->code));
     if (count($rows_text) > 0) {
         foreach ($rows_text as $row) {
             $row['text'] = str_replace($search, $replace, $row['text']);
             $row['context'] = str_replace($search, $replace, $row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an ATutor language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct ATutor table prefix as defined in ./include/config.inc.php . Additional Language Packs can be found on http://atutor.ca .';
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('atutor_' . $version . '_' . $this->code);
     }
 }
 function export($filename = '')
 {
     //		$search  = array('"', "'", "\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
     //		$replace = array('\"', "\'", '\0', '\n', '\r', '\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     global $addslashes;
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $languageTextDAO = new LanguageTextDAO();
     $rows = $languageTextDAO->getAllByLang($this->code);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             //				$row['text']    = str_replace($search, $replace, $row['text']);
             //				$row['context'] = str_replace($search, $replace, $row['context']);
             $row['text'] = $addslashes($row['text']);
             $row['context'] = $addslashes($row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
         return;
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an AChecker language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct AChecker table prefix as defined in ./include/config.inc.php .';
     require AC_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('achecker_' . $version . '_' . $this->code);
     }
 }