Esempio n. 1
0
 function make($src, $name = "Archive.tgz", $returnFile = true)
 {
     $ext = '.' . pathinfo($name, PATHINFO_EXTENSION);
     foreach ($this->WathArchive as $key => $val) {
         if (stripos($ext, $key) !== false) {
             $comp = $val;
         }
     }
     if ($comp == 'zip') {
         $zip = new zip();
         if ($returnFile) {
             $result = $zip->makeZip($src, $dest);
         } else {
             $tmpZip = './' . md5(serialize($src)) . '.zip';
             $result = $zip->makeZip($src, $tmpZip);
             $result = file_get_contents($tmpZip);
             unlink($tmpZip);
         }
         return $result;
     } elseif (strlen($comp) > 1) {
         if (count($src) > 1 || is_dir($src[0]) || $comp == 'tar') {
             $tar = new tar();
             $src = $tar->makeTar($src);
         }
         if ($comp == 'bz') {
             $bzip2 = new bzip2();
             $src = $bzip2->makeBzip2($src);
         } elseif ($comp == 'gz') {
             $gzip = new gzip();
             $src = $gzip->makeGzip($src);
         }
         if ($returnFile) {
             file_put_contents($dest, $src);
             return $dest;
         }
         return $src;
     } else {
         return 'Specifie a valid format at the end of ' . $name . ' filename ! ';
     }
 }
Esempio n. 2
0
 function createPackage($bypasszip = false)
 {
     // Make Db Backup (xml config file ) file
     $xml = new SimpleXMLElement('<xml/>');
     $xml->addChild('name', $this['name']);
     $xml->addChild('namespace', $this['namespace']);
     $xml->addChild('type', $this['type']);
     $xml->addChild('allowed_children', $this['allowed_children'] ?: 0);
     $xml->addChild('specific_to', $this['specific_to'] ?: 0);
     $xml->addChild('is_system', $this['is_system']);
     $xml->addChild('description', $this['description'] ?: 0);
     $xml->addChild('default_enabled', $this['default_enabled']);
     $xml->addChild('has_toolbar_tools', $this['has_toolbar_tools']);
     $xml->addChild('has_owner_modules', $this['has_owner_modules']);
     $xml->addChild('has_live_edit_app_page', $this['has_live_edit_app_page']);
     $xml->addChild('git_path', $this['git_path'] ?: 0);
     $xml->addChild('initialize_and_clone_from_git', $this['initialize_and_clone_from_git']);
     $tools_node = $xml->addChild('Tools');
     foreach ($tools = $this->ref('Tools') as $tools_array) {
         $tool_node = $tools_node->addChild('Tool');
         $tool_node->addChild('name', $tools['name']);
         $tool_node->addChild('display_name', $tools['display_name']);
         $tool_node->addChild('order', $tools['order']);
         $tool_node->addChild('is_serverside', $tools['is_serverside']);
         $tool_node->addChild('is_resizable', $tools['is_resizable']);
         $tool_node->addChild('is_sortable', $tools['is_sortable']);
     }
     $plugins_node = $xml->addChild('Plugins');
     foreach ($plugins = $this->ref('Plugins') as $plugin_array) {
         $plugin_node = $plugins_node->addChild('Plugin');
         $plugin_node->addChild('name', $plugins['name']);
         $plugin_node->addChild('event', $plugins['event']);
         $plugin_node->addChild('params', $plugins['params']);
         $plugin_node->addChild('is_system', $plugins['is_system']);
     }
     file_put_contents(getcwd() . DS . 'epan-components' . DS . $this['namespace'] . DS . 'config.xml', $xml->asXML());
     if (!$bypasszip) {
         // Zip file
         $component_zip = new zip();
         if (file_exists(getcwd() . DS . 'epan-components' . DS . $this['namespace'] . DS . $this['namespace'] . '.zip')) {
             unlink(getcwd() . DS . 'epan-components' . DS . $this['namespace'] . DS . $this['namespace'] . '.zip');
         }
         $component_zip->makeZip(getcwd() . DS . 'epan-components' . DS . $this['namespace'] . DS . '/.', getcwd() . DS . 'epan-components' . DS . $this['namespace'] . DS . $this['namespace'] . '.zip');
         // Download file
         // delete created zip file
     }
 }