static function getTopic($line) { $topicName = substr($line, strlen(self::TOPIC_DELIMITER)); $topic = TopicDao::findByName($topicName); if (!isset($topic)) { TopicService::createTopic($topicName); $topic = TopicDao::findByName($topicName); } return $topic; }
public static function getEnrichedArticles(array $articles) { $articleIds = self::getArticleIds($articles); $articleToAuthors = self::getArticleToAuthors($articleIds); $topicIds = self::getGroupedTopicsIds($articles); $topics = TopicService::getByIds($topicIds); $enrichedArticles = array(); foreach ($articles as $article) { $enrichedArticle = self::enrichArticle($article, $articleToAuthors, $topics); $enrichedArticles[] = $enrichedArticle; } return $enrichedArticles; }
private static function process(array $lines, $editionId, $startIndex) { $index = $startIndex; $topic = TopicService::getDefaultTopic(); foreach ($lines as $line) { if (TopicImporter::isTopicLine($line)) { $topic = TopicImporter::getTopic(trim($line)); } else { if (self::isSpecialArticle($line)) { SpecialArticleImporter::importSingleArticle($line, $editionId, $index); } else { CommonArticleImporter::importSingleArticle($line, $editionId, $index, $topic); } $index++; } } }
private static function createArticle($line, $editionId, $index) { $articleName = self::getArticleName($line); if (!isset($articleName)) { throw new Exception("Can not find article name in line: " . $line); } $engName = self::getArticleEngName($line); $pages = self::getPages($line); $topic = TopicService::getDefaultTopic(); $article = new stdClass(); $article->topic_id = $topic->topic_id; $article->journal_edition_id = $editionId; $article->start_page = $pages->start; $article->end_page = $pages->end; $article->name = $articleName; $article->sort_order = $index; $article->name_eng = $engName; $article->content_file = self::generateContentFileName($index); return $article; }