Exemple #1
0
    $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);
}
if ($f_article_template_id != null && $f_article_template_id != '0') {
Exemple #2
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);
         }
     }
 }
Exemple #3
0
$themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1);
/* @var $themeManagementService \Newscoop\Service\Implementation\ThemeManagementServiceLocal */
$outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME);
/* @var $outputSettingIssueService \Newscoop\Service\Implementation\OutputSettingIssueServiceDoctrine */
$issueService = $resourceId->getService(IIssueService::NAME);
/* @var $issueService \Newscoop\Service\Implementation\IssueServiceDoctrine */
$outputService = $resourceId->getService(IOutputService::NAME);
$syncRsc = $resourceId->getService(ISyncResourceService::NAME);
$outputIssueSettings = current($outputSettingIssueService->findByIssue($issueObj->getIssueId()));
/* @var $outputIssueSettings \Newscoop\Entity\Output\OutputSettingsIssue */
$publicationThemes = $themeManagementService->getThemes($publicationObj->getPublicationId());
if (!$outputIssueSettings) {
    if (count($publicationThemes) > 0) {
        $themePath = $publicationThemes[0]->getPath();
        $outputIssueSettings = new OutputSettingsIssue();
        $outputIssueSettings->setOutput($outputService->findByName('Web'));
        $outputIssueSettings->setIssue($issueService->getById($issueObj->getIssueId()));
        $outputIssueSettings->setThemePath($syncRsc->getThemePath($themePath));
        $outputIssueSettings->setFrontPage(null);
        $outputIssueSettings->setSectionPage(null);
        $outputIssueSettings->setArticlePage(null);
        $outputSettingIssueService->insert($outputIssueSettings);
    } else {
        $errorStr = $translator->trans('This issue cannot be previewed. Please make sure the publication has a theme assigned.', array(), 'issues');
        camp_html_display_error($errorStr, null, true);
    }
} else {
    $themePath = $outputIssueSettings->getThemePath()->getPath();
}
$frontPage = $outputIssueSettings->getFrontPage();
if (is_null($frontPage)) {
 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 setOutput(\Newscoop\Entity\Output $output)
 {
     $this->__load();
     return parent::setOutput($output);
 }