/** * Export project pages * * @param void * @return null */ function export() { $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL); $exportable_modules = explode(',', array_var($_GET, 'modules', null)); if (!is_foreachable($exportable_modules)) { $exportable_modules = null; } // if require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php'; $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules); if (!$output_builder->createOutputFolder()) { $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); } // if $output_builder->createAttachmentsFolder(); $module_categories = Categories::findByModuleSection($this->active_project, PAGES_MODULE, 'pages'); $output_builder->smarty->assign(array('categories' => $module_categories, 'visibility' => $object_visibility)); $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index'); $output_builder->outputToFile('index'); if (is_foreachable($module_categories)) { foreach ($module_categories as $module_category) { $output_builder->smarty->assign('current_category', $module_category); $output_builder->smarty->assign('objects', Pages::findByCategory($module_category, STATE_VISIBLE, $object_visibility)); $output_builder->outputToFile('category_' . $module_category->getId()); } // foreach } // if $pages = ProjectObjects::find(array("conditions" => array("project_id = ? AND module = ? AND type = ?", $this->active_project->getId(), 'pages', 'Page'))); $page_ids = array(); if (is_foreachable($pages)) { $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object'); foreach ($pages as $page) { if (instance_of($page, 'Page')) { $page_ids[] = $page->getId(); $parent = $page->getParent(); $comments = $page->getComments($object_visibility); $output_builder->smarty->assign(array('page' => $page, 'subpages' => $page->getSubpages($object_visibility), 'parent' => $parent, 'comments' => $comments)); if (instance_of($parent, 'Page')) { $output_builder->smarty->assign('parent_url', './page_' . $parent->getId() . '.html'); } else { if (instance_of($parent, 'Category')) { $output_builder->smarty->assign('parent_url', './category_' . $parent->getId() . '.html'); } } // if $output_builder->outputToFile('page_' . $page->getId()); $output_builder->outputObjectsAttachments($comments); $output_builder->outputAttachments($page->getAttachments()); } // if } // foreach $revisions = PageVersions::findByPageIds($page_ids); if (is_foreachable($revisions)) { $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'revision'); foreach ($revisions as $revision) { $output_builder->smarty->assign('revision', $revision); $output_builder->outputToFile('revision_' . $revision->getPageId() . '_' . $revision->getVersion()); } // foreach } // if } // if $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); }
/** * Export files * * @param void * @return null */ function export() { $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL); $exportable_modules = explode(',', array_var($_GET, 'modules', null)); if (!is_foreachable($exportable_modules)) { $exportable_modules = null; } // if require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php'; $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules); if (!$output_builder->createOutputFolder()) { $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); } // if $output_builder->createAttachmentsFolder(); $module_categories = Categories::findByModuleSection($this->active_project, $this->active_module, $this->active_module); $module_objects = Files::findByProject($this->active_project, STATE_VISIBLE, $object_visibility); $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index'); $output_builder->smarty->assign('categories', $module_categories); $output_builder->smarty->assign('objects', $module_objects); $output_builder->outputToFile('index'); // export files by categories if (is_foreachable($module_categories)) { foreach ($module_categories as $module_category) { if (instance_of($module_category, 'Category')) { $objects = Files::find(array('conditions' => array('parent_id = ? AND project_id = ? AND type = ? AND state >= ? AND visibility >= ?', $module_category->getId(), $this->active_project->getId(), 'File', STATE_VISIBLE, $object_visibility), 'order' => 'boolean_field_1, datetime_field_1 DESC')); $output_builder->smarty->assign(array('current_category' => $module_category, 'objects' => $objects)); $output_builder->outputToFile('category_' . $module_category->getId()); } // if } // foreach } // if // export files if (is_foreachable($module_objects)) { $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object'); foreach ($module_objects as $module_object) { if (instance_of($module_object, 'File')) { $revisions = $module_object->getRevisions(); $output_builder->outputAttachments($revisions); $comments = $module_object->getComments($object_visibility); $output_builder->outputObjectsAttachments($comments); $output_builder->smarty->assign('object', $module_object); $output_builder->smarty->assign('comments', $comments); $output_builder->outputToFile('file_' . $module_object->getId()); } // if } // foreach } // if $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); }
/** * Export tickets * * @param void * @return null */ function export() { $object_visibility = array_var($_GET, 'visibility', VISIBILITY_NORMAL); $exportable_modules = explode(',', array_var($_GET, 'modules', null)); if (!is_foreachable($exportable_modules)) { $exportable_modules = null; } // if require_once PROJECT_EXPORTER_MODULE_PATH . '/models/ProjectExporterOutputBuilder.class.php'; $output_builder = new ProjectExporterOutputBuilder($this->active_project, $this->smarty, $this->active_module, $exportable_modules); if (!$output_builder->createOutputFolder()) { $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); } // if $output_builder->createAttachmentsFolder(); $module_categories = Categories::findByModuleSection($this->active_project, $this->active_module, $this->active_module); $module_objects = Tickets::findByProject($this->active_project, null, STATE_VISIBLE, $object_visibility); $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'index'); $output_builder->smarty->assign('categories', $module_categories); $output_builder->smarty->assign('objects', $module_objects); $output_builder->outputToFile('index'); // export tickets by categories if (is_foreachable($module_categories)) { foreach ($module_categories as $module_category) { if (instance_of($module_category, 'Category')) { $output_builder->smarty->assign(array('current_category' => $module_category, 'objects' => Tickets::findByProject($this->active_project, $module_category, STATE_VISIBLE, $object_visibility))); $output_builder->outputToFile('category_' . $module_category->getId()); } // if } // foreach } // if // export tickets if (is_foreachable($module_objects)) { $output_builder->setFileTemplate($this->active_module, $this->controller_name, 'object'); foreach ($module_objects as $module_object) { if (instance_of($module_object, 'Ticket')) { $output_builder->outputAttachments($module_object->getAttachments()); $comments = $module_object->getComments($object_visibility); $output_builder->outputObjectsAttachments($comments); if (module_loaded('timetracking')) { $timerecords = TimeRecords::findByParent($module_object, null, STATE_VISIBLE, $object_visibility); $total_time = TimeRecords::calculateTime($timerecords); } else { $timerecords = null; $total_time = 0; } // if $output_builder->smarty->assign(array('timerecords' => $timerecords, 'total_time' => $total_time, 'object' => $module_object, 'comments' => $comments)); $output_builder->outputToFile('ticket_' . $module_object->getId()); } // if } // foreach } // if $this->serveData($output_builder->execution_log, 'execution_log', null, FORMAT_JSON); }