Inheritance: extends Newscoop\Entity\OutputSettings
 /**
  * Inserts an ouput setting issue
  *
  * @param OutputSettingsIssue $outputSettingsIssue
  */
 public function insert(OutputSettingsIssue $outputSettingsIssue)
 {
     $em = $this->getManager();
     $outputSettingsIssue->setId(null);
     $em->persist($outputSettingsIssue);
     $em->flush();
 }
Beispiel #2
0
if ($issueObj->getWorkflowStatus() == 'Y') {
    $changed &= $issueObj->setPublicationDate($f_publication_date);
}
//@New theme management
$resourceId = new ResourceId('Publication/Edit');
$themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1);
$outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME);
$outputService = $resourceId->getService(IOutputService::NAME);
$issueService = $resourceId->getService(IIssueService::NAME);
$syncRsc = $resourceId->getService(ISyncResourceService::NAME);
$newOutputSetting = false;
$outSetIssues = $outputSettingIssueService->findByIssue($issueObj->getIssueId());
if (count($outSetIssues) > 0) {
    $outSetIssue = $outSetIssues[0];
} else {
    $outSetIssue = new OutputSettingsIssue();
    $outSetIssue->setOutput($outputService->findByName('Web'));
    $outSetIssue->setIssue($issueService->getById($issueObj->getIssueId()));
    $newOutputSetting = true;
}
$outSetIssue->setThemePath($syncRsc->getThemePath($f_theme_id));
if ($f_issue_template_id != null && $f_issue_template_id != '0') {
    $outSetIssue->setFrontPage($syncRsc->getResource('frontPage', $f_issue_template_id));
} else {
    $outSetIssue->setFrontPage(null);
}
if ($f_section_template_id != null && $f_section_template_id != '0') {
    $outSetIssue->setSectionPage($syncRsc->getResource('sectionPage', $f_section_template_id));
} else {
    $outSetIssue->setSectionPage(null);
}
 public function it_gets_theme_path(OutputSettingsIssue $issueOutput, Resource $resource)
 {
     $resource->getPath()->willReturn('publication_1/theme_1/');
     $issueOutput->getThemePath()->willReturn($resource);
     $this->getThemePath()->shouldReturn('publication_1/theme_1/');
 }
Beispiel #4
0
 /**
  * Sets the theme for all issues of the given publication
  *
  * @param $publicationId
  *
  * @param $theme
  *
  * @return bool
  */
 public function setIssuesTheme($publicationId, Newscoop\Entity\Theme $theme, Newscoop\Entity\Theme $publicationTheme)
 {
     global $g_ado_db;
     $sql = $this->buildIssuesQuery($publicationId, $theme->getPath());
     $issuesList = $g_ado_db->GetAll($sql);
     foreach ($issuesList as $issueData) {
         $issue = $this->getIssueService()->findById($issueData['id']);
         if (is_null($issue)) {
             continue;
         }
         $outSetIssues = $this->getOutputSettingIssueService()->findByIssue($issueData['id']);
         $newOutputSetting = false;
         if (count($outSetIssues) > 0) {
             $outSetIssue = $outSetIssues[0];
         } else {
             $outSetIssue = new OutputSettingsIssue();
             $outSetIssue->setOutput($this->getOutputService()->findByName('Web'));
             $outSetIssue->setIssue($issue);
             $newOutputSetting = true;
         }
         $outTh = $this->getThemeService()->getOutputSettings($publicationTheme);
         if (count($outTh) == 0) {
             return false;
         }
         $outTh = array_shift($outTh);
         $outSetIssue->setThemePath($this->getSyncResourceService()->getThemePath($publicationTheme->getPath()));
         if (!empty($issueData['issue_template'])) {
             $rscPath = $publicationTheme->getPath() . basename($issueData['issue_template']);
             if ($rscPath != $outTh->getFrontPage()->getPath()) {
                 $outSetIssue->setFrontPage($this->getSyncResourceService()->getResource('frontPage', $rscPath));
             } else {
                 $outSetIssue->setFrontPage(null);
             }
         } else {
             $outSetIssue->setFrontPage(null);
         }
         if (!empty($issueData['section_template'])) {
             $rscPath = $publicationTheme->getPath() . basename($issueData['section_template']);
             if ($rscPath != $outTh->getSectionPage()->getPath()) {
                 $outSetIssue->setSectionPage($this->getSyncResourceService()->getResource('sectionPage', $rscPath));
             } else {
                 $outSetIssue->setSectionPage(null);
             }
         } else {
             $outSetIssue->setSectionPage(null);
         }
         if (!empty($issueData['article_template'])) {
             $rscPath = $publicationTheme->getPath() . basename($issueData['article_template']);
             if ($rscPath != $outTh->getArticlePage()->getPath()) {
                 $outSetIssue->setArticlePage($this->getSyncResourceService()->getResource('articlePage', $rscPath));
             } else {
                 $outSetIssue->setArticlePage(null);
             }
         } else {
             $outSetIssue->setArticlePage(null);
         }
         if ($newOutputSetting) {
             $this->getOutputSettingIssueService()->insert($outSetIssue);
         } else {
             $this->getOutputSettingIssueService()->update($outSetIssue);
         }
     }
 }
Beispiel #5
0
     }
     if ($themePath == null) {
         $f_theme_id = '0';
     } else {
         $f_theme_id = $themePath;
     }
 } else {
     $f_theme_id = $publicationThemes[0]->getPath();
 }
 $issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
 $outSetIssues = $outputSettingIssueService->findByIssue($issueObj->getIssueId());
 $newOutputSetting = false;
 if (count($outSetIssues) > 0) {
     $outSetIssue = $outSetIssues[0];
 } else {
     $outSetIssue = new OutputSettingsIssue();
     $outSetIssue->setOutput($outputService->findByName('Web'));
     $outSetIssue->setIssue($issueService->getById($issueObj->getIssueId()));
     $newOutputSetting = true;
 }
 $outSetIssue->setThemePath($syncRsc->getThemePath($f_theme_id));
 $outSetIssue->setFrontPage(null);
 $outSetIssue->setSectionPage(null);
 $outSetIssue->setArticlePage(null);
 if (SaaS::singleton()->hasPermission('ManageIssueTemplates')) {
     if ($newOutputSetting) {
         $outputSettingIssueService->insert($outSetIssue);
     } else {
         $outputSettingIssueService->update($outSetIssue);
     }
 }
 function assignTheme(Theme $theme, Publication $publication)
 {
     Validation::notEmpty($theme, 'theme');
     Validation::notEmpty($publication, 'publication');
     // We have to check if there is no other theme by the new theme name.
     foreach ($this->getThemes($publication) as $th) {
         /* @var $th Theme */
         if (trim($th->getName()) === trim($theme->getName())) {
             if ($this->getThemePublication($th) != NULL) {
                 throw new DuplicateNameException();
             } else {
                 $thPath = $th->getPath();
                 $this->rrmdir($this->toFullPath($thPath));
             }
         }
     }
     $themeFolder = $this->getNewThemeFolder(self::FOLDER_PUBLICATION_PREFIX . $publication->getId() . '/');
     $themeFullFolder = $this->toFullPath($themeFolder);
     try {
         $this->copy($this->toFullPath($theme), $themeFullFolder);
         // Reset the theme configs cache so also the new theme will be avaialable
         $this->cacheThemeConfigs = NULL;
         // We need to persist the theme ouput setting for the new publication theme
         $em = $this->getEntityManager();
         $pathRsc = $this->getSyncResourceService()->getThemePath($themeFolder);
         // Persist the coresponding ouput settings theme to the database
         $outSets = $this->loadOutputSettings($themeFolder);
         foreach ($outSets as $outSet) {
             /* @var $outSet OutputSettings */
             $qb = $em->createQueryBuilder();
             $qb->select('th')->from(OutputSettingsTheme::NAME, 'th');
             $qb->where('th.publication = :publication');
             $qb->andWhere('th.themePath = :themePath');
             $qb->andWhere('th.output = :output');
             $qb->setParameter('publication', $publication);
             $qb->setParameter('themePath', $pathRsc);
             $qb->setParameter('output', $outSet->getOutput());
             $result = $qb->getQuery()->getResult();
             if (count($result) > 0) {
                 $outTh = $result[0];
             } else {
                 $outTh = new OutputSettingsTheme();
                 $outTh->setPublication($publication);
                 $outTh->setThemePath($pathRsc);
                 $outTh->setOutput($outSet->getOutput());
             }
             $this->syncOutputSettings($outTh, $outSet);
             $issueOutSettings = $this->getOutputSettingIssueService();
             foreach ($issueOutSettings->getUnthemedIssues($publication) as $issue) {
                 $outIssueTh = new OutputSettingsIssue();
                 $outIssueTh->setIssue($issue);
                 $outIssueTh->setThemePath($pathRsc);
                 $outIssueTh->setOutput($outSet->getOutput());
                 $em->persist($outIssueTh);
             }
             $em->persist($outTh);
         }
         $em->flush();
     } catch (\Exception $e) {
         $this->rrmdir($themeFullFolder);
         throw $e;
     }
     return $this->loadThemeByPath($themeFolder);
 }
 public function setId($id)
 {
     $this->__load();
     return parent::setId($id);
 }