상속: extends Newscoop\Entity\OutputSettings
예제 #1
0
파일: do_edit.php 프로젝트: nidzix/Newscoop
 $modified = true;
 $modified &= $sectionObj->setName($cName);
 $modified &= $sectionObj->setDescription($cDescription);
 //@New theme management
 $resourceId = new ResourceId('Section/Edit');
 $outputSettingSectionService = $resourceId->getService(IOutputSettingSectionService::NAME);
 $outputService = $resourceId->getService(IOutputService::NAME);
 $sectionService = $resourceId->getService(ISectionService::NAME);
 $syncRsc = $resourceId->getService(ISyncResourceService::NAME);
 $newOutputSetting = false;
 $dSection = $sectionService->getById($sectionObj->getSectionId());
 $outSetSections = $outputSettingSectionService->findBySection($dSection);
 if (count($outSetSections) > 0) {
     $outSetSection = $outSetSections[0];
 } else {
     $outSetSection = new OutputSettingsSection();
     $outSetSection->setOutput($outputService->findByName('Web'));
     $outSetSection->setSection($dSection);
     $newOutputSetting = true;
 }
 if ($cSectionTplId != null && $cSectionTplId != '0') {
     $outSetSection->setSectionPage($syncRsc->getResource('sectionPage', $cSectionTplId));
 } else {
     $outSetSection->setSectionPage(null);
 }
 if ($cArticleTplId != null && $cArticleTplId != '0') {
     $outSetSection->setArticlePage($syncRsc->getResource('articlePage', $cArticleTplId));
 } else {
     $outSetSection->setArticlePage(null);
 }
 //@New theme management
예제 #2
0
 /**
  * Set the section output settings for the given publication
  *
  * @param $publicationId
  *
  * @param $theme
  *
  * @param $publicationTheme
  */
 public function setSectionOutSettings($publicationId, Newscoop\Entity\Theme $theme, Newscoop\Entity\Theme $publicationTheme)
 {
     global $g_ado_db;
     $themePath = basename($theme->getPath());
     if (empty($themePath)) {
         $likeStr = '';
     } else {
         $likeStr = $g_ado_db->Escape($themePath) . '/';
     }
     $sql = "SELECT tpl_s.Name AS section_template,\n    tpl_a.Name AS article_template,\n    sec.NrIssue, sec.Number, sec.IdLanguage, sec.id\nFROM Sections AS sec\n    LEFT JOIN Templates AS tpl_s ON sec.SectionTplId = tpl_s.Id\n    LEFT JOIN Templates AS tpl_a ON sec.ArticleTplId = tpl_a.Id\nWHERE sec.IdPublication = {$publicationId}\n\tAND (SectionTplId > 0 OR ArticleTplId > 0)\n    AND (SectionTplId IN (SELECT Id FROM Templates WHERE Name LIKE '{$likeStr}%')\n    \tOR ArticleTplId IN (SELECT Id FROM Templates WHERE Name LIKE '{$likeStr}%'))\nORDER BY Number DESC";
     $sectionsList = $g_ado_db->GetAll($sql);
     foreach ($sectionsList as $sectionsData) {
         $section = $this->getSectionService()->findById($sectionsData['id']);
         if (is_null($section)) {
             continue;
         }
         $outSetSections = $this->getOutputSettingSectionService()->findBySection($sectionsData['id']);
         $newOutputSetting = false;
         if (count($outSetSections) > 0) {
             $outSetSection = $outSetSections[0];
         } else {
             $outSetSection = new OutputSettingsSection();
             $outSetSection->setOutput($this->getOutputService()->findByName('Web'));
             $outSetSection->setSection($section);
             $newOutputSetting = true;
         }
         if (!empty($sectionsData['section_template'])) {
             $rscPath = $publicationTheme->getPath() . basename($sectionsData['section_template']);
             $outSetSection->setSectionPage($this->getSyncResourceService()->getResource('sectionPage', $rscPath));
         } else {
             $outSetSection->setSectionPage(null);
         }
         if (!empty($sectionsData['article_template'])) {
             $rscPath = $publicationTheme->getPath() . basename($sectionsData['article_template']);
             $outSetSection->setArticlePage($this->getSyncResourceService()->getResource('articlePage', $rscPath));
         } else {
             $outSetSection->setArticlePage(null);
         }
         if ($newOutputSetting) {
             $this->getOutputSettingSectionService()->insert($outSetSection);
         } else {
             $this->getOutputSettingSectionService()->update($outSetSection);
         }
     }
 }
 public function setId($id)
 {
     $this->__load();
     return parent::setId($id);
 }