예제 #1
0
 /**
  * Exports a Wiki resource
  * according to the description found in WikiImporter.
  *
  * @param Workspace $workspace
  * @param array     $files
  * @param Wiki      $object
  *
  * @return array
  */
 public function exportWiki(Workspace $workspace, array &$files, Wiki $object)
 {
     // Getting all sections and building array
     $rootSection = $object->getRoot();
     $sections = $this->sectionRepository->children($rootSection);
     array_unshift($sections, $rootSection);
     $sectionsArray = array();
     foreach ($sections as $section) {
         //Getting all contributions and building contributions array
         $activeContribution = $section->getActiveContribution();
         $contributions = $this->contributionRepository->findAllButActiveForSection($section);
         $contributionsArray = array();
         array_unshift($contributions, $activeContribution);
         foreach ($contributions as $contribution) {
             $uid = uniqid() . '.txt';
             $tmpPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $uid;
             file_put_contents($tmpPath, $contribution->getText());
             $files[$uid] = $tmpPath;
             $contributionArray = array('is_active' => $contribution->getId() == $activeContribution->getId(), 'title' => $contribution->getTitle(), 'contributor' => $contribution->getContributor()->getUsername(), 'creation_date' => $contribution->getCreationDate(), 'path' => $uid);
             $contributionsArray[] = array('contribution' => $contributionArray);
         }
         $sectionArray = array('id' => $section->getId(), 'parent_id' => $section->getParent() !== null ? $section->getParent()->getId() : null, 'is_root' => $section->isRoot(), 'visible' => $section->getVisible(), 'creation_date' => $section->getCreationDate(), 'author' => $section->getAuthor()->getUsername(), 'deleted' => $section->getDeleted(), 'deletion_date' => $section->getDeletionDate(), 'contributions' => $contributionsArray);
         $sectionsArray[] = $sectionArray;
     }
     $data = array('options' => array('mode' => $object->getMode()), 'sections' => $sectionsArray);
     return $data;
 }
예제 #2
0
 public function findDeletedSectionsQuery(Wiki $wiki)
 {
     $queryBuilder = $this->createQueryBuilder('section')->join('section.activeContribution', 'contribution')->select('section, contribution')->andWhere('section.root = :rootId')->andWhere('section.deleted = :deleted')->orderBy('section.deletionDate', 'ASC')->setParameter('deleted', true)->setParameter('rootId', $wiki->getRoot()->getId());
     return $queryBuilder->getQuery();
 }