public static function getInstance()
 {
     if (!self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 public function packetAction()
 {
     $format = $this->_getParam('format');
     $formats = array('zip', 'phar');
     if (!in_array($format, $formats)) {
         $this->_helper->redirector->goto('index', 'index');
     }
     if (!extension_loaded($format)) {
         $this->_helper->redirector->goto('index', 'index');
     }
     $class = $this->_getParam('class');
     $classes = array();
     $classesParam = $this->_getParam('classes');
     if (!empty($classesParam)) {
         $classes = explode(',', $classesParam);
     } else {
         $classes = array($class);
     }
     $cached = sprintf('cache/%s.%s', md5(implode(',', $classes) . $this->_libraryId), $format);
     if (!file_exists($cached)) {
         $file = 'cache/files_' . $this->_libraryId . '.xml';
         $data = App_FileDataLoader::load($file);
         $archive = CU_Archive::create($format, $cached);
         foreach ($classes as $class) {
             $file = $data->getFileByClass($class);
             $library = $this->_loadLibrary();
             $this->_requiredFiles[] = $file->name;
             $this->_getRequires($file, $data);
             foreach ($this->_requiredFiles as $require) {
                 $archive->addFile($library['path'] . '/' . $require, $require);
             }
         }
         $archive->close();
     }
     $filename = implode('-', $classes);
     if (strlen($filename) > 100) {
         $filename = substr($filename, 0, 100);
     }
     header('Content-Type: application/' . $format);
     header('Content-Length: ' . filesize($cached));
     header('Content-Disposition: attachment; filename="' . $filename . '.' . $format . '"');
     readfile($cached);
     exit;
 }