/** * Process item * @param Article $article * @return array */ public function processItem($article) { global $g_user, $Campsite; $translator = \Zend_Registry::get('container')->getService('translator'); $editorService = \Zend_Registry::get('container')->getService('newscoop.editor'); $articleLink = $editorService->getLink($article); $articleLinkParams = $editorService->getLinkParameters($article); $articleLinkParamsTranslate = $articleLinkParams . '&f_action=translate&f_action_workflow=' . $article->getWorkflowStatus() . '&f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId(); $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $editorService->getLinkParameters($article); $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . $translator->trans('Preview') . '">' . $translator->trans('Preview') . '</a>'; $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate; $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . $translator->trans('Translate') . '">' . $translator->trans('Translate') . '</a>'; $lockInfo = ''; $lockHighlight = false; $timeDiff = camp_time_diff_str($article->getLockTime()); if ($article->isLocked() && $timeDiff['days'] <= 0) { $lockUser = new User($article->getLockedByUser()); if ($timeDiff['hours'] > 0) { $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['hours'], '$4' => $timeDiff['minutes']), 'articles'); } else { $lockInfo = $translator->trans('The article has been locked by $1 ($2) $3 minute(s) ago.', array('$1' => htmlspecialchars($lockUser->getRealName()), '$2' => htmlspecialchars($lockUser->getUserName()), '$3' => $timeDiff['minutes']), 'articles'); } if ($article->getLockedByUser() != $g_user->getUserId()) { $lockHighlight = true; } } $tmpUser = new User($article->getCreatorId()); $tmpArticleType = new ArticleType($article->getType()); $tmpAuthor = new Author(); $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId()); foreach ((array) $articleAuthors as $author) { if (strtolower($author->getAuthorType()->getName()) == 'author') { $tmpAuthor = $author; break; } } if (!$tmpAuthor->exists() && isset($articleAuthors[0])) { $tmpAuthor = $articleAuthors[0]; } $onFrontPage = $article->onFrontPage() ? $translator->trans('Yes') : $translator->trans('No'); $onSectionPage = $article->onSectionPage() ? $translator->trans('Yes') : $translator->trans('No'); $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true); $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true); $commentsNo = ''; if ($article->commentsEnabled()) { global $controller; $repositoryComments = $controller->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment'); $filter = array('thread' => $article->getArticleNumber(), 'language' => $article->getLanguageId()); $params = array('sFilter' => $filter); $commentsNo = $repositoryComments->getCount($params); } else { $commentsNo = 'No'; } // get language code $language = new Language($article->getLanguageId()); return array($article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '') . '" title="' . $lockInfo . '"></span>' : '', $articleLink, $translator->trans('Edit'), htmlspecialchars($article->getName() . " ({$article->getLanguageName()})"), htmlspecialchars($article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : ''))), htmlspecialchars($article->getSection()->getName()), $article->getWebcode(), htmlspecialchars($tmpArticleType->getDisplayName()), htmlspecialchars($tmpUser->getRealName()), htmlspecialchars($tmpAuthor->getName()), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != null ? $translator->trans('Yes') : $translator->trans('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink); }
/** * Process item * @param Article $article * @return array */ public function processItem(Article $article) { global $g_user, $Campsite; $articleLinkParams = '?f_publication_id=' . $article->getPublicationId() . '&f_issue_number=' . $article->getIssueNumber() . '&f_section_number=' . $article->getSectionNumber() . '&f_article_number=' . $article->getArticleNumber() . '&f_language_id=' . $article->getLanguageId() . '&f_language_selected=' . $article->getLanguageId(); $articleLink = $Campsite['WEBSITE_URL'].'/admin/articles/edit.php' . $articleLinkParams; $previewLink = $Campsite['WEBSITE_URL'].'/admin/articles/preview.php' . $articleLinkParams; $lockInfo = ''; $lockHighlight = false; $timeDiff = camp_time_diff_str($article->getLockTime()); if ($article->isLocked() && ($timeDiff['days'] <= 0)) { $lockUser = new User($article->getLockedByUser()); if ($timeDiff['hours'] > 0) { $lockInfo = getGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['hours'], $timeDiff['minutes']); } else { $lockInfo = getGS('The article has been locked by $1 ($2) $3 minute(s) ago.', htmlspecialchars($lockUser->getRealName()), htmlspecialchars($lockUser->getUserName()), $timeDiff['minutes']); } if ($article->getLockedByUser() != $g_user->getUserId()) { $lockHighlight = true; } } $tmpUser = new User($article->getCreatorId()); $tmpArticleType = new ArticleType($article->getType()); $tmpAuthor = new Author(); $articleAuthors = ArticleAuthor::GetAuthorsByArticle($article->getArticleNumber(), $article->getLanguageId()); foreach((array) $articleAuthors as $author) { if (strtolower($author->getAuthorType()->getName()) == 'author') { $tmpAuthor = $author; break; } } if (!$tmpAuthor->exists() && isset($articleAuthors[0])) { $tmpAuthor = $articleAuthors[0]; } $onFrontPage = $article->onFrontPage() ? getGS('Yes') : getGS('No'); $onSectionPage = $article->onSectionPage() ? getGS('Yes') : getGS('No'); $imagesNo = (int) ArticleImage::GetImagesByArticleNumber($article->getArticleNumber(), true); $topicsNo = (int) ArticleTopic::GetArticleTopics($article->getArticleNumber(), true); $commentsNo = ''; if ($article->commentsEnabled()) { $commentsNo = (int) ArticleComment::GetArticleComments($article->getArticleNumber(), $article->getLanguageId(), null, true); } else { $commentsNo = 'No'; } // get language code $language = new Language($article->getLanguageId()); return array( $article->getArticleNumber(), $article->getLanguageId(), $article->getOrder(), sprintf('%s <a href="%s" title="%s %s">%s</a>', $article->isLocked() ? '<span class="ui-icon ui-icon-locked' . (!$lockHighlight ? ' current-user' : '' ) . '" title="' . $lockInfo . '"></span>' : '', $articleLink, getGS('Edit'), $article->getName() . " ({$article->getLanguageName()})", $article->getName() . (empty($_REQUEST['language']) ? " ({$language->getCode()})" : '')), $tmpArticleType->getDisplayName(), $tmpUser->getRealName(), $tmpAuthor->getName(), $article->getWorkflowStatus(), $onFrontPage, $onSectionPage, $imagesNo, $topicsNo, $commentsNo, (int) $article->getReads(), Geo_Map::GetArticleMapId($article) != NULL ? getGS('Yes') : getGS('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), ); }