public static function GetArticleTemplate($p_lngId, $p_pubId, $p_issNr, $p_sctNr) { global $g_ado_db; $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheKey = $cacheService->getCacheKey(array('GetArticleTemplate', $p_lngId, $p_pubId, $p_issNr, $p_sctNr), 'article'); if ($cacheService->contains($cacheKey)) { return $cacheService->fetch($cacheKey); } else { $resourceId = new ResourceId('template_engine/classes/CampSystem'); $outputService = $resourceId->getService(IOutputService::NAME); if (!\Zend_Registry::isRegistered('webOutput')) { $cacheKeyWebOutput = $cacheService->getCacheKey(array('OutputService', 'Web'), 'outputservice'); if ($cacheService->contains($cacheKeyWebOutput)) { \Zend_Registry::set('webOutput', $cacheService->fetch($cacheKeyWebOutput)); } else { $webOutput = $outputService->findByName('Web'); $cacheService->save($cacheKeyWebOutput, $webOutput); \Zend_Registry::set('webOutput', $webOutput); } } $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME); $sectionObj = new Section($p_pubId, $p_issNr, $p_lngId, $p_sctNr); $data = $templateSearchService->getArticlePage($sectionObj->getSectionId(), \Zend_Registry::get('webOutput')); if (empty($data)) { $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId); } $cacheService->save($cacheKey, $data); return $data; } // fn GetArticleTemplate }
if (!$isValidShortName) { camp_html_add_msg(getGS('The $1 field may only contain letters, digits and underscore (_) character.', '"' . getGS('URL Name') . '"')); } $editUrl = "/{$ADMIN}/sections/edit.php?Pub={$Pub}&Issue={$Issue}&Language={$Language}&Section={$Section}"; if (!camp_html_has_msgs()) { $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') {
//$editorLanguage = camp_session_get('TOL_Language', $languageObj->getCode()); $editorLanguage = !empty($_COOKIE['TOL_Language']) ? $_COOKIE['TOL_Language'] : $languageObj->getCode(); editor_load_tinymce('cDescription', $g_user, 0, $editorLanguage, 'section'); //@New theme management $resourceId = new ResourceId('Section/Edit'); $themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1); $outputSettingIssueService = $resourceId->getService(IOutputSettingIssueService::NAME); $outputSettingSectionService = $resourceId->getService(IOutputSettingSectionService::NAME); $outSetIssues = $outputSettingIssueService->findByIssue($issueObj->getIssueId()); $themePath = null; $tplSectionPath = null; $tplArticlePath = null; if (count($outSetIssues) > 0) { $outSetIssue = $outSetIssues[0]; $themePath = $outSetIssue->getThemePath()->getPath(); $outSetSections = $outputSettingSectionService->findBySection($sectionObj->getSectionId()); if (count($outSetSections) > 0) { $outSetSection = $outSetSections[0]; if ($outSetSection->getSectionPage() != null) { $tplSectionPath = $outSetSection->getSectionPage()->getPath(); } if ($outSetSection->getArticlePage() != null) { $tplArticlePath = $outSetSection->getArticlePage()->getPath(); } } } $issueHasTheme = $themePath != null; if ($issueHasTheme) { $allTemplates = $themeManagementService->getTemplates($themePath); } else { $allTemplates = array();
/** * Create a copy of the article, but make it a translation * of the current one. * * @param int $p_languageId * @param int $p_userId * @param string $p_name * @return Article */ public function createTranslation($p_languageId, $p_userId, $p_name) { $translator = \Zend_Registry::get('container')->getService('translator'); // Construct the duplicate article object. $articleCopy = new Article(); $articleCopy->m_data['IdPublication'] = $this->m_data['IdPublication']; $articleCopy->m_data['NrIssue'] = $this->m_data['NrIssue']; $articleCopy->m_data['NrSection'] = $this->m_data['NrSection']; $articleCopy->m_data['IdLanguage'] = $p_languageId; $articleCopy->m_data['Number'] = $this->m_data['Number']; $values = array(); // Copy some attributes $values['ShortName'] = $this->m_data['ShortName']; $values['Type'] = $this->m_data['Type']; $values['OnFrontPage'] = $this->m_data['OnFrontPage']; $values['OnSection'] = $this->m_data['OnFrontPage']; $values['Public'] = $this->m_data['Public']; $values['ArticleOrder'] = $this->m_data['ArticleOrder']; $values['comments_enabled'] = $this->m_data['comments_enabled']; $values['comments_locked'] = $this->m_data['comments_locked']; $values['rating_enabled'] = $this->m_data['rating_enabled']; // Change some attributes $values['Name'] = $p_name; $values['Published'] = 'N'; $values['IsIndexed'] = 'N'; $values['IdUser'] = $p_userId; // for internall relations in entity we need also to keep sectionId and issueId $issueObj = new Issue($this->m_data['IdPublication'], $p_languageId, $this->m_data['NrIssue']); $sectionObj = new Section($this->m_data['IdPublication'], $this->m_data['NrIssue'], $p_languageId, $this->m_data['NrSection']); $values['issue_id'] = $issueObj->getIssueId(); $values['section_id'] = $sectionObj->getSectionId(); // Create the record $success = $articleCopy->__create($values); if (!$success) { return false; } $articleCopy->setProperty('UploadDate', 'NOW()', true, true); $articleCopy->setProperty('LockUser', 'NULL', true, true); $articleCopy->setProperty('LockTime', 'NULL', true, true); // Insert an entry into the article type table. $articleCopyData = new ArticleData($articleCopy->m_data['Type'], $articleCopy->m_data['Number'], $articleCopy->m_data['IdLanguage']); $articleCopyData->create(); $origArticleData = $this->getArticleData(); $origArticleData->copyToExistingRecord($articleCopy->getArticleNumber(), $p_languageId); $logtext = $translator->trans('Article translated to $4 ($5)', array('$4' => $articleCopy->getTitle(), '$5' => $articleCopy->getLanguageName()), 'api'); Log::ArticleMessage($this, $logtext, null, 31); // geo-map processing Geo_Map::OnCreateTranslation($this->m_data['Number'], $this->m_data['IdLanguage'], $p_languageId); return $articleCopy; }
/** * @author Mihai Balaceanu <*****@*****.**> * New theme management */ $resourceId = new ResourceId('Publication/Edit'); $themeManagementService = $resourceId->getService(IThemeManagementService::NAME_1); /* @var $themeManagementService \Newscoop\Service\Implementation\ThemeManagementServiceLocal */ $outputSettingSectionService = $resourceId->getService(IOutputSettingSectionService::NAME); /* @var $outputSettingSectionService \Newscoop\Service\Implementation\OutputSettingSectionServiceDoctrine */ $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); $outputSectionSettings = current($outputSettingSectionService->findBySection($sectionObj->getSectionId())); /* @var $outputIssueSettings \Newscoop\Entity\Output\OutputSettingsIssue */ $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);
public static function GetArticleTemplate($p_lngId, $p_pubId, $p_issNr, $p_sctNr) { global $g_ado_db; if (CampCache::IsEnabled()) { $paramString = $p_lngId . '_' . $p_pubId . '_' . $p_issNr . '_' . $p_sctNr; $cacheKey = __CLASS__ . '_ArticleTemplate_' . $paramString; $articleTemplate = CampCache::singleton()->fetch($cacheKey); if ($articleTemplate !== false && !empty($articleTemplate)) { return $articleTemplate; } } $resourceId = new ResourceId('template_engine/classes/CampSystem'); /* @var $templateSearchService ITemplateSearchService */ $templateSearchService = $resourceId->getService(ITemplateSearchService::NAME); $outputService = $resourceId->getService(IOutputService::NAME); $sectionObj = new Section($p_pubId, $p_issNr, $p_lngId, $p_sctNr); $data = $templateSearchService->getArticlePage($sectionObj->getSectionId(), $outputService->findByName('Web')); if (empty($data)) { $data = self::GetInvalidURLTemplate($p_pubId, $p_issNr, $p_lngId); } if (CampCache::IsEnabled()) { CampCache::singleton()->store($cacheKey, $data); } return $data; }