/** * An article type is a dynamic table that is created for an article * to allow different publications to display their content in different * ways. * * @param string $p_articleType */ public function ArticleType($p_articleType) { $this->m_metadata = new ArticleTypeField($p_articleType, 'NULL'); $this->m_name = $this->m_metadata->getArticleType(); $this->m_dbTableName = 'X' . $this->m_name; if ($this->m_metadata->exists()) { // Get user-defined values. $this->getUserDefinedColumns(); foreach ($this->m_dbColumns as $columnMetaData) { $this->m_columnNames[] = $columnMetaData->getName(); } } else { $this->m_dbColumns = array(); $this->m_publicFields = array(); } }
/** * An article type is a dynamic table that is created for an article * to allow different publications to display their content in different * ways. * * @param string $p_articleType */ public function ArticleType($p_articleType) { $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheKey = $cacheService->getCacheKey(array('ArticleTypeField', $p_articleType), 'article_type'); if ($cacheService->contains($cacheKey)) { $this->m_metadata = $cacheService->fetch($cacheKey); } else { $this->m_metadata = new ArticleTypeField($p_articleType, 'NULL'); $cacheService->save($cacheKey, $this->m_metadata); } $this->m_name = $this->m_metadata->getArticleType(); $this->m_dbTableName = 'X' . $this->m_name; if ($this->m_metadata->exists()) { // Get user-defined values. $this->getUserDefinedColumns(); foreach ($this->m_dbColumns as $columnMetaData) { $this->m_columnNames[] = $columnMetaData->getName(); } } }
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors) { $translator = \Zend_Registry::get('container')->getService('translator'); $p_errors = array(); $articles = Article::GetArticlesOfType($p_sourceField->getArticleType()); foreach ($articles as $article) { $articleData = $article->getArticleData(); $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName())); if (empty($authorName)) { continue; } $author = new Author($authorName); if (!$author->exists()) { if (!$author->create()) { $p_errors[] = $translator->trans('Unable to create author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home'); continue; } } if (!$article->setAuthorId($author->getId())) { $p_errors[] = $translator->trans('Error setting the author $1 for article no. $2 ($3) of type $4.', array('$1' => $author->getName(), '$2' => $article->getArticleNumber(), '$3' => $article->getName(), '$4' => $article->getType()), 'home'); continue; } } $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('authors'); $cacheService->clearNamespace('article'); return count($p_errors); }
function camp_set_author(ArticleTypeField $p_sourceField, &$p_errors) { $p_errors = array(); $articles = Article::GetArticlesOfType($p_sourceField->getArticleType()); foreach ($articles as $article) { $articleData = $article->getArticleData(); $authorName = trim($articleData->getFieldValue($p_sourceField->getPrintName())); if (empty($authorName)) { continue; } $author = new Author($authorName); if (!$author->exists()) { if (!$author->create()) { $p_errors[] = getGS('Unable to create author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType()); continue; } } if (!$article->setAuthorId($author->getId())) { $p_errors[] = getGS('Error setting the author "$1" for article no. $2 ("$3") of type $4.', $author->getName(), $article->getArticleNumber(), $article->getName(), $article->getType()); continue; } } return count($p_errors); }