Example #1
0
 /**
  * Action to make the table
  */
 public function tableAction()
 {
     $this->getHelper('contextSwitch')->addActionContext('table', 'json')->initContext();
     $view = $this->view;
     $table = $this->getHelper('datatable');
     /* @var $table Action_Helper_Datatable */
     $table->setDataSource($this->commentRepository);
     $table->setOption('oLanguage', array('sSearch' => ''));
     $table->setCols(array('index' => $view->toggleCheckbox(), 'commenter' => getGS('Author'), 'comment' => getGS('Date') . ' / ' . getGS('Comment'), 'thread' => getGS('Article'), 'threadorder' => ''), array('index' => false));
     $table->setInitialSorting(array('comment' => 'desc'));
     $index = 1;
     $acl = array();
     $acl['edit'] = $this->_helper->acl->isAllowed('comment', 'edit');
     $acl['enable'] = $this->_helper->acl->isAllowed('comment', 'enable');
     $acceptanceRepository = $this->_helper->entity->getRepository('Newscoop\\Entity\\Comment\\Acceptance');
     $articleRepository = $this->_helper->entity->getRepository('Newscoop\\Entity\\Article');
     $table->setHandle(function ($comment) use($view, $acl, $acceptanceRepository, &$index) {
         /* var Newscoop\Entity\Comment\Commenter */
         $commenter = $comment->getCommenter();
         $thread = $comment->getThread();
         $articleNo = $comment->getArticleNumber();
         $commentLang = $comment->getLanguage()->getId();
         $article = new Article($commentLang, $articleNo);
         $forum = $comment->getForum();
         $section = $thread->getSection();
         return array('index' => $index++, 'can' => array('enable' => $acl['enable'], 'edit' => $acl['edit']), 'commenter' => array('username' => $commenter->getUsername(), 'name' => $commenter->getName(), 'usernameEncoded' => urlencode($commenter->getUsername()), 'email' => $commenter->getEmail(), 'avatar' => (string) $view->getAvatar($commenter->getEmail(), array('img_size' => 50, 'default_img' => 'wavatar')), 'is' => array('banned' => $acceptanceRepository->isBanned($commenter, null)), 'trace' => array('ip' => 'http://www.ip-adress.com/ip_tracer/' . $commenter->getIp()), 'ip' => $commenter->getIp(), 'url' => $commenter->getUrl(), 'banurl' => $view->url(array('controller' => 'comment-commenter', 'action' => 'toggle-ban', 'commenter' => $commenter->getId(), 'thread' => $comment->getArticleNumber(), 'language' => $comment->getLanguage()->getId()))), 'comment' => array('id' => $comment->getId(), 'created' => array('date' => $comment->getTimeCreated()->format('Y.m.d'), 'time' => $comment->getTimeCreated()->format('H:i:s')), 'subject' => $comment->getSubject(), 'message' => $comment->getMessage(), 'likes' => '', 'dislikes' => '', 'status' => $comment->getStatus(), 'recommended' => $comment->getRecommended(), 'action' => array('update' => $view->url(array('action' => 'update', 'format' => 'json')), 'reply' => $view->url(array('action' => 'reply', 'format' => 'json')))), 'thread' => array('name' => $view->escape($article->getName()), 'link' => array('edit' => $view->baseUrl("admin/articles/edit.php?") . $view->linkArticleObj($article), 'get' => $view->baseUrl("admin/articles/get.php?") . $view->linkArticleObj($article)), 'forum' => array('name' => $view->escape($forum->getName())), 'section' => array('name' => $section ? $view->escape($section->getName()) : null)));
     });
     $table->setOption('fnDrawCallback', 'datatableCallback.draw')->setOption('fnRowCallback', 'datatableCallback.row')->setOption('fnServerData', 'datatableCallback.addServerData')->setOption('fnInitComplete', 'datatableCallback.init')->setOption('sDom', '<"top">lf<"#actionExtender">rit<"bottom"ip>')->setStripClasses()->toggleAutomaticWidth(false)->setDataProp(array('index' => null, 'commenter' => null, 'comment' => null, 'thread' => null, 'threadorder' => null))->setVisible(array('threadorder' => false))->setClasses(array('index' => 'commentId', 'commenter' => 'commentUser', 'comment' => 'commentTimeCreated', 'thread' => 'commentThread'));
     $table->dispatch();
     $this->editForm->setSimpleDecorate()->setAction($this->_helper->url('update'));
     $this->view->editForm = $this->editForm;
 }
Example #2
0
 /**
  * Process item
  * @param Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     return array($article->getArticleNumber(), $article->getLanguageId(), sprintf('
             <div class="context-item" langid="%s">
                 <div class="context-drag-topics"><a href="#" title="drag to sort"></a></div>
                 <div class="context-item-header">
                     <div class="context-item-date">%s</div>
                     <a href="#" class="view-article" onClick="viewArticle($(this).parent(\'div\').parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'), $(this).parents(\'.context-item:eq(0)\').attr(\'langid\'));">%s</a>
                 </div>
                 <a href="javascript:void(0)" class="corner-button" style="display: none" onClick="removeFromContext($(this).parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'));removeFromContext($(this).parents(\'.item:eq(0)\').attr(\'id\'));toggleDragZonePlaceHolder();"><span class="ui-icon ui-icon-closethick"></span></a>
                 <div class="context-item-summary">%s</div>
                 </div>
         ', $article->getLanguageId(), $article->getCreationDate(), getGS('View article'), $article->getName()));
 }
Example #3
0
 /**
  * Process item
  * @param  Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     $translator = \Zend_Registry::get('container')->getService('translator');
     return array($article->getArticleNumber(), $article->getLanguageId(), sprintf('
             <div class="context-item" langid="%s">
                 <div class="context-drag-topics"><a href="#" title="drag to sort"></a></div>
                 <div class="context-item-header">
                     <div class="context-item-date">%s (%s) (%s)</div>
                     <a href="#" class="view-article" onClick="viewArticle($(this).parent(\'div\').parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'), $(this).parents(\'.context-item:eq(0)\').attr(\'langid\'));">%s</a>
                 </div>
                 <a href="javascript:void(0)" class="corner-button" style="display: none" onClick="removeFromContext($(this).parent(\'div\').parent(\'td\').parent(\'tr\').attr(\'id\'));removeFromContext($(this).parents(\'.item:eq(0)\').attr(\'id\'));toggleDragZonePlaceHolder();"><span class="ui-icon ui-icon-closethick"></span></a>
                 <div class="context-item-summary">%s</div>
                 </div>
         ', $article->getLanguageId(), $article->getLastModified(), $article->getWorkflowDisplayString(), $article->getType(), $translator->trans('View article', array(), 'library'), $article->getName()));
 }
Example #4
0
 function findArticle($article_id)
 {
     $location = new Article($this->dbcon, $article_id);
     $this->current_section = $location->getParent();
     $this->current_element = $this->_trimText($location->getName());
     $this->content_type = AMP_CONTENT_PAGETYPE_ARTICLE;
 }
Example #5
0
 /**
  * Process item
  * @param Article $article
  * @return array
  */
 public function processItem(Article $article)
 {
     global $g_user, $Campsite;
     $articleLinkParams = '?f_publication_id=' . $article->getPublicationId() . '&amp;f_issue_number=' . $article->getIssueNumber() . '&amp;f_section_number=' . $article->getSectionNumber() . '&amp;f_article_number=' . $article->getArticleNumber() . '&amp;f_language_id=' . $article->getLanguageId() . '&amp;f_language_selected=' . $article->getLanguageId();
     $articleLinkParamsTranslate = $articleLinkParams . '&amp;f_action=translate&amp;f_action_workflow=' . $article->getWorkflowStatus() . '&amp;f_article_code=' . $article->getArticleNumber() . '_' . $article->getLanguageId();
     $articleLink = $Campsite['WEBSITE_URL'] . '/admin/articles/edit.php' . $articleLinkParams;
     $previewLink = $Campsite['WEBSITE_URL'] . '/admin/articles/preview.php' . $articleLinkParams;
     $htmlPreviewLink = '<a href="' . $previewLink . '" target="_blank" title="' . getGS('Preview') . '">' . getGS('Preview') . '</a>';
     $translateLink = $Campsite['WEBSITE_URL'] . '/admin/articles/translate.php' . $articleLinkParamsTranslate;
     $htmlTranslateLink = '<a href="' . $translateLink . '" target="_blank" title="' . getGS('Translate') . '">' . getGS('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 = 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()) {
         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, getGS('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 ? getGS('Yes') : getGS('No'), (int) sizeof(Geo_Map::GetLocationsByArticle($article)), $article->getCreationDate(), $article->getPublishDate(), $article->getLastModified(), $htmlPreviewLink, $htmlTranslateLink);
 }
Example #6
0
if (!$articleObj->exists()) {
    camp_html_display_error($translator->trans('No such article.', array(), 'articles'));
    exit;
}
// detect if blogger can edit
$userIsBlogger = false;
$blogService = \Zend_Registry::get('container')->getService('blog');
if ($blogService->isBlogger($g_user)) {
    $userIsBlogger = true;
    $userSection = $blogService->getSection($g_user);
    if (empty($userSection) || $userSection->getSectionId() != $articleObj->getSection()->getSectionId()) {
        camp_html_display_error($translator->trans("You are not allowed to edit article.", array(), 'articles'));
        exit;
    }
}
$controller->view->headTitle($articleObj->getName() . ' - ' . $translator->trans('Edit article', array(), 'article_files') . ' - Newscoop Admin', 'SET');
$articleData = $articleObj->getArticleData();
// Get article type fields.
$dbColumns = $articleData->getUserDefinedColumns();
$articleType = new ArticleType($articleObj->getType());
$articleImages = ArticleImage::GetImagesByArticleNumber($f_article_number);
$lockUserObj = new User($articleObj->getLockedByUser());
$articleCreator = new User($articleObj->getCreatorId());
$articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, TRUE);
$em = \Zend_Registry::get('container')->getService('em');
$articleTopics = $em->getRepository("Newscoop\\Entity\\ArticleTopic")->getArticleTopicsIds($f_article_number)->getResult();
$articleFiles = ArticleAttachment::GetAttachmentsByArticleNumber($f_article_number, $f_language_selected);
$articleLanguages = $articleObj->getLanguages();
// Create displayable "last modified" time.
$lastModified = strtotime($articleObj->getLastModified());
$today = getdate();