示例#1
0
 public function trash_empty()
 {
     $limit = 100;
     $c = umiHierarchy::getInstance()->removeDeletedWithLimit($limit);
     $buffer = outputBuffer::current('HTTPOutputBuffer');
     $buffer->charset("utf-8");
     $buffer->contentType("text/xml");
     $data = array("attribute:complete" => (int) ($c < $limit), "attribute:deleted" => $c);
     baseModuleAdmin::setData($data);
     return baseModuleAdmin::doData();
 }
示例#2
0
 public function get_export()
 {
     $id = (int) getRequest('param0');
     $as_file = getRequest('as_file');
     $objects = umiObjectsCollection::getInstance();
     $settings = $objects->getObject($id);
     if (!$settings instanceof umiObject) {
         throw new publicException(getLabel("exchange-err-settings_notfound"));
     }
     $format_id = $settings->format;
     $exportFormat = $objects->getObject($format_id);
     if (!$exportFormat instanceof umiObject) {
         throw new publicException(getLabel("exchange-err-format_undefined"));
     }
     $suffix = $exportFormat->sid;
     $exporter = umiExporter::get($suffix);
     if ($settings->source_name) {
         $exporter->setSourceName($settings->source_name);
     }
     // check cache
     $cache_time = (int) $settings->cache_time;
     $temp_dir = "./sys-temp/export/";
     if (!is_dir($temp_dir)) {
         mkdir($temp_dir, 0777, true);
     }
     $cache_file_path = $temp_dir . $id . "." . $exporter->getFileExt();
     if ($as_file === '1') {
         $temp_folder = $temp_dir . $id;
         if (is_dir($temp_folder)) {
             if (file_exists($temp_dir . $id . ".zip")) {
                 unlink($temp_dir . $id . ".zip");
             }
             $archive = new PclZip($temp_dir . $id . ".zip");
             $archive->add(array($temp_dir . $id . ".xml", $temp_folder), PCLZIP_OPT_REMOVE_PATH, 'sys-temp/export');
             shell_exec("rm -rf {$temp_folder}");
             $zipFile = new umiFile($temp_dir . $id . ".zip");
             $zipFile->download();
             return;
         }
         $cache_file = new umiFile($cache_file_path);
         $cache_file->download();
         return;
     }
     if ($as_file === '0') {
         if (!file_exists($cache_file_path) || !$cache_time || $cache_time && time() > filectime($cache_file_path) + $cache_time * 60) {
             $result = $exporter->export($settings->elements);
             if ($result) {
                 file_put_contents($cache_file_path, $result);
             }
         }
         $buffer = $exporter->setOutputBuffer();
         $buffer->push(file_get_contents($cache_file_path));
         $buffer->end();
         return;
     }
     if ($as_file === null && (!file_exists($cache_file_path) || !$cache_time || $cache_time && time() > filectime($cache_file_path) + $cache_time * 60)) {
         $result = $exporter->export($settings->elements);
         if ($result) {
             file_put_contents($cache_file_path, $result);
         }
     }
     $data = array("attribute:complete" => (int) $exporter->getIsCompleted());
     baseModuleAdmin::setData($data);
     return baseModuleAdmin::doData();
 }